/// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Maticsoft.Model.inv_que model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into inv_que(");
            strSql.Append("que_n_id,text,style,beizhu)");
            strSql.Append(" values (");
            strSql.Append("@que_n_id,@text,@style,@beizhu)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@que_n_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_n_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 bool Update(Maticsoft.Model.inv_que model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update inv_que set ");
            strSql.Append("que_n_id=@que_n_id,");
            strSql.Append("text=@text,");
            strSql.Append("style=@style,");
            strSql.Append("beizhu=@beizhu");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@que_n_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_n_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 Maticsoft.Model.inv_que DataRowToModel(DataRow row)
 {
     Maticsoft.Model.inv_que model = new Maticsoft.Model.inv_que();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["que_n_id"] != null && row["que_n_id"].ToString() != "")
         {
             model.que_n_id = int.Parse(row["que_n_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);
 }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

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

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

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

            Maticsoft.Model.inv_que model = new Maticsoft.Model.inv_que();
            model.que_n_id = que_n_id;
            model.text     = text;
            model.style    = style;
            model.beizhu   = beizhu;

            Maticsoft.BLL.inv_que bll = new Maticsoft.BLL.inv_que();
            bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx");
        }
 private void ShowInfo(int id)
 {
     Maticsoft.BLL.inv_que   bll   = new Maticsoft.BLL.inv_que();
     Maticsoft.Model.inv_que model = bll.GetModel(id);
     this.lblid.Text       = model.id.ToString();
     this.txtque_n_id.Text = model.que_n_id.ToString();
     this.txttext.Text     = model.text;
     this.txtstyle.Text    = model.style;
     this.txtbeizhu.Text   = model.beizhu;
 }
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (!PageValidate.IsNumber(txtque_n_id.Text))
            {
                strErr += "que_n_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_n_id = int.Parse(this.txtque_n_id.Text);
            string text     = this.txttext.Text;
            string style    = this.txtstyle.Text;
            string beizhu   = this.txtbeizhu.Text;


            Maticsoft.Model.inv_que model = new Maticsoft.Model.inv_que();
            model.id       = id;
            model.que_n_id = que_n_id;
            model.text     = text;
            model.style    = style;
            model.beizhu   = beizhu;

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

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

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

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