Beispiel #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(MyERP.Model.PUB_STOCK_MASTER model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update PUB_STOCK_MASTER set ");
            strSql.Append("COMPANY_CODE=@COMPANY_CODE,");
            strSql.Append("COMPANY_NAME=@COMPANY_NAME,");
            strSql.Append("PARENT_COMPANY_CODE=@PARENT_COMPANY_CODE,");
            strSql.Append("STOCK_NAME=@STOCK_NAME,");
            strSql.Append("PARENT_STOCK_CODE=@PARENT_STOCK_CODE,");
            strSql.Append("CREATE_NAME=@CREATE_NAME,");
            strSql.Append("CREATE_DATE=@CREATE_DATE,");
            strSql.Append("UPDATE_NAME=@UPDATE_NAME,");
            strSql.Append("UPDATE_DATE=@UPDATE_DATE,");
            strSql.Append("REMARK=@REMARK");
            strSql.Append(" where STOCK_CODE=@STOCK_CODE ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@COMPANY_CODE",        SqlDbType.NVarChar,  50),
                new SqlParameter("@COMPANY_NAME",        SqlDbType.NVarChar,  50),
                new SqlParameter("@PARENT_COMPANY_CODE", SqlDbType.NChar,     10),
                new SqlParameter("@STOCK_NAME",          SqlDbType.NVarChar,  50),
                new SqlParameter("@PARENT_STOCK_CODE",   SqlDbType.NVarChar,  50),
                new SqlParameter("@CREATE_NAME",         SqlDbType.NVarChar,  50),
                new SqlParameter("@CREATE_DATE",         SqlDbType.DateTime),
                new SqlParameter("@UPDATE_NAME",         SqlDbType.NVarChar,  50),
                new SqlParameter("@UPDATE_DATE",         SqlDbType.DateTime),
                new SqlParameter("@REMARK",              SqlDbType.NVarChar,  50),
                new SqlParameter("@STOCK_CODE",          SqlDbType.NVarChar, 50)
            };
            parameters[0].Value  = model.COMPANY_CODE;
            parameters[1].Value  = model.COMPANY_NAME;
            parameters[2].Value  = model.PARENT_COMPANY_CODE;
            parameters[3].Value  = model.STOCK_NAME;
            parameters[4].Value  = model.PARENT_STOCK_CODE;
            parameters[5].Value  = model.CREATE_NAME;
            parameters[6].Value  = model.CREATE_DATE;
            parameters[7].Value  = model.UPDATE_NAME;
            parameters[8].Value  = model.UPDATE_DATE;
            parameters[9].Value  = model.REMARK;
            parameters[10].Value = model.STOCK_CODE;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public MyERP.Model.PUB_STOCK_MASTER DataRowToModel(DataRow row)
 {
     MyERP.Model.PUB_STOCK_MASTER model = new MyERP.Model.PUB_STOCK_MASTER();
     if (row != null)
     {
         if (row["COMPANY_CODE"] != null)
         {
             model.COMPANY_CODE = row["COMPANY_CODE"].ToString();
         }
         if (row["COMPANY_NAME"] != null)
         {
             model.COMPANY_NAME = row["COMPANY_NAME"].ToString();
         }
         if (row["PARENT_COMPANY_CODE"] != null)
         {
             model.PARENT_COMPANY_CODE = row["PARENT_COMPANY_CODE"].ToString();
         }
         if (row["STOCK_CODE"] != null)
         {
             model.STOCK_CODE = row["STOCK_CODE"].ToString();
         }
         if (row["STOCK_NAME"] != null)
         {
             model.STOCK_NAME = row["STOCK_NAME"].ToString();
         }
         if (row["PARENT_STOCK_CODE"] != null)
         {
             model.PARENT_STOCK_CODE = row["PARENT_STOCK_CODE"].ToString();
         }
         if (row["CREATE_NAME"] != null)
         {
             model.CREATE_NAME = row["CREATE_NAME"].ToString();
         }
         if (row["CREATE_DATE"] != null && row["CREATE_DATE"].ToString() != "")
         {
             model.CREATE_DATE = DateTime.Parse(row["CREATE_DATE"].ToString());
         }
         if (row["UPDATE_NAME"] != null)
         {
             model.UPDATE_NAME = row["UPDATE_NAME"].ToString();
         }
         if (row["UPDATE_DATE"] != null && row["UPDATE_DATE"].ToString() != "")
         {
             model.UPDATE_DATE = DateTime.Parse(row["UPDATE_DATE"].ToString());
         }
         if (row["REMARK"] != null)
         {
             model.REMARK = row["REMARK"].ToString();
         }
     }
     return(model);
 }
Beispiel #3
0
 private void ShowInfo(string STOCK_CODE)
 {
     MyERP.BLL.PUB_STOCK_MASTER   bll   = new MyERP.BLL.PUB_STOCK_MASTER();
     MyERP.Model.PUB_STOCK_MASTER model = bll.GetModel(STOCK_CODE);
     this.txtCOMPANY_CODE.Text        = model.COMPANY_CODE;
     this.txtCOMPANY_NAME.Text        = model.COMPANY_NAME;
     this.txtPARENT_COMPANY_CODE.Text = model.PARENT_COMPANY_CODE;
     this.lblSTOCK_CODE.Text          = model.STOCK_CODE;
     this.txtSTOCK_NAME.Text          = model.STOCK_NAME;
     this.txtPARENT_STOCK_CODE.Text   = model.PARENT_STOCK_CODE;
     this.txtCREATE_NAME.Text         = model.CREATE_NAME;
     this.txtCREATE_DATE.Text         = model.CREATE_DATE.ToString();
     this.txtUPDATE_NAME.Text         = model.UPDATE_NAME;
     this.txtUPDATE_DATE.Text         = model.UPDATE_DATE.ToString();
     this.txtREMARK.Text = model.REMARK;
 }
Beispiel #4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(MyERP.Model.PUB_STOCK_MASTER model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into PUB_STOCK_MASTER(");
            strSql.Append("COMPANY_CODE,COMPANY_NAME,PARENT_COMPANY_CODE,STOCK_CODE,STOCK_NAME,PARENT_STOCK_CODE,CREATE_NAME,CREATE_DATE,UPDATE_NAME,UPDATE_DATE,REMARK)");
            strSql.Append(" values (");
            strSql.Append("@COMPANY_CODE,@COMPANY_NAME,@PARENT_COMPANY_CODE,@STOCK_CODE,@STOCK_NAME,@PARENT_STOCK_CODE,@CREATE_NAME,@CREATE_DATE,@UPDATE_NAME,@UPDATE_DATE,@REMARK)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@COMPANY_CODE",        SqlDbType.NVarChar,  50),
                new SqlParameter("@COMPANY_NAME",        SqlDbType.NVarChar,  50),
                new SqlParameter("@PARENT_COMPANY_CODE", SqlDbType.NChar,     10),
                new SqlParameter("@STOCK_CODE",          SqlDbType.NVarChar,  50),
                new SqlParameter("@STOCK_NAME",          SqlDbType.NVarChar,  50),
                new SqlParameter("@PARENT_STOCK_CODE",   SqlDbType.NVarChar,  50),
                new SqlParameter("@CREATE_NAME",         SqlDbType.NVarChar,  50),
                new SqlParameter("@CREATE_DATE",         SqlDbType.DateTime),
                new SqlParameter("@UPDATE_NAME",         SqlDbType.NVarChar,  50),
                new SqlParameter("@UPDATE_DATE",         SqlDbType.DateTime),
                new SqlParameter("@REMARK",              SqlDbType.NVarChar, 50)
            };
            parameters[0].Value  = model.COMPANY_CODE;
            parameters[1].Value  = model.COMPANY_NAME;
            parameters[2].Value  = model.PARENT_COMPANY_CODE;
            parameters[3].Value  = model.STOCK_CODE;
            parameters[4].Value  = model.STOCK_NAME;
            parameters[5].Value  = model.PARENT_STOCK_CODE;
            parameters[6].Value  = model.CREATE_NAME;
            parameters[7].Value  = model.CREATE_DATE;
            parameters[8].Value  = model.UPDATE_NAME;
            parameters[9].Value  = model.UPDATE_DATE;
            parameters[10].Value = model.REMARK;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public MyERP.Model.PUB_STOCK_MASTER GetModel(string STOCK_CODE)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 COMPANY_CODE,COMPANY_NAME,PARENT_COMPANY_CODE,STOCK_CODE,STOCK_NAME,PARENT_STOCK_CODE,CREATE_NAME,CREATE_DATE,UPDATE_NAME,UPDATE_DATE,REMARK from PUB_STOCK_MASTER ");
            strSql.Append(" where STOCK_CODE=@STOCK_CODE ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@STOCK_CODE", SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = STOCK_CODE;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Beispiel #6
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtCOMPANY_CODE.Text.Trim().Length == 0)
            {
                strErr += "COMPANY_CODE不能为空!\\n";
            }
            if (this.txtCOMPANY_NAME.Text.Trim().Length == 0)
            {
                strErr += "COMPANY_NAME不能为空!\\n";
            }
            if (this.txtPARENT_COMPANY_CODE.Text.Trim().Length == 0)
            {
                strErr += "PARENT_COMPANY_CODE不能为空!\\n";
            }
            if (this.txtSTOCK_NAME.Text.Trim().Length == 0)
            {
                strErr += "STOCK_NAME不能为空!\\n";
            }
            if (this.txtPARENT_STOCK_CODE.Text.Trim().Length == 0)
            {
                strErr += "PARENT_STOCK_CODE不能为空!\\n";
            }
            if (this.txtCREATE_NAME.Text.Trim().Length == 0)
            {
                strErr += "CREATE_NAME不能为空!\\n";
            }
            if (!PageValidate.IsDateTime(txtCREATE_DATE.Text))
            {
                strErr += "CREATE_DATE格式错误!\\n";
            }
            if (this.txtUPDATE_NAME.Text.Trim().Length == 0)
            {
                strErr += "UPDATE_NAME不能为空!\\n";
            }
            if (!PageValidate.IsDateTime(txtUPDATE_DATE.Text))
            {
                strErr += "UPDATE_DATE格式错误!\\n";
            }
            if (this.txtREMARK.Text.Trim().Length == 0)
            {
                strErr += "REMARK不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            string   COMPANY_CODE        = this.txtCOMPANY_CODE.Text;
            string   COMPANY_NAME        = this.txtCOMPANY_NAME.Text;
            string   PARENT_COMPANY_CODE = this.txtPARENT_COMPANY_CODE.Text;
            string   STOCK_CODE          = this.lblSTOCK_CODE.Text;
            string   STOCK_NAME          = this.txtSTOCK_NAME.Text;
            string   PARENT_STOCK_CODE   = this.txtPARENT_STOCK_CODE.Text;
            string   CREATE_NAME         = this.txtCREATE_NAME.Text;
            DateTime CREATE_DATE         = DateTime.Parse(this.txtCREATE_DATE.Text);
            string   UPDATE_NAME         = this.txtUPDATE_NAME.Text;
            DateTime UPDATE_DATE         = DateTime.Parse(this.txtUPDATE_DATE.Text);
            string   REMARK = this.txtREMARK.Text;


            MyERP.Model.PUB_STOCK_MASTER model = new MyERP.Model.PUB_STOCK_MASTER();
            model.COMPANY_CODE        = COMPANY_CODE;
            model.COMPANY_NAME        = COMPANY_NAME;
            model.PARENT_COMPANY_CODE = PARENT_COMPANY_CODE;
            model.STOCK_CODE          = STOCK_CODE;
            model.STOCK_NAME          = STOCK_NAME;
            model.PARENT_STOCK_CODE   = PARENT_STOCK_CODE;
            model.CREATE_NAME         = CREATE_NAME;
            model.CREATE_DATE         = CREATE_DATE;
            model.UPDATE_NAME         = UPDATE_NAME;
            model.UPDATE_DATE         = UPDATE_DATE;
            model.REMARK = REMARK;

            MyERP.BLL.PUB_STOCK_MASTER bll = new MyERP.BLL.PUB_STOCK_MASTER();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }