Exemple #1
0
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="cpmc"></param>
        /// <returns></returns>
        public bool Add(tsuhan_gt_cpmc model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into tsuhan_gt_cpmc(");
            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);
            }
        }
Exemple #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_gt_cpmc cpmc = new tsuhan_gt_cpmc();
                cpmc.产品名称 = this.txtCPName.Text;
                cpmc.录入员  = Convert.ToString(gh);
                cpmc.时间   = DateTime.Now;
                bool result = cpbll.Add(cpmc);
                if (result == true)
                {
                    MessageBox.Show("添加成功", "提示");
                    this.dataGridView1.AutoGenerateColumns = false;
                    DataSet ds = cpbll.GetChanMAll();
                    this.dataGridView1.DataSource = ds.Tables[0];
                }
                else
                {
                    MessageBox.Show("添加失败", "提示");
                }
            }
        }
Exemple #3
0
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="cpmc"></param>
 /// <returns></returns>
 public bool Add(tsuhan_gt_cpmc cpmc)
 {
     return(dal.Add(cpmc));
 }