Esempio n. 1
0
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool Add(tsuhan_gt_cpbm model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into tsuhan_gt_cpbm(");
            strSql.Append("成品编码,录入员,时间)");
            strSql.Append(" values (");
            strSql.Append("@成品编码,@录入员,@时间)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters = {
                    new SqlParameter("@成品编码", SqlDbType.NVarChar,30),
                    new SqlParameter("@录入员", SqlDbType.NVarChar,10),
                    new SqlParameter("@时间", SqlDbType.DateTime)};
            parameters[0].Value = model.成品编码;
            parameters[1].Value = model.录入员;
            parameters[2].Value = model.时间;

            int rows = dbhelper1.ExecuteSql(strSql.ToString(), parameters);
            if (rows>0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
Esempio 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)
      {
          var gt = yhbll.GetModel(gh);
          tsuhan_gt_cpbm cpbm = new tsuhan_gt_cpbm();
          cpbm.成品编码 = this.txtCPBM.Text;
          cpbm.时间 =Convert.ToDateTime(this.dtpTime.Text);
          cpbm.录入员 =Convert.ToString(gt.工号);
          bool result = cpbll.Add(cpbm);
          if (result == true)
          {
              MessageBox.Show("添加成功", "提示");
              this.dataGridView1.AutoGenerateColumns = false;
              DataSet ds = cpbll.GetChanPTable();
              this.dataGridView1.DataSource = ds.Tables[0];
          }
          else
          {
              MessageBox.Show("添加失败", "提示");
          }
      }
 }
Esempio n. 3
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Maticsoft.Model.tsuhan_gt_cpbm model)
 {
     return(dal.Update(model));
 }
Esempio n. 4
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(Maticsoft.Model.tsuhan_gt_cpbm model)
 {
     return(dal.Add(model));
 }