示例#1
0
        protected string QueryCondition()
        {
            string strQueryGoods   = this.txtQueryGoods.Value;
            string strPriceSymbols = this.sltGoodsPriceSymbols.Value;
            string strGoodsPrice   = PubFunction.RemoveSpace(this.txtGoodsPrice.Value);
            string strGoodsClass   = (base.Request["sltGoodsClass"] == null) ? "" : base.Request["sltGoodsClass"].Trim();

            this.txtGoodsClass.Value = strGoodsClass;
            string        strCustom      = this.sltCustomField.Value;
            string        strCustomField = this.txtCustomField.Value;
            string        strGoodsType   = this.sltGoodsType.Value;
            string        strShopId      = this.sltShop.Value;
            StringBuilder strSql         = new StringBuilder();

            strSql.Append(" Goods.GoodsID >0 ");
            if (strQueryGoods != "")
            {
                strSql.AppendFormat("and (Name like '%{0}%' or NameCode like '%{0}%' or GoodsCode like '%{0}%')", strQueryGoods);
            }
            if (strGoodsPrice != "")
            {
                strSql.AppendFormat(" and Price" + strPriceSymbols + "{0} ", decimal.Parse(strGoodsPrice));
            }
            if (strCustom != "")
            {
                strSql.AppendFormat(" and {0} = '{1}'", strCustom, strCustomField);
            }
            if (strGoodsType != "")
            {
                strSql.AppendFormat(" and GoodsType = {0}", int.Parse(strGoodsType));
            }
            if (strGoodsClass != "")
            {
                Chain.Model.GoodsClass model = new Chain.BLL.GoodsClass().GetModel(int.Parse(strGoodsClass));
                if (model.ParentID == 0)
                {
                    string    strClass = int.Parse(strGoodsClass) + ",";
                    DataTable dt       = new Chain.BLL.GoodsClass().GetList("ParentID=" + int.Parse(strGoodsClass)).Tables[0];
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        strClass = strClass + dt.Rows[i]["ClassID"] + ",";
                    }
                    int length = strClass.Length;
                    strClass = strClass.Substring(0, length - 1);
                    strSql.AppendFormat(" and GoodsClassID in ({0})", strClass);
                }
                else
                {
                    strSql.AppendFormat(" and GoodsClassID={0}", int.Parse(strGoodsClass));
                }
            }
            if (strShopId != "")
            {
                strSql.AppendFormat(" and GoodsNumber.ShopID={0}", int.Parse(strShopId));
            }
            return(strSql.ToString());
        }
示例#2
0
        protected string QueryCondition()
        {
            string strQueryGoods = this.txtGoodsName.Value;
            string strGoodsType  = this.sltGoodsType.Value;
            string strShopID     = this.sltShop.Value;
            string strGoodsClass = (base.Request["sltGoodsClass"] == null) ? "" : base.Request["sltGoodsClass"].Trim();

            this.txtGoodsClass.Value = strGoodsClass;
            StringBuilder strSql = new StringBuilder();

            strSql.Append(" 1=1  ");
            if (strQueryGoods != "")
            {
                strSql.AppendFormat("and (GoodsCode like '%{0}%' or Name like '%{0}%' or NameCode like '%{0}%')", strQueryGoods);
            }
            if (strGoodsType != "")
            {
                strSql.AppendFormat("and GoodsType={0}", int.Parse(strGoodsType));
            }
            if (strGoodsClass != "")
            {
                Chain.Model.GoodsClass model = new Chain.BLL.GoodsClass().GetModel(int.Parse(strGoodsClass));
                if (model.ParentID == 0)
                {
                    string    strClass = int.Parse(strGoodsClass) + ",";
                    DataTable dt       = new Chain.BLL.GoodsClass().GetList("ParentID=" + int.Parse(strGoodsClass)).Tables[0];
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        strClass = strClass + dt.Rows[i]["ClassID"] + ",";
                    }
                    int length = strClass.Length;
                    strClass = strClass.Substring(0, length - 1);
                    strSql.AppendFormat(" and GoodsClassID in ({0})", strClass);
                }
                else
                {
                    strSql.AppendFormat(" and GoodsClassID={0}", int.Parse(strGoodsClass));
                }
            }
            if (strShopID != "")
            {
                strSql.AppendFormat(" and OrderShopID={0}", int.Parse(strShopID));
            }
            return(strSql.ToString());
        }
示例#3
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);
        }
示例#4
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);
        }
示例#5
0
        private DataTable CheckGoodsNumData(DataTable dtGoods, bool istable, int ThisShopID)
        {
            DataTable dtGoodsCopy = dtGoods.Copy();

            dtGoodsCopy.Clear();
            if (dtGoods.Rows.Count <= 0)
            {
                File.Delete(this.strSavePath);
                base.OutputWarn("检验的Excel表格还没有商品数据,请填写商品数据再检验。");
            }
            else
            {
                DataTable dtspid = new Chain.BLL.GoodsClass().GetAllList().Tables[0];
                for (int i = 0; i < dtGoods.Rows.Count; i++)
                {
                    bool   bolIndex = false;
                    string strError = "";
                    if (dtGoods.Rows[i].IsNull(0) || dtGoods.Rows[i]["GoodsCode"].ToString() == "")
                    {
                        strError += "商品编码不能为空,";
                        bolIndex  = true;
                    }
                    if (dtGoods.Rows[i]["GoodsCode"].ToString().Length < 5 || dtGoods.Rows[i]["GoodsCode"].ToString().Length > 25)
                    {
                        strError += "商品编码必须是5~25位数字,";
                        bolIndex  = true;
                    }
                    Chain.BLL.Goods bllGoods = new Chain.BLL.Goods();
                    if (!bllGoods.Exists(dtGoods.Rows[i][0].ToString()))
                    {
                        strError += "商品编码不存在系统,";
                        bolIndex  = true;
                    }
                    DataRow[] row = dtGoods.Select(" GoodsCode='" + dtGoods.Rows[i][0].ToString() + "'");
                    if (row.Length > 1)
                    {
                        strError += "商品编码在Excel表重复出现,";
                        bolIndex  = true;
                    }
                    if (dtGoods.Rows[i].IsNull(1) || dtGoods.Rows[i]["Name"].ToString() == "")
                    {
                        strError += "商品名称不能为空,";
                        bolIndex  = true;
                    }
                    if (!dtGoods.Rows[i].IsNull(2) && dtGoods.Rows[i]["Number"].ToString() != "")
                    {
                        if (PubFunction.ProductDecimalNum == 0)
                        {
                            int myid;
                            if (!int.TryParse(dtGoods.Rows[i]["Number"].ToString(), out myid))
                            {
                                strError += "商品库存只能是整数,";
                                bolIndex  = true;
                            }
                        }
                        else
                        {
                            string num = dtGoods.Rows[i]["Number"].ToString().Trim();
                            if (Regex.IsMatch(num, "^\\d+\\.$"))
                            {
                                num += "0";
                            }
                            if (num.IndexOf(".") > -1 && !Regex.IsMatch(num, "^\\d+\\.\\d{1," + PubFunction.ProductDecimalNum.ToString() + "}$"))
                            {
                                strError += string.Format("商品库存只能填写0或正整数或大于0的小数位不超{0}位的小数", PubFunction.ProductDecimalNum);
                                bolIndex  = true;
                            }
                        }
                    }
                    if (bolIndex)
                    {
                        if (strError.Substring(strError.Length - 1, 1) == ",")
                        {
                            strError = strError.Remove(strError.Length - 1);
                        }
                        dtGoods.Rows[i]["Error"] = strError;
                        dtGoodsCopy.Rows.Add(dtGoods.Rows[i].ItemArray);
                    }
                    if (istable)
                    {
                        dtGoodsCopy = dtGoods;
                    }
                }
            }
            return(dtGoodsCopy);
        }
示例#6
0
        private DataTable CheckGoodsData(DataTable dtGoods, bool istable)
        {
            DataTable dtGoodsCopy = dtGoods.Copy();

            dtGoodsCopy.Clear();
            if (dtGoods.Rows.Count <= 0)
            {
                File.Delete(this.strSavePath);
                base.OutputWarn("检验的Excel表格还没有商品数据,请填写商品数据再检验。");
            }
            else
            {
                DataTable dtspid = new Chain.BLL.GoodsClass().GetAllList().Tables[0];
                for (int i = 0; i < dtGoods.Rows.Count; i++)
                {
                    bool   bolIndex = false;
                    string strError = "";
                    if (dtGoods.Rows[i].IsNull(0) || dtGoods.Rows[i]["GoodsCode"].ToString() == "")
                    {
                        strError += "商品编码不能为空,";
                        bolIndex  = true;
                    }
                    if (dtGoods.Rows[i]["GoodsCode"].ToString().Length < 5 || dtGoods.Rows[i]["GoodsCode"].ToString().Length > 25)
                    {
                        strError += "商品编码必须是5~25位数字,";
                        bolIndex  = true;
                    }
                    Chain.BLL.Goods bllGoods = new Chain.BLL.Goods();
                    if (bllGoods.Exists(dtGoods.Rows[i][0].ToString(), this._UserShopID))
                    {
                        strError += "商品编码已存在系统,";
                        bolIndex  = true;
                    }
                    for (int j = 0; j < i; j++)
                    {
                        if (dtGoods.Rows[j][0].ToString() == dtGoods.Rows[i][0].ToString())
                        {
                            strError += "商品编码在Excel表重复出现,";
                            bolIndex  = true;
                        }
                    }
                    if (dtGoods.Rows[i].IsNull(1) || dtGoods.Rows[i]["Name"].ToString() == "")
                    {
                        strError += "商品名称不能为空,";
                        bolIndex  = true;
                    }
                    if (dtGoods.Rows[i].IsNull(3) || dtGoods.Rows[i]["GoodsClassID"].ToString() == "")
                    {
                        strError += "商品分类ID不能为空,";
                        bolIndex  = true;
                    }
                    else
                    {
                        int       myid;
                        DataRow[] drGoodsClass;
                        if (int.TryParse(dtGoods.Rows[i]["GoodsClassID"].ToString(), out myid))
                        {
                            drGoodsClass = dtspid.Select(string.Format(" ClassID = '{0}'", dtGoods.Rows[i]["GoodsClassID"].ToString()));
                            if (drGoodsClass.Length <= 0)
                            {
                                drGoodsClass = dtspid.Select(string.Format(" ClassName = '{0}'", dtGoods.Rows[i]["GoodsClassID"].ToString()));
                            }
                        }
                        else
                        {
                            drGoodsClass = dtspid.Select(string.Format(" ClassName = '{0}'", dtGoods.Rows[i]["GoodsClassID"].ToString()));
                        }
                        if (drGoodsClass.Length > 0)
                        {
                            dtGoods.Rows[i]["GoodsClassID"] = drGoodsClass[0]["ClassID"];
                        }
                        else
                        {
                            strError += "商品分类未找到,";
                            bolIndex  = true;
                        }
                    }
                    if (dtGoods.Rows[i].IsNull(4) || dtGoods.Rows[i]["Unit"].ToString() == "")
                    {
                        strError += "计量单位不能为空,";
                        bolIndex  = true;
                    }
                    decimal yzsz;
                    if (!dtGoods.Rows[i].IsNull(5) && dtGoods.Rows[i]["GoodsBidPrice"].ToString() != "")
                    {
                        if (!decimal.TryParse(dtGoods.Rows[i]["GoodsBidPrice"].ToString(), out yzsz))
                        {
                            strError += "参考进价只能是整数或小数,";
                            bolIndex  = true;
                        }
                    }
                    if (dtGoods.Rows[i].IsNull(6) || dtGoods.Rows[i]["Price"].ToString() == "")
                    {
                        strError += "零售单价不能为空,";
                        bolIndex  = true;
                    }
                    else if (!decimal.TryParse(dtGoods.Rows[i]["Price"].ToString(), out yzsz))
                    {
                        strError += "零售单价只能是整数或小数,";
                        bolIndex  = true;
                    }
                    if (!dtGoods.Rows[i].IsNull(7) && dtGoods.Rows[i]["Point"].ToString() != "")
                    {
                        int myid;
                        if (!int.TryParse(dtGoods.Rows[i]["Point"].ToString(), out myid))
                        {
                            strError += "商品积分只能是整数,";
                            bolIndex  = true;
                        }
                    }
                    if (dtGoods.Rows[i].IsNull(8) || dtGoods.Rows[i]["GoodsType"].ToString() == "")
                    {
                        strError += "商品类型不能为空,";
                        bolIndex  = true;
                    }
                    else
                    {
                        string intType = dtGoods.Rows[i]["GoodsType"].ToString();
                        if (intType != "0" && intType != "1" && intType != "普通商品" && intType != "服务项目")
                        {
                            strError += "商品类型只能是0(普通商品)或1(服务项目),";
                            bolIndex  = true;
                        }
                        else if (intType == "普通商品" || intType == "服务项目")
                        {
                            if (intType == "服务项目")
                            {
                                dtGoods.Rows[i]["GoodsType"] = "1";
                            }
                            else
                            {
                                dtGoods.Rows[i]["GoodsType"] = "0";
                            }
                        }
                    }
                    if (!dtGoods.Rows[i].IsNull(9) && dtGoods.Rows[i]["MinPercent"].ToString() != "")
                    {
                        if (!decimal.TryParse(dtGoods.Rows[i]["MinPercent"].ToString(), out yzsz))
                        {
                            strError += "最低折扣只能是0~1的小数,";
                            bolIndex  = true;
                        }
                        else if (decimal.Parse(dtGoods.Rows[i]["MinPercent"].ToString()) > 1m)
                        {
                            strError += "最低折扣只能是0~1的小数,";
                            bolIndex  = true;
                        }
                    }
                    if (!dtGoods.Rows[i].IsNull(10) && dtGoods.Rows[i]["CommissionType"].ToString() != "")
                    {
                        string intType = dtGoods.Rows[i]["CommissionType"].ToString();
                        if (intType != "1" && intType != "2" && intType != "按固定比例提成" && intType != "按固定金额提成")
                        {
                            strError += "提成类型只能是1(按固定比例提成)或2(按固定金额提成),";
                            bolIndex  = true;
                        }
                        else if (intType == "按固定比例提成" || intType == "按固定金额提成")
                        {
                            if (intType == "按固定比例提成")
                            {
                                dtGoods.Rows[i]["CommissionType"] = "1";
                            }
                            else
                            {
                                dtGoods.Rows[i]["CommissionType"] = "2";
                            }
                        }
                    }
                    if (!dtGoods.Rows[i].IsNull(11) && dtGoods.Rows[i]["CommissionNumber"].ToString() != "")
                    {
                        if (!decimal.TryParse(dtGoods.Rows[i]["CommissionNumber"].ToString(), out yzsz))
                        {
                            strError += "提成金额(比例)只能是数字,";
                            bolIndex  = true;
                        }
                        else if (decimal.Parse(dtGoods.Rows[i]["CommissionNumber"].ToString()) < 0m)
                        {
                            strError += "提成金额(比例)只能是大于0的数字,";
                            bolIndex  = true;
                        }
                    }
                    Chain.BLL.MemCustomField bllCustomField = new Chain.BLL.MemCustomField();
                    DataRow[] drCustomField = bllCustomField.GetList("  CustomType=2 ").Tables[0].Select();
                    DataRow[] array         = drCustomField;
                    for (int k = 0; k < array.Length; k++)
                    {
                        DataRow dr             = array[k];
                        string  strCustomField = dr["CustomField"].ToString();
                        string  strItem        = dtGoods.Rows[i][strCustomField].ToString();
                        if (!bool.Parse(dr["CustomFieldIsNull"].ToString()) && strItem == "")
                        {
                            strError = strError + dr["CustomFieldName"].ToString() + "不能为空,";
                            bolIndex = true;
                        }
                    }
                    if (bolIndex)
                    {
                        if (strError.Substring(strError.Length - 1, 1) == ",")
                        {
                            strError = strError.Remove(strError.Length - 1);
                        }
                        dtGoods.Rows[i]["Error"] = strError;
                        dtGoodsCopy.Rows.Add(dtGoods.Rows[i].ItemArray);
                    }
                    if (istable)
                    {
                        dtGoodsCopy = dtGoods;
                    }
                }
            }
            return(dtGoodsCopy);
        }
示例#7
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);
        }
示例#8
0
        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>");
        }