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

            strSql.Append("update Categorytab set ");
            strSql.Append("Name=@Name,");
            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("@Name",   SqlDbType.VarChar,  200),
                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.Name;
            parameters[1].Value = model.Beizhu;
            parameters[2].Value = model.BY1;
            parameters[3].Value = model.BY2;
            parameters[4].Value = model.BY3;
            parameters[5].Value = model.BY4;
            parameters[6].Value = model.BY5;
            parameters[7].Value = model.BY6;
            parameters[8].Value = model.BY7;
            parameters[9].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #2
0
 private void ShowInfo(int id)
 {
     Maticsoft.BLL.Categorytab   bll   = new Maticsoft.BLL.Categorytab();
     Maticsoft.Model.Categorytab model = bll.GetModel(id);
     this.lblid.Text     = model.id.ToString();
     this.txtName.Text   = model.Name;
     this.txtBeizhu.Text = model.Beizhu;
     this.txtBY1.Text    = model.BY1.ToString();
     this.txtBY2.Text    = model.BY2.ToString();
     this.txtBY3.Text    = model.BY3.ToString();
     this.txtBY4.Text    = model.BY4;
     this.txtBY5.Text    = model.BY5;
     this.txtBY6.Text    = model.BY6;
     this.txtBY7.Text    = model.BY7;
 }
예제 #3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.Categorytab DataRowToModel(DataRow row)
 {
     Maticsoft.Model.Categorytab model = new Maticsoft.Model.Categorytab();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["Name"] != null)
         {
             model.Name = row["Name"].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);
 }
예제 #4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Maticsoft.Model.Categorytab model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Categorytab(");
            strSql.Append("Name,Beizhu,BY1,BY2,BY3,BY4,BY5,BY6,BY7)");
            strSql.Append(" values (");
            strSql.Append("@Name,@Beizhu,@BY1,@BY2,@BY3,@BY4,@BY5,@BY6,@BY7)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Name",   SqlDbType.VarChar,  200),
                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.Name;
            parameters[1].Value = model.Beizhu;
            parameters[2].Value = model.BY1;
            parameters[3].Value = model.BY2;
            parameters[4].Value = model.BY3;
            parameters[5].Value = model.BY4;
            parameters[6].Value = model.BY5;
            parameters[7].Value = model.BY6;
            parameters[8].Value = model.BY7;

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

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

            strSql.Append("select  top 1 id,Name,Beizhu,BY1,BY2,BY3,BY4,BY5,BY6,BY7 from Categorytab ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

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

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

            if (this.txtName.Text.Trim().Length == 0)
            {
                strErr += "Name不能为空!\\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;
            }
            int     id     = int.Parse(this.lblid.Text);
            string  Name   = this.txtName.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.Categorytab model = new Maticsoft.Model.Categorytab();
            model.id     = id;
            model.Name   = Name;
            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.Categorytab bll = new Maticsoft.BLL.Categorytab();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }