当前位置: 首页>>代码示例>>C#>>正文


C# DB.Insert方法代码示例

本文整理汇总了C#中DB.Insert方法的典型用法代码示例。如果您正苦于以下问题:C# DB.Insert方法的具体用法?C# DB.Insert怎么用?C# DB.Insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DB的用法示例。


在下文中一共展示了DB.Insert方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Add_Update

        private bool Add_Update()
        {
            try
            {
                DB db = new DB("products");

                db.AddColumn("pro_cat_id", Categories_CB.SelectedValue);
                db.AddColumn("pro_name", Product_TB.Text.Trim());
                db.AddColumn("pro_sell", Sell_Price_TB.Text.Trim());


                if(Product_Id == null)
                {
                    if(db.IsNotExist("pro_id", "pro_name", "pro_cat_id"))
                    {
                        return db.Insert();
                    }
                    else
                    {
                        Message.Show("هذا المنتج مسجل من قبل", MessageBoxButton.OK, 5);
                        return false;
                    }
                }
                else
                {                 
                    db.AddCondition("pro_Id", this.Product_Id);
                    return db.Update();
                }

            }
            catch
            {
                return false;
            }
        }
开发者ID:Enumeg,项目名称:POS-General,代码行数:35,代码来源:Product.xaml.cs

示例2: InsertDataToSQL

//向sql数据库表插入数据
    public bool InsertDataToSQL(string insert)
    { 
        DB db=new DB();
        SqlConnection conn = db.DBconn();//连接数据库
        //若数据库连接的当前状态是关闭的,则打开连接
      return db.Insert(insert,conn);
    }
开发者ID:zwxscience,项目名称:Paper-management-system,代码行数:8,代码来源:EXCELtoSQL.cs

示例3: Add_Update

        public bool Add_Update()
        {
            try
            {

                DB DataBase = new DB("outcome_types");

                DataBase.AddColumn("ott_name", Name_TB.Text);

                if (this.TypeId == null)
                {
                    if (DataBase.IsNotExist("ott_id", "ott_name"))
                    {
                        return Confirm.Check(DataBase.Insert());
                    }
                    else
                    {
                        Message.Show("لقد تم تسجيل نوع المصروف من قبل", MessageBoxButton.OK, 5);
                        return false;
                    }


                }
                else
                {
                    DataBase.AddCondition("ott_id", this.TypeId);
                    return Confirm.Check(DataBase.Update());
                }
            }
            catch
            {
                //MessageBox.Show("kiki_method");
                return false;
            }
        }
开发者ID:Enumeg,项目名称:POS-General,代码行数:35,代码来源:OutCome_Types.xaml.cs

示例4: SInsert

 public static int SInsert(string sql, params object[] parameter)
 {
     using (DB db = new DB())
     {
         return db.Insert(sql, parameter);
     }
 }
开发者ID:nokitty,项目名称:chaxin,代码行数:7,代码来源:DB.cs

示例5: Add_Update

        private bool Add_Update()
        {
            try
            {

                DB DataBase = new DB("groups");

                DataBase.AddColumn("grp_name", Type_TB.Text);

                if(Group_Id == null)
                {
                    if(DataBase.IsNotExist("grp_id", "grp_name"))
                    {
                        return Confirm.Check(DataBase.Insert());
                    }
                    else
                    {
                        Message.Show("لقد تم تسجيل هذا النوع من قبل", MessageBoxButton.OK, 5);
                        return false;
                    }


                }
                else
                {
                    DataBase.AddCondition("grp_id", this.Group_Id);
                    return Confirm.Check(DataBase.Update());
                }
            }
            catch
            {
                //MessageBox.Show("kiki_method");
                return false;
            }
        }
开发者ID:Enumeg,项目名称:POS-General,代码行数:35,代码来源:Groups.xaml.cs

示例6: Add_Update

        private bool Add_Update()
        {
            try
            {

                DB DataBase = new DB("Categories");

                DataBase.AddColumn("cat_name", Category_TB.Text.Trim());

                if(Category_Id == null)
                {
                    if(DataBase.IsNotExist("cat_id", "cat_name"))
                    {
                        return Confirm.Check(DataBase.Insert());
                    }
                    else
                    {
                        Message.Show("لقد تم تسجيل هذه الفئة من قبل", MessageBoxButton.OK, 5);
                        return false;
                    }


                }
                else
                {
                    DataBase.AddCondition("cat_id", this.Category_Id);
                    return Confirm.Check(DataBase.Update());
                }
            }
            catch
            {
                //MessageBox.Show("kiki_method");
                return false;
            }
        }
开发者ID:Enumeg,项目名称:POS-General,代码行数:35,代码来源:Categories.xaml.cs

示例7: Add_Update

        private bool Add_Update()
        {
            try
            {

                DB DataBase = new DB("Properties");

                DataBase.AddColumn("prp_name", Property_TB.Text.Trim());
                DataBase.AddColumn("prp_cat_id", Categories_CB.SelectedValue, Categories_CB.SelectedIndex < 1);

                if(Property_Id == null)
                {
                    if(Categories_CB.SelectedIndex < 1)
                    {
                        if(DataBase.IsNotExist("prp_id", "prp_name"))
                        {
                            return Confirm.Check(DataBase.Insert());
                        }
                        else
                        {
                            Message.Show("لقد تم تسجيل هذه الصفة من قبل", MessageBoxButton.OK, 5);
                            return false;
                        }
                    }
                    else
                    {
                        if(DataBase.IsNotExist("prp_id", "prp_name", "prp_cat_id"))
                        {
                            return Confirm.Check(DataBase.Insert());
                        }
                        else
                        {
                            Message.Show("لقد تم تسجيل هذه الصفة من قبل", MessageBoxButton.OK, 5);
                            return false;
                        }
                    }



                }
                else
                {
                    DataBase.AddCondition("prp_id", this.Property_Id);
                    return Confirm.Check(DataBase.Update());
                }
            }
            catch
            {
                //MessageBox.Show("kiki_method");
                return false;
            }
        }
开发者ID:Enumeg,项目名称:POS-General,代码行数:52,代码来源:Properties.xaml.cs

示例8: Add_Update

        private bool Add_Update()
        {
            try
            {

                DB DataBase = new DB("attendence");

                DataBase.AddColumn("att_emp_id", Employees_CB.SelectedValue);
                DataBase.AddColumn("att_date", Date_DTP.Value.Value.Date);
                DataBase.AddColumn("att_attend", Attend_DTP.Value.Value.TimeOfDay);
                DataBase.AddColumn("att_leave", null);
                DataBase.AddColumn("att_time", null);
                if(Leave_DTP.Value != null)
                {
                    DataBase.Columns_Values[3].Value = Leave_DTP.Value.Value.TimeOfDay;
                    DataBase.Columns_Values[4].Value = Attend_DTP.Value.Value.TimeOfDay <= Leave_DTP.Value.Value.TimeOfDay ?
                                                       Leave_DTP.Value.Value.TimeOfDay - Attend_DTP.Value.Value.TimeOfDay :
                                                       Leave_DTP.Value.Value.TimeOfDay.Add(new TimeSpan(24, 0, 0)) - Attend_DTP.Value.Value.TimeOfDay;
                }
                if(Attendence_Id == null)
                {
                    if(DataBase.IsNotExist("att_id", "att_emp_id", "att_date"))
                    {
                        return DataBase.Insert();
                    }
                    else
                    {
                        Message.Show("هذا الاسم مستخدم من قبل", MessageBoxButton.OK, 5);
                        return false;
                    }
                }
                else
                {
                    DataBase.AddCondition("att_Id", this.Attendence_Id);
                    return DataBase.Update();
                }

            }
            catch
            {
                return false;
            }
        }
开发者ID:Enumeg,项目名称:POS-General,代码行数:43,代码来源:Add_Update_Attendence.xaml.cs

示例9: Button1_Click

    protected void Button1_Click(object sender, EventArgs e)
    {
        DB db = new DB();
        SqlConnection conn = db.DBconn();
        if (this.TextBox2.Text == "")
        {
            Response.Write("<script>alert('公告标题不可以为空,请重新发布。')</script>");
            return;

        }

        String insert = "insert into Bulletin(admin_ID,admin_Name,topic,content,time) values('" + Session["username"].ToString() + "','" + Session["name"].ToString() + "','" + this.TextBox2.Text + "','" + FreeTextBox1 .Text+ "','" + DateTime.Now + "') ";
        if (db.Insert(insert, conn))
        {
            Response.Write("<script>alert('公告发布成功。');location='issueBulletin.aspx'</script>");
        }
        else
        {
            Response.Write("<script>alert('公告发布失败。可能超出公告最大字数4000字。');location='issueBulletin.aspx'</script>");
        }



    }
开发者ID:zwxscience,项目名称:Paper-management-system,代码行数:24,代码来源:issueBulletin.aspx.cs

示例10: Add_Update

        private bool Add_Update()
        {
            try
            {

                DB DataBase = new DB("points");

                DataBase.AddColumn("pon_name", Point_TB.Text.Trim());
                DataBase.AddColumn("pon_type", Type_CB.SelectedIndex - 1);
                if(Point_Id == null)
                {
                    if(DataBase.IsNotExist("pon_id", "pon_name", "pon_type"))
                    {
                        return Confirm.Check(DataBase.Insert());
                    }
                    else
                    {
                        Message.Show("لقد تم تسجيل هذه النقطة من قبل", MessageBoxButton.OK, 5);
                        return false;
                    }


                }
                else
                {
                    DataBase.AddCondition("pon_id", this.Point_Id);
                    return Confirm.Check(DataBase.Update());
                }
            }
            catch
            {
                //MessageBox.Show("kiki_method");
                return false;
            }
        }
开发者ID:Enumeg,项目名称:POS-General,代码行数:35,代码来源:Points.xaml.cs

示例11: Add_Update

        public bool Add_Update()
        {
            try
            {
                DB DataBase = new DB("users");
                if(Password_TB.Text.Equals(RePassword_TB.Text))
                {
                    if(this.User_Id == null)
                    {
                        DataBase.AddColumn("user_name", Name_TB.Text);
                        DataBase.AddColumn("user_pass", Password_TB.Text.Trim().GetHashCode());
                        DataBase.AddColumn("user_grp_id", Groups_CB.SelectedValue);

                        if(DataBase.IsNotExist("user_id", "user_name"))
                        {
                            return DataBase.Insert();
                        }
                        else
                        {
                            Message.Show("هذا الاسم مستخدم من قبل", MessageBoxButton.OK, 5);
                            return false;
                        }
                    }
                    else
                    {
                        switch(Edit_Mode)
                        {
                            case Edit_Mode.Edit:
                                DataBase.AddColumn("user_name", Name_TB.Text);
                                DataBase.AddColumn("user_grp_id", Groups_CB.SelectedValue);
                                break;
                            case Edit_Mode.Change_Password:
                                DataBase.AddColumn("user_pass", Password_TB.Text.Trim().GetHashCode());
                                break;
                        }
                        DataBase.AddCondition("user_id", this.User_Id);
                        return DataBase.Update();
                    }
                }
                else
                {
                    Message.Show("كلمة المرور غير متطابقة", MessageBoxButton.OK, 10);
                    return false;
                }
            }
            catch
            {
                return false;
            }

        }
开发者ID:Enumeg,项目名称:POS-General,代码行数:51,代码来源:User.xaml.cs

示例12: Button1_Click

    protected void Button1_Click(object sender, EventArgs e)
    {   
        DB db=new DB();
    
  
        if (Button1.Text == "提交")//插入操作
        {
             //查找是否存在于表中如果存在则相当已修改,不存在为插入
          
            String insert = "insert into studentTask(Depart,specify,name,student_ID,class,period,periodUp,teacher_Name,title,kind,project_Name,project_Depart,project_Num,content,aim,ref,remark,Year,teacher_ID) values('" + Label1.Text + "','" + Label2.Text + "','" + Label3.Text + "','" + Label4.Text + "','" + Label5.Text + "','" + Label6.Text + "','" + Label7.Text + "','" + Label8.Text + "','" + Label9.Text + "','" + RadioButtonList1.SelectedValue + "','" + Label10.Text + "','" + Label11.Text + "','" + Label12.Text + "','" + this.TextBox1.Text + "','" + this.TextBox2.Text + "','" + this.TextBox3.Text + "','" + this.TextBox4.Text + "','" + Session["year"] + "','" + Session["teacher_ID"] + "') ";
         
           if(db.Insert(insert,db.DBconn())){
               Response.Write("<script>alert('学生任务书填写成功。');location='studentTaskPaper.aspx'</script>");
           }
            else{
                Response.Write("<script>alert('学生任务书填写失败。');location='studentTaskPaper.aspx'</script>");
            }
       
        }
        else//更新操作
        {
            

            String update = "update studentTask set content='"+this.TextBox1.Text+"',aim='"+this.TextBox2.Text+"',ref='"+this.TextBox3.Text+"',remark='"+this.TextBox4.Text+"' where student_ID='" + Session["username"] + "'";
            
            if (db.Insert(update, db.DBconn()))
            {
                Response.Write("<script>alert('学生任务书修改成功。');location='studentTaskPaper.aspx'</script>");
            }
            else
            {
                Response.Write("<script>alert('学生任务书修改失败。');location='studentTaskPaper.aspx'</script>");
            }
       
        }
    }
开发者ID:zwxscience,项目名称:Paper-management-system,代码行数:36,代码来源:studentTaskPaper.aspx.cs

示例13: Button3_Click1

    protected void Button3_Click1(object sender, EventArgs e)//出题
    {
        //取数
        DB db = new DB();
        //如果title为空,不可以操作
        if (this.papertitle.Text == "")
        {
            Response.Write("<script>alert('论文题目不能为空。');</script>");
            return;

        }

        String insert = "insert into paperApply(teacher_ID,preriod,title,kind,project_Name,project_Depart,project_Num,target,aim_Meaning,current_situation,content,reference,remark,Year,teacher_Name,schedule) values('" + Session["username"]
            + "','" + this.papertime.Text + "','" + this.papertitle.Text + "','" + this.kind.SelectedValue + "','" + this.projectName.Text + "','" + this.project_department.Text + "','" + this.projectNumber.Text + "','" + this.aim.Text
            + "','" + this.mean.Text + "','" + this.state.Text + "','" + this.content.Text + "','" + this.refer.Text + "','" + this.remark.Text + "','" + Session["year"] + "','" + Session["name"] + "','" + TextBox7.Text + "')";
        //验证是否曾经出过此题
        string sel = "select * from paperApply where title='" + this.papertitle.Text + "'";
        DataSet ds = db.Select(sel, db.DBconn());
        string his = "";
        foreach (DataRow theRow in ds.Tables[0].Rows)
        {

          // Console.WriteLine(theRow["CustomerID"] + "\t" + theRow["ContactName"]);
            his = his + "教师" + theRow["teacher_ID"].ToString() + theRow["teacher_Name"].ToString().Trim() + "于" + theRow["Year"].ToString() + "年曾经出过相同的题目。";
        }
        bool state = db.Insert(insert, db.DBconn());
        if (state)
        {
           
            this.Panel1.Visible = false;
            Response.Write("<script>alert('"+his +"课题发布成功。');location='paperOpe.aspx'</script>");
        }
        else
        {
          
            Response.Write("<script>alert('" + his + "数据插入失败!课题发布失败。');location='paperOpe.aspx'</script>");
        }
    }
开发者ID:zwxscience,项目名称:Paper-management-system,代码行数:38,代码来源:paperOpe1.aspx.cs

示例14: Add_Update

        public bool Add_Update()
        {
            try
            {

                DB DataBase = new DB("outcome");

                DataBase.AddColumn("out_date", Date_TB.Text);
                DataBase.AddColumn("out_value", Value_TB.Text);
                DataBase.AddColumn("out_description", Description_TB.Text);
                DataBase.AddColumn("out_ott_id", Type_CB.SelectedValue);
                //DataBase.AddColumn("out_pon_id", Point_ID);



                if (this.Outcome_Id == null)
                {
                    if (DataBase.IsNotExist("out_id", "out_date", "out_value", "out_description", "out_ott_id", "out_pon_id"))
                    {
                        return Confirm.Check(DataBase.Insert());
                    }
                    else
                    {
                        // ye3ny hwa mawgood asln mesh ha3ml 7aga 
                        Message.Show("هذا المستند موجود من قبل", MessageBoxButton.OK, 5);
                        return false;
                        //DataBase.AddCondition("pl_id", this.placeId);
                        //DataBase.Update();

                    }


                }

// hena ye3ny hwa mawgod ba3mel edit
                else
                {
                    DataBase.AddCondition("out_id", this.Outcome_Id);
                    return Confirm.Check(DataBase.Update());
                }
            }
            catch
            {
                return Confirm.Check(false);
            }
        }
开发者ID:Enumeg,项目名称:POS-General,代码行数:46,代码来源:Outcome.xaml.cs

示例15: Button1_Click

    protected void Button1_Click(object sender, EventArgs e)
    {

        DB db = new DB();
        SqlConnection conn = db.DBconn();
        DateTime time = DateTime.Now;
        String topic = "指导记录";
        if (this.TextBox2.Text == "")
        {
            Response.Write("<script>alert('审批内容不能为空!');</script>");
            return;
        }
        String insert = "insert into StoTContent(teacher_ID,teacher_Name,student_ID,student_Name,state,Content,time,topic,Year,count) values('" + Session["username"].ToString() + "','" + Session["name"].ToString() + "','" + Session["student_ID"].ToString() + "','" + Session["student_Name"].ToString() + "','" + this.RadioButtonList1.SelectedValue + "','" + this.TextBox2.Text + "','" + time + "','" + topic + "','" + Session["year"] + "','" + Session["count"] + "') ";
        if (db.Insert(insert, conn))
        {
            Response.Write("<script>alert('指导记录审批成功。');location='guiMarkEA.aspx'</script>");
        }
        else
        {
            Response.Write("<script>alert('指导记录批失败。');location='guiMarkEA.aspx'</script>");
        }


   
    }
开发者ID:zwxscience,项目名称:Paper-management-system,代码行数:25,代码来源:guiMarkEA1.aspx.cs


注:本文中的DB.Insert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。