Exemplo n.º 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Model.KCInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into KCInfo(");
            strSql.Append("GoodsID,GoodsName,CompanyName,DepotName,GoodsNum,AlarmNum)");
            strSql.Append(" values (");
            strSql.Append("@GoodsID,@GoodsName,@CompanyName,@DepotName,@GoodsNum,@AlarmNum)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@GoodsID",     SqlDbType.NVarChar, 50),
                new SqlParameter("@GoodsName",   SqlDbType.NVarChar, 50),
                new SqlParameter("@CompanyName", SqlDbType.NVarChar, 50),
                new SqlParameter("@DepotName",   SqlDbType.NVarChar, 50),
                new SqlParameter("@GoodsNum",    SqlDbType.Int),
                new SqlParameter("@AlarmNum",    SqlDbType.Int)
            };
            parameters[0].Value = model.GoodsID;
            parameters[1].Value = model.GoodsName;
            parameters[2].Value = model.CompanyName;
            parameters[3].Value = model.DepotName;
            parameters[4].Value = model.GoodsNum;
            parameters[5].Value = model.AlarmNum;
            int rows = DBHelper.ExecuteSql(strSql.ToString(), CommandType.Text, parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
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;
            }
        }
Exemplo n.º 3
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
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(Model.KCInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("delete from KCInfo ");
            strSql.Append(" where GoodsID=@GoodsID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@GoodsID", SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = model.GoodsID;
            int rows = DBHelper.ExecuteSql(strSql.ToString(), CommandType.Text, parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.KCInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update KCInfo set ");
            strSql.Append("GoodsName=@GoodsName,");
            strSql.Append("CompanyName=@CompanyName,");
            strSql.Append("DepotName=@DepotName,");
            strSql.Append("GoodsNum=@GoodsNum,");
            strSql.Append("AlarmNum=@AlarmNum");
            strSql.Append(" where GoodsID=@GoodsID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@GoodsID",     SqlDbType.NVarChar, 50),
                new SqlParameter("@GoodsName",   SqlDbType.NVarChar, 50),
                new SqlParameter("@CompanyName", SqlDbType.NVarChar, 50),
                new SqlParameter("@DepotName",   SqlDbType.NVarChar, 50),
                new SqlParameter("@GoodsNum",    SqlDbType.Int),
                new SqlParameter("@AlarmNum",    SqlDbType.Int)
            };
            parameters[0].Value = model.GoodsID;
            parameters[1].Value = model.GoodsName;
            parameters[2].Value = model.CompanyName;
            parameters[3].Value = model.DepotName;
            parameters[4].Value = model.GoodsNum;
            parameters[5].Value = model.AlarmNum;

            int rows = DBHelper.ExecuteSql(strSql.ToString(), CommandType.Text, parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 6
0
 /// <summary>
 /// 删除一条数据
 /// </summary>
 public bool Delete(Model.KCInfo model)
 {
     return(dal.Delete(model));
 }
Exemplo n.º 7
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Model.KCInfo model)
 {
     return(dal.Update(model));
 }
Exemplo n.º 8
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(Model.KCInfo model)
 {
     return(dal.Add(model));
 }
Exemplo n.º 9
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;
            }
        }