Esempio n. 1
0
        public List <Chain.Model.GoodsClass> DataTableToList(DataTable dt)
        {
            List <Chain.Model.GoodsClass> modelList = new List <Chain.Model.GoodsClass>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                for (int i = 0; i < rowsCount; i++)
                {
                    Chain.Model.GoodsClass model = new Chain.Model.GoodsClass();
                    if (dt.Rows[i]["ClassID"] != null && dt.Rows[i]["ClassID"].ToString() != "")
                    {
                        model.ClassID = int.Parse(dt.Rows[i]["ClassID"].ToString());
                    }
                    if (dt.Rows[i]["ClassName"] != null && dt.Rows[i]["ClassName"].ToString() != "")
                    {
                        model.ClassName = dt.Rows[i]["ClassName"].ToString();
                    }
                    if (dt.Rows[i]["ClassRemark"] != null && dt.Rows[i]["ClassRemark"].ToString() != "")
                    {
                        model.ClassRemark = dt.Rows[i]["ClassRemark"].ToString();
                    }
                    if (dt.Rows[i]["ParentID"] != null && dt.Rows[i]["ParentID"].ToString() != "")
                    {
                        model.ParentID = int.Parse(dt.Rows[i]["ParentID"].ToString());
                    }
                    if (dt.Rows[i]["CreateShopID"] != null && dt.Rows[i]["CreateShopID"].ToString() != "")
                    {
                        model.CreateShopID = int.Parse(dt.Rows[i]["CreateShopID"].ToString());
                    }
                    modelList.Add(model);
                }
            }
            return(modelList);
        }
Esempio n. 2
0
        private void bindData()
        {
            if (!string.IsNullOrEmpty(base.Request["ParentID"]))
            {
                string ParentID = base.Request["ParentID"].ToString();
                this.sltGoodsClass.Value = ParentID;
            }
            PubFunction.BindShopSelect(this._UserShopID, this.sltShop, this._UserShopID, true);
            DataTable dtMemLevel = this.bllMemLevel.GetList("").Tables[0];

            this.rptLevelList.DataSource = dtMemLevel;
            this.rptLevelList.DataBind();
            if (!string.IsNullOrEmpty(base.Request["ClassID"]))
            {
                this.sltGoodsClass.Attributes.Add("disabled", "disabled");
                this.sltGoodsClass.Attributes.Add("readonly", "true");
                Chain.Model.GoodsClass mdGoodsClass = this.bllGoodsClass.GetModel(Convert.ToInt32(base.Request["ClassID"]));
                this.txtClassName.Value        = mdGoodsClass.ClassName;
                this.txtClassID.Value          = mdGoodsClass.ClassID.ToString();
                this.txtGoodsClassRemark.Value = mdGoodsClass.ClassRemark;
                this.sltGoodsClass.Value       = mdGoodsClass.ParentID.ToString();
                this.sltShop.Value             = mdGoodsClass.CreateShopID.ToString();
                DataTable dtGoodsClass = this.bllGoodsClassDiscount.GetList(string.Format(" GoodsClassID = '{0}' and DiscountShopID = '{1}'", base.Request["ClassID"], this._UserShopID)).Tables[0];
                for (int i = 0; i < this.rptLevelList.Items.Count; i++)
                {
                    DataRow[] drs = dtGoodsClass.Select(string.Format(" MemLevelID = '{0}'", ((Literal)this.rptLevelList.Items[i].FindControl("ltLevelID")).Text));
                    if (drs.Length > 0)
                    {
                        ((HtmlInputText)this.rptLevelList.Items[i].FindControl("txtDiscountPercent")).Value = (Convert.ToDouble(drs[0]["ClassDiscountPercent"]) * 100.0).ToString();
                        ((HtmlInputText)this.rptLevelList.Items[i].FindControl("txtPointPercent")).Value    = ((drs[0]["ClassPointPercent"].ToString() == "0") ? "0" : Convert.ToDecimal(drs[0]["ClassPointPercent"]).ToString());
                        ((Literal)this.rptLevelList.Items[i].FindControl("ltClassDiscountID")).Text         = drs[0]["ClassDiscountID"].ToString();
                    }
                }
            }
        }
Esempio n. 3
0
        public int UpdateByShop(Chain.Model.GoodsClass model)
        {
            int result;

            if (this.Exists(model.ClassID, model.ClassName, model.CreateShopID))
            {
                result = -1;
            }
            else
            {
                result = (this.dal.Update(model) ? 1 : -3);
            }
            return(result);
        }
Esempio n. 4
0
        public int SyncGoodsClass(int ClassID, List <int> ShopList)
        {
            GoodsClass bllGC = new GoodsClass();

            Chain.Model.GoodsClass model = bllGC.GetModel(ClassID);
            int result;

            if (model != null && ShopList.Count > 0)
            {
                if (model.ParentID != 0)
                {
                    this.dal.SyncGoodsClass(model.ParentID, ShopList);
                }
                result = this.dal.SyncGoodsClass(ClassID, ShopList);
            }
            else
            {
                result = -1;
            }
            return(result);
        }
Esempio n. 5
0
        public int SyncGoodsClass(int ClassID, int ShopID)
        {
            GoodsClass bllGC = new GoodsClass();

            Chain.Model.GoodsClass model = bllGC.GetModel(ClassID);
            int result;

            if (model != null)
            {
                if (model.ParentID != 0)
                {
                    this.dal.SyncGoodsClass(model.ParentID, ShopID);
                }
                result = this.dal.SyncGoodsClass(ClassID, ShopID);
            }
            else
            {
                result = 0;
            }
            return(result);
        }
Esempio n. 6
0
        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;
                    }
                }
            }
        }
Esempio n. 7
0
 public bool Update(Chain.Model.GoodsClass model)
 {
     return(this.dal.Update(model));
 }
Esempio n. 8
0
 public int Add(Chain.Model.GoodsClass model)
 {
     return(this.dal.Add(model));
 }
Esempio n. 9
0
        public int DeleteClassByShop(int ClassID, int ShopID)
        {
            GoodsNumber         bllGN  = new GoodsNumber();
            GoodsClassAuthority bllGCA = new GoodsClassAuthority();
            GoodsClassDiscount  bllGCD = new GoodsClassDiscount();
            GoodsClass          bllGC  = new GoodsClass();
            Goods bllG = new Goods();

            Chain.Model.GoodsClass modelGC = bllGC.GetModel(ClassID);
            int result;

            if (modelGC == null)
            {
                result = -100;
            }
            else
            {
                if (modelGC.ParentID == 0)
                {
                    int childClassCount = bllGCA.GetClassCountByParentID(modelGC.ClassID);
                    if (childClassCount > 0)
                    {
                        int childClassCountInShop = bllGCA.GetClassCountByParentID(modelGC.ClassID, ShopID);
                        if (childClassCountInShop > 0)
                        {
                            result = -2;
                            return(result);
                        }
                        if (bllGN.GetGoodsCount(ClassID, ShopID) == 0)
                        {
                            bllGCA.DeleteAuthority(ClassID, ShopID);
                            result = 1;
                            return(result);
                        }
                        result = -1;
                        return(result);
                    }
                }
                int goodsCount = bllGN.GetGoodsCount(ClassID, ShopID);
                if (goodsCount == 0)
                {
                    bllGCA.DeleteAuthority(ClassID, ShopID);
                    bllGCD.DeleteDiscount(ClassID, ShopID);
                    DataTable dt           = bllGCA.GetShopIDListByClass(ClassID).Tables[0];
                    bool      isClassShare = false;
                    foreach (DataRow item in dt.Rows)
                    {
                        if (Convert.ToInt32(item["ShopID"]) != ShopID)
                        {
                            isClassShare = true;
                            break;
                        }
                    }
                    if (!isClassShare)
                    {
                        bllGC.Delete(ClassID);
                    }
                    result = 1;
                }
                else
                {
                    result = -1;
                }
            }
            return(result);
        }