コード例 #1
0
    protected void setup6_Click(object sender, EventArgs e)
    {
        userinfo = (UserInfoUtil)SessionUtil.Session["UserInfo"];
        string suberrorstr = string.Empty;

        errorstr = string.Empty;
        int j     = 0; //定义错误列表序号
        int total = 0; //总错误记录

        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
        {
            //判断仓库是否存在
            bool flag = ProductInfoBus.ChargeStorage(ds.Tables[0].Rows[i]["主放仓库"].ToString().Trim(), userinfo.CompanyCD);
            if (!flag)
            {
                suberrorstr += (++j).ToString() + ": " + "第" + (i + 2).ToString() + "行中的仓库不存在,导入操作失败!<br>";
            }
        }

        if (j > 0)
        {
            total      += j;
            errorstr    = "<strong>数据存在校验错误列表(主放仓库)</strong><br>";
            errorstr   += suberrorstr;
            suberrorstr = string.Empty;
        }

        j = 0;
        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
        {
            string unitstr = ds.Tables[0].Rows[i]["单位"].ToString().Trim();
            if (unitstr.Length > 0)
            {
                bool flag = ProductInfoBus.ChargeCodeUnit(ds.Tables[0].Rows[i]["单位"].ToString().Trim(), userinfo.CompanyCD);
                if (!flag)
                {
                    suberrorstr += (++j).ToString() + ": " + "第" + (i + 2).ToString() + "行中的物品单位不存在,导入操作失败!<br>";
                }
            }
        }

        if (j > 0)
        {
            total      += j;
            errorstr   += "<strong>数据存在校验错误列表(物品单位)</strong><br>";
            errorstr   += suberrorstr;
            suberrorstr = string.Empty;
        }

        j = 0;
        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
        {
            string unitstr = ds.Tables[0].Rows[i]["物品分类"].ToString().Trim();
            if (unitstr.Length > 0)
            {
                bool flag = ProductInfoBus.ChargeCodeType(ds.Tables[0].Rows[i]["物品分类"].ToString().Trim(), userinfo.CompanyCD);
                if (!flag)
                {
                    suberrorstr += (++j).ToString() + ": " + "第" + (i + 2).ToString() + "行中的物品分类不存在,导入操作失败!<br>";
                }
            }
        }

        if (j > 0)
        {
            total      += j;
            errorstr   += "<strong>数据存在校验错误列表(物品分类)</strong><br>";
            errorstr   += suberrorstr;
            suberrorstr = string.Empty;
        }

        j = 0;


        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
        {
            string unitstr = ds.Tables[0].Rows[i]["条码"].ToString().Trim();
            if (unitstr.Length > 0)
            {
                bool flag = ProductInfoBus.ChargeBarCode(ds.Tables[0].Rows[i]["条码"].ToString().Trim(), userinfo.CompanyCD);
                if (flag)
                {
                    suberrorstr += (++j).ToString() + ": " + "第" + (i + 2).ToString() + "行中的条码已经存在,导入操作失败!<br>";
                }
            }
        }



        if (j > 0)
        {
            total      += j;
            errorstr   += "<strong>数据存在校验错误列表(物品分类)</strong><br>";
            errorstr   += suberrorstr;
            suberrorstr = string.Empty;
        }



        //验证颜色是否存在
        j = 0;
        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
        {
            string unitstr = ds.Tables[0].Rows[i]["颜色"].ToString().Trim();
            if (unitstr.Length > 0)
            {
                bool flag = ProductInfoBus.ValidateProductColor(ds.Tables[0].Rows[i]["颜色"].ToString().Trim(), userinfo.CompanyCD);
                if (!flag)
                {
                    suberrorstr += (++j).ToString() + ": " + "第" + (i + 2).ToString() + "行中的颜色在系统中不存在,导入操作失败!<br>";
                }
            }
        }


        if (j > 0)
        {
            total      += j;
            errorstr   += "<strong>数据存在校验错误列表(物品颜色)</strong><br>";
            errorstr   += suberrorstr;
            suberrorstr = string.Empty;
        }



        if ((total += j) > 0)
        {
            this.tr_result.Visible = true;
            if (Session["newfile"] != null)
            {
                ProductInfoBus.DeleteFile(userinfo.CompanyCD, Session["newfile"].ToString());
            }
            ProductInfoBus.LogInsert(userinfo.CompanyCD, userinfo.DeptID, userinfo.UserID, Request.QueryString["ModuleID"].ToString(), 0, 0, errorstr);
        }
        else
        {
            this.tr_result.Visible = false;
            this.setup5.Enabled    = false;
            this.setup6.Enabled    = false;
            lbl_end.Visible        = true;
            this.btn_input.Enabled = true;
        }
    }