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

            strSql.Append("update inv_option set ");
            strSql.Append("que_id=@que_id,");
            strSql.Append("text=@text,");
            strSql.Append("style=@style,");
            strSql.Append("beizhu=@beizhu");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@que_id", SqlDbType.Int,    4),
                new SqlParameter("@text",   SqlDbType.Text),
                new SqlParameter("@style",  SqlDbType.NChar, 10),
                new SqlParameter("@beizhu", SqlDbType.NChar, 50),
                new SqlParameter("@id",     SqlDbType.Int, 4)
            };
            parameters[0].Value = model.que_id;
            parameters[1].Value = model.text;
            parameters[2].Value = model.style;
            parameters[3].Value = model.beizhu;
            parameters[4].Value = model.id;

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

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

            strSql.Append("insert into inv_option(");
            strSql.Append("que_id,text,style,beizhu)");
            strSql.Append(" values (");
            strSql.Append("@que_id,@text,@style,@beizhu)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@que_id", SqlDbType.Int,    4),
                new SqlParameter("@text",   SqlDbType.Text),
                new SqlParameter("@style",  SqlDbType.NChar, 10),
                new SqlParameter("@beizhu", SqlDbType.NChar, 50)
            };
            parameters[0].Value = model.que_id;
            parameters[1].Value = model.text;
            parameters[2].Value = model.style;
            parameters[3].Value = model.beizhu;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.inv_option DataRowToModel(DataRow row)
 {
     Maticsoft.Model.inv_option model = new Maticsoft.Model.inv_option();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["que_id"] != null && row["que_id"].ToString() != "")
         {
             model.que_id = int.Parse(row["que_id"].ToString());
         }
         if (row["text"] != null)
         {
             model.text = row["text"].ToString();
         }
         if (row["style"] != null)
         {
             model.style = row["style"].ToString();
         }
         if (row["beizhu"] != null)
         {
             model.beizhu = row["beizhu"].ToString();
         }
     }
     return(model);
 }
Exemple #4
0
 private void ShowInfo(int id)
 {
     Maticsoft.BLL.inv_option   bll   = new Maticsoft.BLL.inv_option();
     Maticsoft.Model.inv_option model = bll.GetModel(id);
     this.lblid.Text     = model.id.ToString();
     this.lblque_id.Text = model.que_id.ToString();
     this.lbltext.Text   = model.text;
     this.lblstyle.Text  = model.style;
     this.lblbeizhu.Text = model.beizhu;
 }
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (!PageValidate.IsNumber(txtque_id.Text))
            {
                strErr += "que_id格式错误!\\n";
            }
            if (this.txttext.Text.Trim().Length == 0)
            {
                strErr += "text不能为空!\\n";
            }
            if (this.txtstyle.Text.Trim().Length == 0)
            {
                strErr += "style不能为空!\\n";
            }
            if (this.txtbeizhu.Text.Trim().Length == 0)
            {
                strErr += "beizhu不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int    id     = int.Parse(this.lblid.Text);
            int    que_id = int.Parse(this.txtque_id.Text);
            string text   = this.txttext.Text;
            string style  = this.txtstyle.Text;
            string beizhu = this.txtbeizhu.Text;


            Maticsoft.Model.inv_option model = new Maticsoft.Model.inv_option();
            model.id     = id;
            model.que_id = que_id;
            model.text   = text;
            model.style  = style;
            model.beizhu = beizhu;

            Maticsoft.BLL.inv_option bll = new Maticsoft.BLL.inv_option();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }
Exemple #6
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txttext.Text.Trim().Length == 0)
            {
                strErr += "text不能为空!\\n";
            }
            if (this.txtstyle.Text.Trim().Length == 0)
            {
                strErr += "style不能为空!\\n";
            }
            if (this.txtbeizhu.Text.Trim().Length == 0)
            {
                strErr += "beizhu不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int    que_id = int.Parse(inv_que.SelectedValue);
            string text   = this.txttext.Text;
            string style  = this.txtstyle.Text;
            string beizhu = this.txtbeizhu.Text;

            Maticsoft.Model.inv_option model = new Maticsoft.Model.inv_option();
            model.que_id = que_id;
            model.text   = text;
            model.style  = style;
            model.beizhu = beizhu;

            Maticsoft.BLL.inv_option bll = new Maticsoft.BLL.inv_option();
            bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx");
        }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.inv_option GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,que_id,text,style,beizhu from inv_option ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }