Example #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(ZhangWei.Model.SaleOrder_Detail model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into SaleOrder_Detail(");
            strSql.Append("SaleOrder_ID,Product_ID,Quantity,Price)");
            strSql.Append(" values (");
            strSql.Append("@SaleOrder_ID,@Product_ID,@Quantity,@Price)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@SaleOrder_ID", SqlDbType.Int,   4),
                new SqlParameter("@Product_ID",   SqlDbType.Int,   4),
                new SqlParameter("@Quantity",     SqlDbType.Int,   4),
                new SqlParameter("@Price",        SqlDbType.Money, 8)
            };
            parameters[0].Value = model.SaleOrder_ID;
            parameters[1].Value = model.Product_ID;
            parameters[2].Value = model.Quantity;
            parameters[3].Value = model.Price;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(ZhangWei.Model.SaleOrder_Detail model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update SaleOrder_Detail set ");
            strSql.Append("SaleOrder_ID=@SaleOrder_ID,");
            strSql.Append("Product_ID=@Product_ID,");
            strSql.Append("Quantity=@Quantity,");
            strSql.Append("Price=@Price");
            strSql.Append(" where ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@SaleOrder_ID", SqlDbType.Int,   4),
                new SqlParameter("@Product_ID",   SqlDbType.Int,   4),
                new SqlParameter("@Quantity",     SqlDbType.Int,   4),
                new SqlParameter("@Price",        SqlDbType.Money, 8)
            };
            parameters[0].Value = model.SaleOrder_ID;
            parameters[1].Value = model.Product_ID;
            parameters[2].Value = model.Quantity;
            parameters[3].Value = model.Price;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #3
0
 private void ShowInfo()
 {
     ZhangWei.BLL.SaleOrder_Detail   bll   = new ZhangWei.BLL.SaleOrder_Detail();
     ZhangWei.Model.SaleOrder_Detail model = bll.GetModel();
     this.txtSaleOrder_ID.Text = model.SaleOrder_ID.ToString();
     this.txtProduct_ID.Text   = model.Product_ID.ToString();
     this.txtQuantity.Text     = model.Quantity.ToString();
     this.txtPrice.Text        = model.Price.ToString();
 }
Example #4
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (!PageValidate.IsNumber(txtSaleOrder_ID.Text))
            {
                strErr += "SaleOrder_ID格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtProduct_ID.Text))
            {
                strErr += "Product_ID格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtQuantity.Text))
            {
                strErr += "Quantity格式错误!\\n";
            }
            if (!PageValidate.IsDecimal(txtPrice.Text))
            {
                strErr += "Price格式错误!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int     SaleOrder_ID = int.Parse(this.txtSaleOrder_ID.Text);
            int     Product_ID   = int.Parse(this.txtProduct_ID.Text);
            int     Quantity     = int.Parse(this.txtQuantity.Text);
            decimal Price        = decimal.Parse(this.txtPrice.Text);


            ZhangWei.Model.SaleOrder_Detail model = new ZhangWei.Model.SaleOrder_Detail();
            model.SaleOrder_ID = SaleOrder_ID;
            model.Product_ID   = Product_ID;
            model.Quantity     = Quantity;
            model.Price        = Price;

            ZhangWei.BLL.SaleOrder_Detail bll = new ZhangWei.BLL.SaleOrder_Detail();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }
Example #5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ZhangWei.Model.SaleOrder_Detail GetModel()
        {
            //该表无主键信息,请自定义主键/条件字段
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 SaleOrder_ID,Product_ID,Quantity,Price from SaleOrder_Detail ");
            strSql.Append(" where ");
            SqlParameter[] parameters =
            {
            };

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["SaleOrder_ID"] != null && ds.Tables[0].Rows[0]["SaleOrder_ID"].ToString() != "")
                {
                    model.SaleOrder_ID = int.Parse(ds.Tables[0].Rows[0]["SaleOrder_ID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Product_ID"] != null && ds.Tables[0].Rows[0]["Product_ID"].ToString() != "")
                {
                    model.Product_ID = int.Parse(ds.Tables[0].Rows[0]["Product_ID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Quantity"] != null && ds.Tables[0].Rows[0]["Quantity"].ToString() != "")
                {
                    model.Quantity = int.Parse(ds.Tables[0].Rows[0]["Quantity"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Price"] != null && ds.Tables[0].Rows[0]["Price"].ToString() != "")
                {
                    model.Price = decimal.Parse(ds.Tables[0].Rows[0]["Price"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }