Exemple #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(BookShop.Model.Ship model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Ship set ");
#warning 系统发现缺少更新的字段,请手工确认如此更新是否正确!
            strSql.Append("shipNo=@shipNo,");
            strSql.Append("orderNo=@orderNo,");
            strSql.Append("ISBN=@ISBN");
            strSql.Append(" where shipNo=@shipNo and orderNo=@orderNo and ISBN=@ISBN ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@shipNo",  SqlDbType.Char,      3),
                new SqlParameter("@orderNo", SqlDbType.Char,     15),
                new SqlParameter("@ISBN",    SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = model.shipNo;
            parameters[1].Value = model.orderNo;
            parameters[2].Value = model.ISBN;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(BookShop.Model.Ship model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Ship(");
            strSql.Append("shipNo,orderNo,ISBN)");
            strSql.Append(" values (");
            strSql.Append("@shipNo,@orderNo,@ISBN)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@shipNo",  SqlDbType.Char,      3),
                new SqlParameter("@orderNo", SqlDbType.Char,     15),
                new SqlParameter("@ISBN",    SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = model.shipNo;
            parameters[1].Value = model.orderNo;
            parameters[2].Value = model.ISBN;

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

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

            strSql.Append("select  top 1 shipNo,orderNo,ISBN from Ship ");
            strSql.Append(" where shipNo=@shipNo and orderNo=@orderNo and ISBN=@ISBN ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@shipNo",  SqlDbType.Char,      3),
                new SqlParameter("@orderNo", SqlDbType.Char,     15),
                new SqlParameter("@ISBN",    SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = shipNo;
            parameters[1].Value = orderNo;
            parameters[2].Value = ISBN;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Exemple #4
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtshipNo.Text.Trim().Length == 0)
            {
                strErr += "shipNo不能为空!\\n";
            }
            if (this.txtorderNo.Text.Trim().Length == 0)
            {
                strErr += "orderNo不能为空!\\n";
            }
            if (this.txtISBN.Text.Trim().Length == 0)
            {
                strErr += "ISBN不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            string shipNo  = this.txtshipNo.Text;
            string orderNo = this.txtorderNo.Text;
            string ISBN    = this.txtISBN.Text;

            BookShop.Model.Ship model = new BookShop.Model.Ship();
            model.shipNo  = shipNo;
            model.orderNo = orderNo;
            model.ISBN    = ISBN;

            BookShop.BLL.Ship bll = new BookShop.BLL.Ship();
            bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx");
        }
Exemple #5
0
 private void ShowInfo(string shipNo, string orderNo, string ISBN)
 {
     BookShop.BLL.Ship   bll   = new BookShop.BLL.Ship();
     BookShop.Model.Ship model = bll.GetModel(shipNo, orderNo, ISBN);
     this.lblshipNo.Text  = model.shipNo;
     this.lblorderNo.Text = model.orderNo;
     this.lblISBN.Text    = model.ISBN;
 }
Exemple #6
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public BookShop.Model.Ship DataRowToModel(DataRow row)
 {
     BookShop.Model.Ship model = new BookShop.Model.Ship();
     if (row != null)
     {
         if (row["shipNo"] != null)
         {
             model.shipNo = row["shipNo"].ToString();
         }
         if (row["orderNo"] != null)
         {
             model.orderNo = row["orderNo"].ToString();
         }
         if (row["ISBN"] != null)
         {
             model.ISBN = row["ISBN"].ToString();
         }
     }
     return(model);
 }
Exemple #7
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            string shipNo  = this.lblshipNo.Text;
            string orderNo = this.lblorderNo.Text;
            string ISBN    = this.lblISBN.Text;


            BookShop.Model.Ship model = new BookShop.Model.Ship();
            model.shipNo  = shipNo;
            model.orderNo = orderNo;
            model.ISBN    = ISBN;

            BookShop.BLL.Ship bll = new BookShop.BLL.Ship();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }