Exemplo n.º 1
0
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool Add(tsuhan_scgl_khdm model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into tsuhan_scgl_khdm(");
            strSql.Append("id,客户代码,客户信息,录入员,录入时间)");
            strSql.Append(" values (");
            strSql.Append("@id,@客户代码,@客户信息,@录入员,@录入时间)");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int,4),
                    new SqlParameter("@客户代码", SqlDbType.VarChar,30),
                    new SqlParameter("@客户信息", SqlDbType.VarChar,100),
                    new SqlParameter("@录入员", SqlDbType.VarChar,20),
                    new SqlParameter("@录入时间", SqlDbType.VarChar,50)};
            parameters[0].Value = model.id;
            parameters[1].Value = model.客户代码;
            parameters[2].Value = model.客户信息;
            parameters[3].Value = model.录入员;
            parameters[4].Value = model.录入时间;

            int rows = dbhelper3.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnAdd_Click(object sender, EventArgs e)
 {
     DialogResult dr = MessageBox.Show("确定要添加吗???","提示",MessageBoxButtons.YesNo);
      if (dr == DialogResult.Yes)
      {
          tsuhan_scgl_khdm khdms = new tsuhan_scgl_khdm();
          var gt = yhbll.GetModel(frmOne.txtUserName.Text);
          khdms.客户代码 = this.txtKHDM.Text;
          khdms.客户信息 = this.txtKHXX.Text;
          khdms.录入时间 = DateTime.Now.ToString();
          khdms.录入员 = gt.工号;
          bool result = khdm.Add(khdms);
          if (result == true)
          {
              MessageBox.Show("添加成功", "提示");
              this.btnAdd.Enabled = false;
              this.btnAdd.BackColor = Color.LightGray;
              this.btnDelete.Enabled = true;
              this.btnDelete.BackColor = Color.Gainsboro;
              this.dataGridView1.AutoGenerateColumns = false;
              DataSet ds = khdm.GetKeHTable();
              this.dataGridView1.DataSource = ds.Tables[0];
          }
          else
          {
              MessageBox.Show("添加失败", "提示");
              this.btnDelete.Enabled = false;
              this.btnDelete.BackColor = Color.LightGray;
              this.btnAdd.Enabled = true;
              this.btnAdd.BackColor = Color.Gainsboro;
          }
      }
 }
Exemplo n.º 3
0
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="khdms"></param>
 /// <returns></returns>
 public bool Add(tsuhan_scgl_khdm khdms)
 {
     return dal.Add(khdms); ;
 }