Ejemplo n.º 1
0
 private void dgvCellClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.RowIndex < 0)
     {
         return;
     }
     optrowid = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();
     if (!String.IsNullOrEmpty(optrowid))
     {
         model = dal.GetModel(int.Parse(optrowid));
         if (model != null)
         {
             BLL.tb_proc   dalp = new BLL.tb_proc();
             Model.tb_proc molp = new Model.tb_proc();
             molp                         = dalp.GetModel(int.Parse(model.cr_pid.ToString()));
             this.txtno.Text              = molp.p_no;
             this.txtname.Text            = molp.p_name;
             this.txttyid.Text            = model.cr_pid.ToString();
             this.txtorder.SelectedValue  = model.cr_oid.ToString();
             this.txtprice.Text           = model.cr_price.ToString();
             this.txtrek.Text             = model.cr_remark;
             this.txtnum.Text             = model.cr_num.ToString();
             this.txtstatus.SelectedValue = model.cr_yan.ToString();
         }
     }
 }
Ejemplo n.º 2
0
        private void dgvCellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0)
            {
                return;
            }
            optrowid = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();
            if (!String.IsNullOrEmpty(optrowid))
            {
                model = dal.GetModel(Int32.Parse(optrowid));
                if (model != null)
                {
                    Model.tb_proc ml = new Model.tb_proc();
                    ml           = dalt.GetModel(int.Parse(model.p_pid.ToString()));
                    txtname.Text = ml.p_name;
                    txtno.Text   = ml.p_no;
                    txttyid.Text = model.p_pid.ToString();

                    txttime.Text   = model.p_time;
                    txtnumold.Text = model.p_numold.ToString();
                    txtnumnow.Text = model.p_numnow.ToString();
                    txtuser.Text   = model.p_user;
                    txtrek.Text    = model.p_remark;
                }
            }
        }
Ejemplo n.º 3
0
        private void dgvCellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0)
            {
                return;
            }
            optrowid = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();
            if (!String.IsNullOrEmpty(optrowid))
            {
                model = dal.GetModel(Int32.Parse(optrowid));
                if (model != null)
                {
                    txttype.Text   = getStr(1, int.Parse(model.p_tyid.ToString()));
                    txtck.Text     = getStr(2, int.Parse(model.p_ckid.ToString()));
                    txtkuqu.Text   = getStr(2, int.Parse(model.p_kqid.ToString()));
                    txtrzsj.Text   = getStr(4, int.Parse(model.p_rzfid.ToString()));
                    txttyid.Text   = model.p_tyid.ToString();
                    txtckid.Text   = model.p_ckid.ToString();
                    txtkqid.Text   = model.p_kqid.ToString();
                    txtrzsjid.Text = model.p_rzfid.ToString();

                    txtno.Text           = model.p_no;
                    txtname.Text         = model.p_name;
                    txtprice.Text        = model.p_price;
                    txtchjia.Text        = model.p_shang;
                    txtunit.SelectedText = model.p_unit;
                    txtppai.Text         = model.p_pinpai;
                    txtmodel.Text        = model.p_model;
                }
            }
        }
Ejemplo n.º 4
0
 private void dgvCellClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.RowIndex < 0)
     {
         return;
     }
     optrowid = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();
     if (!String.IsNullOrEmpty(optrowid))
     {
         model = dal.GetModel(int.Parse(optrowid));
         if (model != null)
         {
             this.txtno.Text   = model.p_no;
             this.txtname.Text = model.p_name;
             this.txtsx.Text   = model.p_sx;
             this.txtxx.Text   = model.p_xx;
         }
     }
 }
Ejemplo n.º 5
0
        private void tbBtnClick(object sender, ToolBarButtonClickEventArgs e)
        {
            if (e.Button.ToolTipText == "新增")
            {
                rstValue();
                setModifyMode(true);
                optrowid = null;
            }
            if (e.Button.ToolTipText == "修改")
            {
                if (!String.IsNullOrEmpty(optrowid))
                {
                    setModifyMode(true);
                }
                else
                {
                    MessageBox.Show("请选择所要修改的行", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }
            if (e.Button.ToolTipText == "删除")
            {
                if (!String.IsNullOrEmpty(optrowid))
                {
                    DialogResult result = MessageBox.Show("确认删除?", "删除数据", MessageBoxButtons.OKCancel);
                    if (result == DialogResult.OK)
                    {
                        dal.Delete(int.Parse(optrowid));
                        rstValue();
                        MessageBox.Show("恭喜你,删除成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        bindData("cr_type=1");
                        setModifyMode(false);
                        optrowid = null;
                    }
                }
                else
                {
                    MessageBox.Show("请选择所要删除的行", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }
            if (e.Button.ToolTipText == "提交")
            {
                if (ValidateIput())
                {
                    model = new Model.tb_churu();

                    if (!string.IsNullOrEmpty(optrowid))
                    {
                        model = dal.GetModel(int.Parse(optrowid));
                    }
                    model.cr_oid    = int.Parse(this.txtorder.SelectedValue.ToString());
                    model.cr_pid    = int.Parse(txttyid.Text);
                    model.cr_price  = decimal.Parse(txtprice.Text);
                    model.cr_remark = txtrek.Text;
                    model.cr_type   = 1;
                    model.cr_yan    = int.Parse(this.txtstatus.SelectedValue.ToString());
                    int tempNum = int.Parse(this.txtnum.Text);
                    if (tempNum <= 0)
                    {
                        MessageBox.Show("输入数量有误,请重新输入", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    model.cr_num = tempNum;
                    if (String.IsNullOrEmpty(optrowid))
                    {
                        model.cr_time = System.DateTime.Now.ToString("yyyy-MM-dd");
                        if (dal.Add(model) > 0)
                        {
                            BLL.tb_proc   dap = new BLL.tb_proc();
                            Model.tb_proc mop = new Model.tb_proc();
                            mop = dap.GetModel(int.Parse(txttyid.Text));
                            if (model.cr_yan == 1)
                            {
                                mop.p_num = mop.p_num + int.Parse(this.txtnum.Text); //验收状态:是
                            }
                            else
                            {
                                mop.p_num = mop.p_num + 0; //验收状态:否
                            }
                            if (!string.IsNullOrEmpty(mop.p_sx))
                            {
                                if (mop.p_num > int.Parse(mop.p_sx))
                                {
                                    MessageBox.Show("已超过库存预警上限,请更换", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                    return;
                                }
                            }
                            dap.Update(mop);
                            if (model.cr_yan == 1)
                            {
                                MessageBox.Show("恭喜你,验收入库成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); //验收状态:是
                            }
                            else
                            {
                                MessageBox.Show("商品验收入库失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); //验收状态:否
                            }
                            rstValue();
                            bindData("cr_type=1");
                            setModifyMode(false);
                            optrowid = null;
                        }
                    }
                    else
                    {
                        if (dal.Update(model))
                        {
                            MessageBox.Show("恭喜你,修改成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            rstValue();
                            bindData("cr_type=1");
                            setModifyMode(false);
                            optrowid = null;
                        }
                    }
                }
            }

            if (e.Button.ToolTipText == "取消")
            {
                bindData("cr_type=1");
                rstValue();
                setModifyMode(false);
                optrowid = null;
            }

            if (e.Button.ToolTipText == "退出")
            {
                this.Close();
            }
        }
Ejemplo n.º 6
0
 private void tbBtnClick(object sender, ToolBarButtonClickEventArgs e)
 {
     if (e.Button.ToolTipText == "新增")
     {
         rstValue();
         setModifyMode(true);
         optrowid = null;
     }
     if (e.Button.ToolTipText == "修改")
     {
         if (!String.IsNullOrEmpty(optrowid))
         {
             setModifyMode(true);
         }
         else
         {
             MessageBox.Show("请选择所要修改的行", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             return;
         }
     }
     if (e.Button.ToolTipText == "删除")
     {
         if (!String.IsNullOrEmpty(optrowid))
         {
             DialogResult result = MessageBox.Show("确认删除?", "删除数据", MessageBoxButtons.OKCancel);
             if (result == DialogResult.OK)
             {
                 dal.Delete(int.Parse(optrowid));
                 rstValue();
                 MessageBox.Show("恭喜你,删除成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 bindData("");
                 setModifyMode(false);
                 optrowid = null;
             }
         }
         else
         {
             MessageBox.Show("请选择所要删除的行", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             return;
         }
     }
     if (e.Button.ToolTipText == "提交")
     {
         if (validateIput())
         {
             model = new Model.tb_proc();
             if (!String.IsNullOrEmpty(optrowid))
             {
                 model = dal.GetModel(int.Parse(optrowid));
             }
             model.p_no     = this.txtno.Text;
             model.p_name   = this.txtname.Text;
             model.p_pinpai = this.txtppai.Text;
             model.p_model  = this.txtmodel.Text;
             model.p_price  = this.txtprice.Text;
             model.p_shang  = txtchjia.Text;
             model.p_unit   = txtunit.Text;
             model.p_ckid   = int.Parse(this.txtckid.Text);
             model.p_kqid   = int.Parse(this.txtkqid.Text);
             model.p_tyid   = int.Parse(this.txttyid.Text);
             model.p_rzfid  = int.Parse(this.txtrzsjid.Text);
             if (String.IsNullOrEmpty(optrowid))
             {
                 model.p_addtime = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm");
                 int i = dal.Add(model);
                 if (i > 0)
                 {
                     MessageBox.Show("恭喜你,新增成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     rstValue();
                     bindData("");
                     setModifyMode(false);
                     optrowid = null;
                 }
             }
             else
             {
                 if (dal.Update(model))
                 {
                     MessageBox.Show("恭喜你,修改成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     rstValue();
                     bindData("");
                     setModifyMode(false);
                     optrowid = null;
                 }
             }
         }
     }
     if (e.Button.ToolTipText == "取消")
     {
         bindData("");
         rstValue();
         setModifyMode(false);
         optrowid = null;
     }
     if (e.Button.ToolTipText == "退出")
     {
         this.Close();
     }
 }
Ejemplo n.º 7
0
        private void tbBtnClick(object sender, ToolBarButtonClickEventArgs e)
        {
            if (e.Button.ToolTipText == "新增")
            {
                rstValue();
                setModifyMode(true);
                optrowid = null;
            }
            if (e.Button.ToolTipText == "修改")
            {
                if (!String.IsNullOrEmpty(optrowid))
                {
                    setModifyMode(true);
                }
                else
                {
                    MessageBox.Show("请选择所要修改的行", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }
            if (e.Button.ToolTipText == "删除")
            {
                if (!String.IsNullOrEmpty(optrowid))
                {
                    DialogResult result = MessageBox.Show("确认删除?", "删除数据", MessageBoxButtons.OKCancel);
                    if (result == DialogResult.OK)
                    {
                        dal.Delete(int.Parse(optrowid));
                        rstValue();
                        MessageBox.Show("恭喜你,删除成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        bindData("");
                        setModifyMode(false);
                        optrowid = null;
                    }
                }
                else
                {
                    MessageBox.Show("请选择所要删除的行", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }
            if (e.Button.ToolTipText == "提交")
            {
                if (validateInput())
                {
                    model = new Model.tb_pan();
                    if (!String.IsNullOrEmpty(optrowid))
                    {
                        model = dal.GetModel(int.Parse(optrowid));
                    }
                    model.p_pid  = int.Parse(this.txttyid.Text);
                    model.p_time = this.txttime.Text;
                    int tempNumold = int.Parse(this.txtnumold.Text);
                    if (tempNumold < 0)
                    {
                        MessageBox.Show("输入数量有误,请重新输入", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    model.p_numold = tempNumold;
                    int tempNumnow = int.Parse(this.txtnumnow.Text);
                    if (tempNumnow < 0)
                    {
                        MessageBox.Show("输入数量有误,请重新输入", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    model.p_numnow = tempNumnow;
                    model.p_user   = txtuser.Text;
                    model.p_remark = this.txtrek.Text;


                    if (String.IsNullOrEmpty(optrowid))
                    {
                        int i = dal.Add(model);
                        if (i > 0)
                        {
                            BLL.tb_proc   dalp = new BLL.tb_proc();
                            Model.tb_proc molp = new Model.tb_proc();
                            molp       = dalp.GetModel(int.Parse(model.p_pid.ToString()));
                            molp.p_num = model.p_numnow;
                            dalp.Update(molp);
                            MessageBox.Show("恭喜你,新增成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            rstValue();
                            bindData("");
                            setModifyMode(false);
                            optrowid = null;
                        }
                    }
                    else
                    {
                        if (dal.Update(model))
                        {
                            BLL.tb_proc   dalp = new BLL.tb_proc();
                            Model.tb_proc molp = new Model.tb_proc();
                            molp       = dalp.GetModel(int.Parse(model.p_pid.ToString()));
                            molp.p_num = model.p_numnow;
                            dalp.Update(molp);
                            MessageBox.Show("恭喜你,修改成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            rstValue();
                            bindData("");
                            setModifyMode(false);
                            optrowid = null;
                        }
                    }
                }
            }

            if (e.Button.ToolTipText == "取消")
            {
                bindData("");
                rstValue();
                setModifyMode(false);
                optrowid = null;
            }

            if (e.Button.ToolTipText == "退出")
            {
                this.Close();
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.tb_proc model)
        {
            StringBuilder strSql  = new StringBuilder();
            StringBuilder strSql1 = new StringBuilder();
            StringBuilder strSql2 = new StringBuilder();

            if (model.p_no != null)
            {
                strSql1.Append("p_no,");
                strSql2.Append("'" + model.p_no + "',");
            }
            if (model.p_name != null)
            {
                strSql1.Append("p_name,");
                strSql2.Append("'" + model.p_name + "',");
            }
            if (model.p_tyid != null)
            {
                strSql1.Append("p_tyid,");
                strSql2.Append("" + model.p_tyid + ",");
            }
            if (model.p_pinpai != null)
            {
                strSql1.Append("p_pinpai,");
                strSql2.Append("'" + model.p_pinpai + "',");
            }
            if (model.p_model != null)
            {
                strSql1.Append("p_model,");
                strSql2.Append("'" + model.p_model + "',");
            }
            if (model.p_shang != null)
            {
                strSql1.Append("p_shang,");
                strSql2.Append("'" + model.p_shang + "',");
            }
            if (model.p_price != null)
            {
                strSql1.Append("p_price,");
                strSql2.Append("'" + model.p_price + "',");
            }
            if (model.p_unit != null)
            {
                strSql1.Append("p_unit,");
                strSql2.Append("'" + model.p_unit + "',");
            }
            if (model.p_sx != null)
            {
                strSql1.Append("p_sx,");
                strSql2.Append("'" + model.p_sx + "',");
            }
            if (model.p_xx != null)
            {
                strSql1.Append("p_xx,");
                strSql2.Append("'" + model.p_xx + "',");
            }
            if (model.p_desc != null)
            {
                strSql1.Append("p_desc,");
                strSql2.Append("'" + model.p_desc + "',");
            }
            if (model.p_addtime != null)
            {
                strSql1.Append("p_addtime,");
                strSql2.Append("'" + model.p_addtime + "',");
            }
            if (model.p_ckid != null)
            {
                strSql1.Append("p_ckid,");
                strSql2.Append("" + model.p_ckid + ",");
            }
            if (model.p_kqid != null)
            {
                strSql1.Append("p_kqid,");
                strSql2.Append("" + model.p_kqid + ",");
            }
            if (model.p_num != null)
            {
                strSql1.Append("p_num,");
                strSql2.Append("" + model.p_num + ",");
            }
            if (model.p_rzfid != null)
            {
                strSql1.Append("p_rzfid,");
                strSql2.Append("" + model.p_rzfid + ",");
            }
            strSql.Append("insert into tb_proc(");
            strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1));
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1));
            strSql.Append(")");
            strSql.Append(";select @@IDENTITY");
            object obj = DbSQL.GetSingle(strSql.ToString());

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.tb_proc GetModel(int p_id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1  ");
            strSql.Append(" p_id,p_no,p_name,p_tyid,p_pinpai,p_model,p_shang,p_price,p_unit,p_sx,p_xx,p_desc,p_addtime,p_ckid,p_kqid,p_num,p_rzfid ");
            strSql.Append(" from tb_proc ");
            strSql.Append(" where p_id=" + p_id + "");
            Model.tb_proc model = new Model.tb_proc();
            DataSet       ds    = DbSQL.Query(strSql.ToString());

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["p_id"] != null && ds.Tables[0].Rows[0]["p_id"].ToString() != "")
                {
                    model.p_id = int.Parse(ds.Tables[0].Rows[0]["p_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["p_no"] != null && ds.Tables[0].Rows[0]["p_no"].ToString() != "")
                {
                    model.p_no = ds.Tables[0].Rows[0]["p_no"].ToString();
                }
                if (ds.Tables[0].Rows[0]["p_name"] != null && ds.Tables[0].Rows[0]["p_name"].ToString() != "")
                {
                    model.p_name = ds.Tables[0].Rows[0]["p_name"].ToString();
                }
                if (ds.Tables[0].Rows[0]["p_tyid"] != null && ds.Tables[0].Rows[0]["p_tyid"].ToString() != "")
                {
                    model.p_tyid = int.Parse(ds.Tables[0].Rows[0]["p_tyid"].ToString());
                }
                if (ds.Tables[0].Rows[0]["p_pinpai"] != null && ds.Tables[0].Rows[0]["p_pinpai"].ToString() != "")
                {
                    model.p_pinpai = ds.Tables[0].Rows[0]["p_pinpai"].ToString();
                }
                if (ds.Tables[0].Rows[0]["p_model"] != null && ds.Tables[0].Rows[0]["p_model"].ToString() != "")
                {
                    model.p_model = ds.Tables[0].Rows[0]["p_model"].ToString();
                }
                if (ds.Tables[0].Rows[0]["p_shang"] != null && ds.Tables[0].Rows[0]["p_shang"].ToString() != "")
                {
                    model.p_shang = ds.Tables[0].Rows[0]["p_shang"].ToString();
                }
                if (ds.Tables[0].Rows[0]["p_price"] != null && ds.Tables[0].Rows[0]["p_price"].ToString() != "")
                {
                    model.p_price = ds.Tables[0].Rows[0]["p_price"].ToString();
                }
                if (ds.Tables[0].Rows[0]["p_unit"] != null && ds.Tables[0].Rows[0]["p_unit"].ToString() != "")
                {
                    model.p_unit = ds.Tables[0].Rows[0]["p_unit"].ToString();
                }
                if (ds.Tables[0].Rows[0]["p_sx"] != null && ds.Tables[0].Rows[0]["p_sx"].ToString() != "")
                {
                    model.p_sx = ds.Tables[0].Rows[0]["p_sx"].ToString();
                }
                if (ds.Tables[0].Rows[0]["p_xx"] != null && ds.Tables[0].Rows[0]["p_xx"].ToString() != "")
                {
                    model.p_xx = ds.Tables[0].Rows[0]["p_xx"].ToString();
                }
                if (ds.Tables[0].Rows[0]["p_desc"] != null && ds.Tables[0].Rows[0]["p_desc"].ToString() != "")
                {
                    model.p_desc = ds.Tables[0].Rows[0]["p_desc"].ToString();
                }
                if (ds.Tables[0].Rows[0]["p_addtime"] != null && ds.Tables[0].Rows[0]["p_addtime"].ToString() != "")
                {
                    model.p_addtime = ds.Tables[0].Rows[0]["p_addtime"].ToString();
                }
                if (ds.Tables[0].Rows[0]["p_ckid"] != null && ds.Tables[0].Rows[0]["p_ckid"].ToString() != "")
                {
                    model.p_ckid = int.Parse(ds.Tables[0].Rows[0]["p_ckid"].ToString());
                }
                if (ds.Tables[0].Rows[0]["p_kqid"] != null && ds.Tables[0].Rows[0]["p_kqid"].ToString() != "")
                {
                    model.p_kqid = int.Parse(ds.Tables[0].Rows[0]["p_kqid"].ToString());
                }
                if (ds.Tables[0].Rows[0]["p_num"] != null && ds.Tables[0].Rows[0]["p_num"].ToString() != "")
                {
                    model.p_num = int.Parse(ds.Tables[0].Rows[0]["p_num"].ToString());
                }
                if (ds.Tables[0].Rows[0]["p_rzfid"] != null && ds.Tables[0].Rows[0]["p_rzfid"].ToString() != "")
                {
                    model.p_rzfid = int.Parse(ds.Tables[0].Rows[0]["p_rzfid"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.tb_proc model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update tb_proc set ");
            if (model.p_no != null)
            {
                strSql.Append("p_no='" + model.p_no + "',");
            }
            else
            {
                strSql.Append("p_no= null ,");
            }
            if (model.p_name != null)
            {
                strSql.Append("p_name='" + model.p_name + "',");
            }
            else
            {
                strSql.Append("p_name= null ,");
            }
            if (model.p_tyid != null)
            {
                strSql.Append("p_tyid=" + model.p_tyid + ",");
            }
            else
            {
                strSql.Append("p_tyid= null ,");
            }
            if (model.p_pinpai != null)
            {
                strSql.Append("p_pinpai='" + model.p_pinpai + "',");
            }
            else
            {
                strSql.Append("p_pinpai= null ,");
            }
            if (model.p_model != null)
            {
                strSql.Append("p_model='" + model.p_model + "',");
            }
            else
            {
                strSql.Append("p_model= null ,");
            }
            if (model.p_shang != null)
            {
                strSql.Append("p_shang='" + model.p_shang + "',");
            }
            else
            {
                strSql.Append("p_shang= null ,");
            }
            if (model.p_price != null)
            {
                strSql.Append("p_price='" + model.p_price + "',");
            }
            else
            {
                strSql.Append("p_price= null ,");
            }
            if (model.p_unit != null)
            {
                strSql.Append("p_unit='" + model.p_unit + "',");
            }
            else
            {
                strSql.Append("p_unit= null ,");
            }
            if (model.p_sx != null)
            {
                strSql.Append("p_sx='" + model.p_sx + "',");
            }
            else
            {
                strSql.Append("p_sx= null ,");
            }
            if (model.p_xx != null)
            {
                strSql.Append("p_xx='" + model.p_xx + "',");
            }
            else
            {
                strSql.Append("p_xx= null ,");
            }
            if (model.p_desc != null)
            {
                strSql.Append("p_desc='" + model.p_desc + "',");
            }
            else
            {
                strSql.Append("p_desc= null ,");
            }
            if (model.p_addtime != null)
            {
                strSql.Append("p_addtime='" + model.p_addtime + "',");
            }
            else
            {
                strSql.Append("p_addtime= null ,");
            }
            if (model.p_ckid != null)
            {
                strSql.Append("p_ckid=" + model.p_ckid + ",");
            }
            else
            {
                strSql.Append("p_ckid= null ,");
            }
            if (model.p_kqid != null)
            {
                strSql.Append("p_kqid=" + model.p_kqid + ",");
            }
            else
            {
                strSql.Append("p_kqid= null ,");
            }
            if (model.p_num != null)
            {
                strSql.Append("p_num=" + model.p_num + ",");
            }
            else
            {
                strSql.Append("p_num= null ,");
            }
            if (model.p_rzfid != null)
            {
                strSql.Append("p_rzfid=" + model.p_rzfid + ",");
            }
            else
            {
                strSql.Append("p_rzfid= null ,");
            }
            int n = strSql.ToString().LastIndexOf(",");

            strSql.Remove(n, 1);
            strSql.Append(" where p_id=" + model.p_id + "");
            int rowsAffected = DbSQL.ExecuteSql(strSql.ToString());

            if (rowsAffected > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 11
0
        private void tbBtnClick(object sender, ToolBarButtonClickEventArgs e)
        {
            if (e.Button.ToolTipText == "修改")
            {
                if (!String.IsNullOrEmpty(optrowid))
                {
                    setModifyMode(true);
                }
                else
                {
                    MessageBox.Show("请选择所要修改的行", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }
            if (e.Button.ToolTipText == "提交")
            {
                if (validateIput())
                {
                    model = new Model.tb_proc();

                    if (!string.IsNullOrEmpty(optrowid))
                    {
                        model = dal.GetModel(int.Parse(optrowid));
                    }
                    if (!string.IsNullOrEmpty(this.txtsx.Text))
                    {
                        int tempSx = int.Parse(this.txtsx.Text);
                        if (tempSx < 0)
                        {
                            MessageBox.Show("预警上限数量输入有误,请重新输入", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        model.p_sx = tempSx + "";
                    }
                    else
                    {
                        model.p_xx = "";
                    }

                    if (!string.IsNullOrEmpty(this.txtxx.Text))
                    {
                        int tempXx = int.Parse(this.txtxx.Text);
                        if (tempXx < 0)
                        {
                            MessageBox.Show("预警下限数量输入有误,请重新输入", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        model.p_xx = tempXx + "";
                    }
                    else
                    {
                        model.p_xx = "";
                    }

                    if (!String.IsNullOrEmpty(optrowid))
                    {
                        if (dal.Update(model))
                        {
                            MessageBox.Show("恭喜你,修改成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            rstValue();
                            bindData("");
                            setModifyMode(false);
                            optrowid = null;
                        }
                    }
                }
            }
            if (e.Button.ToolTipText == "取消")
            {
                bindData("");
                rstValue();
                setModifyMode(false);
                optrowid = null;
            }
            if (e.Button.ToolTipText == "退出")
            {
                this.Close();
            }
        }
Ejemplo n.º 12
0
        private void tbBtnClick(object sender, ToolBarButtonClickEventArgs e)
        {
            if (e.Button.ToolTipText == "新增")
            {
                rstValue();
                setModifyMode(true);
                optrowid = null;
            }
            if (e.Button.ToolTipText == "修改")
            {
                if (!String.IsNullOrEmpty(optrowid))
                {
                    setModifyMode(true);
                }
                else
                {
                    MessageBox.Show("请选择所要修改的行", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }
            if (e.Button.ToolTipText == "删除")
            {
                if (!String.IsNullOrEmpty(optrowid))
                {
                    DialogResult result = MessageBox.Show("确认删除?", "删除数据", MessageBoxButtons.OKCancel);
                    if (result == DialogResult.OK)
                    {
                        dal.Delete(int.Parse(optrowid));
                        rstValue();
                        MessageBox.Show("恭喜你,删除成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        bindData("cr_type=3");
                        setModifyMode(false);
                        optrowid = null;
                    }
                }
                else
                {
                    MessageBox.Show("请选择所要删除的行", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }
            if (e.Button.ToolTipText == "提交")
            {
                if (validateInput())
                {
                    model = new Model.tb_churu();
                    if (!string.IsNullOrEmpty(optrowid))
                    {
                        model = dal.GetModel(int.Parse(optrowid));
                    }
                    model.cr_pid    = int.Parse(txttyid.Text);
                    model.cr_remark = txtdesc.Text;
                    model.cr_type   = 3;
                    int tempNum = int.Parse(this.txtnum.Text);
                    if (tempNum <= 0)
                    {
                        MessageBox.Show("输入数量有误,请重新输入", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    model.cr_num = tempNum;
                    if (String.IsNullOrEmpty(optrowid))
                    {
                        model.cr_time = System.DateTime.Now.ToString("yyyy-MM-dd");
                        Model.tb_proc mop = new Model.tb_proc();
                        BLL.tb_proc   dap = new BLL.tb_proc();
                        mop = dap.GetModel(int.Parse(txttyid.Text));
                        if (mop.p_num < int.Parse(this.txtnum.Text))
                        {
                            MessageBox.Show("库存不足,请更换", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            return;
                        }
                        else
                        {
                            if (!string.IsNullOrEmpty(mop.p_xx))
                            {
                                if (mop.p_num < int.Parse(mop.p_xx))
                                {
                                    MessageBox.Show("已达到库存预警下限", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    return;
                                }
                            }
                            if (dal.Add(model) > 0)
                            {
                                mop.p_num = mop.p_num - int.Parse(this.txtnum.Text);
                                dap.Update(mop);
                                MessageBox.Show("恭喜你,报废成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                rstValue();
                                bindData("cr_type=3");
                                setModifyMode(false);
                                optrowid = null;
                            }
                        }
                    }
                    else
                    {
                        if (dal.Update(model))
                        {
                            MessageBox.Show("恭喜你,修改成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            rstValue();
                            bindData("cr_type=3");
                            setModifyMode(false);
                            optrowid = null;
                        }
                    }
                }
            }

            if (e.Button.ToolTipText == "取消")
            {
                bindData("cr_type=3");
                rstValue();
                setModifyMode(false);
                optrowid = null;
            }

            if (e.Button.ToolTipText == "退出")
            {
                this.Close();
            }
        }