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

            if (model.id != "")
            {
                strSql1.Append("id,");
                strSql2.Append("" + model.id + ",");
            }
            if (model.code != null)
            {
                strSql1.Append("code,");
                strSql2.Append("'" + model.code + "',");
            }
            if (model.name != null)
            {
                strSql1.Append("name,");
                strSql2.Append("'" + model.name + "',");
            }
            if (model.spec != null)
            {
                strSql1.Append("spec,");
                strSql2.Append("'" + model.spec + "',");
            }
            if (model.unit != null)
            {
                strSql1.Append("unit,");
                strSql2.Append("'" + model.unit + "',");
            }
            if (model.price != null)
            {
                strSql1.Append("price,");
                strSql2.Append("" + model.price + ",");
            }
            if (model.number != null)
            {
                strSql1.Append("number,");
                strSql2.Append("" + model.number + ",");
            }
            strSql.Append("insert into TStock(");
            strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1));
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1));
            strSql.Append(")");
            int rows = DbHelperSQLite.ExecuteSql(strSql.ToString());

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
0
 private void txtGoodId_EditValueChanged(object sender, EventArgs e)
 {
     bll.TStock   bll = new bll.TStock();
     model.TStock mod = bll.GetModel(txtGoodId.Text);
     if (null != mod)
     {
         txtCode.Text  = mod.code;
         txtName.Text  = mod.name;
         txtPrice.Text = mod.price + "";
         txtSpec.Text  = mod.spec;
         txtUnit.Text  = mod.unit;
     }
     else
     {
         reset();
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Warehousing.model.TStock GetModel(string id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  ");
            strSql.Append(" id,code,name,spec,unit,price,number ");
            strSql.Append(" from TStock ");
            strSql.Append(" where id='" + id + "'");
            Warehousing.model.TStock model = new Warehousing.model.TStock();
            DataSet ds = DbHelperSQLite.Query(strSql.ToString());

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Warehousing.model.TStock DataRowToModel(DataRow row)
 {
     Warehousing.model.TStock model = new Warehousing.model.TStock();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = row["id"].ToString();
         }
         if (row["code"] != null)
         {
             model.code = row["code"].ToString();
         }
         if (row["name"] != null)
         {
             model.name = row["name"].ToString();
         }
         if (row["spec"] != null)
         {
             model.spec = row["spec"].ToString();
         }
         if (row["unit"] != null)
         {
             model.unit = row["unit"].ToString();
         }
         if (row["price"] != null && row["price"].ToString() != "")
         {
             model.price = decimal.Parse(row["price"].ToString());
         }
         if (row["number"] != null && row["number"].ToString() != "")
         {
             model.number = int.Parse(row["number"].ToString());
         }
     }
     return(model);
 }
Exemplo n.º 5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Warehousing.model.TStock model)
 {
     return(dal.Update(model));
 }
Exemplo n.º 6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(Warehousing.model.TStock model)
 {
     return(dal.Add(model));
 }
Exemplo n.º 7
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Warehousing.model.TStock model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update TStock set ");
            if (model.code != null)
            {
                strSql.Append("code='" + model.code + "',");
            }
            else
            {
                strSql.Append("code= null ,");
            }
            if (model.name != null)
            {
                strSql.Append("name='" + model.name + "',");
            }
            else
            {
                strSql.Append("name= null ,");
            }
            if (model.spec != null)
            {
                strSql.Append("spec='" + model.spec + "',");
            }
            else
            {
                strSql.Append("spec= null ,");
            }
            if (model.unit != null)
            {
                strSql.Append("unit='" + model.unit + "',");
            }
            else
            {
                strSql.Append("unit= null ,");
            }
            if (model.price != null)
            {
                strSql.Append("price=" + model.price + ",");
            }
            else
            {
                strSql.Append("price= null ,");
            }
            if (model.number != null)
            {
                strSql.Append("number=" + model.number + ",");
            }
            else
            {
                strSql.Append("number= null ,");
            }
            int n = strSql.ToString().LastIndexOf(",");

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

            if (rowsAffected > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 8
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if ("" == txtGoodId.Text)
            {
                MessageBox.Show("请填写一料一号");
                return;
            }
            if ("" == txtCode.Text)
            {
                MessageBox.Show("请填写商品编码");
                return;
            }
            if ("" == txtName.Text)
            {
                MessageBox.Show("请填写商品名称");
                return;
            }
            if ("" == txtNumber.Text || 0 == int.Parse(txtNumber.Text))
            {
                MessageBox.Show("请填写入库数量,不能为零");
                return;
            }
            if ("" == txtPrice.Text)
            {
                MessageBox.Show("请填写商品商品价格");
                return;
            }
            if ("" == txtSpec.Text)
            {
                MessageBox.Show("请填写规格型号");
                return;
            }
            if ("" == txtUnit.Text)
            {
                MessageBox.Show("请填写计量单位");
                return;
            }
            model.TStock mod = new model.TStock();
            bll.TStock   bll = new bll.TStock();
            mod.id     = txtGoodId.Text;
            mod.code   = txtCode.Text;
            mod.name   = txtName.Text;
            mod.number = int.Parse(txtNumber.Text);
            mod.price  = decimal.Parse(txtPrice.Text);
            mod.spec   = txtSpec.Text;
            mod.unit   = txtUnit.Text;
            DialogResult dr = MessageBox.Show("确认入库 " + mod.number + mod.unit + "?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);

            if (dr == DialogResult.OK)
            {
                bool isExists = bll.Exists(mod.id);
                bool isSuccess;
                if (isExists)
                {
                    model.TStock dataRow = bll.GetModel(mod.id);
                    mod.number = mod.number + dataRow.number;
                    isSuccess  = bll.Update(mod);
                }
                else
                {
                    isSuccess = bll.Add(mod);
                }
                if (isSuccess)
                {
                    MessageBox.Show("入库成功");
                }
                else
                {
                    MessageBox.Show("入库失败");
                }
                reset();
                txtGoodId.Text = "";
            }
        }
Exemplo n.º 9
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if ("" == txtGoodId.Text)
            {
                MessageBox.Show("请填写一料一号");
                return;
            }
            //if ("" == txtCode.Text)
            //{
            //    MessageBox.Show("请填写商品编码");
            //    return;
            //}
            //if ("" == txtName.Text)
            //{
            //    MessageBox.Show("请填写商品名称");
            //    return;
            //}
            //if ("" == txtNumber.Text)
            //{
            //    MessageBox.Show("请填写出库数量");
            //    return;
            //}
            //if ("" == txtPrice.Text)
            //{
            //    MessageBox.Show("请填写商品商品价格");
            //    return;
            //}
            //if ("" == txtSpec.Text)
            //{
            //    MessageBox.Show("请填写规格型号");
            //    return;
            //}
            //if ("" == txtUnit.Text)
            //{
            //    MessageBox.Show("请填写计量单位");
            //    return;
            //}

            //model.TStock mod = new model.TStock();
            bll.TStock bll = new bll.TStock();
            //mod.id = txtGoodId.Text;
            //mod.code = txtCode.Text;
            //mod.name = txtName.Text;
            //mod.number = int.Parse(txtNumber.Text);
            //mod.price = decimal.Parse(txtPrice.Text);
            //mod.spec = txtSpec.Text;
            //mod.unit = txtUnit.Text;
            bool isExists = bll.Exists(txtGoodId.Text);

            if (isExists)
            {
                if ("" == txtNumber.Text)
                {
                    MessageBox.Show("请填写出库数量");
                    return;
                }
                model.TStock mod = new model.TStock();
                mod.number = int.Parse(txtNumber.Text);
                model.TStock dataRow = bll.GetModel(txtGoodId.Text);
                if (0 < dataRow.number)
                {
                    if (mod.number > dataRow.number)
                    {
                        MessageBox.Show("该商品库存为" + dataRow.number + dataRow.unit + ",无法出库" + mod.number + mod.unit);
                    }
                    else
                    {
                        mod.id    = dataRow.id;
                        mod.code  = dataRow.code;
                        mod.name  = dataRow.name;
                        mod.spec  = dataRow.spec;
                        mod.unit  = dataRow.unit;
                        mod.price = dataRow.price;
                        DialogResult dr = MessageBox.Show("确认出库 " + mod.number + mod.unit + "?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                        if (dr == DialogResult.OK)
                        {
                            mod.number = dataRow.number - mod.number;
                            if (bll.Update(mod))
                            {
                                txtGoodId.Text = "";
                                reset();
                                MessageBox.Show("出库成功");
                            }
                            else
                            {
                                MessageBox.Show("未知原因,出库失败");
                            }
                        }
                    }
                }
                else
                {
                    MessageBox.Show("该商品库存为零,无法完成出库操作");
                }
            }


            else
            {
                MessageBox.Show("未在仓库中查找到该商品,无法完成出库操作");
            }
        }