protected void bt_Delete_Click(object sender, EventArgs e)
    {
        string selectids = "";

        foreach (GridViewRow item in gv_List.Rows)
        {
            if (((CheckBox)item.FindControl("cb_Select")).Checked == true)
            {
                selectids += gv_List.DataKeys[item.RowIndex].Value.ToString() + ",";
                int id = int.Parse(gv_List.DataKeys[item.RowIndex].Value.ToString());
                CSO_OfferBalanceBLL bll = new CSO_OfferBalanceBLL(id);
                if (bll.Model.State == 1 && bll.Model.ApproveFlag == 2)
                {
                    bll.Delete();
                }
            }
        }
        if (string.IsNullOrEmpty(selectids))
        {
            MessageBox.Show(this, "请选择要删除的费用单!");
            return;
        }
        MessageBox.Show(this, "删除成功!");
        BindGrid();
    }
Example #2
0
    protected void bt_Save_Click(object sender, EventArgs e)
    {
        CSO_OfferBalance_Detail detail = new CSO_OfferBalanceBLL().GetDetailModel((int)ViewState["ID"]);

        if (detail == null)
        {
            MessageBox.ShowAndClose(this, "参数错误!");
            return;
        }

        detail.AwardFee        = 0 - decimal.Parse(tbx_AdjustFee.Text);
        detail.PayFee          = detail.ActualFee + detail.AwardFee;
        detail["AdjustReason"] = tbx_AdjustReason.Text;

        if (!detail["AdjustReason"].EndsWith("(" + (string)Session["UserName"] + ")"))
        {
            detail["AdjustReason"] += "(" + (string)Session["UserName"] + ")";
        }

        if (detail.AwardFee > 0)
        {
            MessageBox.Show(this, "对不起,扣减金额不可为负!");
            return;
        }
        new CSO_OfferBalanceBLL(detail.Balance).UpdateDetail(detail);
        MessageBox.ShowAndClose(this, "扣减成功!");
    }
 protected void bt_Delete_Click(object sender, EventArgs e)
 {
     int id = (int)ViewState["BalanceID"];
     CSO_OfferBalanceBLL bll = new CSO_OfferBalanceBLL(id);
     if (bll.Model != null && bll.Model.ApproveFlag != 1)
     {
         bll.Delete();
         MessageBox.ShowAndRedirect(this, "结算单删除成功!", "CSO_OfferBalanceList.aspx");
     }
 }
 protected void bt_CreateFeeApply_Click(object sender, EventArgs e)
 {
     int id = (int)ViewState["BalanceID"];
     CSO_OfferBalanceBLL bll = new CSO_OfferBalanceBLL(id);
     if (bll.Model != null && bll.Model.ApproveFlag != 1)
     {
         int feeapplyid = bll.CreateFeeApply((int)Session["UserID"]);
         MessageBox.ShowAndRedirect(this, "费用申请单申请成功!",
             Page.ResolveUrl("~/SubModule/FNA/FeeApply/FeeApplyDetail3.aspx?ID=" + feeapplyid.ToString()));
     }
 }
Example #5
0
    protected void bt_Delete_Click(object sender, EventArgs e)
    {
        int id = (int)ViewState["BalanceID"];
        CSO_OfferBalanceBLL bll = new CSO_OfferBalanceBLL(id);

        if (bll.Model != null && bll.Model.ApproveFlag != 1)
        {
            bll.Delete();
            MessageBox.ShowAndRedirect(this, "结算单删除成功!", "CSO_OfferBalanceList.aspx");
        }
    }
Example #6
0
    protected void bt_CreateFeeApply_Click(object sender, EventArgs e)
    {
        int id = (int)ViewState["BalanceID"];
        CSO_OfferBalanceBLL bll = new CSO_OfferBalanceBLL(id);

        if (bll.Model != null && bll.Model.ApproveFlag != 1)
        {
            int feeapplyid = bll.CreateFeeApply((int)Session["UserID"]);
            MessageBox.ShowAndRedirect(this, "费用申请单申请成功!",
                                       Page.ResolveUrl("~/SubModule/FNA/FeeApply/FeeApplyDetail3.aspx?ID=" + feeapplyid.ToString()));
        }
    }
Example #7
0
    private void DoApprove(int State, string Remark)
    {
        if (tbx_ApplyCost.Text != "0")
        {
            BindGrid();
            MessageBox.Show(this, "批量审批时,不可以设定申请金额条件,请将单笔申请金额设为0再批量审批!");
            return;
        }

        #region 组织明细记录的查询条件
        //会计月条件
        string condition = " CSO_OfferBalance.AccountMonth= " + ddl_AccountMonth.SelectedValue;

        //管理片区
        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;

            condition += " AND CSO_OfferBalance.OrganizeCity IN (" + orgcitys + ")";
        }

        //审批状态
        if (ddl_State.SelectedValue == "1")
        {
            condition +=
                @" AND CSO_OfferBalance.State = 2 AND CSO_OfferBalance.ApproveTask IN 
                    (SELECT EWF_Task_Job.Task FROM  MCS_EWF.dbo.EWF_Task_JobDecision INNER JOIN
                        MCS_EWF.dbo.EWF_Task_Job ON EWF_Task_JobDecision.Job = EWF_Task_Job.ID 
                    WHERE EWF_Task_JobDecision.RecipientStaff=" + Session["UserID"].ToString() + @" AND
                        EWF_Task_JobDecision.DecisionResult=1 and EWF_Task_Job.Status=3)";
        }
        #endregion

        IList <CSO_OfferBalance> list = CSO_OfferBalanceBLL.GetModelList(condition);
        foreach (CSO_OfferBalance apply in list)
        {
            DoApproveTask(apply.ApproveTask, State, Remark);
        }
        BindGrid();
        MessageBox.Show(this, "审批成功!");
    }
    private void BindData()
    {
        CSO_OfferBalance_Detail detail = new CSO_OfferBalanceBLL().GetDetailModel((int)ViewState["ID"]);
        if (detail == null)
        {
            MessageBox.ShowAndClose(this, "参数错误!");
            return;
        }

        if (detail.OfferMan > 0)
        {
            CM_LinkMan doctor = new CM_LinkManBLL(detail.OfferMan).Model;
            if (doctor != null) lb_DoctorName.Text = doctor.Name;
        }

        lb_ActualFee.Text = detail.ActualFee.ToString("0.##");
        tbx_AdjustFee.Text = (0 - detail.AwardFee).ToString("0.##");
        tbx_AdjustReason.Text = detail["AdjustReason"];
    }
    protected void bt_BatAdjust_Click(object sender, EventArgs e)
    {
        foreach (GridViewRow row in gv_List.Rows)
        {
            CheckBox chk = (CheckBox)row.FindControl("chk");
            if (chk != null && chk.Checked)
            {
                int id = (int)gv_List.DataKeys[row.RowIndex]["CSO_OfferBalance_Detail_ID"];
                CSO_OfferBalance_Detail detail = new CSO_OfferBalanceBLL().GetDetailModel(id);
                if (detail == null) continue;

                detail.AwardFee = 0 - detail.ActualFee;
                detail.PayFee = 0;
                detail["AdjustReason"] = "批量扣除(" + (string)Session["UserName"] + ")";
                new CSO_OfferBalanceBLL(detail.Balance).UpdateDetail(detail);
            }
        }

        BindGrid();
    }
    protected void bt_Delete_Click(object sender, EventArgs e)
    {
        string selectids = "";
        foreach (GridViewRow item in gv_List.Rows)
        {
            if (((CheckBox)item.FindControl("cb_Select")).Checked == true)
            {
                selectids += gv_List.DataKeys[item.RowIndex].Value.ToString() + ",";
                int id = int.Parse(gv_List.DataKeys[item.RowIndex].Value.ToString());
                CSO_OfferBalanceBLL bll = new CSO_OfferBalanceBLL(id);
                if (bll.Model.State == 1 && bll.Model.ApproveFlag == 2) bll.Delete();
            }

        }
        if (string.IsNullOrEmpty(selectids))
        {
            MessageBox.Show(this, "请选择要删除的费用单!");
            return;
        }
        MessageBox.Show(this, "删除成功!");
        BindGrid();
    }
Example #11
0
    protected void bt_Submit_Click(object sender, EventArgs e)
    {
        int id = (int)ViewState["BalanceID"];
        CSO_OfferBalanceBLL bll = new CSO_OfferBalanceBLL(id);

        if (bll.Model != null && bll.Model.State == 1)
        {
            #region 发起工作流
            NameValueCollection dataobjects = new NameValueCollection();
            dataobjects.Add("ID", ViewState["BalanceID"].ToString());
            dataobjects.Add("OrganizeCity", bll.Model.OrganizeCity.ToString());
            dataobjects.Add("AccountMonth", bll.Model.AccountMonth.ToString());
            dataobjects.Add("TotalFee", bll.Items.Sum(p => p.PayFee).ToString("0.##"));

            #region 组合审批任务主题
            string          title = "";
            AC_AccountMonth month = new AC_AccountMonthBLL(bll.Model.AccountMonth).Model;
            if (month != null)
            {
                title += month.Name;
            }
            title += " " + TreeTableBLL.GetFullPathName("MCS_SYS.dbo.Addr_OrganizeCity", bll.Model.OrganizeCity);
            title += "营养教育新客费用申请";

            #endregion

            int TaskID = EWF_TaskBLL.NewTask("CSO_OfferBalanceApply", (int)Session["UserID"], title,
                                             "~/SubModule/CSO/CSO_OfferBalanceDetail.aspx?OfferBalanceID=" + ViewState["BalanceID"].ToString(), dataobjects);
            if (TaskID > 0)
            {
                bll.Submit(TaskID, (int)Session["UserID"]);

                new EWF_TaskBLL(TaskID).Start();        //直接启动流程
            }
            #endregion

            MessageBox.ShowAndRedirect(this, "结算单成功提交申请!", "CSO_OfferBalanceList.aspx");
        }
    }
Example #12
0
    private void BindData()
    {
        CSO_OfferBalance_Detail detail = new CSO_OfferBalanceBLL().GetDetailModel((int)ViewState["ID"]);

        if (detail == null)
        {
            MessageBox.ShowAndClose(this, "参数错误!");
            return;
        }

        if (detail.OfferMan > 0)
        {
            CM_LinkMan doctor = new CM_LinkManBLL(detail.OfferMan).Model;
            if (doctor != null)
            {
                lb_DoctorName.Text = doctor.Name;
            }
        }

        lb_ActualFee.Text     = detail.ActualFee.ToString("0.##");
        tbx_AdjustFee.Text    = (0 - detail.AwardFee).ToString("0.##");
        tbx_AdjustReason.Text = detail["AdjustReason"];
    }
    protected void bt_Save_Click(object sender, EventArgs e)
    {
        CSO_OfferBalance_Detail detail = new CSO_OfferBalanceBLL().GetDetailModel((int)ViewState["ID"]);
        if (detail == null)
        {
            MessageBox.ShowAndClose(this, "参数错误!");
            return;
        }

        detail.AwardFee = 0 - decimal.Parse(tbx_AdjustFee.Text);
        detail.PayFee = detail.ActualFee + detail.AwardFee;
        detail["AdjustReason"] = tbx_AdjustReason.Text;

        if (!detail["AdjustReason"].EndsWith("(" + (string)Session["UserName"] + ")"))
            detail["AdjustReason"] += "(" + (string)Session["UserName"] + ")";

        if (detail.AwardFee > 0)
        {
            MessageBox.Show(this, "对不起,扣减金额不可为负!");
            return;
        }
        new CSO_OfferBalanceBLL(detail.Balance).UpdateDetail(detail);
        MessageBox.ShowAndClose(this, "扣减成功!");
    }
Example #14
0
    private void BindData()
    {
        CSO_OfferBalance m = new CSO_OfferBalanceBLL(int.Parse(ViewState["BalanceID"].ToString())).Model;

        if (m != null)
        {
            pl_detail.BindData(m);

            if (m.State != 1)
            {
                bt_Submit.Visible          = false;
                bt_Delete.Visible          = false;
                gv_List.Columns[1].Visible = false;
                bt_BatAdjust.Visible       = false;
            }

            if (m.ApproveFlag != 1)
            {
                bt_CreateFeeApply.Visible = false;
            }

            BindGrid();
        }
    }
Example #15
0
    protected void bt_BatAdjust_Click(object sender, EventArgs e)
    {
        foreach (GridViewRow row in gv_List.Rows)
        {
            CheckBox chk = (CheckBox)row.FindControl("chk");
            if (chk != null && chk.Checked)
            {
                int id = (int)gv_List.DataKeys[row.RowIndex]["CSO_OfferBalance_Detail_ID"];
                CSO_OfferBalance_Detail detail = new CSO_OfferBalanceBLL().GetDetailModel(id);
                if (detail == null)
                {
                    continue;
                }


                detail.AwardFee        = 0 - detail.ActualFee;
                detail.PayFee          = 0;
                detail["AdjustReason"] = "批量扣除(" + (string)Session["UserName"] + ")";
                new CSO_OfferBalanceBLL(detail.Balance).UpdateDetail(detail);
            }
        }

        BindGrid();
    }
    private void BindData()
    {
        CSO_OfferBalance m = new CSO_OfferBalanceBLL(int.Parse(ViewState["BalanceID"].ToString())).Model;
        if (m != null)
        {
            pl_detail.BindData(m);

            if (m.State != 1)
            {
                bt_Submit.Visible = false;
                bt_Delete.Visible = false;
                gv_List.Columns[1].Visible = false;
                bt_BatAdjust.Visible = false;
            }

            if (m.ApproveFlag != 1) bt_CreateFeeApply.Visible = false;

            BindGrid();
        }
    }
Example #17
0
    private void BindGrid()
    {
        int month        = int.Parse(ddl_AccountMonth.SelectedValue);
        int organizecity = int.Parse(tr_OrganizeCity.SelectValue);
        int level        = int.Parse(ddl_Level.SelectedValue);
        int state        = int.Parse(ddl_State.SelectedValue);

        decimal _cost = 0;

        decimal.TryParse(tbx_ApplyCost.Text, out _cost);

        if (MCSTabControl1.SelectedIndex == 0)
        {
            DataTable dtSummary = CSO_OfferBalanceBLL.Summary(month, organizecity, level, state, (int)Session["UserID"]);
            #region 矩阵化数据表,扩展表数据列
            dtSummary.Columns.Add(new DataColumn("ID", Type.GetType("System.Int32")));
            if (level < 10)
            {
                foreach (DataRow row in dtSummary.Rows)
                {
                    row["ID"] = row["OrganizeCity"];
                }
                dtSummary = MatrixTable.Matrix(dtSummary, new string[] { "ID", "管理片区名称" },
                                               new string[] { "结算标准", "派发品牌", "派发产品" }, new string[] { "有效名单", "支付费用" }, false, true);
            }
            else if (level == 10)
            {
                //按经销商查看
                #region 将经销商的ID赋至表ID列
                foreach (DataRow row in dtSummary.Rows)
                {
                    row["ID"]    = row["经销商ID"] == DBNull.Value ? 0 : row["经销商ID"];
                    row["经销商名称"] = row["经销商名称"] == DBNull.Value ? "无" : row["经销商名称"];
                }
                #endregion

                dtSummary = MatrixTable.Matrix(dtSummary, new string[] { "ID", "管理片区名称", "经销商名称" },
                                               new string[] { "结算标准", "派发品牌", "派发产品" }, new string[] { "有效名单", "支付费用" }, false, true);
            }
            else if (level == 20)
            {
                //按医生查看
                #region 将医生的ID赋至表ID列
                foreach (DataRow row in dtSummary.Rows)
                {
                    row["ID"]    = row["VIPID"] == DBNull.Value ? 0 : row["VIPID"];
                    row["VIP姓名"] = row["VIP姓名"] == DBNull.Value ? "无" : row["VIP姓名"];
                }
                #endregion

                dtSummary = MatrixTable.Matrix(dtSummary, new string[] { "ID", "管理片区名称", "经销商名称", "VIP姓名" },
                                               new string[] { "结算标准", "派发品牌", "派发产品" }, new string[] { "有效名单", "支付费用" }, false, true);
            }
            #endregion

            if (dtSummary != null && dtSummary.Rows.Count > 0)
            {
                dtSummary = MatrixTable.ColumnSummaryTotal(dtSummary, new int[] { 1 }, new string[] { "有效名单", "支付费用" });

                #region 增加本月新客数
                string thismonthnewclientcount = "Convert([3.新客标准→小计→→有效名单], 'System.Int32')";
                if (dtSummary.Columns.Contains("4.3段新客标准→小计→→有效名单"))
                {
                    thismonthnewclientcount += " + Convert([4.3段新客标准→小计→→有效名单], 'System.Int32')";
                }

                string thismonthnewclientfee = "Convert([3.新客标准→小计→→支付费用], 'System.Decimal')";
                if (dtSummary.Columns.Contains("4.3段新客标准→小计→→支付费用"))
                {
                    thismonthnewclientfee += " + Convert([4.3段新客标准→小计→→支付费用], 'System.Decimal')";
                }

                dtSummary.Columns.Add(new DataColumn("本月新客户数", Type.GetType("System.Int32"), thismonthnewclientcount));
                dtSummary.Columns.Add(new DataColumn("本月新客户费", Type.GetType("System.Decimal"), thismonthnewclientfee));
                #endregion

                #region 获取上月新客
                dtSummary.Columns.Add(new DataColumn("上月新客数", Type.GetType("System.Int32")));
                dtSummary.Columns.Add(new DataColumn("上月新客费", Type.GetType("System.Decimal")));
                string ids = "";
                foreach (DataRow row in dtSummary.Rows)
                {
                    ids += row["ID"].ToString() + ",";
                }
                if (ids.EndsWith(","))
                {
                    ids = ids.Substring(0, ids.Length - 1);
                }
                DataTable dtPreMonth = null;
                if (level < 10)
                {
                    dtPreMonth = CSO_OfferBalanceBLL.GetNewClientAmountAndFee_ByMonthAndOrganzieCity(month - 1, ids);
                }
                else if (level == 10)
                {
                    dtPreMonth = CSO_OfferBalanceBLL.GetNewClientAmountAndFee_ByMonthAndDistributors(month - 1, ids);
                }
                else if (level == 20)
                {
                    dtPreMonth = CSO_OfferBalanceBLL.GetNewClientAmountAndFee_ByMonthAndDoctors(month - 1, ids);
                }

                if (dtPreMonth != null)
                {
                    foreach (DataRow row in dtSummary.Rows)
                    {
                        DataRow[] selectedrows = dtPreMonth.Select("ID=" + row["ID"].ToString());
                        if (selectedrows.Length > 0)
                        {
                            row["上月新客数"] = (int)selectedrows[0]["EffectiveAmount"];
                            row["上月新客费"] = (decimal)selectedrows[0]["PayFee"];
                        }
                        else
                        {
                            row["上月新客数"] = 0;
                            row["上月新客费"] = 0;
                        }
                    }
                }
                #region 增加上月新增增长比较
                dtSummary.Columns.Add("较上月新客增长量", Type.GetType("System.Int32"), "CONVERT([本月新客户数],'System.Int32') - [上月新客数]");
                dtSummary.Columns.Add("较上月新客增长率(%)", Type.GetType("System.String"),
                                      "IIF([上月新客数]=0,'-',CONVERT(CONVERT((CONVERT([本月新客户数],'System.Int32') - [上月新客数])*100/[上月新客数],'System.Int32'),'System.String'))+'%'");
                #endregion
                #endregion


                #region  金额条件过滤
                if (_cost != 0)
                {
                    switch (ddl_ComparerField.SelectedValue)
                    {
                    case "1":
                        dtSummary.DefaultView.RowFilter = "[1.派样185标准→小计→→有效名单]" + ddl_ApplyCostOP.SelectedValue + _cost;
                        break;

                    case "2":
                        dtSummary.DefaultView.RowFilter = "[2.派样400标准→小计→→有效名单]" + ddl_ApplyCostOP.SelectedValue + _cost;
                        break;

                    case "3":
                        dtSummary.DefaultView.RowFilter = "[本月新客户数]" + ddl_ApplyCostOP.SelectedValue + _cost;
                        break;

                    case "4":
                        dtSummary.DefaultView.RowFilter = "[合计→支付费用]" + ddl_ApplyCostOP.SelectedValue + _cost;
                        break;

                    case "5":
                        dtSummary.DefaultView.RowFilter = "[较上月新客增长量]" + ddl_ApplyCostOP.SelectedValue + _cost;
                        break;

                    case "6":
                        dtSummary.DefaultView.RowFilter = "上月新客数>0 AND (([较上月新客增长量]*100/[上月新客数])" + ddl_ApplyCostOP.SelectedValue + _cost + ")";
                        break;

                    default:
                        break;
                    }
                    dtSummary = dtSummary.DefaultView.ToTable();
                }
                #endregion

                #region 增加合计行
                List <string> valuecolumns = new List <string>();
                valuecolumns.Add("ID");
                valuecolumns.Add("上月新客数");
                valuecolumns.Add("上月新客费");
                foreach (DataColumn c in dtSummary.Columns)
                {
                    if (c.ColumnName.Contains("→"))
                    {
                        valuecolumns.Add(c.ColumnName);
                    }
                }
                MatrixTable.TableAddSummaryRow(dtSummary, "管理片区名称", valuecolumns.ToArray());
                #endregion
            }

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

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

            MatrixTable.GridViewMatric(gv_List);
        }
        else
        {
            #region 组织明细记录的查询条件
            string condition = "CSO_OfferBalance.AccountMonth=" + month.ToString();
            //管理片区及所有下属管理片区
            if (tr_OrganizeCity.SelectValue == "0")
            {
                #region 绑定用户可管辖的管理片区
                Org_StaffBLL staff = new Org_StaffBLL((int)Session["UserID"]);
                tr_OrganizeCity.DataSource = staff.GetStaffOrganizeCity();

                if (tr_OrganizeCity.DataSource.Select("ID = 1").Length > 0)
                {
                    tr_OrganizeCity.RootValue   = "0";
                    tr_OrganizeCity.SelectValue = "1";
                }
                else
                {
                    tr_OrganizeCity.RootValue   = new Addr_OrganizeCityBLL(staff.Model.OrganizeCity).Model.SuperID.ToString();
                    tr_OrganizeCity.SelectValue = staff.Model.OrganizeCity.ToString();
                }
                if ((int)ViewState["OrganizeCity"] > 0)
                {
                    tr_OrganizeCity.SelectValue = ViewState["OrganizeCity"].ToString();
                }
                #endregion
            }
            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;

                condition += " AND CSO_OfferBalance.OrganizeCity IN (" + orgcitys + ")";
            }
            //审批状态
            if (ddl_State.SelectedValue == "0")
            {
                condition += " AND CSO_OfferBalance.State IN (2,3) ";
            }
            else if (ddl_State.SelectedValue == "1")
            {
                condition +=
                    @" AND CSO_OfferBalance.State = 2 AND CSO_OfferBalance.ApproveTask IN 
(SELECT EWF_Task_Job.Task FROM  [192.168.8.82].MCS_EWF.dbo.EWF_Task_JobDecision INNER JOIN
    [192.168.8.82].MCS_EWF.dbo.EWF_Task_Job ON EWF_Task_JobDecision.Job = EWF_Task_Job.ID 
WHERE EWF_Task_JobDecision.RecipientStaff=" + Session["UserID"].ToString() + @" AND
    EWF_Task_JobDecision.DecisionResult=1 and EWF_Task_Job.Status=3)";
            }
            else if (ddl_State.SelectedValue == "2")
            {
                condition += " AND CSO_OfferBalance.State = 3 ";
            }
            else if (ddl_State.SelectedValue == "3")
            {
                AC_AccountMonth m = new AC_AccountMonthBLL(month).Model;
                condition +=
                    @" AND CSO_OfferBalance.State IN (2,3) AND CSO_OfferBalance.ApproveTask IN 
(SELECT EWF_Task_Job.Task FROM  [192.168.8.82].MCS_EWF.dbo.EWF_Task_JobDecision INNER JOIN
	[192.168.8.82].MCS_EWF.dbo.EWF_Task_Job ON EWF_Task_JobDecision.Job = EWF_Task_Job.ID 
WHERE EWF_Task_JobDecision.RecipientStaff=" + Session["UserID"].ToString() + @" AND
	EWF_Task_JobDecision.DecisionResult IN(2,5,6) AND 
	EWF_Task_JobDecision.DecisionTime BETWEEN DATEADD(month,-1,'"     + m.BeginDate.ToString("yyyy-MM-dd") + @"') AND 
		DATEADD(month,3,'"         + m.BeginDate.ToString("yyyy-MM-dd") + @"'))";
            }
            #endregion

            gv_ListDetail.ConditionString = condition;
            gv_ListDetail.BindGrid();
        }

        if (gv_List.Rows.Count > 0 || gv_ListDetail.Rows.Count > 0)
        {
            btn_Approve.Enabled   = state == 1;
            btn_UnApprove.Enabled = state == 1;
        }
        else
        {
            btn_Approve.Enabled   = false;
            btn_UnApprove.Enabled = false;
        }
    }
    protected void bt_Submit_Click(object sender, EventArgs e)
    {
        int id = (int)ViewState["BalanceID"];
        CSO_OfferBalanceBLL bll = new CSO_OfferBalanceBLL(id);
        if (bll.Model != null && bll.Model.State == 1)
        {
            #region 发起工作流
            NameValueCollection dataobjects = new NameValueCollection();
            dataobjects.Add("ID", ViewState["BalanceID"].ToString());
            dataobjects.Add("OrganizeCity", bll.Model.OrganizeCity.ToString());
            dataobjects.Add("AccountMonth", bll.Model.AccountMonth.ToString());
            dataobjects.Add("TotalFee", bll.Items.Sum(p => p.PayFee).ToString("0.##"));

            #region 组合审批任务主题
            string title = "";
            AC_AccountMonth month = new AC_AccountMonthBLL(bll.Model.AccountMonth).Model;
            if (month != null) title += month.Name;
            title += " " + TreeTableBLL.GetFullPathName("MCS_SYS.dbo.Addr_OrganizeCity", bll.Model.OrganizeCity);
            title += "营养教育新客费用申请";

            #endregion

            int TaskID = EWF_TaskBLL.NewTask("CSO_OfferBalanceApply", (int)Session["UserID"], title,
                "~/SubModule/CSO/CSO_OfferBalanceDetail.aspx?OfferBalanceID=" + ViewState["BalanceID"].ToString(), dataobjects);
            if (TaskID > 0)
            {
                bll.Submit(TaskID, (int)Session["UserID"]);

                new EWF_TaskBLL(TaskID).Start();        //直接启动流程
            }
            #endregion

            MessageBox.ShowAndRedirect(this, "结算单成功提交申请!", "CSO_OfferBalanceList.aspx");
        }
    }