Пример #1
0
    private void BindFillDataProgress(bool nocache)
    {
        int staff = (int)Session["UserID"];

        if (!string.IsNullOrEmpty(select_FillDataStaff.SelectValue))
        {
            int.TryParse(select_FillDataStaff.SelectValue, out staff);
        }

        DataTable dt = Org_StaffBLL.GetFillDataProgress(staff, nocache);

        gv_FillDataProgress.DataSource = dt;
        gv_FillDataProgress.BindGrid();
    }
    private void BindGrid()
    {
        int month        = int.Parse(ddl_Month.SelectedValue);
        int organizecity = int.Parse(tr_OrganizeCity.SelectValue);
        int level        = int.Parse(ddl_Level.SelectedValue);
        int state        = int.Parse(ddl_State.SelectedValue);
        int iscxp        = int.Parse(ddl_IsCXP.SelectedValue);

        if (new Addr_OrganizeCityBLL(organizecity).Model.Level >= 2 &&
            month == AC_AccountMonthBLL.GetMonthByDate(DateTime.Today.AddDays(-10)))
        {
            if ((int)ViewState["ClientType"] == 3)
            {
                DataTable dtFillDataProgress = Org_StaffBLL.GetFillDataProgress((int)Session["UserID"], true);
                DataRow[] rows;
                if (iscxp == 1)
                {
                    rows = dtFillDataProgress.Select("ItemCode='013'");
                }
                else
                {
                    rows = dtFillDataProgress.Select("ItemCode='007'");
                }

                if (rows.Length > 0)
                {
                    int ItemTargetCount   = (int)rows[0]["ItemTargetCount"];
                    int ItemCompleteCount = (int)rows[0]["ItemCompleteCount"];
                    if (ItemTargetCount > ItemCompleteCount)
                    {
                        MessageBox.Show(this, "对不起,还有" + (ItemTargetCount - ItemCompleteCount).ToString() +
                                        "家门店库存尚未录入,无法提交或审核!具体请查看桌面填报进度表.");
                        bt_Approve.Enabled = false;
                        bt_Submit.Enabled  = false;
                    }
                }
            }
        }

        if (MCSTabControl1.SelectedIndex == 0)
        {
            DataTable dt_summary = SVM_InventoryBLL.GetSummaryTotal(organizecity, month, (int)ViewState["ClientType"], level, state, iscxp, (int)Session["UserID"]);
            dt_summary = MatrixTable.Matrix(dt_summary, new string[] { "管理片区名称" }, new string[] { "品牌", "段位" }, "金额", true, true);

            gv_Summary.DataSource = dt_summary;
            gv_Summary.DataBind();
            MatrixTable.GridViewMatric(gv_Summary);
            if (dt_summary.Columns.Count >= 24)
            {
                gv_Summary.Width = new Unit(dt_summary.Columns.Count * 60);
            }
            else
            {
                gv_Summary.Width = new Unit(100, UnitType.Percentage);
            }
        }
        else
        {
            string condition = " 1=1 ";

            #region 组织查询条件
            //管理片区及所有下属管理片区
            if (tr_OrganizeCity.SelectValue != "1")
            {
                Addr_OrganizeCityBLL orgcity = new Addr_OrganizeCityBLL(int.Parse(tr_OrganizeCity.SelectValue));
                string orgcitys = orgcity.GetAllChildNodeIDs();
                if (orgcitys != "")
                {
                    orgcitys += ",";
                }
                orgcitys += tr_OrganizeCity.SelectValue;
                if (CM_ClientBLL.GetModelList("OrganizeCity IN (" + orgcitys + ") AND ActiveFlag=1 AND CM_Client.ClientType=" + ViewState["ClientType"].ToString()).Count != 0)
                {
                    condition += " AND SVM_Inventory.OrganizeCity IN (" + orgcitys + ")";
                }
                else
                {
                    condition += " AND CM_Client.ClientManager=" + Session["UserID"].ToString();
                }
            }


            condition += " AND MCS_SYS.dbo.UF_Spilt2('MCS_SVM.dbo.SVM_Inventory',SVM_Inventory.ExtPropertys,'IsCXP')=" + ddl_IsCXP.SelectedValue;

            //会计月条件
            condition += " AND SVM_Inventory.AccountMonth =" + ddl_Month.SelectedValue;

            condition += " AND CM_Client.ClientType=" + ViewState["ClientType"].ToString();
            switch (ddl_State.SelectedValue)
            {
            case "1":
                condition += "  AND SVM_Inventory.ApproveFlag=2 AND  MCS_SYS.dbo.UF_Spilt2('MCS_SVM.dbo.SVM_Inventory',SVM_Inventory.ExtPropertys,'SubmitFlag')='2'";
                break;

            case "2":
                condition += "  AND SVM_Inventory.ApproveFlag=2 AND  MCS_SYS.dbo.UF_Spilt2('MCS_SVM.dbo.SVM_Inventory',SVM_Inventory.ExtPropertys,'SubmitFlag')='1'";
                break;

            case "3":
                condition += " AND SVM_Inventory.ApproveFlag=1";
                break;
            }
            #endregion

            gv_List.ConditionString = condition;
            gv_List.BindGrid();
        }
    }
    private void BindGrid()
    {
        int month        = int.Parse(ddl_Month.SelectedValue);
        int organizecity = int.Parse(tr_OrganizeCity.SelectValue);
        int level        = int.Parse(ddl_Level.SelectedValue);
        int state        = int.Parse(ddl_State.SelectedValue);
        int flag         = int.Parse(ddl_Flag.SelectedValue);

        #region 判断是否可以审批通过
        string[] allowdays = Addr_OrganizeCityParamBLL.GetValueByType(1, 7).Replace(" ", "").Split(new char[] { ',', ',', ';', ';' });
        string   date      = DateTime.Now.Day.ToString();
        if (allowdays.Contains(date))
        {
            bt_Approve.Enabled = false;
            bt_Approve.ToolTip = "每月21-25号不可对进销存审批通过!";
        }
        #endregion

        if (new Addr_OrganizeCityBLL(organizecity).Model.Level >= 2 &&
            month == AC_AccountMonthBLL.GetMonthByDate(DateTime.Today.AddDays(-10)))
        {
            if ((int)ViewState["ClientType"] == 3 && (int)ViewState["Type"] == 2)
            {
                DataTable dtFillDataProgress = Org_StaffBLL.GetFillDataProgress((int)Session["UserID"], true);
                DataRow[] rows;
                if (flag == 1)
                {
                    rows = dtFillDataProgress.Select("ItemCode='006'");
                }
                else
                {
                    rows = dtFillDataProgress.Select("ItemCode='012'");
                }

                if (rows.Length > 0)
                {
                    int ItemTargetCount   = (int)rows[0]["ItemTargetCount"];
                    int ItemCompleteCount = (int)rows[0]["ItemCompleteCount"];
                    if (ItemTargetCount > ItemCompleteCount)
                    {
                        MessageBox.Show(this, "对不起,还有" + (ItemTargetCount - ItemCompleteCount).ToString() +
                                        "家门店销量尚未录入,无法提交或审核!具体请查看桌面填报进度表.");
                        bt_Approve.Enabled = false;
                        bt_Submit.Enabled  = false;
                    }
                }
            }
        }

        if (MCSTabControl1.SelectedIndex == 0)
        {
            DataTable dt_summary = SVM_SalesVolumeBLL.GetSummaryTotal(organizecity, month, (int)ViewState["ClientType"], flag, level, state, (int)ViewState["Type"], (int)Session["UserID"]);
            dt_summary            = MatrixTable.Matrix(dt_summary, new string[] { "管理片区名称" }, new string[] { "品牌", "段位" }, "金额", true, true);
            gv_Summary.DataSource = dt_summary;
            gv_Summary.DataBind();
            MatrixTable.GridViewMatric(gv_Summary);
            if (dt_summary.Columns.Count >= 24)
            {
                gv_Summary.Width = new Unit(dt_summary.Columns.Count * 60);
            }
            else
            {
                gv_Summary.Width = new Unit(100, UnitType.Percentage);
            }
        }
        else if (MCSTabControl1.SelectedIndex == 1)
        {
            if (organizecity == 1 || new Addr_OrganizeCityBLL(organizecity).Model.Level < 2)
            {
                MessageBox.Show(this, "按客户及SKU查询时,不能按总部及大区级别查询!");
                return;
            }
            DataTable dt_summary = SVM_SalesVolumeBLL.GetSummaryTotal2(organizecity, month, (int)ViewState["ClientType"], flag, state, (int)ViewState["Type"], (int)Session["UserID"]);
            dt_summary            = MatrixTable.Matrix(dt_summary, new string[] { "管理片区名称", "客户名称", "责任业代" }, new string[] { "品牌", "产品名称" }, "数量", true, true);
            gv_Summary.DataSource = dt_summary;
            gv_Summary.DataBind();
            MatrixTable.GridViewMatric(gv_Summary);
            if (dt_summary.Columns.Count >= 24)
            {
                gv_Summary.Width = new Unit(dt_summary.Columns.Count * 60);
            }
            else
            {
                gv_Summary.Width = new Unit(100, UnitType.Percentage);
            }
        }
        else
        {
            string            condition = " SVM_SalesVolume.AccountMonth=" + ddl_Month.SelectedValue;
            IList <CM_Client> cmlist    = new List <CM_Client>();
            if (organizecity > 1)
            {
                Addr_OrganizeCityBLL orgcity = new Addr_OrganizeCityBLL(organizecity);
                string orgcitys = orgcity.GetAllChildNodeIDs();
                if (orgcitys != "")
                {
                    orgcitys += ",";
                }
                orgcitys += tr_OrganizeCity.SelectValue;
                cmlist    = CM_ClientBLL.GetModelList("OrganizeCity IN (" + orgcitys + ") AND ActiveFlag=1 AND CM_Client.ClientType=" + ViewState["ClientType"].ToString());

                if (CM_ClientBLL.GetModelList("OrganizeCity IN (" + orgcitys + ") AND ActiveFlag=1 AND CM_Client.ClientType=" + ViewState["ClientType"].ToString()).Count != 0)
                {
                    condition += " AND SVM_SalesVolume.OrganizeCity IN (" + orgcitys + ")";
                }
            }

            condition += ddl_Flag.SelectedValue == "1" ? " AND SVM_SalesVolume.Flag<6" : " AND SVM_SalesVolume.Flag>6";

            AC_AccountMonthBLL _monthbll = new AC_AccountMonthBLL(month);

            if (ViewState["ClientType"] != null)
            {
                switch ((int)ViewState["ClientType"])
                {
                case 2:
                    if ((int)ViewState["Type"] == 1)
                    {
                        condition += " AND SVM_SalesVolume.Client IN( Select ID FROM MCS_CM.dbo.CM_Client Where ClientType=2 AND  MCS_SYS.dbo.UF_Spilt2('MCS_CM.dbo.CM_Client',CM_Client.ExtPropertys,'DIClassify')='2'";
                    }
                    else
                    {
                        condition += " AND SVM_SalesVolume.Supplier IN( Select ID FROM MCS_CM.dbo.CM_Client Where ClientType=2";
                    }
                    break;

                case 3:
                    condition += (int)ViewState["Type"] == 1 ? " AND SVM_SalesVolume.Client IN" : " AND SVM_SalesVolume.Supplier IN";
                    condition += "( Select ID FROM MCS_CM.dbo.CM_Client Where ClientType=3 ";
                    break;
                }
                if (cmlist.Count == 0)
                {
                    condition += " AND CM_Client.ClientManager=" + Session["UserID"].ToString();
                }
                condition += " AND ApproveFlag=1 AND OpenTime<='" + _monthbll.Model.EndDate + "'AND ISNULL(CloseTime,GETDATE())>='" + _monthbll.Model.BeginDate + "')";
            }
            switch (ddl_State.SelectedValue)
            {
            case "1":
                condition += "AND SVM_SalesVolume.ApproveFlag=2 AND  MCS_SYS.dbo.UF_Spilt2('MCS_SVM.dbo.SVM_SalesVolume',SVM_SalesVolume.ExtPropertys,'SubmitFlag')='2'";
                break;

            case "2":
                condition += "AND SVM_SalesVolume.ApproveFlag=2 AND  MCS_SYS.dbo.UF_Spilt2('MCS_SVM.dbo.SVM_SalesVolume',SVM_SalesVolume.ExtPropertys,'SubmitFlag')='1'";
                break;

            case "3":
                condition += " AND SVM_SalesVolume.ApproveFlag=1";
                break;
            }
            gv_List.ConditionString = condition;
            gv_List.BindGrid();
        }
    }