Пример #1
0
    private void BindGrid()
    {
        int month        = int.Parse(ddl_Month.SelectedValue);
        int organizecity = int.Parse(tr_OrganizeCity.SelectValue);
        int state        = int.Parse(ddl_State.SelectedValue);
        int RTChannel    = int.Parse(ddl_RTChannel.SelectedValue);
        int RTType       = int.Parse(ddl_RTType.SelectedValue);

        string condition = "";

        if (tbx_ApplyCost.Text != "0")
        {
            condition = "TotalApplyCost" + ddl_OP.SelectedValue + tbx_ApplyCost.Text;
        }

        if (txt_FeeRate.Text != "0")
        {
            if (condition != "")
            {
                condition += " AND ";
            }
            condition += "CONVERT(DECIMAL(10,3),REPLACE(ApplyCostRate,'%',''))" + ddl_FeeRateOP.SelectedValue + txt_FeeRate.Text;
        }
        DataTable dtSummary = FNA_FeeApplyBLL.GetRTChannelFLFee
                                  (month, organizecity, state, int.Parse(Session["UserID"].ToString()), RTChannel, condition, RTType);

        if (dtSummary.Rows.Count == 0)
        {
            gv_List.DataBind();
            return;
        }

        #region 求行小计
        MatrixTable.TableAddRowSubTotal(dtSummary, new string[] { "区域信息→大区", "区域信息→营业部", "区域信息→办事处", "零售店基本情况→费用代垫客户" },
                                        new string[] { "卖场销售额→上月", "卖场销售额→本月", "费用情况→总费用", "费用情况→我司费用", "费用情况→经销商费用" }, true);
        //计算小计行费率
        foreach (DataRow dr in dtSummary.Rows)
        {
            if (dr[0].ToString() == "总计" ||
                dr[1].ToString() == "小计" ||
                dr[2].ToString() == "小计" ||
                dr[3].ToString() == "小计" ||
                dr[4].ToString() == "小计")
            {
                dr["费用情况→我司费率"]  = (decimal)dr["卖场销售额→本月"] == 0 ? "100%" : ((decimal)dr["费用情况→我司费用"] / (decimal)dr["卖场销售额→本月"]).ToString("0.#%");
                dr["费用情况→经销商费率"] = (decimal)dr["卖场销售额→本月"] == 0 ? "100%" : ((decimal)dr["费用情况→经销商费用"] / (decimal)dr["卖场销售额→本月"]).ToString("0.#%");
            }
        }
        #endregion

        gv_List.DataSource = dtSummary;
        gv_List.DataBind();

        if (dtSummary.Columns.Count >= 24)
        {
            gv_List.Width = new Unit(dtSummary.Columns.Count * 60);
        }
        else
        {
            gv_List.Width = new Unit(100, UnitType.Percentage);
        }

        MatrixTable.GridViewMatric(gv_List);

        for (int i = 0; i < 4; i++)
        {
            MatrixTable.GridViewMergSampeValueRow(gv_List, i);
        }

        if (Right_Assign_BLL.GetAccessRight(Session["UserName"].ToString(), 1510, "BatApproveFee"))
        {
            bt_Approve.Visible            = (ddl_State.SelectedValue == "1");
            bt_UnApprove.Visible          = (ddl_State.SelectedValue == "1");
            bt_ExcludeApplyDetail.Visible = (ddl_State.SelectedValue == "1");

            if (state == 1 && condition == "" && RTChannel == 0 && RTType == 0)
            {
                bt_Approve.Enabled   = true;
                bt_UnApprove.Enabled = true;

                #region 判断能否审批

                if (ddl_State.SelectedValue == "1")
                {
                    Org_StaffBLL _staff = new Org_StaffBLL((int)Session["UserID"]);
                    DataTable    dt     = _staff.GetLowerPositionTask(2, int.Parse(tr_OrganizeCity.SelectValue), month);

                    if (AC_AccountMonthBLL.GetCurrentMonth() - 1 <= int.Parse(ddl_Month.SelectedValue))
                    {
                        string[] allowdays1 = Addr_OrganizeCityParamBLL.GetValueByType(1, 5).Replace(" ", "").Split(new char[] { ',', ',', ';', ';' });
                        string[] allowdays2 = Addr_OrganizeCityParamBLL.GetValueByType(1, 6).Replace(" ", "").Split(new char[] { ',', ',', ';', ';' });
                        string   date       = DateTime.Now.Day.ToString();
                        if (allowdays1.Contains(date))
                        {
                            bt_Approve.Enabled = false;
                        }
                        else if (allowdays2.Contains(date))
                        {
                            DataTable dt2 = new DataTable();
                            if (_staff.Model.Position == 210)
                            {
                                dt2 = _staff.GetFillProcessDetail(2);
                            }
                            if (dt2.Rows.Count > 0)
                            {
                                bt_Approve.Enabled = false;
                            }
                        }
                        else
                        {
                            bt_UnApprove.Enabled = false;
                        }
                    }
                    else
                    {
                        bt_UnApprove.Enabled = false;
                    }

                    if (dt.Rows.Count > 0)
                    {
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "message", "<script language='javascript'>var tempid = Math.random() * 10000; \r\n window.showModalDialog('" + Page.ResolveClientUrl("~/SubModule/Pop_ShowLowerPositionTask.aspx") +
                                                                "?Type=2&StaffID=0&Month=" + ddl_Month.SelectedValue + "&City=" + tr_OrganizeCity.SelectValue + "&tempid='+tempid, window, 'dialogWidth:520px;DialogHeight=600px;status:yes;resizable=no');</script>", false);
                        bt_Approve.Enabled = false;
                    }
                }
                #endregion
            }
            else
            {
                bt_Approve.Enabled   = false;
                bt_UnApprove.Enabled = false;
            }
        }
        else
        {
            bt_Approve.Visible            = false;
            bt_UnApprove.Visible          = false;
            bt_ExcludeApplyDetail.Visible = false;
        }
    }
Пример #2
0
    private void BindGrid()
    {
        int month        = int.Parse(ddl_Month.SelectedValue);
        int organizecity = int.Parse(tr_OrganizeCity.SelectValue);
        int state        = int.Parse(ddl_State.SelectedValue);
        int RTChannel    = int.Parse(ddl_RTChannel.SelectedValue);
        int RTType       = int.Parse(ddl_RTType.SelectedValue);

        string condition = "";

        if (!(ddl_OP.SelectedValue == ">" && tbx_ApplyCost.Text == "0"))
        {
            condition = "TotalApplyCost" + ddl_OP.SelectedValue + tbx_ApplyCost.Text;
        }

        if (txt_FeeRate.Text != "0")
        {
            if (condition != "")
            {
                condition += " AND ";
            }
            condition += "CONVERT(DECIMAL(10,3),REPLACE(ApplyCostRate,'%',''))" + ddl_FeeRateOP.SelectedValue + txt_FeeRate.Text;
        }

        if (ddl_Flag.SelectedValue != "0")
        {
            if (condition != "")
            {
                condition += " AND ";
            }
            if (ddl_Flag.SelectedValue == "1")
            {
                condition += "发生月='" + ddl_Month.SelectedItem.Text + "'";
            }
            else
            {
                condition += "发生月<>'" + ddl_Month.SelectedItem.Text + "'";
            }
        }
        #region 获取科目过滤条件
        string ATSuppierIDs = "";
        if (ddl_AccountTitle.SelectedValue == "34")
        {
            ATSuppierIDs = "176";
        }
        else if (ddl_AccountTitle.SelectedValue == "33")
        {
            ATSuppierIDs = "73";
        }
        else if (ddl_AccountTitle.SelectedValue != "0")
        {
            ATSuppierIDs = ddl_AccountTitle.SelectedValue;
        }
        #endregion

        DataTable dtSummary = FNA_FeeApplyBLL.GetRTChannelDiaplayFee
                                  (month, organizecity, state, int.Parse(Session["UserID"].ToString()), RTChannel, condition, RTType, ATSuppierIDs);
        if (dtSummary.Rows.Count == 0)
        {
            gv_List.DataBind();
            return;
        }

        #region 求行小计
        MatrixTable.TableAddRowSubTotal(dtSummary, new string[] { "区域信息→大区", "区域信息→营业部", "区域信息→办事处", "零售店基本情况→费用代垫客户" },
                                        new string[] { "陈列费用明细信息→我司费用", "陈列费用明细信息→经销商费用" }, true);
        //计算小计行费率
        //foreach (DataRow dr in dtSummary.Rows)
        //{
        //    if (dr[0].ToString() == "总计" ||
        //        dr[1].ToString() == "小计" ||
        //        dr[2].ToString() == "小计" ||
        //        dr[3].ToString() == "小计" ||
        //        dr[4].ToString() == "小计")
        //    {
        //        dr["陈列费用合计→我司费率"] = (decimal)dr["卖场销量合计→本月预估"] == 0 ? "100%" : ((decimal)dr["陈列费用明细信息→我司费用"] / (decimal)dr["卖场销量合计→本月预估"]).ToString("0.#%");
        //        dr["陈列费用合计→经销商费率"] = (decimal)dr["卖场销量合计→本月预估"] == 0 ? "100%" : ((decimal)dr["陈列费用明细信息→经销商费用"] / (decimal)dr["卖场销量合计→本月预估"]).ToString("0.#%");
        //    }
        //}
        #endregion

        gv_List.DataSource = dtSummary;
        gv_List.DataBind();

        if (dtSummary.Columns.Count >= 24)
        {
            gv_List.Width = new Unit(dtSummary.Columns.Count * 50);
        }
        else
        {
            gv_List.Width = new Unit(100, UnitType.Percentage);
        }

        ViewState["condition"]    = condition;
        ViewState["ATSuppierIDs"] = ATSuppierIDs;
        MatrixTable.GridViewMatric(gv_List);

        for (int i = 0; i < 19; i++)
        {
            MatrixTable.GridViewMergSampeValueRow(gv_List, i);
        }

        if (Right_Assign_BLL.GetAccessRight(Session["UserName"].ToString(), 1509, "BatApproveFee"))
        {
            bt_Approve.Visible            = (ddl_State.SelectedValue == "1");
            bt_UnApprove.Visible          = (ddl_State.SelectedValue == "1");
            bt_ExcludeApplyDetail.Visible = (ddl_State.SelectedValue == "1");

            if (state == 1 && condition == "" && RTChannel == 0 && RTType == 0 && ATSuppierIDs == "")
            {
                bt_Approve.Enabled   = true;
                bt_UnApprove.Enabled = true;

                #region 判断费用申请进度

                if (ddl_State.SelectedValue == "1")
                {
                    Org_StaffBLL _staff = new Org_StaffBLL((int)Session["UserID"]);
                    DataTable    dt     = _staff.GetLowerPositionTask(1, int.Parse(tr_OrganizeCity.SelectValue), month);
                    if (dt.Rows.Count > 0)
                    {
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "message", "<script language='javascript'>var tempid = Math.random() * 10000; \r\n window.showModalDialog('" + Page.ResolveClientUrl("~/SubModule/Pop_ShowLowerPositionTask.aspx") +
                                                                "?Type=1&StaffID=0&Month=" + ddl_Month.SelectedValue + "&City=" + tr_OrganizeCity.SelectValue + "&tempid='+tempid, window, 'dialogWidth:520px;DialogHeight=600px;status:yes;resizable=no');</script>", false);
                        bt_Approve.Enabled = false;
                        //bt_UnApprove.Enabled = false;
                    }
                }

                #endregion
            }
            else
            {
                bt_Approve.Enabled   = false;
                bt_UnApprove.Enabled = false;
            }
        }
        else
        {
            bt_Approve.Visible            = false;
            bt_UnApprove.Visible          = false;
            bt_ExcludeApplyDetail.Visible = false;
        }
    }