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

            strSql.Append("update ContractTab set ");
            strSql.Append("OrderNumber=@OrderNumber,");
            strSql.Append("CommodityID=@CommodityID,");
            strSql.Append("beizhu=@beizhu,");
            strSql.Append("By1=@By1,");
            strSql.Append("By2=@By2,");
            strSql.Append("By3=@By3,");
            strSql.Append("By4=@By4,");
            strSql.Append("By5=@By5,");
            strSql.Append("By6=@By6,");
            strSql.Append("By7=@By7");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@OrderNumber", SqlDbType.VarChar,  200),
                new SqlParameter("@CommodityID", SqlDbType.VarChar, 4000),
                new SqlParameter("@beizhu",      SqlDbType.VarChar, 4000),
                new SqlParameter("@By1",         SqlDbType.Decimal,    9),
                new SqlParameter("@By2",         SqlDbType.Decimal,    9),
                new SqlParameter("@By3",         SqlDbType.Decimal,    9),
                new SqlParameter("@By4",         SqlDbType.VarChar, 4000),
                new SqlParameter("@By5",         SqlDbType.VarChar, 4000),
                new SqlParameter("@By6",         SqlDbType.VarChar, 4000),
                new SqlParameter("@By7",         SqlDbType.VarChar, 4000),
                new SqlParameter("@id",          SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.OrderNumber;
            parameters[1].Value  = model.CommodityID;
            parameters[2].Value  = model.beizhu;
            parameters[3].Value  = model.By1;
            parameters[4].Value  = model.By2;
            parameters[5].Value  = model.By3;
            parameters[6].Value  = model.By4;
            parameters[7].Value  = model.By5;
            parameters[8].Value  = model.By6;
            parameters[9].Value  = model.By7;
            parameters[10].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.ContractTab DataRowToModel(DataRow row)
 {
     Maticsoft.Model.ContractTab model = new Maticsoft.Model.ContractTab();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["OrderNumber"] != null)
         {
             model.OrderNumber = row["OrderNumber"].ToString();
         }
         if (row["CommodityID"] != null)
         {
             model.CommodityID = row["CommodityID"].ToString();
         }
         if (row["beizhu"] != null)
         {
             model.beizhu = row["beizhu"].ToString();
         }
         if (row["By1"] != null && row["By1"].ToString() != "")
         {
             model.By1 = decimal.Parse(row["By1"].ToString());
         }
         if (row["By2"] != null && row["By2"].ToString() != "")
         {
             model.By2 = decimal.Parse(row["By2"].ToString());
         }
         if (row["By3"] != null && row["By3"].ToString() != "")
         {
             model.By3 = decimal.Parse(row["By3"].ToString());
         }
         if (row["By4"] != null)
         {
             model.By4 = row["By4"].ToString();
         }
         if (row["By5"] != null)
         {
             model.By5 = row["By5"].ToString();
         }
         if (row["By6"] != null)
         {
             model.By6 = row["By6"].ToString();
         }
         if (row["By7"] != null)
         {
             model.By7 = row["By7"].ToString();
         }
     }
     return(model);
 }
Beispiel #3
0
 private void ShowInfo(int id)
 {
     Maticsoft.BLL.ContractTab   bll   = new Maticsoft.BLL.ContractTab();
     Maticsoft.Model.ContractTab model = bll.GetModel(id);
     this.lblid.Text          = model.id.ToString();
     this.lblOrderNumber.Text = model.OrderNumber;
     this.lblCommodityID.Text = model.CommodityID.ToString();
     this.lblbeizhu.Text      = model.beizhu;
     this.lblBy1.Text         = model.By1.ToString();
     this.lblBy2.Text         = model.By2.ToString();
     this.lblBy3.Text         = model.By3.ToString();
     this.lblBy4.Text         = model.By4;
     this.lblBy5.Text         = model.By5;
     this.lblBy6.Text         = model.By6;
     this.lblBy7.Text         = model.By7;
 }
Beispiel #4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Maticsoft.Model.ContractTab model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into ContractTab(");
            strSql.Append("OrderNumber,CommodityID,beizhu,By1,By2,By3,By4,By5,By6,By7)");
            strSql.Append(" values (");
            strSql.Append("@OrderNumber,@CommodityID,@beizhu,@By1,@By2,@By3,@By4,@By5,@By6,@By7)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@OrderNumber", SqlDbType.VarChar,  200),
                new SqlParameter("@CommodityID", SqlDbType.VarChar, 4000),
                new SqlParameter("@beizhu",      SqlDbType.VarChar, 4000),
                new SqlParameter("@By1",         SqlDbType.Decimal,    9),
                new SqlParameter("@By2",         SqlDbType.Decimal,    9),
                new SqlParameter("@By3",         SqlDbType.Decimal,    9),
                new SqlParameter("@By4",         SqlDbType.VarChar, 4000),
                new SqlParameter("@By5",         SqlDbType.VarChar, 4000),
                new SqlParameter("@By6",         SqlDbType.VarChar, 4000),
                new SqlParameter("@By7",         SqlDbType.VarChar, 4000)
            };
            parameters[0].Value = model.OrderNumber;
            parameters[1].Value = model.CommodityID;
            parameters[2].Value = model.beizhu;
            parameters[3].Value = model.By1;
            parameters[4].Value = model.By2;
            parameters[5].Value = model.By3;
            parameters[6].Value = model.By4;
            parameters[7].Value = model.By5;
            parameters[8].Value = model.By6;
            parameters[9].Value = model.By7;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Beispiel #5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.ContractTab GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,OrderNumber,CommodityID,beizhu,By1,By2,By3,By4,By5,By6,By7 from ContractTab ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

            Maticsoft.Model.ContractTab model = new Maticsoft.Model.ContractTab();
            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
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtOrderNumber.Text.Trim().Length == 0)
            {
                strErr += "OrderNumber不能为空!\\n";
            }
            if (!PageValidate.IsNumber(txtCommodityID.Text))
            {
                strErr += "CommodityID格式错误!\\n";
            }
            if (this.txtbeizhu.Text.Trim().Length == 0)
            {
                strErr += "beizhu不能为空!\\n";
            }
            if (!PageValidate.IsDecimal(txtBy1.Text))
            {
                strErr += "By1格式错误!\\n";
            }
            if (!PageValidate.IsDecimal(txtBy2.Text))
            {
                strErr += "By2格式错误!\\n";
            }
            if (!PageValidate.IsDecimal(txtBy3.Text))
            {
                strErr += "By3格式错误!\\n";
            }
            if (this.txtBy4.Text.Trim().Length == 0)
            {
                strErr += "By4不能为空!\\n";
            }
            if (this.txtBy5.Text.Trim().Length == 0)
            {
                strErr += "By5不能为空!\\n";
            }
            if (this.txtBy6.Text.Trim().Length == 0)
            {
                strErr += "By6不能为空!\\n";
            }
            if (this.txtBy7.Text.Trim().Length == 0)
            {
                strErr += "By7不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            string  OrderNumber = this.txtOrderNumber.Text;
            int     CommodityID = int.Parse(this.txtCommodityID.Text);
            string  beizhu      = this.txtbeizhu.Text;
            decimal By1         = decimal.Parse(this.txtBy1.Text);
            decimal By2         = decimal.Parse(this.txtBy2.Text);
            decimal By3         = decimal.Parse(this.txtBy3.Text);
            string  By4         = this.txtBy4.Text;
            string  By5         = this.txtBy5.Text;
            string  By6         = this.txtBy6.Text;
            string  By7         = this.txtBy7.Text;

            Maticsoft.Model.ContractTab model = new Maticsoft.Model.ContractTab();
            model.OrderNumber = OrderNumber;
            model.CommodityID = CommodityID;
            model.beizhu      = beizhu;
            model.By1         = By1;
            model.By2         = By2;
            model.By3         = By3;
            model.By4         = By4;
            model.By5         = By5;
            model.By6         = By6;
            model.By7         = By7;

            Maticsoft.BLL.ContractTab bll = new Maticsoft.BLL.ContractTab();
            bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx");
        }