Ejemplo n.º 1
0
        private void toolSave_Click(object sender, EventArgs e)
        {
            if (txtThGoodsID.Text == "" || txtSellID.Text == "" || txtGoodsID.Text == "" || txtSellID.Text == "" || txtThGoodsName.Text == "" || numSellGoodsNum.Text == "" || txtThHasPay.Text == "" || txtThNeedPay.Text == "" || cboEmpID.Text == "")
            {
                MessageBox.Show("请将信息添加完整!");
                return;
            }
            Model.THGoodsInfo model = new Model.THGoodsInfo();//实例化model层
            model.THGoodsID     = txtThGoodsID.Text.Trim();
            model.KCID          = "";
            model.GoodsID       = txtGoodsID.Text.Trim();
            model.SellID        = txtSellID.Text.Trim();
            model.EmploayeeID   = cboEmpID.Text.Trim();
            model.THGoodsName   = txtThGoodsName.Text.Trim();
            model.THGoodsNum    = int.Parse(numSellGoodsNum.Text.Trim());
            model.THGoodsTime   = DateTime.Parse(daThGoodsTime.Value.ToString());
            model.THGoodsPrice  = float.Parse(txtThGoodsPrice.Text.Trim());
            model.THNeedPay     = float.Parse(txtThNeedPay.Text.Trim());
            model.THHasPay      = float.Parse(txtThHasPay.Text.Trim());
            model.THGoodsResult = txtThGoodsResult.Text;

            BLL.THGoodsInfo bll = new BLL.THGoodsInfo();//实例化BLL层

            Model.KCInfo kcInfo = new Model.KCInfo();
            kcInfo.GoodsID     = txtGoodsID.Text.Trim();
            kcInfo.GoodsName   = txtThGoodsName.Text.Trim();
            kcInfo.DepotName   = txtDepotName.Text.Trim();
            kcInfo.CompanyName = txtCompanyName.Text.Trim();
            string strWhere = " GoodsID = '" + kcInfo.GoodsID + "'";

            BLL.KCInfo bllkcInfo = new BLL.KCInfo();//实例化BLL层
            DataSet    ds        = new DataSet();

            ds = bllkcInfo.GetList(strWhere);
            int sum = int.Parse(ds.Tables[0].Rows[0]["商品数量"].ToString());

            kcInfo.GoodsNum = sum + int.Parse(numSellGoodsNum.Value.ToString());
            switch (flag)
            {
            case 0:
            {
            } break;

            case 1:
            {
                if (bll.Add(model))    //将员工信息添加到数据库中,根据返回值判断是否添加成功
                {
                    DataBind();        //窗体登录时绑定数据到DataGridView
                    ControlStatus();
                }
                if (!bllkcInfo.Update(kcInfo))
                {
                    MessageBox.Show("未能够把数据添加到仓库中");
                }
            } break;
            }
        }
Ejemplo n.º 2
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     if (txtAlarmNum.Text == "" || txtGoodsNum.Text == "" || txtid.Text == "" || txtGoodsName.Text == "" || txtDepotName.Text == "" || txtCompanyName.Text == "")
     {
         MessageBox.Show("请将信息添加完整!");
         return;
     }
     Model.KCInfo model = new Model.KCInfo();
     model.GoodsID     = txtid.Text.Trim();
     model.GoodsName   = txtGoodsName.Text.Trim();
     model.CompanyName = txtCompanyName.Text.Trim();
     model.DepotName   = txtDepotName.Text.Trim();
     model.GoodsNum    = int.Parse(txtGoodsNum.Text.Trim());
     model.AlarmNum    = int.Parse(txtAlarmNum.Text.Trim());
     BLL.KCInfo bll = new BLL.KCInfo();
     if (bll.Update(model)) //将员工信息添加到数据库中,根据返回值判断是否添加成功
     {
         DataBind();        //窗体登录时绑定数据到DataGridView
     }
 }
Ejemplo n.º 3
0
        private void toolSave_Click(object sender, EventArgs e)
        {
            if (txtGoodsID.Text == "" || txtGoodsName.Text == "" || cboComName.Text == "" || cboDepotName.Text == "")
            {
                MessageBox.Show("请将信息添加完整!");
                return;
            }
            Model.JHGoodsInfo model = new Model.JHGoodsInfo();//实例化model层
            model.GoodsID        = txtGoodsID.Text.Trim();
            model.EmployeeID     = cboEmployeeID.Text.Trim();
            model.CompanyName    = cboComName.Text.Trim();
            model.DepotName      = cboDepotName.Text.Trim();
            model.GoodsName      = txtGoodsName.Text;
            model.GoodsNum       = int.Parse(numGoodsNum.Value.ToString());
            model.GoodsUnit      = cmbGoodsUnit.Text.Trim();
            model.GoodsJHPrice   = float.Parse(txtGoodsJHPrice.Text.Trim());
            model.GoodsSellPrice = float.Parse(txtSellGoodsPrice.Text.Trim());
            model.GoodsNeedPay   = float.Parse(txtGoodsNeedPrice.Text.Trim());
            model.GoodsHasPay    = float.Parse(txtGoodsHasPay.Text.Trim());
            model.GoodsRemark    = txtRemarks.Text;
            model.GoodsTime      = DateTime.Parse(dateTimePicker1.Text);
            BLL.JHGoodsInfo bll    = new BLL.JHGoodsInfo();//实例化BLL层
            Model.KCInfo    kcInfo = new Model.KCInfo();
            kcInfo.GoodsID     = txtGoodsID.Text.Trim();
            kcInfo.GoodsName   = txtGoodsName.Text;
            kcInfo.CompanyName = cboComName.Text.Trim();
            kcInfo.DepotName   = cboDepotName.Text.Trim();
            kcInfo.GoodsNum    = int.Parse(numGoodsNum.Value.ToString());
            BLL.KCInfo bllkcInfo = new BLL.KCInfo();//实例化BLL层
            switch (flag)
            {
            case 0:
            {
            } break;

            case 1:
            {
                if (bll.Add(model))    //将员工信息添加到数据库中,根据返回值判断是否添加成功
                {
                    DataBind();        //窗体登录时绑定数据到DataGridView
                    ControlStatus();
                }
                if (!bllkcInfo.Add(kcInfo))
                {
                    MessageBox.Show("未能够把数据添加到仓库中");
                }
            } break;

            case 2:
            {
                if (bll.Update(model)) //根据返回布尔值判断是否修改数据成功
                {
                    DataBind();        //窗体登录时绑定数据到DataGridView
                    ControlStatus();
                }
                if (!bllkcInfo.Update(kcInfo))
                {
                    MessageBox.Show("未能够把数据修改到仓库中");
                }
            } break;
            }
        }