Beispiel #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(ZhangWei.Model.BackStock model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into BackStock(");
            strSql.Append("BackDate,Dept_ID,StoreHouse_ID,Employee_ID,Remark)");
            strSql.Append(" values (");
            strSql.Append("@BackDate,@Dept_ID,@StoreHouse_ID,@Employee_ID,@Remark)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@BackDate",      SqlDbType.DateTime),
                new SqlParameter("@Dept_ID",       SqlDbType.Int,       4),
                new SqlParameter("@StoreHouse_ID", SqlDbType.Int,       4),
                new SqlParameter("@Employee_ID",   SqlDbType.Int,       4),
                new SqlParameter("@Remark",        SqlDbType.VarChar, 250)
            };
            parameters[0].Value = model.BackDate;
            parameters[1].Value = model.Dept_ID;
            parameters[2].Value = model.StoreHouse_ID;
            parameters[3].Value = model.Employee_ID;
            parameters[4].Value = model.Remark;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Beispiel #2
0
 private void ShowInfo(int BackStock_ID)
 {
     ZhangWei.BLL.BackStock   bll   = new ZhangWei.BLL.BackStock();
     ZhangWei.Model.BackStock model = bll.GetModel(BackStock_ID);
     this.lblBackStock_ID.Text  = model.BackStock_ID.ToString();
     this.lblBackDate.Text      = model.BackDate.ToString();
     this.lblDept_ID.Text       = model.Dept_ID.ToString();
     this.lblStoreHouse_ID.Text = model.StoreHouse_ID.ToString();
     this.lblEmployee_ID.Text   = model.Employee_ID.ToString();
     this.lblRemark.Text        = model.Remark;
 }
Beispiel #3
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (!PageValidate.IsDateTime(txtBackDate.Text))
            {
                strErr += "BackDate格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtDept_ID.Text))
            {
                strErr += "Dept_ID格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtStoreHouse_ID.Text))
            {
                strErr += "StoreHouse_ID格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtEmployee_ID.Text))
            {
                strErr += "Employee_ID格式错误!\\n";
            }
            if (this.txtRemark.Text.Trim().Length == 0)
            {
                strErr += "Remark不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int      BackStock_ID  = int.Parse(this.lblBackStock_ID.Text);
            DateTime BackDate      = DateTime.Parse(this.txtBackDate.Text);
            int      Dept_ID       = int.Parse(this.txtDept_ID.Text);
            int      StoreHouse_ID = int.Parse(this.txtStoreHouse_ID.Text);
            int      Employee_ID   = int.Parse(this.txtEmployee_ID.Text);
            string   Remark        = this.txtRemark.Text;


            ZhangWei.Model.BackStock model = new ZhangWei.Model.BackStock();
            model.BackStock_ID  = BackStock_ID;
            model.BackDate      = BackDate;
            model.Dept_ID       = Dept_ID;
            model.StoreHouse_ID = StoreHouse_ID;
            model.Employee_ID   = Employee_ID;
            model.Remark        = Remark;

            ZhangWei.BLL.BackStock bll = new ZhangWei.BLL.BackStock();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }
Beispiel #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ZhangWei.Model.BackStock GetModel(int BackStock_ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 BackStock_ID,BackDate,Dept_ID,StoreHouse_ID,Employee_ID,Remark from BackStock ");
            strSql.Append(" where BackStock_ID=@BackStock_ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@BackStock_ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = BackStock_ID;

            ZhangWei.Model.BackStock model = new ZhangWei.Model.BackStock();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["BackStock_ID"] != null && ds.Tables[0].Rows[0]["BackStock_ID"].ToString() != "")
                {
                    model.BackStock_ID = int.Parse(ds.Tables[0].Rows[0]["BackStock_ID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["BackDate"] != null && ds.Tables[0].Rows[0]["BackDate"].ToString() != "")
                {
                    model.BackDate = DateTime.Parse(ds.Tables[0].Rows[0]["BackDate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Dept_ID"] != null && ds.Tables[0].Rows[0]["Dept_ID"].ToString() != "")
                {
                    model.Dept_ID = int.Parse(ds.Tables[0].Rows[0]["Dept_ID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["StoreHouse_ID"] != null && ds.Tables[0].Rows[0]["StoreHouse_ID"].ToString() != "")
                {
                    model.StoreHouse_ID = int.Parse(ds.Tables[0].Rows[0]["StoreHouse_ID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Employee_ID"] != null && ds.Tables[0].Rows[0]["Employee_ID"].ToString() != "")
                {
                    model.Employee_ID = int.Parse(ds.Tables[0].Rows[0]["Employee_ID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Remark"] != null && ds.Tables[0].Rows[0]["Remark"].ToString() != "")
                {
                    model.Remark = ds.Tables[0].Rows[0]["Remark"].ToString();
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Beispiel #5
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(ZhangWei.Model.BackStock model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update BackStock set ");
            strSql.Append("BackDate=@BackDate,");
            strSql.Append("Dept_ID=@Dept_ID,");
            strSql.Append("StoreHouse_ID=@StoreHouse_ID,");
            strSql.Append("Employee_ID=@Employee_ID,");
            strSql.Append("Remark=@Remark");
            strSql.Append(" where BackStock_ID=@BackStock_ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@BackDate",      SqlDbType.DateTime),
                new SqlParameter("@Dept_ID",       SqlDbType.Int,         4),
                new SqlParameter("@StoreHouse_ID", SqlDbType.Int,         4),
                new SqlParameter("@Employee_ID",   SqlDbType.Int,         4),
                new SqlParameter("@Remark",        SqlDbType.VarChar,   250),
                new SqlParameter("@BackStock_ID",  SqlDbType.Int, 4)
            };
            parameters[0].Value = model.BackDate;
            parameters[1].Value = model.Dept_ID;
            parameters[2].Value = model.StoreHouse_ID;
            parameters[3].Value = model.Employee_ID;
            parameters[4].Value = model.Remark;
            parameters[5].Value = model.BackStock_ID;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #6
0
        protected void Button2_Click(object sender, EventArgs e)
        {
            if (HiddenField1.Value == "")
            {
                Maticsoft.Common.MessageBox.Show(this, "请添加商品");
                return;
            }
            else
            {
                Model.BackStock ml_bs = new ZhangWei.Model.BackStock();
                ml_bs.BackDate      = Convert.ToDateTime(BackDate.Text);
                ml_bs.Dept_ID       = Convert.ToInt32(DropDownList1.SelectedValue);
                ml_bs.Employee_ID   = Convert.ToInt32(DropDownList2.SelectedValue);
                ml_bs.StoreHouse_ID = Convert.ToInt32(DropDownList3.SelectedValue);
                ml_bs.Remark        = this.TextBox1.Text;


                Int32    BackStock_id = new BLL.BackStock().Add(ml_bs);
                string   Ids          = HiddenField1.Value.Replace(" ", "").Replace("\r\n", "");
                string   Qtys         = HiddenField2.Value.Replace(" ", "").Replace("\r\n", "");
                string   Prices       = HiddenField3.Value.Replace(" ", "").Replace("\r\n", "");
                string[] ArrIds       = Ids.Split(new char[] { '|' });
                string[] ArrQty       = Qtys.Split(new char[] { '|' });
                string[] ArrPri       = Prices.Split(new char[] { '|' });
                for (int i = 0; i < ArrIds.Length - 1; i++)
                {
                    //Model.Sale_Detail ml_sa = new ZhangWei.Model.Sale_Detail();
                    Model.BackStock_Detail ml_bsd = new ZhangWei.Model.BackStock_Detail();
                    ml_bsd.BackStock_ID = BackStock_id;
                    ml_bsd.Product_ID   = Convert.ToInt32(ArrIds[i]);
                    ml_bsd.Price        = Convert.ToDecimal(ArrPri[i]);
                    ml_bsd.Quantity     = Convert.ToDecimal(ArrQty[i]);

                    BLL.BackStock_Detail bl_bsd = new ZhangWei.BLL.BackStock_Detail();
                    Model.StockPile      ml_sp  = new BLL.StockPile().GetModelByProId(Convert.ToInt32(ArrIds[i]), Convert.ToInt32(DropDownList3.SelectedValue));
                    BLL.StockPile        bl_sp  = new ZhangWei.BLL.StockPile();
                    if (ml_sp == null)
                    {
                        Model.Product ml_pr = new BLL.Product().GetModel(Convert.ToInt32(ArrIds[i]));
                        ml_sp                = new ZhangWei.Model.StockPile();
                        ml_sp.Product_ID     = Convert.ToInt32(ArrIds[i]);
                        ml_sp.Dept_ID        = Convert.ToInt32(DropDownList1.SelectedValue);
                        ml_sp.FirstEnterDate = DateTime.Now;
                        ml_sp.LastLeaveDate  = DateTime.Now;
                        ml_sp.Price          = Convert.ToDecimal(ArrPri[i]);
                        ml_sp.StoreHouse_ID  = Convert.ToInt32(DropDownList3.SelectedValue);
                        ml_sp.Quantity       = 0;
                        ml_sp.Quantity      -= Convert.ToDecimal(ArrQty[i]);
                        bl_sp.Add(ml_sp);
                    }
                    else
                    {
                        ml_sp.Quantity     -= Convert.ToDecimal(ArrQty[i]);
                        ml_sp.LastLeaveDate = DateTime.Now;
                        bl_sp.Update(ml_sp);
                    }
                    bl_bsd.Add(ml_bsd);
                }
                Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "/warehouse/BackStock/List.aspx");
            }
        }