コード例 #1
0
        private void GetMemList(string strSql)
        {
            Chain.BLL.Mem member = new Chain.BLL.Mem();
            int           Counts = this.NetPagerParameter.RecordCount;

            strSql += " and Mem.MemShopID = SysShop.ShopID and Mem.MemLevelID = MemLevel.LevelID and Mem.MemUserID = SysUser.UserID ";
            strSql += " and Mem.MemShopID =SysShopMemLevel.ShopID and SysShopMemLevel.MemLevelID=MemLevel.LevelID ";
            DataTable dtMem = member.GetListSP(this.NetPagerParameter.PageSize, this.NetPagerParameter.CurrentPageIndex, out Counts, new string[]
            {
                PubFunction.GetMemListShopAuthority(this._UserShopID, "MemShopID", strSql)
            }).Tables[0];

            this.NetPagerParameter.RecordCount    = Counts;
            this.NetPagerParameter.CustomInfoHTML = string.Format("<div class=\"results\"><span>当前第{0}/{1}页 共{2}条记录 每页{3}条</span></div>", new object[]
            {
                this.NetPagerParameter.CurrentPageIndex,
                this.NetPagerParameter.PageCount,
                this.NetPagerParameter.RecordCount,
                this.NetPagerParameter.PageSize
            });
            this.gvMemList.DataSource = dtMem;
            this.gvMemList.DataBind();
            PageBase.BindSerialRepeater(this.gvMemList, this.NetPagerParameter.PageSize * (this.NetPagerParameter.CurrentPageIndex - 1));
            Chain.BLL.MemCustomField          bllCustom = new Chain.BLL.MemCustomField();
            List <Chain.Model.MemCustomField> fieldlist = bllCustom.GetModelList("CustomType=1 and CustomFieldIsShow=1");

            if (fieldlist.Count > 0)
            {
                StringBuilder strHeader = new StringBuilder();
                StringBuilder strHtml   = new StringBuilder();
                for (int i = 0; i < this.gvMemList.Items.Count; i++)
                {
                    Literal   ltlMemID = (Literal)this.gvMemList.Items[i].FindControl("ltlMemID");
                    Literal   ltlHtml  = (Literal)this.gvMemList.Items[i].FindControl("ltlHtml");
                    int       MemID    = Convert.ToInt32(ltlMemID.Text);
                    DataRow[] drMem    = dtMem.Select(string.Format(" MemID = {0}", MemID));
                    strHtml.Length = 0;
                    foreach (Chain.Model.MemCustomField mdCustomField in fieldlist)
                    {
                        if (i == 0)
                        {
                            strHeader.AppendFormat("<th>{0}</th>", mdCustomField.CustomFieldName);
                        }
                        strHtml.AppendFormat("<td>{0}</td>", drMem[0][mdCustomField.CustomField]);
                    }
                    ltlHtml.Text = strHtml.ToString();
                }
                this.ltlHeader.Text = strHeader.ToString();
            }
        }
コード例 #2
0
        private void GetGoodsList(string strSql)
        {
            Chain.BLL.Goods bllGoods = new Chain.BLL.Goods();
            int             Counts   = this.NetPagerParameter.RecordCount;

            strSql = strSql + " and Goods.GoodsClassID = GoodsClass.ClassID and Goods.GoodsID = GoodsNumber.GoodsID and GoodsNumber.ShopID=" + this.sltShop.Value;
            DataTable dtGoods = bllGoods.GetListSP(this.NetPagerParameter.PageSize, this.NetPagerParameter.CurrentPageIndex, out Counts, new string[]
            {
                strSql
            }).Tables[0];

            this.NetPagerParameter.RecordCount    = Counts;
            this.NetPagerParameter.CustomInfoHTML = string.Format("<div class=\"results\"><span>当前第{0}/{1}页 共{2}条记录 每页{3}条</span></div>", new object[]
            {
                this.NetPagerParameter.CurrentPageIndex,
                this.NetPagerParameter.PageCount,
                this.NetPagerParameter.RecordCount,
                this.NetPagerParameter.PageSize
            });
            this.gvGoodsList.DataSource = dtGoods;
            this.gvGoodsList.DataBind();
            PageBase.BindSerialRepeater(this.gvGoodsList, this.NetPagerParameter.PageSize * (this.NetPagerParameter.CurrentPageIndex - 1));
            Chain.BLL.MemCustomField          bllCustom = new Chain.BLL.MemCustomField();
            List <Chain.Model.MemCustomField> fieldlist = bllCustom.GetModelList("CustomType=2 and CustomFieldIsShow=1");

            if (fieldlist.Count > 0)
            {
                StringBuilder strHeader = new StringBuilder();
                StringBuilder strHtml   = new StringBuilder();
                for (int i = 0; i < this.gvGoodsList.Items.Count; i++)
                {
                    Literal   ltlGoodsID = (Literal)this.gvGoodsList.Items[i].FindControl("ltlGoodsID");
                    Literal   ltlHtml    = (Literal)this.gvGoodsList.Items[i].FindControl("ltlHtml");
                    int       GoodsID    = Convert.ToInt32(ltlGoodsID.Text);
                    DataRow[] drGoods    = dtGoods.Select(string.Format(" GoodsID = {0}", GoodsID));
                    strHtml.Length = 0;
                    foreach (Chain.Model.MemCustomField mdCustomField in fieldlist)
                    {
                        if (i == 0)
                        {
                            strHeader.AppendFormat("<th>{0}</th>", mdCustomField.CustomFieldName);
                        }
                        strHtml.AppendFormat("<td>{0}</td>", drGoods[0][mdCustomField.CustomField]);
                    }
                    ltlHtml.Text = strHtml.ToString();
                }
                this.ltlHeader.Text = strHeader.ToString();
            }
        }
コード例 #3
0
 private void Get_ParameterList(DataTable dtMem)
 {
     try
     {
         Chain.BLL.MemCustomField          bllCustom = new Chain.BLL.MemCustomField();
         List <Chain.Model.MemCustomField> fieldlist = bllCustom.GetModelList("  CustomType=1  ");
         this.GetCustomFields(fieldlist);
         this.gvErrorMem.DataSource = dtMem;
         this.gvErrorMem.DataBind();
     }
     catch
     {
         base.OutputWarn("Excel表中数据格式有严重错误,请改正数据再验证。");
     }
 }
コード例 #4
0
 private void Get_ParameterList(DataTable dtGoods)
 {
     try
     {
         Chain.BLL.MemCustomField          bllCustom = new Chain.BLL.MemCustomField();
         List <Chain.Model.MemCustomField> fieldlist = bllCustom.GetModelList(" CustomType=2 ");
         this.GetCustomFields(fieldlist);
         if (this.GridView1.Visible)
         {
             this.GridView1.DataSource = dtGoods;
             this.GridView1.DataBind();
         }
         else
         {
             this.gvErrorGoods.DataSource = dtGoods;
             this.gvErrorGoods.DataBind();
         }
     }
     catch
     {
         base.OutputWarn("Excel表中数据格式有严重错误,请改正数据再验证。");
     }
 }
コード例 #5
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);
        }
コード例 #6
0
        private DataTable CheckData(DataTable dtMem)
        {
            DataTable dtMemCopy = dtMem.Copy();

            dtMemCopy.Clear();
            if (dtMem.Rows.Count <= 0)
            {
                File.Delete(this.strSavePath);
                base.OutputWarn("检验的Excel表格还没有会员数据,请填写会员数据再检验。");
            }
            else
            {
                for (int i = 0; i < dtMem.Rows.Count; i++)
                {
                    bool   bolIndex = false;
                    string strError = "";
                    if (dtMem.Rows[i].IsNull(0) || dtMem.Rows[i]["MemCard"].ToString() == "")
                    {
                        strError += "会员卡号不能为空,";
                        bolIndex  = true;
                    }
                    if (dtMem.Rows[i]["MemCard"].ToString().Length < 4 || dtMem.Rows[i]["MemCard"].ToString().Length > 20)
                    {
                        strError += "会员卡号长度为3~20位,";
                        bolIndex  = true;
                    }
                    if (!dtMem.Rows[i].IsNull("MemCardNumber") && dtMem.Rows[i]["MemCardNumber"].ToString() != "" && (dtMem.Rows[i]["MemCardNumber"].ToString().Length < 4 || dtMem.Rows[i]["MemCardNumber"].ToString().Length > 20))
                    {
                        strError += "卡面号码长度为3~20位,";
                        bolIndex  = true;
                    }
                    Chain.BLL.Mem bllMem = new Chain.BLL.Mem();
                    int           exists = bllMem.Exists(0, dtMem.Rows[i][0].ToString(), dtMem.Rows[i][4].ToString(), dtMem.Rows[i][16].ToString());
                    int           num    = exists;
                    if (num != -6)
                    {
                        switch (num)
                        {
                        case -2:
                            strError += "手机号码已存在系统,";
                            bolIndex  = true;
                            break;

                        case -1:
                            strError += "卡号已存在系统,";
                            bolIndex  = true;
                            break;
                        }
                    }
                    else
                    {
                        strError += "卡面号码已存在系统,";
                        bolIndex  = true;
                    }
                    bool bolCardIndex     = false;
                    bool bolMobileIndex   = false;
                    bool bolMemCardNumber = false;
                    for (int j = 0; j < i; j++)
                    {
                        if (dtMem.Rows[j][0].ToString() == dtMem.Rows[i][0].ToString())
                        {
                            bolCardIndex = true;
                        }
                        if (dtMem.Rows[j][4].ToString() == dtMem.Rows[i][4].ToString() && dtMem.Rows[i][4].ToString() != "")
                        {
                            bolMobileIndex = true;
                        }
                        if (dtMem.Rows[j][16].ToString() == dtMem.Rows[i][16].ToString() && dtMem.Rows[i][16].ToString() != "")
                        {
                            bolMemCardNumber = true;
                        }
                    }
                    if (bolCardIndex)
                    {
                        strError += "卡号在Excel表重复出现,";
                        bolIndex  = true;
                    }
                    if (bolMobileIndex)
                    {
                        strError += "手机号码在Excel表重复出现,";
                        bolIndex  = true;
                    }
                    if (bolMemCardNumber)
                    {
                        strError += "卡面号码在Excel表重复出现,";
                        bolIndex  = true;
                    }
                    if (dtMem.Rows[i].IsNull(2) || dtMem.Rows[i][2].ToString() == "")
                    {
                        strError += "性别不能为空,";
                        bolIndex  = true;
                    }
                    else if (dtMem.Rows[i][2].ToString() != "男" && dtMem.Rows[i][2].ToString() != "女")
                    {
                        strError += "性别的格式不正确,";
                        bolIndex  = true;
                    }
                    if (dtMem.Rows[i][3].ToString() != "")
                    {
                        Regex regex = new Regex("(\\d{15}$|^\\d{18}$|^\\d{17}(\\d|X|x))");
                        if (!regex.IsMatch(dtMem.Rows[i][3].ToString()))
                        {
                            strError += "身份证的格式不正确,";
                            bolIndex  = true;
                        }
                    }
                    try
                    {
                        if (dtMem.Rows[i][6].ToString() == "未设置")
                        {
                            dtMem.Rows[i][6] = "1900-01-01";
                        }
                        if (dtMem.Rows[i][6].ToString() != "")
                        {
                            DateTime.Parse(dtMem.Rows[i][6].ToString());
                        }
                    }
                    catch
                    {
                        strError += "生日的格式不正确,";
                        bolIndex  = true;
                    }
                    if (dtMem.Rows[i].IsNull(7) || dtMem.Rows[i][7].ToString() == "")
                    {
                        strError += "积分不能为空,";
                        bolIndex  = true;
                    }
                    if (dtMem.Rows[i].IsNull(8) || dtMem.Rows[i][8].ToString() == "")
                    {
                        strError += "余额不能为空,";
                        bolIndex  = true;
                    }
                    if (dtMem.Rows[i].IsNull(9) || dtMem.Rows[i][9].ToString() == "")
                    {
                        strError += "历史消费金额不能为空,";
                        bolIndex  = true;
                    }
                    else
                    {
                        try
                        {
                            Convert.ToDecimal(dtMem.Rows[i][9].ToString());
                        }
                        catch
                        {
                            strError += "历史消费金额的格式不正确,";
                            bolIndex  = true;
                        }
                    }
                    if (dtMem.Rows[i].IsNull(12) || dtMem.Rows[i][12].ToString() == "")
                    {
                        strError += "会员等级不能为空,";
                        bolIndex  = true;
                    }
                    if (dtMem.Rows[i].IsNull(13) || dtMem.Rows[i][13].ToString() == "")
                    {
                        strError += "开卡商家不能为空,";
                        bolIndex  = true;
                    }
                    else if (dtMem.Rows[i][13].ToString().Trim() == "0")
                    {
                        strError += "开卡商家输入有误,";
                        bolIndex  = true;
                    }
                    if (dtMem.Rows[i].IsNull(14) || dtMem.Rows[i][14].ToString() == "")
                    {
                        strError += "办卡日期不能为空,";
                        bolIndex  = true;
                    }
                    else
                    {
                        try
                        {
                            DateTime dtime = DateTime.Parse(dtMem.Rows[i][14].ToString());
                            dtMem.Rows[i][14] = dtime.ToShortDateString();
                        }
                        catch
                        {
                            strError += "办卡时期的格式不正确,";
                            bolIndex  = true;
                        }
                    }
                    Chain.BLL.MemCustomField bllCustomField = new Chain.BLL.MemCustomField();
                    DataRow[] drCustomField = bllCustomField.GetList(" CustomType=1 ").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        = dtMem.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);
                        }
                        dtMem.Rows[i]["Error"] = strError;
                        dtMemCopy.Rows.Add(dtMem.Rows[i].ItemArray);
                    }
                }
            }
            return(dtMemCopy);
        }