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

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

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int    caseId   = int.Parse(this.lblcaseId.Text);
            string caseName = this.txtcaseName.Text;


            YueDuLibrary.Model.BookCase model = new YueDuLibrary.Model.BookCase();
            model.caseId   = caseId;
            model.caseName = caseName;

            YueDuLibrary.BLL.BookCase bll = new YueDuLibrary.BLL.BookCase();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }
Beispiel #2
0
 private void ShowInfo(int caseId)
 {
     YueDuLibrary.BLL.BookCase   bll   = new YueDuLibrary.BLL.BookCase();
     YueDuLibrary.Model.BookCase model = bll.GetModel(caseId);
     this.lblcaseId.Text   = model.caseId.ToString();
     this.txtcaseName.Text = model.caseName;
 }
Beispiel #3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(YueDuLibrary.Model.BookCase model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update BookCase set ");
            strSql.Append("caseName=@caseName");
            strSql.Append(" where caseId=@caseId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@caseName", SqlDbType.VarChar, 10),
                new SqlParameter("@caseId",   SqlDbType.Int, 4)
            };
            parameters[0].Value = model.caseName;
            parameters[1].Value = model.caseId;

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

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

            strSql.Append("insert into BookCase(");
            strSql.Append("caseName)");
            strSql.Append(" values (");
            strSql.Append("@caseName)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@caseName", SqlDbType.VarChar, 10)
            };
            parameters[0].Value = model.caseName;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Beispiel #5
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public YueDuLibrary.Model.BookCase DataRowToModel(DataRow row)
 {
     YueDuLibrary.Model.BookCase model = new YueDuLibrary.Model.BookCase();
     if (row != null)
     {
         if (row["caseId"] != null && row["caseId"].ToString() != "")
         {
             model.caseId = int.Parse(row["caseId"].ToString());
         }
         if (row["caseName"] != null)
         {
             model.caseName = row["caseName"].ToString();
         }
     }
     return(model);
 }
Beispiel #6
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtcaseName.Text.Trim().Length == 0)
            {
                strErr += "请输入书架名称\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            string caseName = this.txtcaseName.Text;

            YueDuLibrary.Model.BookCase model = new YueDuLibrary.Model.BookCase();
            model.caseName = caseName;

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

            strSql.Append("select  top 1 caseId,caseName from BookCase ");
            strSql.Append(" where caseId=@caseId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@caseId", SqlDbType.Int, 4)
            };
            parameters[0].Value = caseId;

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

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