Exemple #1
0
        /// <summary>
        ///  更新一条数据
        /// </summary>
        public void Update(NoName.NetShop.Model.ProductModel model)
        {
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetStoredProcCommand("UP_pdProduct_Update");

            db.AddInParameter(dbCommand, "ProductId", DbType.Int32, model.ProductId);
            db.AddInParameter(dbCommand, "ProductName", DbType.AnsiString, model.ProductName);
            db.AddInParameter(dbCommand, "ProductCode", DbType.AnsiString, model.ProductCode);
            db.AddInParameter(dbCommand, "CatePath", DbType.AnsiString, model.CatePath);
            db.AddInParameter(dbCommand, "CateId", DbType.Int32, model.CateId);
            db.AddInParameter(dbCommand, "TradePrice", DbType.Decimal, model.TradePrice);
            db.AddInParameter(dbCommand, "MerchantPrice", DbType.Decimal, model.MerchantPrice);
            db.AddInParameter(dbCommand, "ReducePrice", DbType.Decimal, model.ReducePrice);
            db.AddInParameter(dbCommand, "Stock", DbType.Int32, model.Stock);
            db.AddInParameter(dbCommand, "SmallImage", DbType.AnsiString, model.SmallImage);
            db.AddInParameter(dbCommand, "MediumImage", DbType.AnsiString, model.MediumImage);
            db.AddInParameter(dbCommand, "LargeImage", DbType.AnsiString, model.LargeImage);
            db.AddInParameter(dbCommand, "Keywords", DbType.AnsiString, model.Keywords);
            db.AddInParameter(dbCommand, "Brief", DbType.AnsiString, model.Brief);
            db.AddInParameter(dbCommand, "PageView", DbType.Int32, model.PageView);
            db.AddInParameter(dbCommand, "InsertTime", DbType.DateTime, model.InsertTime);
            db.AddInParameter(dbCommand, "ChangeTime", DbType.DateTime, model.ChangeTime);
            db.AddInParameter(dbCommand, "Status", DbType.Byte, model.Status);
            db.AddInParameter(dbCommand, "SortValue", DbType.Int32, model.SortValue);
            db.AddInParameter(dbCommand, "Score", DbType.Int32, model.Score);
            db.ExecuteNonQuery(dbCommand);
        }
Exemple #2
0
 private void ShowInfo(int ProductId)
 {
     NoName.NetShop.BLL.ProductModelBll bll   = new NoName.NetShop.BLL.ProductModelBll();
     NoName.NetShop.Model.ProductModel  model = bll.GetModel(ProductId);
     this.lblProductId.Text     = model.ProductId.ToString();
     this.txtProductName.Text   = model.ProductName;
     this.txtProductCode.Text   = model.ProductCode;
     this.txtCatePath.Text      = model.CatePath;
     this.txtCateId.Text        = model.CateId.ToString();
     this.txtTradePrice.Text    = model.TradePrice.ToString();
     this.txtMerchantPrice.Text = model.MerchantPrice.ToString();
     this.txtReducePrice.Text   = model.ReducePrice.ToString();
     this.txtStock.Text         = model.Stock.ToString();
     this.txtSmallImage.Text    = model.SmallImage;
     this.txtMediumImage.Text   = model.MediumImage;
     this.txtLargeImage.Text    = model.LargeImage;
     this.txtKeywords.Text      = model.Keywords;
     this.txtBrief.Text         = model.Brief;
     this.txtPageView.Text      = model.PageView.ToString();
     this.txtInsertTime.Text    = model.InsertTime.ToString();
     this.txtChangeTime.Text    = model.ChangeTime.ToString();
     this.txtStatus.Text        = model.Status.ToString();
     this.txtSortValue.Text     = model.SortValue.ToString();
     this.txtScore.Text         = model.Score.ToString();
 }
Exemple #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public NoName.NetShop.Model.ProductModel GetModel(int ProductId)
        {
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetStoredProcCommand("UP_pdProduct_GetModel");

            db.AddInParameter(dbCommand, "ProductId", DbType.Int32, ProductId);

            NoName.NetShop.Model.ProductModel model = null;
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    model = ReaderBind(dataReader);
                }
            }
            return(model);
        }
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            string strErr="";
            if(this.txtProductName.Text =="")
            {
            strErr+="ProductName����Ϊ�գ�\\n";
            }
            if(this.txtProductCode.Text =="")
            {
            strErr+="ProductCode����Ϊ�գ�\\n";
            }
            if(this.txtCatePath.Text =="")
            {
            strErr+="CatePath����Ϊ�գ�\\n";
            }
            if(!PageValidate.IsNumber(txtCateId.Text))
            {
            strErr+="CateId�������֣�\\n";
            }
            if(!PageValidate.IsDecimal(txtTradePrice.Text))
            {
            strErr+="TradePrice�������֣�\\n";
            }
            if(!PageValidate.IsDecimal(txtMerchantPrice.Text))
            {
            strErr+="MerchantPrice�������֣�\\n";
            }
            if(!PageValidate.IsDecimal(txtReducePrice.Text))
            {
            strErr+="ReducePrice�������֣�\\n";
            }
            if(!PageValidate.IsNumber(txtStock.Text))
            {
            strErr+="Stock�������֣�\\n";
            }
            if(this.txtSmallImage.Text =="")
            {
            strErr+="SmallImage����Ϊ�գ�\\n";
            }
            if(this.txtMediumImage.Text =="")
            {
            strErr+="MediumImage����Ϊ�գ�\\n";
            }
            if(this.txtLargeImage.Text =="")
            {
            strErr+="LargeImage����Ϊ�գ�\\n";
            }
            if(this.txtKeywords.Text =="")
            {
            strErr+="Keywords����Ϊ�գ�\\n";
            }
            if(this.txtBrief.Text =="")
            {
            strErr+="Brief����Ϊ�գ�\\n";
            }
            if(!PageValidate.IsNumber(txtPageView.Text))
            {
            strErr+="PageView�������֣�\\n";
            }
            if(!PageValidate.IsDateTime(txtInsertTime.Text))
            {
            strErr+="InsertTime����ʱ���ʽ��\\n";
            }
            if(!PageValidate.IsDateTime(txtChangeTime.Text))
            {
            strErr+="ChangeTime����ʱ���ʽ��\\n";
            }
            if(!PageValidate.IsNumber(txtStatus.Text))
            {
            strErr+="Status�������֣�\\n";
            }
            if(!PageValidate.IsNumber(txtSortValue.Text))
            {
            strErr+="SortValue�������֣�\\n";
            }
            if(!PageValidate.IsNumber(txtScore.Text))
            {
            strErr+="Score�������֣�\\n";
            }

            if(strErr!="")
            {
            MessageBox.Show(this,strErr);
            return;
            }
            string ProductName=this.txtProductName.Text;
            string ProductCode=this.txtProductCode.Text;
            string CatePath=this.txtCatePath.Text;
            int CateId=int.Parse(this.txtCateId.Text);
            decimal TradePrice=decimal.Parse(this.txtTradePrice.Text);
            decimal MerchantPrice=decimal.Parse(this.txtMerchantPrice.Text);
            decimal ReducePrice=decimal.Parse(this.txtReducePrice.Text);
            int Stock=int.Parse(this.txtStock.Text);
            string SmallImage=this.txtSmallImage.Text;
            string MediumImage=this.txtMediumImage.Text;
            string LargeImage=this.txtLargeImage.Text;
            string Keywords=this.txtKeywords.Text;
            string Brief=this.txtBrief.Text;
            int PageView=int.Parse(this.txtPageView.Text);
            DateTime InsertTime=DateTime.Parse(this.txtInsertTime.Text);
            DateTime ChangeTime=DateTime.Parse(this.txtChangeTime.Text);
            int Status=int.Parse(this.txtStatus.Text);
            int SortValue=int.Parse(this.txtSortValue.Text);
            int Score=int.Parse(this.txtScore.Text);

            NoName.NetShop.Model.ProductModel model=new NoName.NetShop.Model.ProductModel();
            model.ProductName=ProductName;
            model.ProductCode=ProductCode;
            model.CatePath=CatePath;
            model.CateId=CateId;
            model.TradePrice=TradePrice;
            model.MerchantPrice=MerchantPrice;
            model.ReducePrice=ReducePrice;
            model.Stock=Stock;
            model.SmallImage=SmallImage;
            model.MediumImage=MediumImage;
            model.LargeImage=LargeImage;
            model.Keywords=Keywords;
            model.Brief=Brief;
            model.PageView=PageView;
            model.InsertTime=InsertTime;
            model.ChangeTime=ChangeTime;
            model.Status=Status;
            model.SortValue=SortValue;
            model.Score=Score;

            NoName.NetShop.BLL.ProductModelBll bll=new NoName.NetShop.BLL.ProductModelBll();
            bll.Update(model);
        }
Exemple #5
0
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public NoName.NetShop.Model.ProductModel ReaderBind(IDataReader dataReader)
        {
            NoName.NetShop.Model.ProductModel model = new NoName.NetShop.Model.ProductModel();
            object ojb;

            ojb = dataReader["ProductId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ProductId = (int)ojb;
            }
            model.ProductName = dataReader["ProductName"].ToString();
            model.ProductCode = dataReader["ProductCode"].ToString();
            model.CatePath    = dataReader["CatePath"].ToString();
            ojb = dataReader["CateId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.CateId = (int)ojb;
            }
            ojb = dataReader["TradePrice"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.TradePrice = (decimal)ojb;
            }
            ojb = dataReader["MerchantPrice"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.MerchantPrice = (decimal)ojb;
            }
            ojb = dataReader["ReducePrice"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ReducePrice = (decimal)ojb;
            }
            ojb = dataReader["Stock"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Stock = (int)ojb;
            }
            model.SmallImage  = dataReader["SmallImage"].ToString();
            model.MediumImage = dataReader["MediumImage"].ToString();
            model.LargeImage  = dataReader["LargeImage"].ToString();
            model.Keywords    = dataReader["Keywords"].ToString();
            model.Brief       = dataReader["Brief"].ToString();
            ojb = dataReader["PageView"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.PageView = (int)ojb;
            }
            ojb = dataReader["InsertTime"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.InsertTime = (DateTime)ojb;
            }
            ojb = dataReader["ChangeTime"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ChangeTime = (DateTime)ojb;
            }
            ojb = dataReader["Status"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Status = (int)ojb;
            }
            ojb = dataReader["SortValue"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.SortValue = (int)ojb;
            }
            ojb = dataReader["Score"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Score = (int)ojb;
            }
            return(model);
        }
Exemple #6
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtProductName.Text == "")
            {
                strErr += "ProductName不能为空!\\n";
            }
            if (this.txtProductCode.Text == "")
            {
                strErr += "ProductCode不能为空!\\n";
            }
            if (this.txtCatePath.Text == "")
            {
                strErr += "CatePath不能为空!\\n";
            }
            if (!PageValidate.IsNumber(txtCateId.Text))
            {
                strErr += "CateId不是数字!\\n";
            }
            if (!PageValidate.IsDecimal(txtTradePrice.Text))
            {
                strErr += "TradePrice不是数字!\\n";
            }
            if (!PageValidate.IsDecimal(txtMerchantPrice.Text))
            {
                strErr += "MerchantPrice不是数字!\\n";
            }
            if (!PageValidate.IsDecimal(txtReducePrice.Text))
            {
                strErr += "ReducePrice不是数字!\\n";
            }
            if (!PageValidate.IsNumber(txtStock.Text))
            {
                strErr += "Stock不是数字!\\n";
            }
            if (this.txtSmallImage.Text == "")
            {
                strErr += "SmallImage不能为空!\\n";
            }
            if (this.txtMediumImage.Text == "")
            {
                strErr += "MediumImage不能为空!\\n";
            }
            if (this.txtLargeImage.Text == "")
            {
                strErr += "LargeImage不能为空!\\n";
            }
            if (this.txtKeywords.Text == "")
            {
                strErr += "Keywords不能为空!\\n";
            }
            if (this.txtBrief.Text == "")
            {
                strErr += "Brief不能为空!\\n";
            }
            if (!PageValidate.IsNumber(txtPageView.Text))
            {
                strErr += "PageView不是数字!\\n";
            }
            if (!PageValidate.IsDateTime(txtInsertTime.Text))
            {
                strErr += "InsertTime不是时间格式!\\n";
            }
            if (!PageValidate.IsDateTime(txtChangeTime.Text))
            {
                strErr += "ChangeTime不是时间格式!\\n";
            }
            if (!PageValidate.IsNumber(txtStatus.Text))
            {
                strErr += "Status不是数字!\\n";
            }
            if (!PageValidate.IsNumber(txtSortValue.Text))
            {
                strErr += "SortValue不是数字!\\n";
            }
            if (!PageValidate.IsNumber(txtScore.Text))
            {
                strErr += "Score不是数字!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            string   ProductName   = this.txtProductName.Text;
            string   ProductCode   = this.txtProductCode.Text;
            string   CatePath      = this.txtCatePath.Text;
            int      CateId        = int.Parse(this.txtCateId.Text);
            decimal  TradePrice    = decimal.Parse(this.txtTradePrice.Text);
            decimal  MerchantPrice = decimal.Parse(this.txtMerchantPrice.Text);
            decimal  ReducePrice   = decimal.Parse(this.txtReducePrice.Text);
            int      Stock         = int.Parse(this.txtStock.Text);
            string   SmallImage    = this.txtSmallImage.Text;
            string   MediumImage   = this.txtMediumImage.Text;
            string   LargeImage    = this.txtLargeImage.Text;
            string   Keywords      = this.txtKeywords.Text;
            string   Brief         = this.txtBrief.Text;
            int      PageView      = int.Parse(this.txtPageView.Text);
            DateTime InsertTime    = DateTime.Parse(this.txtInsertTime.Text);
            DateTime ChangeTime    = DateTime.Parse(this.txtChangeTime.Text);
            int      Status        = int.Parse(this.txtStatus.Text);
            int      SortValue     = int.Parse(this.txtSortValue.Text);
            int      Score         = int.Parse(this.txtScore.Text);


            NoName.NetShop.Model.ProductModel model = new NoName.NetShop.Model.ProductModel();
            model.ProductName   = ProductName;
            model.ProductCode   = ProductCode;
            model.CatePath      = CatePath;
            model.CateId        = CateId;
            model.TradePrice    = TradePrice;
            model.MerchantPrice = MerchantPrice;
            model.ReducePrice   = ReducePrice;
            model.Stock         = Stock;
            model.SmallImage    = SmallImage;
            model.MediumImage   = MediumImage;
            model.LargeImage    = LargeImage;
            model.Keywords      = Keywords;
            model.Brief         = Brief;
            model.PageView      = PageView;
            model.InsertTime    = InsertTime;
            model.ChangeTime    = ChangeTime;
            model.Status        = Status;
            model.SortValue     = SortValue;
            model.Score         = Score;

            NoName.NetShop.BLL.ProductModelBll bll = new NoName.NetShop.BLL.ProductModelBll();
            bll.Update(model);
        }