Esempio n. 1
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (!PageValidate.IsNumber(txtquantity.Text))
            {
                strErr += "quantity格式错误!\\n";
            }
            if (this.txtboookState.Text.Trim().Length == 0)
            {
                strErr += "boookState不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            string orderNo    = this.lblorderNo.Text;
            string ISBN       = this.lblISBN.Text;
            int    quantity   = int.Parse(this.txtquantity.Text);
            string boookState = this.txtboookState.Text;


            BookShop.Model.Sale model = new BookShop.Model.Sale();
            model.orderNo    = orderNo;
            model.ISBN       = ISBN;
            model.quantity   = quantity;
            model.boookState = boookState;

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

            strSql.Append("update Sale set ");
            strSql.Append("quantity=@quantity,");
            strSql.Append("bookState=@bookState");
            strSql.Append(" where orderNo=@orderNo and ISBN=@ISBN ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@quantity",  SqlDbType.Int,   4),
                new SqlParameter("@bookState", SqlDbType.Char,  1),
                new SqlParameter("@orderNo",   SqlDbType.Char, 15),
                new SqlParameter("@ISBN",      SqlDbType.Char, 17)
            };
            parameters[0].Value = model.quantity;
            parameters[1].Value = model.bookState;
            parameters[2].Value = model.orderNo;
            parameters[3].Value = model.ISBN;

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

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

            strSql.Append("insert into Sale(");
            strSql.Append("orderNo,ISBN,quantity,bookState)");
            strSql.Append(" values (");
            strSql.Append("@orderNo,@ISBN,@quantity,@bookState)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@orderNo",   SqlDbType.Char, 15),
                new SqlParameter("@ISBN",      SqlDbType.Char, 17),
                new SqlParameter("@quantity",  SqlDbType.Int,   4),
                new SqlParameter("@bookState", SqlDbType.Char, 1)
            };
            parameters[0].Value = model.orderNo;
            parameters[1].Value = model.ISBN;
            parameters[2].Value = model.quantity;
            parameters[3].Value = model.bookState;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public BookShop.Model.Sale GetModel(string orderNo, string ISBN)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 orderNo,ISBN,quantity,bookState from Sale ");
            strSql.Append(" where orderNo=@orderNo and ISBN=@ISBN ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@orderNo", SqlDbType.Char, 15),
                new SqlParameter("@ISBN",    SqlDbType.Char, 17)
            };
            parameters[0].Value = orderNo;
            parameters[1].Value = ISBN;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Esempio n. 5
0
 private void ShowInfo(string orderNo, string ISBN)
 {
     BookShop.BLL.Sale   bll   = new BookShop.BLL.Sale();
     BookShop.Model.Sale model = bll.GetModel(orderNo, ISBN);
     this.lblorderNo.Text    = model.orderNo;
     this.lblISBN.Text       = model.ISBN;
     this.txtquantity.Text   = model.quantity.ToString();
     this.txtboookState.Text = model.boookState;
 }
Esempio n. 6
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public BookShop.Model.Sale DataRowToModel(DataRow row)
 {
     BookShop.Model.Sale model = new BookShop.Model.Sale();
     if (row != null)
     {
         if (row["orderNo"] != null)
         {
             model.orderNo = row["orderNo"].ToString();
         }
         if (row["ISBN"] != null)
         {
             model.ISBN = row["ISBN"].ToString();
         }
         if (row["quantity"] != null && row["quantity"].ToString() != "")
         {
             model.quantity = int.Parse(row["quantity"].ToString());
         }
         if (row["bookState"] != null)
         {
             model.bookState = row["bookState"].ToString();
         }
     }
     return(model);
 }