Exemple #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(Maticsoft.Model.Product model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into P_Product(");
            strSql.Append("ProductId,BrandId,CategoryId,Name,Descn,Image,ImageSmall,Price,VipPrice,Cheapness)");
            strSql.Append(" values (");
            strSql.Append("@ProductId,@BrandId,@CategoryId,@Name,@Descn,@Image,@ImageSmall,@Price,@VipPrice,@Cheapness)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ProductId",  SqlDbType.VarChar,  20),
                new SqlParameter("@BrandId",    SqlDbType.VarChar,  20),
                new SqlParameter("@CategoryId", SqlDbType.VarChar,  20),
                new SqlParameter("@Name",       SqlDbType.VarChar,  80),
                new SqlParameter("@Descn",      SqlDbType.Text),
                new SqlParameter("@Image",      SqlDbType.VarChar, 150),
                new SqlParameter("@ImageSmall", SqlDbType.VarChar, 150),
                new SqlParameter("@Price",      SqlDbType.Money,     8),
                new SqlParameter("@VipPrice",   SqlDbType.Money,     8),
                new SqlParameter("@Cheapness",  SqlDbType.Int)
            };
            parameters[0].Value = model.ProductId;
            parameters[1].Value = model.BrandId;
            parameters[2].Value = model.CategoryId;
            parameters[3].Value = model.Name;
            parameters[4].Value = model.Descn;
            parameters[5].Value = model.Image;
            parameters[6].Value = model.ImageSmall;
            parameters[7].Value = model.Price;
            parameters[8].Value = model.VipPrice;
            parameters[9].Value = model.Cheapness;

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
Exemple #2
0
        private void bind()
        {
            Maticsoft.BLL.Product probll = new Maticsoft.BLL.Product();
            int index = int.Parse(Request.QueryString["ProID"].ToString());

            Maticsoft.Model.Product     promodel  = probll.GetModel(index);
            Maticsoft.BLL.ProductType   typebll   = new Maticsoft.BLL.ProductType();
            Maticsoft.Model.ProductType typemodel = typebll.GetModel(int.Parse(promodel.ProTypeID.ToString()));
            Maticsoft.BLL.ProductXing   xinbll    = new Maticsoft.BLL.ProductXing();
            Maticsoft.Model.ProductXing xinmodel  = xinbll.GetModel(int.Parse(promodel.ProXingID.ToString()));
            lblchutime.Text   = Convert.ToDateTime(promodel.Prochutime.ToString()).ToString("yyyy-MM-dd");
            lblstarttime.Text = Convert.ToDateTime(promodel.Fatime.ToString()).ToString("yyyy-MM-dd");
            lbltitle.Text     = promodel.ProName;
            lbltype.Text      = typemodel.ProTypeTitle;
            lblxinghao.Text   = xinmodel.ProXingTitle;
            Image1.ImageUrl   = promodel.ImageURL;
            txtcontent.Text   = promodel.Procontent;
            if (promodel.Toujian == 1)
            {
                toujian.Visible = false;
            }
            else
            {
                toujian.Visible = true;
            }
        }
Exemple #3
0
        private void ShowInfo(string Id)
        {
            Maticsoft.BLL.Products.Product bll   = new Maticsoft.BLL.Products.Product();
            Maticsoft.Model.Product        model = bll.GetModel(Id);
            Session["Product"]     = model;
            this.lblProductId.Text = model.ProductId.ToString();
            this.txtName.Text      = model.Name;
            txtDescn.Text          = model.Descn;
            txtPrice.Text          = model.Price.ToString();
            txtvipPrice.Text       = model.VipPrice.ToString();


            for (int i = 0; i < this.dropCategory.Items.Count; i++)
            {
                if (this.dropCategory.Items[i].Value == model.CategoryId)
                {
                    this.dropCategory.Items[i].Selected = true;
                }
            }
            if (model.Cheapness == 1)
            {
                radbtn_Cheap.Checked = true;
            }
            else
            {
                radbtn_CheapNo.Checked = true;
            }
            //for (int i = 0; i < this.dropBrand.Items.Count; i++)
            //{
            //    if (this.dropBrand.Items[i].Value == model.BrandId)
            //    {
            //        this.dropBrand.Items[i].Selected = true;
            //    }
            //}
        }
Exemple #4
0
        private void ShowInfo(string Id)
        {            
            Maticsoft.BLL.Products.Product bll = new Maticsoft.BLL.Products.Product();
            Maticsoft.Model.Product model = bll.GetModel(Id);
            //Maticsoft.BLL.Products.Brand bllb = new Maticsoft.BLL.Products.Brand();
            Maticsoft.BLL.Products.Category bllc = new Maticsoft.BLL.Products.Category();
            
            this.lblProductId.Text = model.ProductId.ToString();
            this.lblName.Text = model.Name;
            lblDescn.Text = model.Descn;
            lblPrice.Text = model.Price.ToString();
            lblvipprice.Text = model.VipPrice.ToString();
            lblImage.Text = model.Image;
            //lblBrandId.Text = bllb.GetName(model.BrandId);
            lblCategoryId.Text = bllc.GetName(model.CategoryId);
            if (model.Cheapness == 1)
            {
                Label1.Text = "ÊÇ";
            }
            else
            {
                Label1.Text = "·ñ";
            }


        }
Exemple #5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.Product GetModel(int ProID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ProID,ProName,ProTypeID,ImageURL,ProXingID,Prochutime,Fatime,Toujian,HitNum,Procontent,ProMonery from Product ");
            strSql.Append(" where ProID=@ProID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ProID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ProID;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["ProID"].ToString() != "")
                {
                    model.ProID = int.Parse(ds.Tables[0].Rows[0]["ProID"].ToString());
                }
                model.ProName = ds.Tables[0].Rows[0]["ProName"].ToString();
                if (ds.Tables[0].Rows[0]["ProTypeID"].ToString() != "")
                {
                    model.ProTypeID = int.Parse(ds.Tables[0].Rows[0]["ProTypeID"].ToString());
                }
                model.ImageURL = ds.Tables[0].Rows[0]["ImageURL"].ToString();
                if (ds.Tables[0].Rows[0]["ProXingID"].ToString() != "")
                {
                    model.ProXingID = int.Parse(ds.Tables[0].Rows[0]["ProXingID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Prochutime"].ToString() != "")
                {
                    model.Prochutime = DateTime.Parse(ds.Tables[0].Rows[0]["Prochutime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Fatime"].ToString() != "")
                {
                    model.Fatime = DateTime.Parse(ds.Tables[0].Rows[0]["Fatime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Toujian"].ToString() != "")
                {
                    model.Toujian = int.Parse(ds.Tables[0].Rows[0]["Toujian"].ToString());
                }
                if (ds.Tables[0].Rows[0]["HitNum"].ToString() != "")
                {
                    model.HitNum = int.Parse(ds.Tables[0].Rows[0]["HitNum"].ToString());
                }
                model.Procontent = ds.Tables[0].Rows[0]["Procontent"].ToString();
                model.ProMonery  = ds.Tables[0].Rows[0]["ProMonery"].ToString();
                return(model);
            }
            else
            {
                return(null);
            }
        }
Exemple #6
0
        protected void btnok_Click(object sender, EventArgs e)
        {
            Maticsoft.BLL.Product probll = new Maticsoft.BLL.Product();
            int index = int.Parse(Request.QueryString["ProID"].ToString());

            Maticsoft.Model.Product promodel = probll.GetModel(index);
            promodel.Toujian = 1;
            probll.Update(promodel);
            Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<scripe>alert('推荐成功....')</script>");
            bind();
        }
Exemple #7
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.Product model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Product set ");
            strSql.Append("ProName=@ProName,");
            strSql.Append("ProTypeID=@ProTypeID,");
            strSql.Append("ImageURL=@ImageURL,");
            strSql.Append("ProXingID=@ProXingID,");
            strSql.Append("Prochutime=@Prochutime,");
            strSql.Append("Fatime=@Fatime,");
            strSql.Append("Toujian=@Toujian,");
            strSql.Append("HitNum=@HitNum,");
            strSql.Append("Procontent=@Procontent,");
            strSql.Append("ProMonery=@ProMonery");
            strSql.Append(" where ProID=@ProID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ProID",      SqlDbType.Int,         4),
                new SqlParameter("@ProName",    SqlDbType.VarChar,   200),
                new SqlParameter("@ProTypeID",  SqlDbType.Int,         4),
                new SqlParameter("@ImageURL",   SqlDbType.Text),
                new SqlParameter("@ProXingID",  SqlDbType.Int,         4),
                new SqlParameter("@Prochutime", SqlDbType.DateTime),
                new SqlParameter("@Fatime",     SqlDbType.DateTime),
                new SqlParameter("@Toujian",    SqlDbType.Int,         4),
                new SqlParameter("@HitNum",     SqlDbType.Int,         4),
                new SqlParameter("@Procontent", SqlDbType.Text),
                new SqlParameter("@ProMonery",  SqlDbType.Text)
            };
            parameters[0].Value  = model.ProID;
            parameters[1].Value  = model.ProName;
            parameters[2].Value  = model.ProTypeID;
            parameters[3].Value  = model.ImageURL;
            parameters[4].Value  = model.ProXingID;
            parameters[5].Value  = model.Prochutime;
            parameters[6].Value  = model.Fatime;
            parameters[7].Value  = model.Toujian;
            parameters[8].Value  = model.HitNum;
            parameters[9].Value  = model.Procontent;
            parameters[10].Value = model.ProMonery;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #8
0
 protected void datapro_ItemDataBound(object sender, DataListItemEventArgs e)
 {
     if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
     {
         Maticsoft.BLL.Product pronll = new Maticsoft.BLL.Product();
         int proid = int.Parse(datapro.DataKeys[e.Item.ItemIndex].ToString());
         Maticsoft.Model.Product   promodel = pronll.GetModel(proid);
         Maticsoft.BLL.ProductType typebll  = new Maticsoft.BLL.ProductType();
         int typeid = int.Parse(promodel.ProTypeID.ToString());
         Maticsoft.Model.ProductType typemodel = typebll.GetModel(typeid);
         ((Label)e.Item.FindControl("lbltype")).Text = typemodel.ProTypeTitle;
     }
 }
Exemple #9
0
 private void ShowInfo(int ProID)
 {
     Maticsoft.BLL.Product   bll   = new Maticsoft.BLL.Product();
     Maticsoft.Model.Product model = bll.GetModel(ProID);
     this.lblProID.Text      = model.ProID.ToString();
     this.lblProName.Text    = model.ProName;
     this.lblProTypeID.Text  = model.ProTypeID.ToString();
     this.lblProXingID.Text  = model.ProXingID.ToString();
     this.lblProchutime.Text = model.Prochutime.ToString();
     this.lblFatime.Text     = model.Fatime.ToString();
     this.lblToujian.Text    = model.Toujian?"ÊÇ":"·ñ";
     this.lblHitNum.Text     = model.HitNum.ToString();
     this.lblProcontent.Text = model.Procontent;
 }
        private void bind()
        {
            Maticsoft.BLL.Product probll = new Maticsoft.BLL.Product();
            int index = int.Parse(Request.QueryString["ProID"].ToString());

            Maticsoft.Model.Product promodel = probll.GetModel(index);
            txtfatime.Text        = Convert.ToDateTime(promodel.Fatime.ToString()).ToString("yyyy-MM-dd");
            Image1.ImageUrl       = promodel.ImageURL;
            txtprocontent.Text    = promodel.Procontent;
            txtprotitle.Text      = promodel.ProName;
            txttme.Text           = Convert.ToDateTime(promodel.Prochutime.ToString()).ToString("yyyy-MM-dd");
            drptype.SelectedValue = promodel.ProTypeID.ToString();
            drpxing.SelectedValue = promodel.ProXingID.ToString();
        }
Exemple #11
0
 private void ShowInfo(int ProID)
 {
     Maticsoft.BLL.Product   bll   = new Maticsoft.BLL.Product();
     Maticsoft.Model.Product model = bll.GetModel(ProID);
     this.lblProID.Text      = model.ProID.ToString();
     this.txtProName.Text    = model.ProName;
     this.txtProTypeID.Text  = model.ProTypeID.ToString();
     this.txtProXingID.Text  = model.ProXingID.ToString();
     this.txtProchutime.Text = model.Prochutime.ToString();
     this.txtFatime.Text     = model.Fatime.ToString();
     this.chkToujian.Checked = model.Toujian;
     this.txtHitNum.Text     = model.HitNum.ToString();
     this.txtProcontent.Text = model.Procontent;
 }
Exemple #12
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (Request.QueryString["ProID"] != null)
         {
             if (Request.QueryString["ProID"].ToString() != "")
             {
                 int proid = int.Parse(Request.QueryString["ProID"].ToString());
                 Maticsoft.BLL.Product       probll    = new Maticsoft.BLL.Product();
                 Maticsoft.Model.Product     promodel  = probll.GetModel(proid);
                 Maticsoft.BLL.ProductType   typebll   = new Maticsoft.BLL.ProductType();
                 Maticsoft.Model.ProductType typemodel = typebll.GetModel(int.Parse(promodel.ProTypeID.ToString()));
                 Maticsoft.BLL.ProductXing   xingbll   = new Maticsoft.BLL.ProductXing();
                 Maticsoft.Model.ProductXing xingmodel = xingbll.GetModel(int.Parse(promodel.ProXingID.ToString()));
                 lblFatime.Text = Convert.ToDateTime(promodel.Fatime.ToString()).ToString("yyyy-MM-dd");
                 int hitnum = 0;
                 if (promodel.HitNum != null)
                 {
                     promodel.HitNum = promodel.HitNum + 1;
                     probll.Update(promodel);
                     lblHitNum.Text = promodel.HitNum.ToString();
                 }
                 else
                 {
                     promodel.HitNum = 1;
                     probll.Update(promodel);
                     lblHitNum.Text = promodel.HitNum.ToString();
                 }
                 lblProcontent.Text   = promodel.Procontent;
                 lblProName.Text      = promodel.ProName;
                 lblProName1.Text     = promodel.ProName;
                 lblProTypeTitle.Text = typemodel.ProTypeTitle;
                 lblProXingTitle.Text = xingmodel.ProXingTitle;
                 ImgImageURL.ImageUrl = promodel.ImageURL;
             }
             else
             {
                 Response.Redirect("product.aspx");
             }
         }
         else
         {
             Response.Redirect("product.aspx");
         }
     }
 }
Exemple #13
0
 protected void btnok_Click(object sender, EventArgs e)
 {
     Maticsoft.BLL.Product   probll   = new Maticsoft.BLL.Product();
     Maticsoft.Model.Product promodel = new Maticsoft.Model.Product();
     if (txtprotitle.Text.Trim() == "")
     {
         lbltitle.Text = "请填写产品名称";
         return;
     }
     promodel.ProName = txtprotitle.Text.Trim();
     lbltitle.Text    = "";
     try
     {
         promodel.ProTypeID = int.Parse(drptype.SelectedValue);
     }
     catch (Exception e1)
     { }
     try
     {
         promodel.ProXingID = int.Parse(drpxing.SelectedValue);
     }
     catch (Exception e2)
     { }
     if (txttme.Text.Trim() == "")
     {
         lblprotime.Text = "请填写产品出品时间";
         return;
     }
     promodel.Prochutime = Convert.ToDateTime(txttme.Text.Trim());
     lblprotime.Text     = "";
     if (txtfatime.Text.Trim() == "")
     {
         lbltime.Text = "请填写发布时间";
         return;
     }
     promodel.Fatime     = Convert.ToDateTime(txtfatime.Text.Trim());
     lbltime.Text        = "";
     promodel.ImageURL   = Image1.ImageUrl;
     promodel.Toujian    = 0;
     promodel.Procontent = txtprocontent.Text.Trim();
     probll.Add(promodel);
     Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('信息添加成功!')</script>");
     txtprotitle.Text   = string.Empty;
     txttme.Text        = string.Empty;
     txtfatime.Text     = string.Empty;
     txtprocontent.Text = string.Empty;
 }
Exemple #14
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Maticsoft.Model.Product model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Product(");
            strSql.Append("ProName,ProTypeID,ImageURL,ProXingID,Prochutime,Fatime,Toujian,HitNum,Procontent,ProMonery)");
            strSql.Append(" values (");
            strSql.Append("@ProName,@ProTypeID,@ImageURL,@ProXingID,@Prochutime,@Fatime,@Toujian,@HitNum,@Procontent,@ProMonery)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ProName",    SqlDbType.VarChar,   200),
                new SqlParameter("@ProTypeID",  SqlDbType.Int,         4),
                new SqlParameter("@ImageURL",   SqlDbType.Text),
                new SqlParameter("@ProXingID",  SqlDbType.Int,         4),
                new SqlParameter("@Prochutime", SqlDbType.DateTime),
                new SqlParameter("@Fatime",     SqlDbType.DateTime),
                new SqlParameter("@Toujian",    SqlDbType.Int,         4),
                new SqlParameter("@HitNum",     SqlDbType.Int,         4),
                new SqlParameter("@Procontent", SqlDbType.Text),
                new SqlParameter("@ProMonery",  SqlDbType.Text)
            };
            parameters[0].Value = model.ProName;
            parameters[1].Value = model.ProTypeID;
            parameters[2].Value = model.ImageURL;
            parameters[3].Value = model.ProXingID;
            parameters[4].Value = model.Prochutime;
            parameters[5].Value = model.Fatime;
            parameters[6].Value = model.Toujian;
            parameters[7].Value = model.HitNum;
            parameters[8].Value = model.Procontent;
            parameters[9].Value = model.ProMonery;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemple #15
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.Product GetModel(string ProductId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select * from P_Product ");
            strSql.Append(" where ProductId=@ProductId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ProductId", SqlDbType.VarChar)
            };
            parameters[0].Value = ProductId;
            Maticsoft.Model.Product model = new Maticsoft.Model.Product();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            model.ProductId = ProductId;
            if (ds.Tables[0].Rows.Count > 0)
            {
                model.BrandId    = ds.Tables[0].Rows[0]["BrandId"].ToString();
                model.CategoryId = ds.Tables[0].Rows[0]["CategoryId"].ToString();
                model.Name       = ds.Tables[0].Rows[0]["Name"].ToString();
                model.Descn      = ds.Tables[0].Rows[0]["Descn"].ToString();
                model.Image      = ds.Tables[0].Rows[0]["Image"].ToString();
                model.ImageSmall = ds.Tables[0].Rows[0]["ImageSmall"].ToString();
                if (ds.Tables[0].Rows[0]["Price"].ToString() != "")
                {
                    model.Price = decimal.Parse(ds.Tables[0].Rows[0]["Price"].ToString());
                }
                if (ds.Tables[0].Rows[0]["VipPrice"].ToString() != "")
                {
                    model.VipPrice = decimal.Parse(ds.Tables[0].Rows[0]["VipPrice"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Cheapness"].ToString() != "")
                {
                    model.Cheapness = int.Parse(ds.Tables[0].Rows[0]["Cheapness"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Exemple #16
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Maticsoft.Model.Product model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update P_Product set ");
            strSql.Append("BrandId=@BrandId,");
            strSql.Append("CategoryId=@CategoryId,");
            strSql.Append("Name=@Name,");
            strSql.Append("Descn=@Descn,");
            strSql.Append("Image=@Image,");
            strSql.Append("ImageSmall=@ImageSmall,");
            strSql.Append("Price=@Price,");
            strSql.Append("VipPrice=@VipPrice,");
            strSql.Append("Cheapness=@Cheapness");
            strSql.Append(" where ProductId=@ProductId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@BrandId",    SqlDbType.VarChar,  20),
                new SqlParameter("@CategoryId", SqlDbType.VarChar,  20),
                new SqlParameter("@ProductId",  SqlDbType.VarChar,  20),
                new SqlParameter("@Name",       SqlDbType.VarChar,  80),
                new SqlParameter("@Descn",      SqlDbType.Text),
                new SqlParameter("@Image",      SqlDbType.VarChar, 150),
                new SqlParameter("@ImageSmall", SqlDbType.VarChar, 150),
                new SqlParameter("@Price",      SqlDbType.Money,     8),
                new SqlParameter("@VipPrice",   SqlDbType.Money,     8),
                new SqlParameter("@Cheapness",  SqlDbType.Int)
            };
            parameters[0].Value = model.BrandId;
            parameters[1].Value = model.CategoryId;
            parameters[2].Value = model.ProductId;
            parameters[3].Value = model.Name;
            parameters[4].Value = model.Descn;
            parameters[5].Value = model.Image;
            parameters[6].Value = model.ImageSmall;
            parameters[7].Value = model.Price;
            parameters[8].Value = model.VipPrice;
            parameters[9].Value = model.Cheapness;

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
Exemple #17
0
        private void ShowNews(string productID)//显示新闻
        {
            Maticsoft.BLL.Products.Product bll   = new Maticsoft.BLL.Products.Product();
            Maticsoft.Model.Product        model = bll.GetModelByCache(productID);

            this.lblProductId.Text = model.ProductId.ToString();
            this.lblName.Text      = model.Name;
            lblDescn.Text          = model.Descn;
            lblPrice.Text          = model.Price.ToString();
            lblvipprice.Text       = model.VipPrice.ToString();
            Image1.ImageUrl        = "ProductImages/" + model.Image;
            Maticsoft.BLL.Products.Category bllc = new Maticsoft.BLL.Products.Category();
            lblCategoryId.Text = bllc.GetName(model.CategoryId);
            if (model.Cheapness == 1)
            {
                Label1.Text = "是";
            }
            else
            {
                Label1.Text = "否";
            }
        }
Exemple #18
0
 /// <summary>
 /// �õ�һ������ʵ��
 /// </summary>
 public Maticsoft.Model.Product GetModel(string ProductId)
 {
     StringBuilder strSql = new StringBuilder();
     strSql.Append("select * from P_Product ");
     strSql.Append(" where ProductId=@ProductId");
     SqlParameter[] parameters = {
             new SqlParameter("@ProductId", SqlDbType.VarChar)};
     parameters[0].Value = ProductId;
     Maticsoft.Model.Product model = new Maticsoft.Model.Product();
     DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
     model.ProductId = ProductId;
     if (ds.Tables[0].Rows.Count > 0)
     {
         model.BrandId = ds.Tables[0].Rows[0]["BrandId"].ToString();
         model.CategoryId = ds.Tables[0].Rows[0]["CategoryId"].ToString();
         model.Name = ds.Tables[0].Rows[0]["Name"].ToString();
         model.Descn = ds.Tables[0].Rows[0]["Descn"].ToString();
         model.Image = ds.Tables[0].Rows[0]["Image"].ToString();
         model.ImageSmall = ds.Tables[0].Rows[0]["ImageSmall"].ToString();
         if (ds.Tables[0].Rows[0]["Price"].ToString() != "")
         {
             model.Price = decimal.Parse(ds.Tables[0].Rows[0]["Price"].ToString());
         }
         if (ds.Tables[0].Rows[0]["VipPrice"].ToString() != "")
         {
             model.VipPrice = decimal.Parse(ds.Tables[0].Rows[0]["VipPrice"].ToString());
         }
         if (ds.Tables[0].Rows[0]["Cheapness"].ToString() != "")
         {
             model.Cheapness = int.Parse(ds.Tables[0].Rows[0]["Cheapness"].ToString());
         }
         return model;
     }
     else
     {
         return null;
     }
 }
Exemple #19
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            Maticsoft.BLL.Products.Product bll = new Maticsoft.BLL.Products.Product();

            string ProductId = this.txtProductId.Text;
            string BrandId = this.dropBrand.SelectedValue;
            string CategoryId = this.dropCategory.SelectedValue;
            string Name = this.txtName.Text;
            string Descn = this.txtDescn.Text;
            string Price = this.txtPrice.Text;
            string vipPrice = this.txtvipPrice.Text;

            if (bll.Exists(ProductId))
            {
                lblMsg.Visible = true;
                lblMsg.Text = "编号已经存在!";
                return;
            }

            Maticsoft.Model.Product model = new Maticsoft.Model.Product();
            model.ProductId = ProductId;
            model.BrandId = BrandId;
            model.CategoryId = CategoryId;
            model.Name = Name;
            model.Descn = Descn;
            if (Price != "")
            {
                model.Price = decimal.Parse(Price);
            }
            if (vipPrice != "")
            {
                model.VipPrice = decimal.Parse(vipPrice);
            }
            if (radbtn_Cheap.Checked)
            {
                model.Cheapness = 1;
            }


            #region 上传缩略图文件

            //if (this.FileUpSmall.PostedFile != null)
            //{
            //    string strErr = "";
            //    int size = this.FileUpSmall.PostedFile.ContentLength;//大小
            //    if (size >1)
            //    {
            //        if (size > 1024000)
            //        {
            //            strErr += "对不起,文件大小不能大于1M!\\n";
            //        }

            //        if (strErr != "")
            //        {
            //            LTP.Common.MessageBox.Show(this, strErr);
            //            return;
            //        }

            //        string UploadFileType1 = this.FileUpSmall.PostedFile.ContentType;
            //        string UploadFilePath1 = this.FileUpSmall.PostedFile.FileName;
            //        int start1 = UploadFilePath1.LastIndexOf("\\");

            //        string filename1 = UploadFilePath1.Substring(start1 + 1);
            //        filename1 = DateTime.Now.ToString("yyyyMMddHHmmss") + "Small" + filename1;

            //        model.ImageSmall = filename1;

            //        Stream StreamObject1 = this.FileUpSmall.PostedFile.InputStream;//建立数据流对像
            //        switch (UploadFileType1)
            //        {
            //            case "image/gif":
            //            case "image/bmp":
            //            case "image/pjpeg":
            //                {
            //                    System.Drawing.Image myImage = System.Drawing.Image.FromStream(StreamObject1);
            //                    int w = myImage.Width;
            //                    int h = myImage.Height;

            //                }
            //                break;
            //            case "application/x-shockwave-flash":
            //                break;
            //            case "video/x-ms-wmv":
            //            case "video/mpeg":
            //            case "video/x-ms-asf":
            //            case "video/avi":
            //            case "audio/mpeg":
            //            case "audio/mid":
            //            case "audio/wav":
            //            case "audio/x-ms-wma":
            //                break;
            //            default:
            //                strErr += "对不起,不允许该文件格式上传!\\n";
            //                break;
            //        }


            //        string path1 = ProductImageFolder + filename1;
            //        path1 = Server.MapPath(path1);
            //        try
            //        {
            //            this.FileUpSmall.PostedFile.SaveAs(path1); //如果抱错,注意UploadFile目录的访问权限
            //        }
            //        catch (System.Exception ex)
            //        {
            //            Response.Write("请确保" + ProductImageFolder + "目录具有写的权限。" + ex.Message);
            //            return;
            //        }
            //    }

            //}



            #endregion


            #region 上传图片文件

            if (this.FileUp.PostedFile != null)
            {
                string strErr = "";
                int size1 = this.FileUp.PostedFile.ContentLength;//大小
                if (size1 > 1)
                {
                    if (size1 > 1024000)
                    {
                        strErr += "对不起,文件大小不能大于1M!\\n";
                    }

                    if (strErr != "")
                    {
                        LTP.Common.MessageBox.Show(this, strErr);
                        return;
                    }

                    string UploadFileType = this.FileUp.PostedFile.ContentType;
                    string UploadFilePath = this.FileUp.PostedFile.FileName;
                    int start = UploadFilePath.LastIndexOf("\\");

                    string filename = UploadFilePath.Substring(start + 1);
                    filename = DateTime.Now.ToString("yyyyMMddHHmmss") + filename;

                    model.Image = filename;

                    Stream StreamObject = this.FileUp.PostedFile.InputStream;//建立数据流对像
                    switch (UploadFileType)
                    {
                        case "image/gif":
                        case "image/bmp":
                        case "image/pjpeg":
                            {
                                System.Drawing.Image myImage = System.Drawing.Image.FromStream(StreamObject);
                                int w = myImage.Width;
                                int h = myImage.Height;


                            }
                            break;
                        case "application/x-shockwave-flash":
                            break;
                        case "video/x-ms-wmv":
                        case "video/mpeg":
                        case "video/x-ms-asf":
                        case "video/avi":
                        case "audio/mpeg":
                        case "audio/mid":
                        case "audio/wav":
                        case "audio/x-ms-wma":
                            break;
                        default:
                            strErr += "对不起,不允许该文件格式上传!\\n";
                            break;
                    }

                    if (strErr != "")
                    {
                        LTP.Common.MessageBox.Show(this, strErr);
                        return;
                    }

                    string path = ProductImageFolder + filename;
                    path = Server.MapPath(path);
                    try
                    {
                        this.FileUp.PostedFile.SaveAs(path); //如果抱错,注意UploadFile目录的访问权限
                    }
                    catch //(System.Exception ex)
                    {
                        Response.Write("请确保" + ProductImageFolder + "目录具有写的权限。");
                        return;
                    }
                }
            }            
            #endregion
            bll.Add(model);
            if (chkAddContinue.Checked)
            {
                Response.Redirect("Add.aspx");
            }
            else
            {
                Response.Redirect("index.aspx");
            }


        }
Exemple #20
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtProName.Text.Trim().Length == 0)
            {
                strErr += "ProName不能为空!\\n";
            }
            if (!PageValidate.IsNumber(txtProTypeID.Text))
            {
                strErr += "ProTypeID格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtProXingID.Text))
            {
                strErr += "ProXingID格式错误!\\n";
            }
            if (!PageValidate.IsDateTime(txtProchutime.Text))
            {
                strErr += "Prochutime格式错误!\\n";
            }
            if (!PageValidate.IsDateTime(txtFatime.Text))
            {
                strErr += "Fatime格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtHitNum.Text))
            {
                strErr += "HitNum格式错误!\\n";
            }
            if (this.txtProcontent.Text.Trim().Length == 0)
            {
                strErr += "Procontent不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            string   ProName    = this.txtProName.Text;
            int      ProTypeID  = int.Parse(this.txtProTypeID.Text);
            int      ProXingID  = int.Parse(this.txtProXingID.Text);
            DateTime Prochutime = DateTime.Parse(this.txtProchutime.Text);
            DateTime Fatime     = DateTime.Parse(this.txtFatime.Text);
            bool     Toujian    = this.chkToujian.Checked;
            int      HitNum     = int.Parse(this.txtHitNum.Text);
            string   Procontent = this.txtProcontent.Text;

            Maticsoft.Model.Product model = new Maticsoft.Model.Product();
            model.ProName    = ProName;
            model.ProTypeID  = ProTypeID;
            model.ProXingID  = ProXingID;
            model.Prochutime = Prochutime;
            model.Fatime     = Fatime;
            model.Toujian    = Toujian;
            model.HitNum     = HitNum;
            model.Procontent = Procontent;

            Maticsoft.BLL.Product bll = new Maticsoft.BLL.Product();
            bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx");
        }
Exemple #21
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            Maticsoft.BLL.Products.Product bll = new Maticsoft.BLL.Products.Product();

            string ProductId  = this.txtProductId.Text;
            string BrandId    = this.dropBrand.SelectedValue;
            string CategoryId = this.dropCategory.SelectedValue;
            string Name       = this.txtName.Text;
            string Descn      = this.txtDescn.Text;
            string Price      = this.txtPrice.Text;
            string vipPrice   = this.txtvipPrice.Text;

            if (bll.Exists(ProductId))
            {
                lblMsg.Visible = true;
                lblMsg.Text    = "编号已经存在!";
                return;
            }

            Maticsoft.Model.Product model = new Maticsoft.Model.Product();
            model.ProductId  = ProductId;
            model.BrandId    = BrandId;
            model.CategoryId = CategoryId;
            model.Name       = Name;
            model.Descn      = Descn;
            if (Price != "")
            {
                model.Price = decimal.Parse(Price);
            }
            if (vipPrice != "")
            {
                model.VipPrice = decimal.Parse(vipPrice);
            }
            if (radbtn_Cheap.Checked)
            {
                model.Cheapness = 1;
            }


            #region   缩略图文件

            //if (this.FileUpSmall.PostedFile != null)
            //{
            //    string strErr = "";
            //    int size = this.FileUpSmall.PostedFile.ContentLength;//大小
            //    if (size >1)
            //    {
            //        if (size > 1024000)
            //        {
            //            strErr += "对不起,文件大小不能大于1M!\\n";
            //        }

            //        if (strErr != "")
            //        {
            //            LTP.Common.MessageBox.Show(this, strErr);
            //            return;
            //        }

            //        string UploadFileType1 = this.FileUpSmall.PostedFile.ContentType;
            //        string UploadFilePath1 = this.FileUpSmall.PostedFile.FileName;
            //        int start1 = UploadFilePath1.LastIndexOf("\\");

            //        string filename1 = UploadFilePath1.Substring(start1 + 1);
            //        filename1 = DateTime.Now.ToString("yyyyMMddHHmmss") + "Small" + filename1;

            //        model.ImageSmall = filename1;

            //        Stream StreamObject1 = this.FileUpSmall.PostedFile.InputStream;//建立数据流对像
            //        switch (UploadFileType1)
            //        {
            //            case "image/gif":
            //            case "image/bmp":
            //            case "image/pjpeg":
            //                {
            //                    System.Drawing.Image myImage = System.Drawing.Image.FromStream(StreamObject1);
            //                    int w = myImage.Width;
            //                    int h = myImage.Height;

            //                }
            //                break;
            //            case "application/x-shockwave-flash":
            //                break;
            //            case "video/x-ms-wmv":
            //            case "video/mpeg":
            //            case "video/x-ms-asf":
            //            case "video/avi":
            //            case "audio/mpeg":
            //            case "audio/mid":
            //            case "audio/wav":
            //            case "audio/x-ms-wma":
            //                break;
            //            default:
            //                strErr += "对不起,不允许该文件格式上传!\\n";
            //                break;
            //        }


            //        string path1 = ProductImageFolder + filename1;
            //        path1 = Server.MapPath(path1);
            //        try
            //        {
            //            this.FileUpSmall.PostedFile.SaveAs(path1); //如果抱错,注意UploadFile目录的访问权限
            //        }
            //        catch (System.Exception ex)
            //        {
            //            Response.Write("请确保" + ProductImageFolder + "目录具有写的权限。" + ex.Message);
            //            return;
            //        }
            //    }

            //}



            #endregion


            #region   图片文件

            if (this.FileUp.PostedFile != null)
            {
                string strErr = "";
                int    size1  = this.FileUp.PostedFile.ContentLength;//大小
                if (size1 > 1)
                {
                    if (size1 > 1024000)
                    {
                        strErr += "对不起,文件大小不能大于1M!\\n";
                    }

                    if (strErr != "")
                    {
                        LTP.Common.MessageBox.Show(this, strErr);
                        return;
                    }

                    string UploadFileType = this.FileUp.PostedFile.ContentType;
                    string UploadFilePath = this.FileUp.PostedFile.FileName;
                    int    start          = UploadFilePath.LastIndexOf("\\");

                    string filename = UploadFilePath.Substring(start + 1);
                    filename = DateTime.Now.ToString("yyyyMMddHHmmss") + filename;

                    model.Image = filename;

                    Stream StreamObject = this.FileUp.PostedFile.InputStream;//建立数据流对像
                    switch (UploadFileType)
                    {
                    case "image/gif":
                    case "image/bmp":
                    case "image/pjpeg":
                    {
                        System.Drawing.Image myImage = System.Drawing.Image.FromStream(StreamObject);
                        int w = myImage.Width;
                        int h = myImage.Height;
                    }
                    break;

                    case "application/x-shockwave-flash":
                        break;

                    case "video/x-ms-wmv":
                    case "video/mpeg":
                    case "video/x-ms-asf":
                    case "video/avi":
                    case "audio/mpeg":
                    case "audio/mid":
                    case "audio/wav":
                    case "audio/x-ms-wma":
                        break;

                    default:
                        strErr += "对不起,不允许该文件格式上传!\\n";
                        break;
                    }

                    if (strErr != "")
                    {
                        LTP.Common.MessageBox.Show(this, strErr);
                        return;
                    }

                    string path = ProductImageFolder + filename;
                    path = Server.MapPath(path);
                    try
                    {
                        this.FileUp.PostedFile.SaveAs(path); //如果抱错,注意UploadFile目录的访问权限
                    }
                    catch                                    //(System.Exception ex)
                    {
                        Response.Write("请确保" + ProductImageFolder + "目录具有写的权限。");
                        return;
                    }
                }
            }
            #endregion
            bll.Add(model);
            if (chkAddContinue.Checked)
            {
                Response.Redirect("Add.aspx");
            }
            else
            {
                Response.Redirect("index.aspx");
            }
        }