Esempio n. 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(ZhangWei.Model.ProductSpec model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update ProductSpec set ");
            strSql.Append("Name=@Name,");
            strSql.Append("Employee_ID=@Employee_ID,");
            strSql.Append("CreateDate=@CreateDate,");
            strSql.Append("Remark=@Remark");
            strSql.Append(" where ProductSpec_ID=@ProductSpec_ID");
            SqlParameter[] parameters =
            {
                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("@ProductSpec_ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = model.Name;
            parameters[1].Value = model.Employee_ID;
            parameters[2].Value = model.CreateDate;
            parameters[3].Value = model.Remark;
            parameters[4].Value = model.ProductSpec_ID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(ZhangWei.Model.ProductSpec model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into ProductSpec(");
            strSql.Append("Name,Employee_ID,CreateDate,Remark)");
            strSql.Append(" values (");
            strSql.Append("@Name,@Employee_ID,@CreateDate,@Remark)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                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.Name;
            parameters[1].Value = model.Employee_ID;
            parameters[2].Value = model.CreateDate;
            parameters[3].Value = model.Remark;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Esempio n. 3
0
 private void ShowInfo(int ProductSpec_ID)
 {
     ZhangWei.BLL.ProductSpec   bll   = new ZhangWei.BLL.ProductSpec();
     ZhangWei.Model.ProductSpec model = bll.GetModel(ProductSpec_ID);
     this.lblProductSpec_ID.Text = model.ProductSpec_ID.ToString();
     this.txtName.Text           = model.Name;
     this.txtEmployee_ID.Text    = model.Employee_ID.ToString();
     this.txtCreateDate.Text     = model.CreateDate.ToString();
     this.txtRemark.Text         = model.Remark;
 }
Esempio n. 4
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            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;
            }
            string   Name        = this.txtName.Text;
            int      Employee_ID = UserModel.Employee_ID;
            DateTime CreateDate  = DateTime.Now;

            //string Remark=this.txtRemark.Text;

            ZhangWei.Model.ProductSpec model = new ZhangWei.Model.ProductSpec();
            model.Name        = Name;
            model.Employee_ID = Employee_ID;
            model.CreateDate  = CreateDate;
            //model.Remark=Remark;
            if (new BLL.ProductSpec().GetList("Name = '" + Name + "'").Tables[0].Rows.Count > 0)
            {
                Maticsoft.Common.MessageBox.Show(this, "该规格已经存在,不用重复添加,以免造成货品资料混乱。");
            }
            else
            {
                ZhangWei.BLL.ProductSpec bll = new ZhangWei.BLL.ProductSpec();
                bll.Add(model);
                Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx");
            }
        }
Esempio n. 5
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            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      ProductSpec_ID = int.Parse(this.lblProductSpec_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.ProductSpec model = new ZhangWei.Model.ProductSpec();
            model.ProductSpec_ID = ProductSpec_ID;
            model.Name           = Name;
            model.Employee_ID    = Employee_ID;
            model.CreateDate     = CreateDate;
            model.Remark         = Remark;

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

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

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

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