Ejemplo n.º 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(WebDemo.Model.WebDemo.NoteBookGroup model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update NoteBookGroup set ");
            strSql.Append("NoteBookID=@NoteBookID,");
            strSql.Append("GroupName=@GroupName,");
            strSql.Append("LimitNum=@LimitNum,");
            strSql.Append("ReMark=@ReMark");
            strSql.Append(" where GroupID=@GroupID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@NoteBookID", SqlDbType.VarChar,  20),
                new SqlParameter("@GroupName",  SqlDbType.VarChar,  50),
                new SqlParameter("@LimitNum",   SqlDbType.Int,       4),
                new SqlParameter("@ReMark",     SqlDbType.VarChar, 200),
                new SqlParameter("@GroupID",    SqlDbType.Int, 4)
            };
            parameters[0].Value = model.NoteBookID;
            parameters[1].Value = model.GroupName;
            parameters[2].Value = model.LimitNum;
            parameters[3].Value = model.ReMark;
            parameters[4].Value = model.GroupID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(WebDemo.Model.WebDemo.NoteBookGroup model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into NoteBookGroup(");
            strSql.Append("GroupID,NoteBookID,GroupName,LimitNum,ReMark)");
            strSql.Append(" values (");
            strSql.Append("@GroupID,@NoteBookID,@GroupName,@LimitNum,@ReMark)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@GroupID",    SqlDbType.Int,      4),
                new SqlParameter("@NoteBookID", SqlDbType.VarChar, 20),
                new SqlParameter("@GroupName",  SqlDbType.VarChar, 50),
                new SqlParameter("@LimitNum",   SqlDbType.Int,      4),
                new SqlParameter("@ReMark",     SqlDbType.VarChar, 200)
            };
            parameters[0].Value = model.GroupID;
            parameters[1].Value = model.NoteBookID;
            parameters[2].Value = model.GroupName;
            parameters[3].Value = model.LimitNum;
            parameters[4].Value = model.ReMark;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public WebDemo.Model.WebDemo.NoteBookGroup DataRowToModel(DataRow row)
 {
     WebDemo.Model.WebDemo.NoteBookGroup model = new WebDemo.Model.WebDemo.NoteBookGroup();
     if (row != null)
     {
         if (row["GroupID"] != null && row["GroupID"].ToString() != "")
         {
             model.GroupID = int.Parse(row["GroupID"].ToString());
         }
         if (row["NoteBookID"] != null)
         {
             model.NoteBookID = row["NoteBookID"].ToString();
         }
         if (row["GroupName"] != null)
         {
             model.GroupName = row["GroupName"].ToString();
         }
         if (row["LimitNum"] != null && row["LimitNum"].ToString() != "")
         {
             model.LimitNum = int.Parse(row["LimitNum"].ToString());
         }
         if (row["ReMark"] != null)
         {
             model.ReMark = row["ReMark"].ToString();
         }
     }
     return(model);
 }
Ejemplo n.º 4
0
 private void ShowInfo(int GroupID)
 {
     WebDemo.BLL.WebDemo.NoteBookGroup   bll   = new WebDemo.BLL.WebDemo.NoteBookGroup();
     WebDemo.Model.WebDemo.NoteBookGroup model = bll.GetModel(GroupID);
     this.lblGroupID.Text    = model.GroupID.ToString();
     this.lblNoteBookID.Text = model.NoteBookID;
     this.lblGroupName.Text  = model.GroupName;
     this.lblLimitNum.Text   = model.LimitNum.ToString();
     this.lblReMark.Text     = model.ReMark;
 }
Ejemplo n.º 5
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (!PageValidate.IsNumber(txtGroupID.Text))
            {
                strErr += "GroupID格式错误!\\n";
            }
            if (this.txtNoteBookID.Text.Trim().Length == 0)
            {
                strErr += "NoteBookID不能为空!\\n";
            }
            if (this.txtGroupName.Text.Trim().Length == 0)
            {
                strErr += "GroupName不能为空!\\n";
            }
            if (!PageValidate.IsNumber(txtLimitNum.Text))
            {
                strErr += "LimitNum格式错误!\\n";
            }
            if (this.txtReMark.Text.Trim().Length == 0)
            {
                strErr += "ReMark不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int    GroupID    = int.Parse(this.txtGroupID.Text);
            string NoteBookID = this.txtNoteBookID.Text;
            string GroupName  = this.txtGroupName.Text;
            int    LimitNum   = int.Parse(this.txtLimitNum.Text);
            string ReMark     = this.txtReMark.Text;

            WebDemo.Model.WebDemo.NoteBookGroup model = new WebDemo.Model.WebDemo.NoteBookGroup();
            model.GroupID    = GroupID;
            model.NoteBookID = NoteBookID;
            model.GroupName  = GroupName;
            model.LimitNum   = LimitNum;
            model.ReMark     = ReMark;

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

            strSql.Append("select  top 1 GroupID,NoteBookID,GroupName,LimitNum,ReMark from NoteBookGroup ");
            strSql.Append(" where GroupID=@GroupID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@GroupID", SqlDbType.Int, 4)
            };
            parameters[0].Value = GroupID;

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

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