Example #1
0
        public void DataBind()//定义一个函数用于绑定数据到DataGridView
        {
            BLL.SellGoodsInfo bll = new BLL.SellGoodsInfo();
            DataSet           ds  = new DataSet();

            ds = bll.GetList();                      //执行SQL语句,将结果存在ds中
            dataGridView1.DataSource = ds.Tables[0]; //将ds中的表作为DataGridView的数据源
        }
Example #2
0
        private void toolSave_Click(object sender, EventArgs e)
        {
            if (txtSellID.Text == "" || txtDepotName.Text == "" || txtGoodsID.Text == "" || txtGoodsName.Text == "" || txtdeSellPrice.Text == "" || txtSellNeedPay.Text == "" || txtdeSellHasPay.Text == "")
            {
                MessageBox.Show("请将信息添加完整!");
                return;
            }
            Model.SellGoodsInfo model = new Model.SellGoodsInfo();//实例化model层
            model.SellID         = txtSellID.Text.Trim();
            model.GoodsID        = txtGoodsID.Text.Trim();
            model.EmployeeID     = cboEmpID.Text.Trim();
            model.CompanyName    = txtCompanyName.Text.Trim();
            model.DepotName      = txtDepotName.Text.Trim();
            model.GoodsName      = txtGoodsName.Text.Trim();
            model.SellGoodsNum   = int.Parse(numSellGoodsNum.Value.ToString());
            model.SellGoodsTime  = DateTime.Parse(this.DaSellGoodsTime.Text);
            model.SellGoodsPrice = txtdeSellPrice.Text.Trim();
            model.SellNeedPay    = txtSellNeedPay.Text.Trim();
            model.SellHasPay     = txtdeSellHasPay.Text.Trim();
            model.SellRemark     = txtSellRemark.Text.Trim();
            BLL.SellGoodsInfo bll    = new BLL.SellGoodsInfo();//实例化BLL层
            Model.KCInfo      kcInfo = new Model.KCInfo();
            kcInfo.GoodsID     = txtGoodsID.Text.Trim();
            kcInfo.GoodsName   = txtGoodsName.Text;
            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;
            }
        }