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

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

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemple #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(ZhangWei.Model.EnterStock model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update EnterStock set ");
            strSql.Append("EnterDate=@EnterDate,");
            strSql.Append("Dept_ID=@Dept_ID,");
            strSql.Append("StoreHouse_ID=@StoreHouse_ID,");
            strSql.Append("Employee_ID=@Employee_ID");
            strSql.Append(" where EnterStock_ID=@EnterStock_ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@EnterDate",     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("@EnterStock_ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = model.EnterDate;
            parameters[1].Value = model.Dept_ID;
            parameters[2].Value = model.StoreHouse_ID;
            parameters[3].Value = model.Employee_ID;
            parameters[4].Value = model.EnterStock_ID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #3
0
 private void ShowInfo(int EnterStock_ID)
 {
     ZhangWei.BLL.EnterStock   bll   = new ZhangWei.BLL.EnterStock();
     ZhangWei.Model.EnterStock model = bll.GetModel(EnterStock_ID);
     this.lblEnterStock_ID.Text = model.EnterStock_ID.ToString();
     this.lblEnterDate.Text     = model.EnterDate.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();
 }
Exemple #4
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (!PageValidate.IsDateTime(txtEnterDate.Text))
            {
                strErr += "EnterDate格式错误!\\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 (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int      EnterStock_ID = int.Parse(this.lblEnterStock_ID.Text);
            DateTime EnterDate     = DateTime.Parse(this.txtEnterDate.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);


            ZhangWei.Model.EnterStock model = new ZhangWei.Model.EnterStock();
            model.EnterStock_ID = EnterStock_ID;
            model.EnterDate     = EnterDate;
            model.Dept_ID       = Dept_ID;
            model.StoreHouse_ID = StoreHouse_ID;
            model.Employee_ID   = Employee_ID;

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

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

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["EnterStock_ID"] != null && ds.Tables[0].Rows[0]["EnterStock_ID"].ToString() != "")
                {
                    model.EnterStock_ID = int.Parse(ds.Tables[0].Rows[0]["EnterStock_ID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["EnterDate"] != null && ds.Tables[0].Rows[0]["EnterDate"].ToString() != "")
                {
                    model.EnterDate = DateTime.Parse(ds.Tables[0].Rows[0]["EnterDate"].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());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }