protected void btnGoodsClassSave_Click(object sender, EventArgs e) { Chain.BLL.GoodsClassAuthority bllGCA = new Chain.BLL.GoodsClassAuthority(); if (string.IsNullOrEmpty(base.Request["ClassID"])) { Chain.Model.GoodsClass mdGoodsClass = new Chain.Model.GoodsClass(); mdGoodsClass.ClassName = this.txtClassName.Value; mdGoodsClass.ClassRemark = this.txtGoodsClassRemark.Value; mdGoodsClass.ParentID = Convert.ToInt32(this.sltGoodsClass.Value); mdGoodsClass.CreateShopID = Convert.ToInt32(this.sltShop.Value); int flag = this.bllGoodsClass.Add(mdGoodsClass); int modelGCA = bllGCA.Add(new Chain.Model.GoodsClassAuthority { ClassID = flag, ShopID = Convert.ToInt32(this.sltShop.Value) }); if (flag > 0 && modelGCA > 0) { ArrayList sqlArray = new ArrayList(); string strSqlColumn = "INSERT INTO GoodsClassDiscount (GoodsClassID,MemLevelID,DiscountShopID,ClassDiscountPercent,ClassPointPercent) VALUES ('{0}','{1}','{2}','{3}','{4}')"; string GoodsClassID = flag.ToString(); mdGoodsClass.ClassID = flag; for (int i = 0; i < this.rptLevelList.Items.Count; i++) { string MemLevelID = ((Literal)this.rptLevelList.Items[i].FindControl("ltLevelID")).Text; string ClassDiscountPercent = (Convert.ToDecimal(((HtmlInputText)this.rptLevelList.Items[i].FindControl("txtDiscountPercent")).Value.Trim()) / 100m).ToString(); string ClassPointPercent = ((HtmlInputText)this.rptLevelList.Items[i].FindControl("txtPointPercent")).Value.Trim(); ClassPointPercent = ((ClassPointPercent == "0") ? "0" : Convert.ToDecimal(ClassPointPercent).ToString()); string strSql = string.Format(strSqlColumn, new object[] { GoodsClassID, MemLevelID, this._UserShopID, ClassDiscountPercent, ClassPointPercent }); sqlArray.Add(strSql); } if (this.bllGoodsClassDiscount.AddList(sqlArray)) { this.lblShowSync.Attributes.Add("style", "display:none"); this.lblShowSyncPartial.Attributes.Add("style", "display:none"); this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "message", "<Script Language='JavaScript' defer>art.dialog({title: '系统提示',time: 2,content:'保存成功',close: function () { location.href = 'SetGoodsLevel.aspx?PID=73'; }});</script>"); } else { this.bllGoodsClass.Delete(flag); base.OutputWarn("保存失败,请重试!"); } } else { switch (flag) { case -1: base.OutputWarn("类别名称已存在,请重试!"); break; case 0: base.OutputWarn("保存失败,请重试!"); break; default: base.OutputWarn("保存失败,请重试!"); break; } } } else { Chain.Model.GoodsClass mdGoodsClass = this.bllGoodsClass.GetModel(Convert.ToInt32(base.Request["ClassID"])); mdGoodsClass.ClassName = this.txtClassName.Value; mdGoodsClass.ClassRemark = this.txtGoodsClassRemark.Value; int flag = this.bllGoodsClass.UpdateByShop(mdGoodsClass); if (flag > 0) { ArrayList sqlArray = new ArrayList(); string strSqlColumn = "UPDATE GoodsClassDiscount SET ClassDiscountPercent = '{0}',ClassPointPercent = '{1}' WHERE ClassDiscountID = '{2}'"; string strAllSql = string.Empty; string ClassDiscountPercent = string.Empty; string ClassPointPercent = string.Empty; string ClassDiscountID = string.Empty; for (int i = 0; i < this.rptLevelList.Items.Count; i++) { ClassDiscountID = ((Literal)this.rptLevelList.Items[i].FindControl("ltClassDiscountID")).Text; ClassDiscountPercent = (Convert.ToDecimal(((HtmlInputText)this.rptLevelList.Items[i].FindControl("txtDiscountPercent")).Value.Trim()) / 100m).ToString(); ClassPointPercent = ((HtmlInputText)this.rptLevelList.Items[i].FindControl("txtPointPercent")).Value.Trim(); ClassPointPercent = ((ClassPointPercent == "0") ? "0" : Convert.ToDecimal(ClassPointPercent).ToString()); strAllSql = string.Format(strSqlColumn, ClassDiscountPercent, ClassPointPercent, ClassDiscountID); sqlArray.Add(strAllSql); } if (this.bllGoodsClassDiscount.AddList(sqlArray)) { this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "message", "<Script Language='JavaScript' defer>art.dialog({title: '系统提示',time: 2,content:'保存成功',close: function () { location.href = 'SetGoodsLevel.aspx?PID=73'; }});</script>"); } else { base.OutputWarn("保存失败,请重试!"); } } else { switch (flag) { case -1: base.OutputWarn("类别名称已存在,请重试!"); break; case 0: base.OutputWarn("保存失败,请重试!"); break; default: base.OutputWarn("保存失败,请重试!"); break; } } } }
protected void btnCopy_Click(object sender, EventArgs e) { Chain.BLL.SysShop bllShop = new Chain.BLL.SysShop(); Chain.BLL.GoodsClassAuthority bllGoodsClassAuthority = new Chain.BLL.GoodsClassAuthority(); Chain.BLL.GoodsClass bllGoodsClass = new Chain.BLL.GoodsClass(); DataTable dtShop = bllShop.GetList("ShopID>0 and ShopType=3 and IsMain=0 ").Tables[0]; DataTable dtGoodsClass = bllGoodsClass.GetList("CreateShopID=" + this._UserShopID).Tables[0]; for (int i = 0; i < dtShop.Rows.Count; i++) { int ShopID = int.Parse(dtShop.Rows[i]["ShopID"].ToString()); for (int j = 0; j < dtGoodsClass.Rows.Count; j++) { int ClassID = int.Parse(dtGoodsClass.Rows[j]["ClassID"].ToString()); Chain.Model.GoodsClassAuthority modelGoodsClassAuthority = new Chain.Model.GoodsClassAuthority(); modelGoodsClassAuthority.ClassID = ClassID; modelGoodsClassAuthority.ShopID = ShopID; int count = bllGoodsClassAuthority.GetRecordCount(string.Concat(new object[] { "ShopID=", ShopID, " and ClassID=", ClassID })); if (count == 0) { bllGoodsClassAuthority.Add(modelGoodsClassAuthority); } } } Chain.BLL.GoodsClassDiscount bllGoodsClassDiscount = new Chain.BLL.GoodsClassDiscount(); DataTable dtClassDiscount = bllGoodsClassDiscount.GetList("DiscountShopID=" + this._UserShopID).Tables[0]; for (int i = 0; i < dtShop.Rows.Count; i++) { int ShopID = int.Parse(dtShop.Rows[i]["ShopID"].ToString()); for (int j = 0; j < dtClassDiscount.Rows.Count; j++) { Chain.Model.GoodsClassDiscount modelGoodsClassDiscount = new Chain.Model.GoodsClassDiscount(); int ClassID = int.Parse(dtClassDiscount.Rows[j]["GoodsClassID"].ToString()); int MemLevelID = int.Parse(dtClassDiscount.Rows[j]["MemLevelID"].ToString()); modelGoodsClassDiscount.GoodsClassID = ClassID; modelGoodsClassDiscount.MemLevelID = MemLevelID; modelGoodsClassDiscount.DiscountShopID = ShopID; modelGoodsClassDiscount.ClassDiscountPercent = int.Parse(dtClassDiscount.Rows[j]["ClassDiscountPercent"].ToString()); modelGoodsClassDiscount.ClassPointPercent = int.Parse(dtClassDiscount.Rows[j]["ClassPointPercent"].ToString()); DataTable dtShopGoodsClassDiscount = bllGoodsClassDiscount.GetList(string.Concat(new object[] { "MemLevelID=", MemLevelID, " and DiscountShopID=", ShopID, " and GoodsClassID=", ClassID })).Tables[0]; if (dtShopGoodsClassDiscount.Rows.Count == 0) { bllGoodsClassDiscount.Add(modelGoodsClassDiscount); } else { modelGoodsClassDiscount.ClassDiscountID = int.Parse(dtShopGoodsClassDiscount.Rows[0]["ClassDiscountID"].ToString()); bllGoodsClassDiscount.Update(modelGoodsClassDiscount); } } } Chain.BLL.Goods bllGoods = new Chain.BLL.Goods(); DataTable dtGoods = bllGoods.GetGoodsList("CreateShopID=" + this._UserShopID).Tables[0]; Chain.BLL.GoodsNumber bllGoodsNumber = new Chain.BLL.GoodsNumber(); for (int i = 0; i < dtShop.Rows.Count; i++) { int ShopID = int.Parse(dtShop.Rows[i]["ShopID"].ToString()); for (int j = 0; j < dtGoods.Rows.Count; j++) { int GoodsID = int.Parse(dtGoods.Rows[j]["GoodsID"].ToString()); int count = bllGoodsNumber.GetRecordCount(string.Concat(new object[] { "GoodsID=", GoodsID, " and ShopID=", ShopID })); Chain.Model.GoodsNumber modelGoodsNumber = new Chain.Model.GoodsNumber(); modelGoodsNumber.GoodsID = GoodsID; modelGoodsNumber.Number = 0m; modelGoodsNumber.ShopID = ShopID; if (count == 0) { bllGoodsNumber.Add(modelGoodsNumber); } } } this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "message", "<Script Language='JavaScript' defer>art.dialog({title: '系统提示',time: 2,content:'同步成功',close: function () { location.href = 'GoodsList.aspx?PID=62'; }});</script>"); }