Exemple #1
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtNoteBookName.Text.Trim().Length == 0)
            {
                strErr += "NoteBookName不能为空!\\n";
            }
            if (this.txtReMark.Text.Trim().Length == 0)
            {
                strErr += "ReMark不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            string NoteBookID   = this.lblNoteBookID.Text;
            string NoteBookName = this.txtNoteBookName.Text;
            string ReMark       = this.txtReMark.Text;


            WebDemo.Model.WebDemo.Notebookpc model = new WebDemo.Model.WebDemo.Notebookpc();
            model.NoteBookID   = NoteBookID;
            model.NoteBookName = NoteBookName;
            model.ReMark       = ReMark;

            WebDemo.BLL.WebDemo.Notebookpc bll = new WebDemo.BLL.WebDemo.Notebookpc();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }
Exemple #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(WebDemo.Model.WebDemo.Notebookpc model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Notebookpc set ");
            strSql.Append("NoteBookName=@NoteBookName,");
            strSql.Append("ReMark=@ReMark");
            strSql.Append(" where NoteBookID=@NoteBookID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@NoteBookName", SqlDbType.VarChar,  50),
                new SqlParameter("@ReMark",       SqlDbType.VarChar, 200),
                new SqlParameter("@NoteBookID",   SqlDbType.VarChar, 20)
            };
            parameters[0].Value = model.NoteBookName;
            parameters[1].Value = model.ReMark;
            parameters[2].Value = model.NoteBookID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(WebDemo.Model.WebDemo.Notebookpc model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Notebookpc(");
            strSql.Append("NoteBookID,NoteBookName,ReMark)");
            strSql.Append(" values (");
            strSql.Append("@NoteBookID,@NoteBookName,@ReMark)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@NoteBookID",   SqlDbType.VarChar, 20),
                new SqlParameter("@NoteBookName", SqlDbType.VarChar, 50),
                new SqlParameter("@ReMark",       SqlDbType.VarChar, 200)
            };
            parameters[0].Value = model.NoteBookID;
            parameters[1].Value = model.NoteBookName;
            parameters[2].Value = model.ReMark;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #4
0
 private void ShowInfo(string NoteBookID)
 {
     WebDemo.BLL.WebDemo.Notebookpc   bll   = new WebDemo.BLL.WebDemo.Notebookpc();
     WebDemo.Model.WebDemo.Notebookpc model = bll.GetModel(NoteBookID);
     this.lblNoteBookID.Text   = model.NoteBookID;
     this.txtNoteBookName.Text = model.NoteBookName;
     this.txtReMark.Text       = model.ReMark;
 }
Exemple #5
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public WebDemo.Model.WebDemo.Notebookpc DataRowToModel(DataRow row)
 {
     WebDemo.Model.WebDemo.Notebookpc model = new WebDemo.Model.WebDemo.Notebookpc();
     if (row != null)
     {
         if (row["NoteBookID"] != null)
         {
             model.NoteBookID = row["NoteBookID"].ToString();
         }
         if (row["NoteBookName"] != null)
         {
             model.NoteBookName = row["NoteBookName"].ToString();
         }
         if (row["ReMark"] != null)
         {
             model.ReMark = row["ReMark"].ToString();
         }
     }
     return(model);
 }
Exemple #6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public WebDemo.Model.WebDemo.Notebookpc GetModel(string NoteBookID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 NoteBookID,NoteBookName,ReMark from Notebookpc ");
            strSql.Append(" where NoteBookID=@NoteBookID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@NoteBookID", SqlDbType.VarChar, 20)
            };
            parameters[0].Value = NoteBookID;

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

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