/// <summary>
    /// 导出工资单并写入文件路径
    /// </summary>
    /// <param name="AccountMonth"></param>
    /// <param name="OrganizeCity"></param>
    /// <param name="BankCode">1:农行(导出为txt);2:建行(导出为Excel);3:导出农行Excel</param>
    /// <param name="Remark"></param>
    /// <param name="filePath">文件存放路径</param>
    public bool Salary_Export(int AccountMonth, int OrganizeCity, int BankCode, string Remark, string filePath)
    {
        int       bankCode = BankCode == 1 || BankCode == 3 ? 1 : 2;
        DataTable table    = PM_SalaryBLL.Salary_Table_Export(AccountMonth, OrganizeCity, bankCode, Remark);

        if (table == null || table.Columns.Count == 0 || table.Rows.Count == 0)
        {
            return(false);
        }

        bool flag = false;

        if (BankCode == 1)
        {
            flag = SalaryTableToTxt(table, filePath);
        }
        else if (BankCode == 2)
        {
            flag = SalaryTableToExcel(table, filePath);
        }
        else if (BankCode == 3)
        {
            flag = SalaryTableToExcel(table, filePath);
        }
        return(flag);
    }
Ejemplo n.º 2
0
    protected void bt_Submit_Click(object sender, EventArgs e)
    {
        if ((int)ViewState["ID"] > 0)
        {
            bt_Save_Click(null, null);

            PM_SalaryBLL bll = new PM_SalaryBLL((int)ViewState["ID"]);

            #region 判断预算余额是否够工单申请(暂不使用)
            //int feetype = ConfigHelper.GetConfigInt("SalaryFeeType");

            //decimal budgetbalance = FNA_BudgetBLL.GetUsableAmount((int)ViewState["ApplyMonth"], bll.Model.OrganizeCity, feetype) +
            //    FNA_BudgetBLL.GetUsableAmount((int)ViewState["ApplyMonth"], bll.Model.OrganizeCity, 0);
            //if (budgetbalance < bll.GetSumSalary())
            //{
            //    MessageBox.Show(this, "对不起,您当前的预算余额不够申请此导购员工资申请,您当前的预算余额为:" + budgetbalance.ToString());
            //    return;
            //}
            #endregion

            #region 判断导购是否有销量
            //if(new PM_SalaryBLL((int)ViewState["ID"]).Items.Sum(p=>p.ActSalesVolume)==0)
            //{
            //     MessageBox.Show(this, "该工资单中所有导购的销量均为零,请确认是否异常!");

            //     return;
            //}
            #endregion

            if (bll.Model["TaskID"] != "" && bll.Model.State == 2)
            {
                MessageBox.ShowAndRedirect(this, "该工资单已提交,请勿重复提交!", "PM_SalaryDetailList.aspx?ID=" + ViewState["ID"].ToString());
                return;
            }

            #region 发起工作流
            NameValueCollection dataobjects = new NameValueCollection();
            dataobjects.Add("ID", ViewState["ID"].ToString());
            dataobjects.Add("OrganizeCity", bll.Model.OrganizeCity.ToString());
            dataobjects.Add("AccountMonth", bll.Model.AccountMonth.ToString());
            dataobjects.Add("ApplyCost", lb_TotalCost.Text);
            dataobjects.Add("PromotorNum", bll.Items.Count.ToString());

            //组合审批任务主题
            Addr_OrganizeCity _city = new Addr_OrganizeCityBLL(bll.Model.OrganizeCity).Model;
            string            title = _city.Name + ",导购员工资总额:" + lb_TotalCost.Text + ",人数:" + bll.Items.Count.ToString();

            int TaskID = EWF_TaskBLL.NewTask("PM_SalaryApplyFlow", (int)Session["UserID"], title, "~/SubModule/PM/PM_SalaryDetailList.aspx?ID=" + ViewState["ID"].ToString(), dataobjects);
            if (TaskID > 0)
            {
                bll.Submit((int)Session["UserID"], TaskID, 0);
                new EWF_TaskBLL(TaskID).Start();        //直接启动流程
            }
            #endregion

            MessageBox.ShowAndRedirect(this, "导购员工资提交申请成功!", "../EWF/TaskDetail.aspx?TaskID=" + TaskID.ToString());
        }
    }
Ejemplo n.º 3
0
    protected void gv_PromotorSalary_DataBound(object sender, EventArgs e)
    {
        if (gv_PromotorSalary.HeaderRow != null)
        {
            IList <CM_Client> lists;
            string            clientname = "";
            string            RetailerS  = "";
            gv_PromotorSalary.HeaderRow.Cells[0].Visible = false;
            int taskindex = 0;
            for (int i = 0; i < gv_PromotorSalary.HeaderRow.Cells.Count; i++)
            {
                if (gv_PromotorSalary.HeaderRow.Cells[i].Text == "审批工作流")
                {
                    taskindex = i;
                }
            }
            foreach (GridViewRow r in gv_PromotorSalary.Rows)
            {
                clientname         = "";
                lists              = new List <CM_Client>();
                RetailerS          = "";
                r.Cells[0].Visible = false;
                RetailerS          = new PM_SalaryBLL().GetDetailModel(int.Parse(gv_PromotorSalary.DataKeys[r.RowIndex].Value.ToString()))["RetailerS"];
                if (RetailerS.Equals(""))
                {
                    r.Cells[5].Text = clientname;
                    continue;
                }

                lists = CM_ClientBLL.GetModelList("ID IN (" + RetailerS + ")");
                int count = 0;
                foreach (CM_Client c in lists)
                {
                    if (count < 2)
                    {
                        clientname += "<a href='../CM/RT/RetailerDetail.aspx?ClientID=" + c.ID.ToString() + "' target='_blank' class='listViewTdLinkS1'>"
                                      + c.FullName + "</a><br/>";
                    }
                    else
                    {
                        break;
                    }
                    count++;
                }
                if (count > 1)
                {
                    clientname += "共" + lists.Count.ToString() + "个门名";
                }
                r.Cells[6].Text = clientname;
                if (taskindex > 0)
                {
                    r.Cells[r.Cells.Count - 1].Text = "<a href='../EWF/TaskDetail.aspx?TaskID=" + r.Cells[taskindex].Text + "' target='_blank' class='listViewTdLinkS1'>"
                                                      + r.Cells[taskindex].Text + "</a>";
                }
            }
        }
    }
Ejemplo n.º 4
0
    protected void bt_Merge_Click(object sender, EventArgs e)
    {
        int result = PM_SalaryBLL.Merge((int)ViewState["AccountMonth"], ViewState["ID"].ToString(), (int)Session["UserID"]);

        if (result > 0)
        {
            MessageBox.ShowAndRedirect(this, "合并成功!", "PM_SalaryDetailList.aspx?ID=" + result.ToString());
        }
        else
        {
            MessageBox.Show(this, "合并失败,此工资单上级管理片区无工资单。");
        }
    }
Ejemplo n.º 5
0
    protected void btnCancel_Click(object sender, EventArgs e)
    {
        List <int> failureList = new List <int>();

        //重置导购人数和门店总销售金额
        int     promotorCount = int.Parse(lbl_PromotorCount.Text);
        decimal salesAmount   = decimal.Parse(lbl_SalesAmount.Text);

        foreach (GridViewRow gr in gv_List.Rows)
        {
            if (((CheckBox)gr.FindControl("chk_ID")).Checked == true)
            {
                int SalaryDetailID = int.Parse(gv_List.DataKeys[gr.RowIndex][0].ToString());


                int UserID = int.Parse(Session["UserID"].ToString());
                int ret    = PM_SalaryBLL.CancelSalaryDetail(SalaryDetailID, UserID);
                if (ret != 0)
                {
                    failureList.Add(SalaryDetailID);
                }
                else
                {
                    promotorCount--;//取消成功后人数减1
                    //扣除该导购销售额
                    PM_SalaryBLL bll = new PM_SalaryBLL(SalaryDetailID);
                    salesAmount -= bll.GetDetailModel(SalaryDetailID).ActSalesVolume;
                }
            }
        }

        lbl_PromotorCount.Text = promotorCount.ToString();
        lbl_SalesAmount.Text   = salesAmount.ToString();

        if (failureList.Count == 0)
        {
            MessageBox.Show(this, "取消成功");
        }
        else
        {
            StringBuilder sb = new StringBuilder("错误代码:");
            foreach (int item in failureList)
            {
                sb.Append(item.ToString() + ",");
            }
            sb.Remove(sb.Length - 1, 1);
            MessageBox.Show(this, sb.ToString());
        }

        BindGrid();
    }
    protected void btnCancel_Click(object sender, EventArgs e)
    {
        List<int> failureList = new List<int>();

        //重置导购人数和门店总销售金额
        int promotorCount = int.Parse(lbl_PromotorCount.Text);
        decimal salesAmount = decimal.Parse(lbl_SalesAmount.Text);

        foreach (GridViewRow gr in gv_List.Rows)
        {
            if (((CheckBox)gr.FindControl("chk_ID")).Checked == true)
            {
                int SalaryDetailID = int.Parse(gv_List.DataKeys[gr.RowIndex][0].ToString());

                int UserID = int.Parse(Session["UserID"].ToString());
                int ret = PM_SalaryBLL.CancelSalaryDetail(SalaryDetailID, UserID);
                if (ret != 0)
                {
                    failureList.Add(SalaryDetailID);
                }
                else
                {
                    promotorCount--;//取消成功后人数减1
                    //扣除该导购销售额
                    PM_SalaryBLL bll = new PM_SalaryBLL(SalaryDetailID);
                    salesAmount -= bll.GetDetailModel(SalaryDetailID).ActSalesVolume;
                }
            }
        }

        lbl_PromotorCount.Text = promotorCount.ToString();
        lbl_SalesAmount.Text = salesAmount.ToString();

        if (failureList.Count == 0)
        {
            MessageBox.Show(this, "取消成功");
        }
        else
        {
            StringBuilder sb = new StringBuilder("错误代码:");
            foreach (int item in failureList)
            {
                sb.Append(item.ToString() + ",");
            }
            sb.Remove(sb.Length - 1, 1);
            MessageBox.Show(this, sb.ToString());
        }

        BindGrid();
    }
 protected bool GetEnable(int promotor, int approveflag)
 {
     bool enableflag = true;
     try
     {
         int SalaryState = PM_SalaryBLL.PM_Salary_GetStateByPromotor(promotor, int.Parse(ddl_AccountMonth.SelectedValue));
         if (SalaryState>0&& SalaryState <= 3|| approveflag == 1)//已提交或审核通过的工资表不可修改底量与奖惩
         {
             enableflag = false;
         }
     }
     catch (Exception e)
     {
         throw e;
     }
     return enableflag;
 }
    private AC_AccountMonth GetMaxSalaryDate(int Prmomtor, int accountmonth)
    {
        string conditon = "ID IN (SELECT MAX(SalaryID) FROM MCS_Promotor.dbo.PM_SalaryDetail WHERE Promotor=" + Prmomtor.ToString() + ")";

        if (accountmonth != 0)
        {
            conditon += " AND AccountMonth=" + accountmonth.ToString();
        }
        IList <PM_Salary>  _listsalary = PM_SalaryBLL.GetModelList(conditon);
        AC_AccountMonthBLL _mbll;

        if (_listsalary.Count > 0)
        {
            _mbll = new AC_AccountMonthBLL(_listsalary[0].AccountMonth);
            return(_mbll.Model);
        }
        else
        {
            return(null);
        }
    }
 protected bool GetInsureEnable(int promotor, int approveflag)
 {
     bool enableflag = true;
     try
     {
         int SalaryState = PM_SalaryBLL.PM_Salary_GetStateByPromotor(promotor, int.Parse(ddl_AccountMonth.SelectedValue));
         if (SalaryState>0&& SalaryState <= 3 || approveflag == 1)//已提交或审核通过的工资表不可修改底量与奖惩
         {
             enableflag = false;
         }
         //社保模式为【自购保险】才可填写社保报销额
         IList<PM_PromotorSalary> PM_SalaryList = PM_PromotorSalaryBLL.GetModelList("Promotor=" + promotor.ToString() + " AND State=3 AND ApproveFlag=1");
         if (PM_SalaryList.Count > 0 && PM_SalaryList[0].InsuranceMode != 8)
         {
             enableflag = false;
         }
     }
     catch (Exception e)
     {
         throw e;
     }
     return enableflag;
 }
Ejemplo n.º 10
0
    protected void bt_Generate_Click(object sender, EventArgs e)
    {
        int organizecity = 0;
        int client       = 0;
        int month        = 0;

        int.TryParse(tr_OrganizeCity.SelectValue, out organizecity);
        int.TryParse(select_Client.SelectValue, out client);
        int.TryParse(ddl_Month.SelectedValue, out month);

        if (organizecity == 0)
        {
            MessageBox.Show(this, "请选择管理片区!");
            return;
        }

        if (client == 0)
        {
            MessageBox.Show(this, "请选择经销商!");
            return;
        }

        #region 判断指定区域下是否还有门店销量未审核

        Addr_OrganizeCityBLL _bll = new Addr_OrganizeCityBLL(organizecity);
        if (_bll.Model.Level < ConfigHelper.GetConfigInt("OrganizeCity-CityLevel"))
        {
            MessageBox.Show(this, "对不起,导购工资不能在营业部及以上层级生成!");
            return;
        }

        string citys = _bll.GetAllChildNodeIDs();
        if (citys == "")
        {
            citys = organizecity.ToString();
        }
        else
        {
            citys += "," + organizecity.ToString();
        }
        string condition = "Type=3 AND AccountMonth=" + month.ToString() +
                           " AND Promotor IS NOT NULL AND OrganizeCity IN (" + citys + ") AND ApproveFlag=2 AND Flag=1";

        int counts = SVM_SalesVolumeBLL.GetModelList(condition).Count;
        if (counts > 0)
        {
            MessageBox.Show(this, "对不起,您区域还有" + counts.ToString() + "条导购销量未审核");
            return;
        }
        #endregion

        int id = PM_SalaryBLL.GenerateSalary(organizecity, client, month, (int)Session["UserID"]);

        if (id > 0)
        {
            MessageBox.ShowAndRedirect(this, "导购员工资生成成功,请及时核对工资信息并提交!", "PM_SalaryList.aspx?Client=" + select_Client.SelectValue);
        }
        else if (id == 0)
        {
            MessageBox.Show(this, "对不起,该经销商下无导购员需要生成工资!");
        }
        else if (id == -1)
        {
            MessageBox.Show(this, "对不起,该月该经销商已有导购员工资生成!,请选择正确的会计月与经销商!");
        }
        else if (id == -2)
        {
            MessageBox.Show(this, "对不起,该经销商下不存在导购员!");
        }
        else if (id == -3)
        {
            MessageBox.ShowAndRedirect(this, "对不起,请先维护导购员的奖惩调整项,并且审核之后才能生成工资!", "PM_SalaryDataObject.aspx?AccountMonth=" + month.ToString());
        }
        else if (id == -4)
        {
            MessageBox.Show(this, "对不起,有部分导购员的薪酬定义没有正确维护,请正确设定薪酬定义信息后,再生成工资!");
        }
        else
        {
            MessageBox.Show(this, "对不起,导购员工资生成失败!错误码:" + id.ToString());
        }
    }
    private void BindGrid()
    {
        PM_SalaryBLL bll = new PM_SalaryBLL((int)ViewState["ID"]);
        string condition = "PM_SalaryDetail.SalaryID=" + ViewState["ID"].ToString() + " AND PM_SalaryDataObject.AccountMonth=" + ViewState["AccountMonth"].ToString();
        if (tr_OrganizeCity.SelectValue != bll.Model.OrganizeCity.ToString())
        {
            Addr_OrganizeCityBLL orgcity = new Addr_OrganizeCityBLL(int.Parse(tr_OrganizeCity.SelectValue));
            string orgcitys = orgcity.GetAllChildNodeIDs();
            if (orgcitys != "") orgcitys += ",";
            orgcitys += tr_OrganizeCity.SelectValue;
            condition += " AND  MCS_Promotor.dbo.PM_Promotor.OrganizeCity in(" + orgcitys + ") ";
        }
        if (cb_OnlyDisplayZero.Checked)
        {
            condition += " AND PM_SalaryDetail.Bonus=0";
        }

        if (txt_Promotor.Text.Trim() != "")
        {
            condition += " AND PM_Promotor.Name LIKE '%" + txt_Promotor.Text.Trim() + "%'";
        }

        //获取未被取消的已生成的导购工资
        condition += " AND CAST(MCS_SYS.dbo.UF_Spilt(PM_SalaryDetail.ExtPropertys,'|',31) AS  INT)!=1 ";

        gv_List.OrderFields = "PM_Promotor_Name";
        gv_List.ConditionString = condition;
        gv_List.BindGrid();
        MatrixTable.GridViewMatric(gv_List);

        lb_TotalCost.Text = PM_SalaryBLL.GetSumSalary((int)ViewState["ID"]).ToString("0.##");

        if ((int)ViewState["State"] == 2 || ((int)ViewState["State"] == 3))
        {

            foreach (GridViewRow gr in gv_List.Rows)
            {
                if (Request.QueryString["Decision"] != "" && Request.QueryString["Decision"] == "Y")
                {
                    bt_SaveChange.Visible = true;
                    ((TextBox)gr.FindControl("tbx_PayAdjust_Approve")).Enabled = true;
                    ((TextBox)gr.FindControl("tbx_PayAdjust_Reason")).Enabled = true;
                    ((TextBox)gr.FindControl("tbx_DIPayAdjust_Approve")).Enabled = true;
                    ((TextBox)gr.FindControl("tbx_DIPayAdjust_Reason")).Enabled = true;

                    PM_SalaryDetail _detail = new PM_SalaryBLL().GetDetailModel((int)gv_List.DataKeys[gr.RowIndex][0]);

                    if (CM_ContractBLL.GetModelList(@" Classify=4 AND Client IN (SELECT Client FROM MCS_Promotor.dbo.PM_PromotorInRetailer
                    WHERE Promotor= " + _detail.Promotor + ") AND State=3 AND ApproveFlag=1 AND MCS_SYS.dbo.UF_Spilt(ExtPropertys,'|',3)<>''"
                     + "AND CONVERT(DECIMAL(18,3),MCS_SYS.dbo.UF_Spilt(ExtPropertys,'|',3))>0 AND '" + bll.Model.InputTime.ToString("yyyy-MM-dd") + "'"
                     + "Between BeginDate AND EndDate").Count == 0)
                    {
                        ((TextBox)gr.FindControl("tbx_PMFee_Adjust")).Enabled = true;
                        ((TextBox)gr.FindControl("tbx_PMFee_Adjust_Reason")).Enabled = true;
                    }
                    ((TextBox)gr.FindControl("tbx_PMFee1_Adjust")).Enabled = true;

                }
            }
        }
        for (int i = 0; i < gv_List.Columns.Count; i++)
        {

            if (gv_List.Columns[i].HeaderText.Contains("小计") ||
                gv_List.Columns[i].HeaderText.Contains("合计") ||
                gv_List.Columns[i].HeaderText.Contains("我司实发额"))
            {
                gv_List.Columns[i].HeaderStyle.ForeColor = System.Drawing.Color.Blue;
                gv_List.Columns[i].ItemStyle.ForeColor = System.Drawing.Color.Blue;
            }

            if (gv_List.Columns[i].HeaderText.Contains("导购实得薪资小计"))
            {
                gv_List.Columns[i].HeaderStyle.ForeColor = System.Drawing.Color.Brown;
                gv_List.Columns[i].ItemStyle.ForeColor = System.Drawing.Color.Brown;
                gv_List.Columns[i].ItemStyle.Font.Bold = true;
            }
        }
    }
    private void BindData()
    {
        PM_SalaryBLL bll = new PM_SalaryBLL((int)ViewState["ID"]);
        pn_detail.BindData(bll.Model);
        ViewState["AccountMonth"] = bll.Model.AccountMonth;
        ViewState["ApplyMonth"] = AC_AccountMonthBLL.GetMonthByDate(bll.Model.InputTime);
        ViewState["State"] = bll.Model.State;

        #region 绑定管理片区
        Org_StaffBLL staff = new Org_StaffBLL((int)Session["UserID"]);
        tr_OrganizeCity.DataSource = staff.GetStaffOrganizeCity();
        tr_OrganizeCity.RootValue = new Addr_OrganizeCityBLL(bll.Model.OrganizeCity).Model.SuperID.ToString();
        tr_OrganizeCity.SelectValue = bll.Model.OrganizeCity.ToString();
        lbl_PromotorCount.Text = bll.Items.Count(p => p["FlagCancel"] != "1").ToString();
        lbl_SalesAmount.Text = bll.Items.Where(p => p["FlagCancel"] != "1").Sum(p => p.ActSalesVolume).ToString();
        #endregion
        if (Request.QueryString["Decision"] != "" && Request.QueryString["Decision"] == "Y" && bll.Model.State == 2)
        {
            ViewState["Enable"] = true;
        }

        BindGrid();

        ShowBtnCancel(false);

        if (bll.Model.State != 1)
        {
            pn_detail.SetControlsEnable(false);

            bt_Delete.Visible = false;
            bt_Save.Visible = false;
            bt_Submit.Visible = false;
            bt_Merge.Visible = false;
        }
        else
        {
            //当前操作人为工资生成人(生成人未提交之前可以取消工资)
            int UserID = 0;
            if (int.TryParse(Session["UserID"].ToString(), out UserID) && UserID == bll.Model.InputStaff)
            {
                ShowBtnCancel(true);
            }
        }

        //if (bll.Model.State != 3)
        //{
        //    BindBudgetInfo((int)ViewState["ApplyMonth"], bll.Model.OrganizeCity);
        //}

        if (Request.QueryString["Decision"] != "" && Request.QueryString["Decision"] == "Y")
        {
            Page.ClientScript.RegisterStartupScript(Page.GetType(), "工资不能单独审批", " <script>window.parent.document.getElementById('ctl00_ContentPlaceHolder1_btn_Pass').disabled='disabled'; </script>");
            Page.ClientScript.RegisterStartupScript(Page.GetType(), "工资不能单条审批", " <script>window.parent.document.getElementById('ctl00_ContentPlaceHolder1_bt_SaveDecisionComment').disabled='disabled'; </script>");
            Page.ClientScript.RegisterStartupScript(Page.GetType(), "工资不能单条处理", " <script>window.parent.document.getElementById('ctl00_ContentPlaceHolder1_btn_WaitProcess').disabled='disabled'; </script>");
            string[] allowdays = Addr_OrganizeCityParamBLL.GetValueByType(1, 9).Replace(" ", "").Split(new char[] { ',', ',', ';', ';' });
            if (!allowdays.Contains(DateTime.Now.Day.ToString()))
            {
                Page.ClientScript.RegisterStartupScript(Page.GetType(), "超时不能单独审批", " <script>window.parent.document.getElementById('ctl00_ContentPlaceHolder1_btn_NotPass').disabled='disabled'; </script>");
            }
            //流程中允许取消工资
            ShowBtnCancel(true);
        }
    }
Ejemplo n.º 13
0
    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 rtchannel    = int.Parse(ddl_RTChannel.SelectedValue);


        switch (MCSTabControl1.SelectedTabItem.Value)
        {
        case "0":
        {
            #region 显示统计分析
            DataTable dtSummary = PM_SalaryBLL.GetSummary(month, organizecity, level, state, int.Parse(Session["UserID"].ToString()), int.Parse(ddl_SalaryClassify.SelectedValue));
            if (dtSummary.Rows.Count == 0)
            {
                gv_List.DataBind();
                return;
            }
            //MatrixTable.TableAddSummaryRow(dtSummary, "管理片区名称",
            //    new string[] { "导购员人数", "我司实发额", "上上月总销量", "上月总销量", "上月与上上月增长量", "本月总销量", "本月与上月增长量", "本月婴儿粉销量", "费用A", "费用B", "经销商承担薪资合计" });


            //dtSummary.Columns.Add("婴儿粉比(%)", Type.GetType("System.Decimal"), "IIF(本月总销量=0,0,本月婴儿粉销量/本月总销量*100)").SetOrdinal(10);
            //dtSummary.Columns.Add("费率A(%)", Type.GetType("System.Decimal"), "IIF(本月总销量=0,0,费用A/本月总销量*100)").SetOrdinal(13);
            //dtSummary.Columns.Add("费率B(%)", Type.GetType("System.Decimal"), "IIF(本月总销量=0,0,费用B/本月总销量*100)").SetOrdinal(14);

            //gv_List.Width = new Unit(100, UnitType.Percentage);
            if (txt_FeeRate.Text != "0")
            {
                dtSummary.DefaultView.RowFilter = "[奶粉部费率A(%)]" + ddl_FeeRateOP.SelectedValue + txt_FeeRate.Text;
            }

            gv_List.DataSource = dtSummary.DefaultView;

            gv_List.DataBind();
            GridViewMergSampeValueRow(gv_List, 0, "", 0, "");
            GridViewMergSampeValueRow(gv_List, 1, "", 0, "");
            GridViewMergSampeValueRow(gv_List, 2, "", 0, "");
            #endregion
        }
        break;

        case "1":
        {
            #region 显示汇总单数据源
            DataTable dtSummary = PM_SalaryBLL.GetSummaryTotal(month, organizecity, level, state, int.Parse(Session["UserID"].ToString()), int.Parse(ddl_SalaryClassify.SelectedValue));
            if (dtSummary.Rows.Count == 0)
            {
                gv_List.DataBind();
                return;
            }
            if (dtSummary.Columns.Count >= 24)
            {
                gv_List.Width = new Unit(dtSummary.Columns.Count * 65);
            }
            else
            {
                gv_List.Width = new Unit(100, UnitType.Percentage);
            }

            dtSummary.Columns.Add("费率A(%)", Type.GetType("System.Decimal"), "IIF(本月总销量=0,0,费用A/本月总销量*100)").SetOrdinal(dtSummary.Columns.Count - 1);
            if (txt_FeeRate.Text != "0")
            {
                dtSummary.DefaultView.RowFilter = "[费率A(%)]" + ddl_FeeRateOP.SelectedValue + txt_FeeRate.Text;
            }

            #region 增加合计行
            if (dtSummary.Rows.Count > 0)
            {
                DataRow dr = dtSummary.NewRow();
                dr[0]        = 0;
                dr["管理片区名称"] = "合计";

                for (int column = 2; column < dtSummary.Columns.Count - 1; column++)
                {
                    decimal sum = 0;
                    for (int i = 0; i < dtSummary.Rows.Count; i++)
                    {
                        decimal d = 0;
                        if (decimal.TryParse(dtSummary.Rows[i][column].ToString(), out d))
                        {
                            sum += d;
                        }
                    }
                    dr[column] = sum;
                }
                dtSummary.Rows.Add(dr);
            }
            #endregion
            gv_List.DataSource = dtSummary.DefaultView;
            gv_List.DataBind();

            MatrixTable.GridViewMatric(gv_List);
            #endregion
        }
        break;

        case "2":
        {
            //string condition = " MCS_SYS.dbo.UF_Spilt(PM_SalaryDetail.ExtPropertys,'|',31)!='1'	";//--FlagCancel	是否取消已生成的导购人员导购工(	31)
            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;

                condition += " AND PM_Salary.OrganizeCity IN (" + orgcitys + ")";
            }
            if (ddl_SalaryClassify.SelectedValue != "0")
            {
                condition += "AND MCS_SYS.dbo.UF_Spilt2('MCS_Promotor.dbo.PM_Salary',PM_Salary.ExtPropertys,'PMClassfiy')=" + ddl_SalaryClassify.SelectedValue;
            }
            //会计月条件
            condition += " AND PM_Salary.AccountMonth = " + ddl_Month.SelectedValue;

            //审批状态
            if (ddl_State.SelectedValue == "0")
            {
                condition += " AND PM_Salary.State IN (2,3) ";
            }
            else if (ddl_State.SelectedValue == "1")
            {
                condition +=
                    @" AND	PM_Salary.State = 2 AND 
			MCS_SYS.dbo.UF_Spilt(PM_Salary.ExtPropertys,'|',1) 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 
					 INNER JOIN MCS_EWF.dbo.EWF_Task ON	 EWF_Task_Job.Task= EWF_Task.ID 
                     INNER JOIN MCS_EWF.dbo.EWF_Flow_App ON EWF_Task.App=EWF_Flow_App.ID AND EWF_Flow_App.Code='PM_SalaryApplyFlow'
				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 PM_Salary.State = 3 ";
            }
            else if (ddl_State.SelectedValue == "3")
            {
                AC_AccountMonth m = new AC_AccountMonthBLL(month).Model;
                condition +=
                    @" AND PM_Salary.State IN (2,3) AND MCS_SYS.dbo.UF_Spilt(PM_Salary.ExtPropertys,'|',1) 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 
                 INNER JOIN MCS_EWF.dbo.EWF_Task ON	 EWF_Task_Job.Task= EWF_Task.ID 
                 INNER JOIN MCS_EWF.dbo.EWF_Flow_App ON EWF_Task.App=EWF_Flow_App.ID AND EWF_Flow_App.Code='PM_SalaryApplyFlow'
                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();
        }
        break;

        case "3":
        {
            DataTable dtSummary = PM_SalaryBLL.GetDetailByState(month, organizecity, level, state, int.Parse(Session["UserID"].ToString()), int.Parse(ddl_SalaryClassify.SelectedValue), rtchannel);
            if (dtSummary.Rows.Count == 0)
            {
                gv_PromotorSalary.DataBind();
                return;
            }
            if (dtSummary.Columns.Count >= 24)
            {
                gv_PromotorSalary.Width = new Unit(dtSummary.Columns.Count * 65);
            }
            else
            {
                gv_PromotorSalary.Width = new Unit(100, UnitType.Percentage);
            }
            dtSummary.Columns.Add("所在门店").SetOrdinal(6);
            if (txt_FeeRate.Text != "0")
            {
                dtSummary.DefaultView.RowFilter = "[费率A%]" + ddl_FeeRateOP.SelectedValue + txt_FeeRate.Text;
            }
            gv_PromotorSalary.DataSource = dtSummary.DefaultView;
            gv_PromotorSalary.DataBind();
            MatrixTable.GridViewMatric(gv_PromotorSalary);
        }
        break;
        }

        #region 是否可以批量审批
        if (state != 1)
        {
            gv_List.Columns[0].ItemStyle.Width = new Unit(1);
            bt_Approved.Visible   = false;
            bt_UnApproved.Visible = false;
        }
        else
        {
            bt_Approved.Visible   = true;
            bt_UnApproved.Visible = true;
            gv_List.Columns[0].ItemStyle.Width = new Unit(68);
            Org_StaffBLL _staff = new Org_StaffBLL((int)Session["UserID"]);
            DataTable    dt     = _staff.GetLowerPositionTask(3, int.Parse(tr_OrganizeCity.SelectValue), month);

            if (AC_AccountMonthBLL.GetCurrentMonth() - 1 <= int.Parse(ddl_Month.SelectedValue))
            {
                string[] allowday1 = Addr_OrganizeCityParamBLL.GetValueByType(1, 3).Split(new char[] { ',', ',', ';', ';' });
                string[] allowday2 = Addr_OrganizeCityParamBLL.GetValueByType(1, 4).Split(new char[] { ',', ',', ';', ';' });
                int      day       = DateTime.Now.Day;
                if (allowday1.Contains(day.ToString()))
                {
                    bt_Approved.Visible = false;
                }
                else if (allowday2.Contains(day.ToString()))
                {
                    #region 判断费用申请进度
                    Org_StaffBLL bll = new Org_StaffBLL((int)Session["UserID"]);
                    DataTable    dt2 = new DataTable();
                    if (bll.Model.Position == 210)
                    {
                        dt2 = bll.GetFillProcessDetail(3);
                    }
                    if (dt.Rows.Count > 0)
                    {
                        bt_Approved.Visible = false;
                    }
                    #endregion
                }
                else
                {
                    bt_UnApproved.Enabled = false;
                    bt_Approved.Enabled   = dt.Rows.Count == 0;
                }
            }
            else
            {
                bt_UnApproved.Enabled = false;
                bt_Approved.Enabled   = dt.Rows.Count == 0;
            }
            if (dt.Rows.Count > 0)
            {
                bt_Approved.Enabled = false;

                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=3&StaffID=0&Month=" + ddl_Month.SelectedValue + "&City=" + tr_OrganizeCity.SelectValue + "&tempid='+tempid, window, 'dialogWidth:520px;DialogHeight=600px;status:yes;resizable=no');</script>", false);
            }
        }
        #endregion
    }
    protected void bt_Submit_Click(object sender, EventArgs e)
    {
        if ((int)ViewState["ID"] > 0)
        {
            bt_Save_Click(null, null);

            PM_SalaryBLL bll = new PM_SalaryBLL((int)ViewState["ID"]);

            #region 判断预算余额是否够工单申请(暂不使用)
            //int feetype = ConfigHelper.GetConfigInt("SalaryFeeType");

            //decimal budgetbalance = FNA_BudgetBLL.GetUsableAmount((int)ViewState["ApplyMonth"], bll.Model.OrganizeCity, feetype) +
            //    FNA_BudgetBLL.GetUsableAmount((int)ViewState["ApplyMonth"], bll.Model.OrganizeCity, 0);
            //if (budgetbalance < bll.GetSumSalary())
            //{
            //    MessageBox.Show(this, "对不起,您当前的预算余额不够申请此导购员工资申请,您当前的预算余额为:" + budgetbalance.ToString());
            //    return;
            //}
            #endregion

            #region 判断导购是否有销量
            //if(new PM_SalaryBLL((int)ViewState["ID"]).Items.Sum(p=>p.ActSalesVolume)==0)
            //{
            //     MessageBox.Show(this, "该工资单中所有导购的销量均为零,请确认是否异常!");

            //     return;
            //}
            #endregion

            if (bll.Model["TaskID"] != "" && bll.Model.State == 2)
            {
                MessageBox.ShowAndRedirect(this, "该工资单已提交,请勿重复提交!", "PM_SalaryDetailList.aspx?ID=" + ViewState["ID"].ToString());
                return;
            }

            #region 发起工作流
            NameValueCollection dataobjects = new NameValueCollection();
            dataobjects.Add("ID", ViewState["ID"].ToString());
            dataobjects.Add("OrganizeCity", bll.Model.OrganizeCity.ToString());
            dataobjects.Add("AccountMonth", bll.Model.AccountMonth.ToString());
            dataobjects.Add("ApplyCost", lb_TotalCost.Text);
            dataobjects.Add("PromotorNum", bll.Items.Count.ToString());

            //组合审批任务主题
            Addr_OrganizeCity _city = new Addr_OrganizeCityBLL(bll.Model.OrganizeCity).Model;
            string title = _city.Name + ",导购员工资总额:" + lb_TotalCost.Text + ",人数:" + bll.Items.Count.ToString();

            int TaskID = EWF_TaskBLL.NewTask("PM_SalaryApplyFlow", (int)Session["UserID"], title, "~/SubModule/PM/PM_SalaryDetailList.aspx?ID=" + ViewState["ID"].ToString(), dataobjects);
            if (TaskID > 0)
            {
                bll.Submit((int)Session["UserID"], TaskID, 0);
                new EWF_TaskBLL(TaskID).Start();        //直接启动流程
            }
            #endregion

            MessageBox.ShowAndRedirect(this, "导购员工资提交申请成功!", "../EWF/TaskDetail.aspx?TaskID=" + TaskID.ToString());
        }
    }
    protected void bt_SaveChange_Click(object sender, EventArgs e)
    {
        PM_SalaryBLL bll = new PM_SalaryBLL((int)ViewState["ID"]);

        #region 保存每一个导购员工资情况
        foreach (GridViewRow row in gv_List.Rows)
        {
            string _promotorname = ((HyperLink)(row.FindControl("hy_PromotorName"))).Text;

            int id = (int)gv_List.DataKeys[row.RowIndex][0];
            PM_SalaryDetail detail = bll.Items.First<PM_SalaryDetail>(item => item.ID == id);

            decimal org_adjust = 0; decimal di_org_adjust = 0;
            decimal adjust = 0; decimal di_adjust = 0;
            decimal pm_fee = 0, pm_fee_adjust = 0, pm_fee1 = 0, pm_fee1_adjust = 0;
            decimal org_pm_fee_adjust = 0, org_pm_fee1_adjust = 0, pm_fee2 = 0;

            decimal.TryParse(detail["PayAdjust_Approve"], out org_adjust);
            decimal.TryParse(((TextBox)row.FindControl("tbx_PayAdjust_Approve")).Text, out adjust);
            decimal.TryParse(detail["DIPayAdjust_Approve"], out di_org_adjust);
            decimal.TryParse(((TextBox)row.FindControl("tbx_DIPayAdjust_Approve")).Text, out di_adjust);
            decimal.TryParse(((TextBox)row.FindControl("tbx_PMFee_Adjust")).Text, out pm_fee_adjust);
            decimal.TryParse(((TextBox)row.FindControl("tbx_PMFee1_Adjust")).Text, out pm_fee1_adjust);
            decimal.TryParse(detail["PMFee"], out pm_fee);
            decimal.TryParse(detail["PMFee1"], out pm_fee1);
            decimal.TryParse(detail["PMFee_Adjust"], out org_pm_fee_adjust);
            decimal.TryParse(detail["PMFee1_Adjust"], out org_pm_fee1_adjust);
            decimal.TryParse(detail["PMFee2"], out pm_fee2);

            if (detail.Bonus < 0)
                detail.Bonus = 0;
            if (detail.Pay1 < 0)
                detail.Pay1 = 0;
            if (org_adjust != adjust)
            {
                detail["PayAdjust_Approve"] = adjust.ToString();
                if (((TextBox)row.FindControl("tbx_PayAdjust_Reason")).Text == "")
                {
                    MessageBox.Show(this, "第" + (row.RowIndex + 1).ToString() + "行," + _promotorname + "的工资审批调整后,原因不能为空!");
                    return;
                }
                detail.Sum1 += Math.Round(adjust - org_adjust, 1, MidpointRounding.AwayFromZero);
                if (detail.Sum1 + detail.Sum3 < 0)
                {
                    MessageBox.Show(this, "第" + (row.RowIndex + 1).ToString() + "行," + _promotorname + "的工资审批调整后,导购实得薪资小计不能为负!");
                    return;
                }
                detail["Remark"] += "--" + Session["UserRealName"].ToString() + "将调整从" + org_adjust.ToString() + "修改为" + detail["PayAdjust_Approve"] + ";修改原因:" + ((TextBox)row.FindControl("tbx_PayAdjust_Reason")).Text;
                if (detail.Sum1 < 0)
                {
                    MessageBox.Show(this, "第" + (row.RowIndex + 1).ToString() + "行," + _promotorname + "的工资审批调整后,我司提成不能为负!");
                    ((TextBox)row.FindControl("tbx_PayAdjust_Approve")).Focus();
                    return;
                }
                bll.UpdateDetail(detail);
                PM_SalaryBLL.UpdateAdjustRecord((int)ViewState["ID"], (int)Session["UserID"], org_adjust.ToString(), detail["PayAdjust_Approve"], _promotorname);
            }
            if (di_org_adjust != di_adjust)
            {
                detail["DIPayAdjust_Approve"] = di_adjust.ToString();
                if (((TextBox)row.FindControl("tbx_DIPayAdjust_Reason")).Text == "")
                {
                    MessageBox.Show(this, "第" + (row.RowIndex + 1).ToString() + "行," + _promotorname + "的工资审批调整后,经销商调整原因不能为空!");
                    return;
                }
                detail.Sum3 += Math.Round(di_adjust - di_org_adjust, 1, MidpointRounding.AwayFromZero);
                if (detail.Sum1 + detail.Sum3 < 0)
                {
                    MessageBox.Show(this, "第" + (row.RowIndex + 1).ToString() + "行," + _promotorname + "的工资审批调整后,导购实得薪资小计不能为负!");
                    return;
                }
                detail["DI_Remark"] += "--" + Session["UserRealName"].ToString() + "将调整从" + di_org_adjust.ToString() + "修改为" + detail["DIPayAdjust_Approve"] + ";修改原因:" + ((TextBox)row.FindControl("tbx_DIPayAdjust_Reason")).Text;
                if (detail.Sum3 < 0)
                {
                    MessageBox.Show(this, "第" + (row.RowIndex + 1).ToString() + "行," + _promotorname + "的工资审批调整后,经销商薪资合计不能为负!");
                    ((TextBox)row.FindControl("tbx_DIPayAdjust_Approve")).Focus();
                    return;
                }
                bll.UpdateDetail(detail);
            }
            if (pm_fee_adjust - org_pm_fee_adjust != 0 || pm_fee1_adjust - org_pm_fee1_adjust != 0)
            {
                if (pm_fee_adjust - org_pm_fee_adjust != 0)
                {
                    detail["PMFee_Adjust"] = pm_fee_adjust.ToString();

                    if (((TextBox)row.FindControl("tbx_PMFee_Adjust_Reason")).Text == "")
                    {
                        MessageBox.Show(this, "第" + (row.RowIndex + 1).ToString() + "行," + _promotorname + "的工资审批调整后,管理费明细调整原因不能为空!");
                        return;
                    }

                    pm_fee2 = pm_fee2 + pm_fee_adjust;

                    if (pm_fee2 < 0)
                    {
                        MessageBox.Show(this, "第" + (row.RowIndex + 1).ToString() + "行," + _promotorname + "的工资审批调整后,导购管理费不能为负!");
                        return;
                    }
                    detail["PMFee_Remark"] += "--" + Session["UserRealName"].ToString() + "将管理费调整从" + org_pm_fee_adjust.ToString() + "修改为" + pm_fee_adjust.ToString() + ";修改原因:" + ((TextBox)row.FindControl("tbx_PMFee_Adjust_Reason")).Text;
                }
                if (pm_fee1_adjust - org_pm_fee1_adjust != 0)
                {
                    detail["PMFee1_Adjust"] = pm_fee1_adjust.ToString();
                    if (((TextBox)row.FindControl("tbx_PMFee_Adjust_Reason")).Text == "")
                    {
                        MessageBox.Show(this, "第" + (row.RowIndex + 1).ToString() + "行," + _promotorname + "的工资审批调整后,管理费明细调整原因不能为空!");
                        return;
                    }
                    pm_fee1 = pm_fee1 + pm_fee1_adjust;
                    if (pm_fee1 < 0)
                    {
                        MessageBox.Show(this, "第" + (row.RowIndex + 1).ToString() + "行," + _promotorname + "的工资审批调整后,导购管理费小计不能为负!");
                        return;
                    }
                    detail["PMFee_Remark"] += "--" + Session["UserRealName"].ToString() + "将管理费小计调整从" + org_pm_fee1_adjust.ToString() + "修改为" + pm_fee1_adjust.ToString() + ";修改原因:" + ((TextBox)row.FindControl("tbx_PMFee_Adjust_Reason")).Text;
                }
                detail.CoPMFee = Math.Round(pm_fee2 + pm_fee1, 1, MidpointRounding.AwayFromZero);
                detail["PMFeeTotal"] = (detail.CoPMFee + detail.DIPMFee).ToString();
                bll.UpdateDetail(detail);
            }
        }

        #endregion

        BindGrid();
        MessageBox.Show(this, "工资调整金额保存成功!");
    }
Ejemplo n.º 16
0
    protected void DoApprove(bool ApproveFlag)
    {
        #region 仅查看待我审批的工资申请单
        string taskids = "";
        if (ddl_State.SelectedValue == "1")
        {
            taskids = GetNeedMeApproveTaskIDs();

            if (taskids == "")
            {
                MessageBox.Show(this, "对不起,没有需要待您审批的费用申请单!");
                return;
            }
        }
        #endregion
        string[] TaskIDs = taskids.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

        int    organizecity = int.Parse(tr_OrganizeCity.SelectValue);
        string condition    = " PM_Salary.State = 2 ";

        #region 组织明细记录的查询条件
        //管理片区及所有下属管理片区
        if (organizecity != 1)
        {
            Addr_OrganizeCityBLL orgcity = new Addr_OrganizeCityBLL(organizecity);
            string orgcitys = orgcity.GetAllChildNodeIDs();
            if (orgcitys != "")
            {
                orgcitys += ",";
            }
            orgcitys += organizecity.ToString();

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

        if (ddl_SalaryClassify.SelectedValue != "0")
        {
            condition += "AND MCS_SYS.dbo.UF_Spilt2('MCS_Promotor.dbo.PM_Salary',PM_Salary.ExtPropertys,'PMClassfiy')=" + ddl_SalaryClassify.SelectedValue;
        }
        //会计月条件
        condition += " AND PM_Salary.AccountMonth = " + ddl_Month.SelectedValue;

        IList <PM_Salary> lists = PM_SalaryBLL.GetModelList(condition);
        #endregion

        foreach (PM_Salary salary in lists)
        {
            if (TaskIDs.Contains(salary["TaskID"]))
            {
                int             jobid = EWF_TaskBLL.StaffCanApproveTask(int.Parse(salary["TaskID"]), (int)Session["UserID"]);
                EWF_Task_JobBLL job   = new EWF_Task_JobBLL(jobid);
                if (job.Model != null)
                {
                    int decision = job.StaffCanDecide((int)Session["UserID"]);
                    if (decision > 0)
                    {
                        if (ApproveFlag)
                        {
                            job.Decision(decision, (int)Session["UserID"], 2, "汇总单批量审批通过!");       //2:审批已通过
                        }
                        else
                        {
                            job.Decision(decision, (int)Session["UserID"], 3, "汇总单批量未能审批通过!");    //3:审批未通过
                        }
                    }
                }
            }
        }

        BindGrid();
        MessageBox.Show(this, ApproveFlag ? "审批成功!" : "已成功将选择区域的申请单,设为批复未通过!");
        return;
    }
Ejemplo n.º 17
0
    //private void BindBudgetInfo(int month, int organizecity)
    //{
    //    tbl_BudgetInfo.Visible = true;
    //    int feetype = ConfigHelper.GetConfigInt("SalaryFeeType");

    //    lb_BudgetAmount.Text = (FNA_BudgetBLL.GetSumBudgetAmount(month, organizecity, feetype) +
    //        FNA_BudgetBLL.GetSumBudgetAmount(month, organizecity, 0)).ToString("0.###");

    //    lb_BudgetBalance.Text = (FNA_BudgetBLL.GetUsableAmount(month, organizecity, feetype) +
    //        FNA_BudgetBLL.GetUsableAmount(month, organizecity, 0)).ToString("0.###");
    //}
    #endregion



    private void BindData()
    {
        PM_SalaryBLL bll = new PM_SalaryBLL((int)ViewState["ID"]);

        pn_detail.BindData(bll.Model);
        ViewState["AccountMonth"] = bll.Model.AccountMonth;
        ViewState["ApplyMonth"]   = AC_AccountMonthBLL.GetMonthByDate(bll.Model.InputTime);
        ViewState["State"]        = bll.Model.State;

        #region 绑定管理片区
        Org_StaffBLL staff = new Org_StaffBLL((int)Session["UserID"]);
        tr_OrganizeCity.DataSource  = staff.GetStaffOrganizeCity();
        tr_OrganizeCity.RootValue   = new Addr_OrganizeCityBLL(bll.Model.OrganizeCity).Model.SuperID.ToString();
        tr_OrganizeCity.SelectValue = bll.Model.OrganizeCity.ToString();
        lbl_PromotorCount.Text      = bll.Items.Count(p => p["FlagCancel"] != "1").ToString();
        lbl_SalesAmount.Text        = bll.Items.Where(p => p["FlagCancel"] != "1").Sum(p => p.ActSalesVolume).ToString();
        #endregion
        if (Request.QueryString["Decision"] != "" && Request.QueryString["Decision"] == "Y" && bll.Model.State == 2)
        {
            ViewState["Enable"] = true;
        }

        BindGrid();

        ShowBtnCancel(false);

        if (bll.Model.State != 1)
        {
            pn_detail.SetControlsEnable(false);

            bt_Delete.Visible = false;
            bt_Save.Visible   = false;
            bt_Submit.Visible = false;
            bt_Merge.Visible  = false;
        }
        else
        {
            //当前操作人为工资生成人(生成人未提交之前可以取消工资)
            int UserID = 0;
            if (int.TryParse(Session["UserID"].ToString(), out UserID) && UserID == bll.Model.InputStaff)
            {
                ShowBtnCancel(true);
            }
        }

        //if (bll.Model.State != 3)
        //{
        //    BindBudgetInfo((int)ViewState["ApplyMonth"], bll.Model.OrganizeCity);
        //}

        if (Request.QueryString["Decision"] != "" && Request.QueryString["Decision"] == "Y")
        {
            Page.ClientScript.RegisterStartupScript(Page.GetType(), "工资不能单独审批", " <script>window.parent.document.getElementById('ctl00_ContentPlaceHolder1_btn_Pass').disabled='disabled'; </script>");
            Page.ClientScript.RegisterStartupScript(Page.GetType(), "工资不能单条审批", " <script>window.parent.document.getElementById('ctl00_ContentPlaceHolder1_bt_SaveDecisionComment').disabled='disabled'; </script>");
            Page.ClientScript.RegisterStartupScript(Page.GetType(), "工资不能单条处理", " <script>window.parent.document.getElementById('ctl00_ContentPlaceHolder1_btn_WaitProcess').disabled='disabled'; </script>");
            string[] allowdays = Addr_OrganizeCityParamBLL.GetValueByType(1, 9).Replace(" ", "").Split(new char[] { ',', ',', ';', ';' });
            if (!allowdays.Contains(DateTime.Now.Day.ToString()))
            {
                Page.ClientScript.RegisterStartupScript(Page.GetType(), "超时不能单独审批", " <script>window.parent.document.getElementById('ctl00_ContentPlaceHolder1_btn_NotPass').disabled='disabled'; </script>");
            }
            //流程中允许取消工资
            ShowBtnCancel(true);
        }
    }
    protected void gv_PromotorSalary_DataBound(object sender, EventArgs e)
    {
        if (gv_PromotorSalary.HeaderRow != null)
        {
            IList<CM_Client> lists;
            string clientname = "";
            string RetailerS = "";
            gv_PromotorSalary.HeaderRow.Cells[0].Visible = false;
            int taskindex = 0;
            for (int i = 0; i < gv_PromotorSalary.HeaderRow.Cells.Count; i++)
                if (gv_PromotorSalary.HeaderRow.Cells[i].Text == "审批工作流")
                    taskindex = i;
            foreach (GridViewRow r in gv_PromotorSalary.Rows)
            {
                clientname = "";
                lists = new List<CM_Client>();
                RetailerS = "";
                r.Cells[0].Visible = false;
                RetailerS = new PM_SalaryBLL().GetDetailModel(int.Parse(gv_PromotorSalary.DataKeys[r.RowIndex].Value.ToString()))["RetailerS"];
                if (RetailerS.Equals(""))
                {
                    r.Cells[5].Text = clientname;
                    continue;
                }

                lists = CM_ClientBLL.GetModelList("ID IN (" + RetailerS + ")");
                int count = 0;
                foreach (CM_Client c in lists)
                {
                    if (count < 2)
                    {
                        clientname += "<a href='../CM/RT/RetailerDetail.aspx?ClientID=" + c.ID.ToString() + "' target='_blank' class='listViewTdLinkS1'>"
                            + c.FullName + "</a><br/>";
                    }
                    else
                    {
                        break;
                    }
                    count++;
                }
                if (count > 1) clientname += "共" + lists.Count.ToString() + "个门名";
                r.Cells[6].Text = clientname;
                if (taskindex > 0)
                    r.Cells[r.Cells.Count - 1].Text = "<a href='../EWF/TaskDetail.aspx?TaskID=" + r.Cells[taskindex].Text + "' target='_blank' class='listViewTdLinkS1'>"
                        + r.Cells[taskindex].Text + "</a>";
            }
        }
    }
Ejemplo n.º 19
0
    private void BindGrid()
    {
        PM_SalaryBLL bll       = new PM_SalaryBLL((int)ViewState["ID"]);
        string       condition = "PM_SalaryDetail.SalaryID=" + ViewState["ID"].ToString() + " AND PM_SalaryDataObject.AccountMonth=" + ViewState["AccountMonth"].ToString();

        if (tr_OrganizeCity.SelectValue != bll.Model.OrganizeCity.ToString())
        {
            Addr_OrganizeCityBLL orgcity = new Addr_OrganizeCityBLL(int.Parse(tr_OrganizeCity.SelectValue));
            string orgcitys = orgcity.GetAllChildNodeIDs();
            if (orgcitys != "")
            {
                orgcitys += ",";
            }
            orgcitys  += tr_OrganizeCity.SelectValue;
            condition += " AND  MCS_Promotor.dbo.PM_Promotor.OrganizeCity in(" + orgcitys + ") ";
        }
        if (cb_OnlyDisplayZero.Checked)
        {
            condition += " AND PM_SalaryDetail.Bonus=0";
        }

        if (txt_Promotor.Text.Trim() != "")
        {
            condition += " AND PM_Promotor.Name LIKE '%" + txt_Promotor.Text.Trim() + "%'";
        }

        //获取未被取消的已生成的导购工资
        condition += " AND CAST(MCS_SYS.dbo.UF_Spilt(PM_SalaryDetail.ExtPropertys,'|',31) AS  INT)!=1 ";


        gv_List.OrderFields     = "PM_Promotor_Name";
        gv_List.ConditionString = condition;
        gv_List.BindGrid();
        MatrixTable.GridViewMatric(gv_List);

        lb_TotalCost.Text = PM_SalaryBLL.GetSumSalary((int)ViewState["ID"]).ToString("0.##");

        if ((int)ViewState["State"] == 2 || ((int)ViewState["State"] == 3))
        {
            foreach (GridViewRow gr in gv_List.Rows)
            {
                if (Request.QueryString["Decision"] != "" && Request.QueryString["Decision"] == "Y")
                {
                    bt_SaveChange.Visible = true;
                    ((TextBox)gr.FindControl("tbx_PayAdjust_Approve")).Enabled   = true;
                    ((TextBox)gr.FindControl("tbx_PayAdjust_Reason")).Enabled    = true;
                    ((TextBox)gr.FindControl("tbx_DIPayAdjust_Approve")).Enabled = true;
                    ((TextBox)gr.FindControl("tbx_DIPayAdjust_Reason")).Enabled  = true;

                    PM_SalaryDetail _detail = new PM_SalaryBLL().GetDetailModel((int)gv_List.DataKeys[gr.RowIndex][0]);

                    if (CM_ContractBLL.GetModelList(@" Classify=4 AND Client IN (SELECT Client FROM MCS_Promotor.dbo.PM_PromotorInRetailer
                    WHERE Promotor= " + _detail.Promotor + ") AND State=3 AND ApproveFlag=1 AND MCS_SYS.dbo.UF_Spilt(ExtPropertys,'|',3)<>''"
                                                    + "AND CONVERT(DECIMAL(18,3),MCS_SYS.dbo.UF_Spilt(ExtPropertys,'|',3))>0 AND '" + bll.Model.InputTime.ToString("yyyy-MM-dd") + "'"
                                                    + "Between BeginDate AND EndDate").Count == 0)
                    {
                        ((TextBox)gr.FindControl("tbx_PMFee_Adjust")).Enabled        = true;
                        ((TextBox)gr.FindControl("tbx_PMFee_Adjust_Reason")).Enabled = true;
                    }
                    ((TextBox)gr.FindControl("tbx_PMFee1_Adjust")).Enabled = true;
                }
            }
        }
        for (int i = 0; i < gv_List.Columns.Count; i++)
        {
            if (gv_List.Columns[i].HeaderText.Contains("小计") ||
                gv_List.Columns[i].HeaderText.Contains("合计") ||
                gv_List.Columns[i].HeaderText.Contains("我司实发额"))
            {
                gv_List.Columns[i].HeaderStyle.ForeColor = System.Drawing.Color.Blue;
                gv_List.Columns[i].ItemStyle.ForeColor   = System.Drawing.Color.Blue;
            }

            if (gv_List.Columns[i].HeaderText.Contains("导购实得薪资小计"))
            {
                gv_List.Columns[i].HeaderStyle.ForeColor = System.Drawing.Color.Brown;
                gv_List.Columns[i].ItemStyle.ForeColor   = System.Drawing.Color.Brown;
                gv_List.Columns[i].ItemStyle.Font.Bold   = true;
            }
        }
    }
Ejemplo n.º 20
0
    protected void bt_SaveChange_Click(object sender, EventArgs e)
    {
        PM_SalaryBLL bll = new PM_SalaryBLL((int)ViewState["ID"]);

        #region 保存每一个导购员工资情况
        foreach (GridViewRow row in gv_List.Rows)
        {
            string _promotorname = ((HyperLink)(row.FindControl("hy_PromotorName"))).Text;

            int             id     = (int)gv_List.DataKeys[row.RowIndex][0];
            PM_SalaryDetail detail = bll.Items.First <PM_SalaryDetail>(item => item.ID == id);

            decimal org_adjust = 0; decimal di_org_adjust = 0;
            decimal adjust = 0; decimal di_adjust = 0;
            decimal pm_fee = 0, pm_fee_adjust = 0, pm_fee1 = 0, pm_fee1_adjust = 0;
            decimal org_pm_fee_adjust = 0, org_pm_fee1_adjust = 0, pm_fee2 = 0;

            decimal.TryParse(detail["PayAdjust_Approve"], out org_adjust);
            decimal.TryParse(((TextBox)row.FindControl("tbx_PayAdjust_Approve")).Text, out adjust);
            decimal.TryParse(detail["DIPayAdjust_Approve"], out di_org_adjust);
            decimal.TryParse(((TextBox)row.FindControl("tbx_DIPayAdjust_Approve")).Text, out di_adjust);
            decimal.TryParse(((TextBox)row.FindControl("tbx_PMFee_Adjust")).Text, out pm_fee_adjust);
            decimal.TryParse(((TextBox)row.FindControl("tbx_PMFee1_Adjust")).Text, out pm_fee1_adjust);
            decimal.TryParse(detail["PMFee"], out pm_fee);
            decimal.TryParse(detail["PMFee1"], out pm_fee1);
            decimal.TryParse(detail["PMFee_Adjust"], out org_pm_fee_adjust);
            decimal.TryParse(detail["PMFee1_Adjust"], out org_pm_fee1_adjust);
            decimal.TryParse(detail["PMFee2"], out pm_fee2);

            if (detail.Bonus < 0)
            {
                detail.Bonus = 0;
            }
            if (detail.Pay1 < 0)
            {
                detail.Pay1 = 0;
            }
            if (org_adjust != adjust)
            {
                detail["PayAdjust_Approve"] = adjust.ToString();
                if (((TextBox)row.FindControl("tbx_PayAdjust_Reason")).Text == "")
                {
                    MessageBox.Show(this, "第" + (row.RowIndex + 1).ToString() + "行," + _promotorname + "的工资审批调整后,原因不能为空!");
                    return;
                }
                detail.Sum1 += Math.Round(adjust - org_adjust, 1, MidpointRounding.AwayFromZero);
                if (detail.Sum1 + detail.Sum3 < 0)
                {
                    MessageBox.Show(this, "第" + (row.RowIndex + 1).ToString() + "行," + _promotorname + "的工资审批调整后,导购实得薪资小计不能为负!");
                    return;
                }
                detail["Remark"] += "--" + Session["UserRealName"].ToString() + "将调整从" + org_adjust.ToString() + "修改为" + detail["PayAdjust_Approve"] + ";修改原因:" + ((TextBox)row.FindControl("tbx_PayAdjust_Reason")).Text;
                if (detail.Sum1 < 0)
                {
                    MessageBox.Show(this, "第" + (row.RowIndex + 1).ToString() + "行," + _promotorname + "的工资审批调整后,我司提成不能为负!");
                    ((TextBox)row.FindControl("tbx_PayAdjust_Approve")).Focus();
                    return;
                }
                bll.UpdateDetail(detail);
                PM_SalaryBLL.UpdateAdjustRecord((int)ViewState["ID"], (int)Session["UserID"], org_adjust.ToString(), detail["PayAdjust_Approve"], _promotorname);
            }
            if (di_org_adjust != di_adjust)
            {
                detail["DIPayAdjust_Approve"] = di_adjust.ToString();
                if (((TextBox)row.FindControl("tbx_DIPayAdjust_Reason")).Text == "")
                {
                    MessageBox.Show(this, "第" + (row.RowIndex + 1).ToString() + "行," + _promotorname + "的工资审批调整后,经销商调整原因不能为空!");
                    return;
                }
                detail.Sum3 += Math.Round(di_adjust - di_org_adjust, 1, MidpointRounding.AwayFromZero);
                if (detail.Sum1 + detail.Sum3 < 0)
                {
                    MessageBox.Show(this, "第" + (row.RowIndex + 1).ToString() + "行," + _promotorname + "的工资审批调整后,导购实得薪资小计不能为负!");
                    return;
                }
                detail["DI_Remark"] += "--" + Session["UserRealName"].ToString() + "将调整从" + di_org_adjust.ToString() + "修改为" + detail["DIPayAdjust_Approve"] + ";修改原因:" + ((TextBox)row.FindControl("tbx_DIPayAdjust_Reason")).Text;
                if (detail.Sum3 < 0)
                {
                    MessageBox.Show(this, "第" + (row.RowIndex + 1).ToString() + "行," + _promotorname + "的工资审批调整后,经销商薪资合计不能为负!");
                    ((TextBox)row.FindControl("tbx_DIPayAdjust_Approve")).Focus();
                    return;
                }
                bll.UpdateDetail(detail);
            }
            if (pm_fee_adjust - org_pm_fee_adjust != 0 || pm_fee1_adjust - org_pm_fee1_adjust != 0)
            {
                if (pm_fee_adjust - org_pm_fee_adjust != 0)
                {
                    detail["PMFee_Adjust"] = pm_fee_adjust.ToString();

                    if (((TextBox)row.FindControl("tbx_PMFee_Adjust_Reason")).Text == "")
                    {
                        MessageBox.Show(this, "第" + (row.RowIndex + 1).ToString() + "行," + _promotorname + "的工资审批调整后,管理费明细调整原因不能为空!");
                        return;
                    }

                    pm_fee2 = pm_fee2 + pm_fee_adjust;

                    if (pm_fee2 < 0)
                    {
                        MessageBox.Show(this, "第" + (row.RowIndex + 1).ToString() + "行," + _promotorname + "的工资审批调整后,导购管理费不能为负!");
                        return;
                    }
                    detail["PMFee_Remark"] += "--" + Session["UserRealName"].ToString() + "将管理费调整从" + org_pm_fee_adjust.ToString() + "修改为" + pm_fee_adjust.ToString() + ";修改原因:" + ((TextBox)row.FindControl("tbx_PMFee_Adjust_Reason")).Text;
                }
                if (pm_fee1_adjust - org_pm_fee1_adjust != 0)
                {
                    detail["PMFee1_Adjust"] = pm_fee1_adjust.ToString();
                    if (((TextBox)row.FindControl("tbx_PMFee_Adjust_Reason")).Text == "")
                    {
                        MessageBox.Show(this, "第" + (row.RowIndex + 1).ToString() + "行," + _promotorname + "的工资审批调整后,管理费明细调整原因不能为空!");
                        return;
                    }
                    pm_fee1 = pm_fee1 + pm_fee1_adjust;
                    if (pm_fee1 < 0)
                    {
                        MessageBox.Show(this, "第" + (row.RowIndex + 1).ToString() + "行," + _promotorname + "的工资审批调整后,导购管理费小计不能为负!");
                        return;
                    }
                    detail["PMFee_Remark"] += "--" + Session["UserRealName"].ToString() + "将管理费小计调整从" + org_pm_fee1_adjust.ToString() + "修改为" + pm_fee1_adjust.ToString() + ";修改原因:" + ((TextBox)row.FindControl("tbx_PMFee_Adjust_Reason")).Text;
                }
                detail.CoPMFee       = Math.Round(pm_fee2 + pm_fee1, 1, MidpointRounding.AwayFromZero);
                detail["PMFeeTotal"] = (detail.CoPMFee + detail.DIPMFee).ToString();
                bll.UpdateDetail(detail);
            }
        }


        #endregion

        BindGrid();
        MessageBox.Show(this, "工资调整金额保存成功!");
    }