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

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

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Esempio n. 2
0
 private void ShowInfo(int ProductList_ID)
 {
     ZhangWei.BLL.ProductList   bll   = new ZhangWei.BLL.ProductList();
     ZhangWei.Model.ProductList model = bll.GetModel(ProductList_ID);
     this.lblProductClass_ID.Text = model.ProductClass_ID.ToString();
     this.lblProductList_ID.Text  = model.ProductList_ID.ToString();
     this.lblName.Text            = model.Name;
     this.lblEmployee_ID.Text     = model.Employee_ID.ToString();
     this.lblCreateDate.Text      = model.CreateDate.ToString();
     this.lblRemark.Text          = model.Remark;
 }
Esempio n. 3
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (!PageValidate.IsNumber(txtProductClass_ID.Text))
            {
                strErr += "ProductClass_ID格式错误!\\n";
            }
            if (this.txtName.Text.Trim().Length == 0)
            {
                strErr += "Name不能为空!\\n";
            }
            if (!PageValidate.IsNumber(txtEmployee_ID.Text))
            {
                strErr += "Employee_ID格式错误!\\n";
            }
            if (!PageValidate.IsDateTime(txtCreateDate.Text))
            {
                strErr += "CreateDate格式错误!\\n";
            }
            if (this.txtRemark.Text.Trim().Length == 0)
            {
                strErr += "Remark不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int      ProductClass_ID = int.Parse(this.txtProductClass_ID.Text);
            int      ProductList_ID  = int.Parse(this.lblProductList_ID.Text);
            string   Name            = this.txtName.Text;
            int      Employee_ID     = int.Parse(this.txtEmployee_ID.Text);
            DateTime CreateDate      = DateTime.Parse(this.txtCreateDate.Text);
            string   Remark          = this.txtRemark.Text;


            ZhangWei.Model.ProductList model = new ZhangWei.Model.ProductList();
            model.ProductClass_ID = ProductClass_ID;
            model.ProductList_ID  = ProductList_ID;
            model.Name            = Name;
            model.Employee_ID     = Employee_ID;
            model.CreateDate      = CreateDate;
            model.Remark          = Remark;

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

            strSql.Append("select  top 1 ProductClass_ID,ProductList_ID,Name,Employee_ID,CreateDate,Remark from ProductList ");
            strSql.Append(" where ProductList_ID=@ProductList_ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ProductList_ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ProductList_ID;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["ProductClass_ID"] != null && ds.Tables[0].Rows[0]["ProductClass_ID"].ToString() != "")
                {
                    model.ProductClass_ID = int.Parse(ds.Tables[0].Rows[0]["ProductClass_ID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ProductList_ID"] != null && ds.Tables[0].Rows[0]["ProductList_ID"].ToString() != "")
                {
                    model.ProductList_ID = int.Parse(ds.Tables[0].Rows[0]["ProductList_ID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Name"] != null && ds.Tables[0].Rows[0]["Name"].ToString() != "")
                {
                    model.Name = ds.Tables[0].Rows[0]["Name"].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]["CreateDate"] != null && ds.Tables[0].Rows[0]["CreateDate"].ToString() != "")
                {
                    model.CreateDate = DateTime.Parse(ds.Tables[0].Rows[0]["CreateDate"].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);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(ZhangWei.Model.ProductList model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update ProductList set ");
            strSql.Append("ProductClass_ID=@ProductClass_ID,");
            strSql.Append("Name=@Name,");
            strSql.Append("Employee_ID=@Employee_ID,");
            strSql.Append("CreateDate=@CreateDate,");
            strSql.Append("Remark=@Remark");
            strSql.Append(" where ProductList_ID=@ProductList_ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ProductClass_ID", SqlDbType.Int,         4),
                new SqlParameter("@Name",            SqlDbType.VarChar,    30),
                new SqlParameter("@Employee_ID",     SqlDbType.Int,         4),
                new SqlParameter("@CreateDate",      SqlDbType.DateTime),
                new SqlParameter("@Remark",          SqlDbType.VarChar,   250),
                new SqlParameter("@ProductList_ID",  SqlDbType.Int, 4)
            };
            parameters[0].Value = model.ProductClass_ID;
            parameters[1].Value = model.Name;
            parameters[2].Value = model.Employee_ID;
            parameters[3].Value = model.CreateDate;
            parameters[4].Value = model.Remark;
            parameters[5].Value = model.ProductList_ID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }