Exemplo n.º 1
0
    protected void select_Client_SelectChange(object sender, MCSControls.MCSWebControls.SelectChangeEventArgs e)
    {
        bt_Generate.Enabled = false;
        if (select_Client.SelectValue != "")
        {
            IList <CM_Contract> lists = CM_ContractBLL.GetModelList("Client=" + select_Client.SelectValue + " AND State=3");

            if (lists.Count == 0)
            {
                MessageBox.Show(this, "对不起,该客户没有可以申请费用的租赁协议!");
                return;
            }

            foreach (CM_Contract contract in lists)
            {
                CM_ContractBLL bll = new CM_ContractBLL(contract.ID);
                if (bll.Items.Count == 0)
                {
                    continue;
                }

                if (bll.Items[0]["PayEndDate"] == "" || DateTime.Parse(bll.Items[0]["PayEndDate"]) < contract.EndDate)
                {
                    ddl_Contract.Items.Add(new ListItem("合同编号:" + contract["Code"] + " [" + contract.BeginDate.ToString("yyyy-MM-dd") + "至" +
                                                        contract.EndDate.ToString("yyyy-MM-dd") + "]", contract.ID.ToString()));
                }
            }

            if (ddl_Contract.Items.Count > 0)
            {
                ddl_Contract_SelectedIndexChanged(null, null);
                bt_Generate.Enabled = true;
            }
        }
    }
    protected void bt_AddPromotor_Click(object sender, EventArgs e)
    {
        //判断门店返利协议是否已过期
        bool   flag              = true;
        string condition         = " Client=" + ViewState["ClientID"].ToString() + "  AND Classify=2 ";
        IList <CM_Contract> list = CM_ContractBLL.GetModelList(condition);

        foreach (CM_Contract contract in list)
        {
            int currentMonth = AC_AccountMonthBLL.GetCurrentMonth();
            int endMonth     = AC_AccountMonthBLL.GetMonthByDate(contract.EndDate);

            if (contract.State == 3 || contract.State == 9 && endMonth >= currentMonth)
            {
                flag = false;
                break;
            }
        }
        if (!flag)
        {
            MessageBox.Show(this, "当前门店存在返利协议费用");
            return;
        }

        PM_PromotorInRetailerBLL bll = new PM_PromotorInRetailerBLL();

        bll.Model.Client   = int.Parse(ViewState["ClientID"].ToString());
        bll.Model.Promotor = int.Parse(ddl_Promotor.SelectedValue.ToString());
        if (bll.Model.Promotor <= 0)
        {
            MessageBox.Show(this, "导购员未选择,请选择需要添加的导购员!");
            return;
        }
        if (bll._GetModelList(" Promotor=" + bll.Model.Promotor + " and  Client=" + bll.Model.Client).Count > 0)
        {
            MessageBox.Show(this, "该导购员那已经存在!");
            return;
        }
        else
        {
            CM_ClientBLL _cm = new CM_ClientBLL(bll.Model.Client);
            //导购店添加返利协议
            if (_cm.Model["RTClassify"] == "2")
            {
                MessageBox.Show(this, _cm.CheckRealClassifyShowMessage(2));
                return;
            }
            bll.Add();
        }
        ddl_Promotor.SelectedValue = "0";
        BindData();
    }
    private void BindGrid()
    {
        if (ViewState["ClientID"] != null)
        {
            CM_ClientBLL bll = new CM_ClientBLL((int)ViewState["ClientID"]);

            #region 绑定住宿人员
            gv_Staff.ConditionString = "MCS_CM.dbo.CM_StaffInProperty.Client = " + ViewState["ClientID"].ToString() + " AND Org_Staff.Dimission=1";
            gv_Staff.BindGrid();
            #endregion

            #region 绑定兼管片区
            if (bll.Model.OrganizeCity > 1)
            {
                ddl_PropertyInOrganizeCity.Items.Clear();

                int superid = new Addr_OrganizeCityBLL(bll.Model.OrganizeCity).Model.SuperID;
                IList <Addr_OrganizeCity> lists = Addr_OrganizeCityBLL.GetModelList("SuperID = " + superid.ToString() +
                                                                                    " AND ID <> " + bll.Model.OrganizeCity.ToString() +
                                                                                    " AND ID NOT IN (SELECT OrganizeCity FROM MCS_CM.dbo.CM_PropertyInOrganizeCity WHERE Client=" + bll.Model.ID.ToString() + ")");
                if (lists.Count > 0)
                {
                    foreach (Addr_OrganizeCity city in lists)
                    {
                        ddl_PropertyInOrganizeCity.Items.Add(new ListItem("(" + city.Code + ")" + city.Name, city.ID.ToString()));
                    }
                }

                ddl_PropertyInOrganizeCity.Items.Insert(0, new ListItem("请选择...", "0"));

                gv_PropertyInOrganizeCity.BindGrid <Addr_OrganizeCity>(bll.ClientInOrganizeCity_GetOrganizeCitys());
            }
            else
            {
                tr_PropertyInOrganizeCity.Visible = false;
            }
            #endregion

            #region 绑定电话列表
            gv_Telephone.ConditionString = "Client=" + bll.Model.ID.ToString();
            gv_Telephone.BindGrid();
            #endregion

            #region 绑定合同列表
            gv_List_Contract.BindGrid(CM_ContractBLL.GetModelList("Client=" + bll.Model.ID.ToString()));
            #endregion
        }
    }
    private void BindGrid()
    {
        if (ViewState["ClientID"] != null)
        {
            string ConditionStr = "CM_LinkMan.ClientID = " + ViewState["ClientID"].ToString();
            gv_List.ConditionString = ConditionStr;
            gv_List.BindGrid();

            gv_Promotor.ConditionString = "PM_PromotorInRetailer.Client = " + ViewState["ClientID"].ToString();
            gv_Promotor.BindGrid();

            #region 判断是否允许新增导购名单至该店
            //IList<CM_Contract> contracts = CM_ContractBLL.GetModelList("Client= " + ViewState["ClientID"].ToString() +
            //    " AND GETDATE() BETWEEN BeginDate AND DATEADD(day,1,ISNULL(EndDate,GETDATE())) AND State=3");

            //CM_Contract _c = contracts.FirstOrDefault(p => p.Classify == 3);
            //if (_c == null || _c["PromotorCount"] == "" || gv_Promotor.Rows.Count >= int.Parse(_c["PromotorCount"]))
            //{
            //    ddl_Promotor.Enabled = false;
            //    bt_AddPromotor.Enabled = false;
            //}
            //else
            //{
            //    ddl_Promotor.Enabled = true;
            //    bt_AddPromotor.Enabled = true;
            //}
            #endregion

            gv_list01.ConditionString = "CM_Contract.State<8 AND CM_Contract.Client = " + ViewState["ClientID"].ToString();
            gv_list01.BindGrid();

            IList <CM_Contract> _listcontract = CM_ContractBLL.GetModelList("State IN(1,2) AND Classify=2 AND Client=" + ViewState["ClientID"].ToString() + " Order By EndDate DESC");
            if (_listcontract.Count > 0)
            {
                bt_AddContract2.Enabled = false;
                bt_AddContract2.ToolTip = "该门店有未提交或审批中返利协议,请先处理完再新增";
            }
            _listcontract = CM_ContractBLL.GetModelList("State IN(1,2) AND Classify=3 AND Client=" + ViewState["ClientID"].ToString() + " Order By EndDate DESC");
            if (_listcontract.Count > 0)
            {
                bt_AddContract3.Enabled = false;
                bt_AddContract3.ToolTip = "该门店有未提交或审批中导购协议,请先处理完再新增";
            }
        }
    }
    protected void bt_OK_Click(object sender, EventArgs e)
    {
        CM_ContractBLL _bll = null;

        #region 判断合同编码是否重复
        //合同编码的获取
        TextBox tbx_ContractCode = pl_detail.FindControl("CM_Contract_ContractCode") == null ? null : (TextBox)pl_detail.FindControl("CM_Contract_ContractCode");
        if ((int)ViewState["ContractID"] == 0)
        {
            _bll = new CM_ContractBLL();

            if (tbx_ContractCode != null && tbx_ContractCode.Text != "" && CM_ContractBLL.GetModelList("ContractCode='" + tbx_ContractCode.Text.Trim() + "'").Count > 0)
            {
                MessageBox.Show(this, "对不起,合同编码" + tbx_ContractCode.Text.Trim() + "数据库已存在。");
                return;
            }
        }
        else
        {
            _bll = new CM_ContractBLL((int)ViewState["ContractID"]);
            if (tbx_ContractCode != null && tbx_ContractCode.Text != "" && CM_ContractBLL.GetModelList("ContractCode='" + tbx_ContractCode.Text.Trim() + "' AND ID !=" + _bll.Model.ID.ToString()).Count > 0)
            {
                MessageBox.Show(this, "对不起,合同编码" + tbx_ContractCode.Text.Trim() + "数据库已存在。");
                return;
            }
        }
        #endregion

        pl_detail.GetData(_bll.Model);

        ListTable <CM_ContractDetail> _details = ViewState["Details"] as ListTable <CM_ContractDetail>;
        if ((int)ViewState["ContractID"] == 0)
        {
            _bll.Model.Classify     = 21;   //租赁合同
            _bll.Model.State        = 1;
            _bll.Model.ApproveFlag  = 2;
            _bll.Model.InsertTime   = DateTime.Now;
            _bll.Model.InsertStaff  = (int)Session["UserID"];
            _bll.Model.Client       = int.Parse(ViewState["ClientID"].ToString());
            _bll.Items              = _details.GetListItem();
            ViewState["ContractID"] = _bll.Add();
        }
        else
        {
            _bll.Model.UpdateTime  = DateTime.Now;
            _bll.Model.UpdateStaff = (int)Session["UserID"];
            _bll.Update();
            #region 修改明细
            _bll.Items = _details.GetListItem(ItemState.Added);
            _bll.AddDetail();

            foreach (CM_ContractDetail _deleted in _details.GetListItem(ItemState.Deleted))
            {
                _bll.DeleteDetail(_deleted.ID);
            }

            _bll.Items = _details.GetListItem(ItemState.Modified);
            _bll.UpdateDetail();

            #endregion
        }
        if (Request.QueryString["Decision"] != "" && Request.QueryString["Decision"] == "Y")
        {
            MessageBox.Show(this, "协议编码保存成功!");
        }
        else
        {
            MessageBox.ShowAndRedirect(this, "保存物业协议详细信息成功!", "PropertyContractDetail.aspx?ContractID=" + ViewState["ContractID"].ToString());
        }
    }
Exemplo n.º 6
0
    protected void bt_AddToWriteOffList_Click(object sender, EventArgs e)
    {
        ListTable <FNA_FeeWriteOffDetail> _details = Session["FeeWriteOffDetails"] as ListTable <FNA_FeeWriteOffDetail>;
        int maxid = 0;

        if (_details != null)
        {
            if (_details.GetListItem().Count > 0)
            {
                maxid = _details.GetListItem().Max(p => p.ID);
            }
        }
        maxid++;

        foreach (GridViewRow row in gv_FeeAplyList.Rows)
        {
            CheckBox cb_Selected = (CheckBox)row.FindControl("cb_Selected");
            if (cb_Selected.Checked)
            {
                int applyid       = (int)gv_FeeAplyList.DataKeys[row.RowIndex][0];
                int applydetialid = (int)gv_FeeAplyList.DataKeys[row.RowIndex][1];

                FNA_FeeApplyBLL    applyBLL    = new FNA_FeeApplyBLL(applyid);
                FNA_FeeApply       apply       = applyBLL.Model;
                FNA_FeeApplyDetail applydetail = applyBLL.GetDetailModel(applydetialid);

                #region 陈列、返利费用判断协议是否关联合同
                IList <CM_Contract> contractList;
                contractList = CM_ContractBLL.GetModelList(@"ContractCode!='' AND ContractCode=MCS_SYS.dbo.UF_Spilt('" + applydetail.Remark + "',':',2)");
                if (applydetail.RelateContractDetail != 0)
                {
                    int ID = 0;
                    CM_ContractDetail detail = new CM_ContractBLL().GetDetailModel(applydetail.RelateContractDetail);
                    if (detail != null)
                    {
                        ID = detail.ContractID;
                    }
                    contractList = CM_ContractBLL.GetModelList("ID=" + ID.ToString());
                }

                if (contractList.Count > 0 && contractList[0].Classify < 3 && ATMT_AttachmentBLL.GetModelList("RelateType=35 AND RelateID=" + contractList[0].ID.ToString()).Count == 0)
                {
                    MessageBox.Show(this, "陈列、返利费用操作费用核销申请时,门店协议必须上传附件,请上传后再核销!");
                    return;
                }
                #endregion

                FNA_FeeWriteOffDetail m = new FNA_FeeWriteOffDetail();
                m.ID            = maxid++;
                m.ApplyDetailID = applydetialid;
                m.Client        = applydetail.Client;
                m.AccountTitle  = applydetail.AccountTitle;
                m.ProductBrand  = apply.ProductBrand;
                m.ApplyCost     = applydetail.AvailCost;
                m.BeginMonth    = applydetail.BeginMonth;
                m.EndMonth      = applydetail.EndMonth;
                m.BeginDate     = applydetail.BeginDate;
                m.EndDate       = applydetail.EndDate;
                m.WriteOffCost  = applydetail.AvailCost;
                m.Remark        = applydetail.Remark;
                if (applydetail["BankVoucherNo"] != "")
                {
                    m.Remark += ",凭证:" + applydetail["BankVoucherNo"];
                }

                if (applydetail.Remark.IndexOf("是否CA") > 0)
                {
                    m.Remark = applydetail.Remark.Substring(applydetail.Remark.IndexOf("是否CA") - 1);
                }
                if (_details == null)
                {
                    _details = new ListTable <FNA_FeeWriteOffDetail>(new List <FNA_FeeWriteOffDetail>(), "ID");
                }
                _details.Add(m);
            }
        }

        BindGrid();
        gv_FeeAplyList.PageIndex = 0;
        BindFeeApplyNoWriteOff();
    }
Exemplo n.º 7
0
        private static int DoGenerateSalary(int OrganizeCity, int DIClient, int AccountMonth, int Staff, string SalaryClassify, DataTable promotors)
        {
            if (promotors.Select("SalaryClassify=0").Length > 0)
            {
                return(-4);
            }
            string PMClassifys = SalaryClassify == "1" ? "1,4,5" : "3";//专职工资1,兼职工资2 (根据底薪模式进行筛选)


            #region 过滤促销员类别
            DataRow[] row_promotr = promotors.Select("SalaryClassify IN (" + PMClassifys + ")");
            if (row_promotr.Length == 0)
            {
                return(1);                        //该类别无促销员
            }
            #endregion

            AC_AccountMonth month     = new AC_AccountMonthBLL(AccountMonth).Model;
            int             monthDays = month.EndDate.Subtract(month.BeginDate).Days + 1;
            #region 生成工资单头信息
            PM_SalaryBLL bll = new PM_SalaryBLL();
            bll.Model.OrganizeCity  = OrganizeCity;
            bll.Model.AccountMonth  = AccountMonth;
            bll.Model.InputStaff    = Staff;
            bll.Model.State         = 1;
            bll.Model["Client"]     = DIClient.ToString();
            bll.Model["PMClassfiy"] = SalaryClassify;
            #endregion

            #region 依次为每个促销员计算工资单
            decimal target = 0; //目标销量
            foreach (DataRow row in row_promotr)
            {
                PM_Promotor p = new PM_PromotorBLL(int.Parse(row["Promotor"].ToString())).Model;

                if (row["ErrType"].ToString() == "1" || PM_Salary_GetStateByPromotor(p.ID, AccountMonth) > 0)
                {
                    continue;
                }

                PM_SalaryDetail detail = new PM_SalaryDetail();
                #region 获取促销员工资相关信息
                IList <PM_SalaryDataObject> PM_DataList = PM_SalaryDataObjectBLL.GetModelList("ApproveFlag=1 AND Promotor=" + p.ID.ToString() + " and AccountMonth=" + AccountMonth.ToString());
                if (PM_DataList.Count == 0)
                {
                    return(-3);                       //无出勤天数及调整信息
                }
                IList <PM_PromotorSalary> PM_Salary = PM_PromotorSalaryBLL.GetModelList("Promotor=" + p.ID.ToString() + " AND State=3 AND ApproveFlag=1");
                if (PM_Salary.Count == 0)
                {
                    return(-4);               //无薪酬定义
                }
                int[]  InsurancTyps  = { 1 }; //如果工资生成月是导购入职月且保险类型为【给予补贴】,则导购的社保方式为工伤
                string InsuranceMode = p.BeginWorkDate >= month.BeginDate && Array.IndexOf(InsurancTyps, PM_Salary[0].InsuranceMode) != -1 ? "2" : PM_Salary[0].InsuranceMode.ToString();


                #region 取终端门店导购费用协议管理内的管理费分摊比例及提成分摊比例

                #region 实时保存导购信息
                detail["OrganizeCity"] = p.OrganizeCity.ToString();
                detail["Dimission"]    = p.Dimission.ToString();
                IList <PM_PromotorInRetailer> rtlist = PM_PromotorInRetailerBLL.GetModelList("Promotor=" + p.ID.ToString());
                string rts = "";
                foreach (PM_PromotorInRetailer m in rtlist)
                {
                    rts += m.Client.ToString() + ",";
                }
                detail["RetailerS"]        = rts != "" ? rts.Substring(0, rts.Length - 1) : "";
                detail["BankName"]         = p["BankName"];
                detail["AccountCode"]      = p["AccountCode"];
                detail["Classfiy"]         = p["Classfiy"];
                detail["MobileNumber"]     = p.MobileNumber;
                detail["EndWorkDate"]      = p.EndWorkDate.ToString();
                detail["IDCode"]           = p["IDCode"];
                detail["RTManager"]        = rtlist.Count > 0 ? new CM_ClientBLL(rtlist[0].Client).Model.ClientManager.ToString() : "0";
                detail["BasePayMode"]      = PM_Salary[0].ID.ToString();
                detail["MonthDays"]        = monthDays.ToString();
                detail["InsuranceMode"]    = InsuranceMode;
                detail["InsuranceSubsidy"] = InsuranceMode == "1" ? PM_Salary[0].InsuranceSubsidy.ToString() : "0";
                detail["BeginWorkDate"]    = p.BeginWorkDate.ToString();
                #endregion
                decimal             PromotorCostRate  = 0;   //促管费分摊比例
                decimal             PromotorAwardRate = 100; //促销员提成分摊比例
                IList <CM_Contract> CM_ContractList   = CM_ContractBLL.GetModelList("Client=" + row["Client"].ToString() + " AND Classify=3 AND ApproveFlag=1 AND State IN (3,9) AND CM_Contract.EndDate >= '" + month.BeginDate.ToString("yyyy-MM-dd") + "'AND CM_Contract.BeginDate<='" + month.EndDate.ToString("yyyy-MM-dd") + "'");
                if (CM_ContractList.Count > 0)
                {
                    decimal.TryParse(CM_ContractList[0]["PromotorCostRate"], out PromotorCostRate);
                    decimal.TryParse(CM_ContractList[0]["PromotorAwardRate"], out PromotorAwardRate);
                }
                #endregion

                //保险
                IList <PM_StdInsuranceCost> InsuranceCostList = PM_StdInsuranceCostBLL.GetModelList("InsuranceMode=" + InsuranceMode);
                #endregion

                detail.Promotor = p.ID;

                #region 计算促销员提成
                //计算促销员当月实际销量数量或金额
                //DataTable dt = PM_Salary_GetActSalesVolume(AccountMonth, p.ID);

                target                    = PM_DataList[0].SalesTarget;
                detail.ActWorkDays        = PM_DataList[0].ActWorkDays;
                detail.ActSalesVolume     = PM_DataList[0].Data12;                                                                                                          //实际销售额
                detail["MixesSales"]      = PM_DataList[0].Data13.ToString();                                                                                               //冲调部销量
                detail["MilkPowderSales"] = PM_DataList[0].Data14.ToString();                                                                                               //奶粉部销量
                detail.Bonus              = PM_DataList[0].ActWorkDays > 0 && detail.ActSalesVolume > 0 ? Math.Round(PM_DataList[0].Data11 + PM_DataList[0].Data18, 1) : 0; //按销售数量提成,每一分对应一元  Data11总提成
                #endregion

                detail.Pay9 = 0;
                //底薪补贴
                decimal BasePaySubsidy = PM_Salary[0].BasePaySubsidyBeginDate <= month.EndDate && (PM_Salary[0].BasePaySubsidyEndDate == new DateTime(1900, 1, 1) || PM_Salary[0].BasePaySubsidyEndDate.AddDays(1) > month.BeginDate) ? PM_Salary[0].BasePaySubsidy : 0;
                detail.Pay2 = Math.Round(BasePaySubsidy / monthDays * detail.ActWorkDays, 0, MidpointRounding.AwayFromZero);

                #region 获取薪酬信息
                #region 计算底薪
                int basepaymode = PM_Salary[0].BasePayMode;
                if (basepaymode >= 4 && PM_DataList[0]["ISFloating"] != "1")//如果暂不执行浮动底薪,则执行固定底薪
                {
                    basepaymode = 1;
                }

                switch (basepaymode)
                {
                case 1:
                    //固定底薪
                    detail.Pay1 = detail.ActWorkDays > 0 ? Math.Round(PM_Salary[0].BasePay / monthDays * detail.ActWorkDays, 0, MidpointRounding.AwayFromZero) : 0;
                    break;

                case 2:
                    //坎级底薪
                    break;

                case 3:
                    //兼职底薪

                    /*
                     * 1.	底薪计算原则:总销量*8%(我司承担);
                     * 2.	提成计算原则:总销量*6%(根据以分摊的批复为准,默认为我司不承担。);
                     */
                    detail.Pay1 = PM_DataList[0].ActWorkDays > 0 ? Math.Round(PM_DataList[0].Data15 * 0.08m, 0, MidpointRounding.AwayFromZero) : 0;
                    if (detail.Pay1 > 900)
                    {
                        detail.Pay1 = 900;                       //2013-05-08 加入900上限
                    }
                    detail.Bonus = PM_DataList[0].ActWorkDays > 0 && PM_DataList[0].Data15 > 0 ? Math.Round(PM_DataList[0].Data11 + PM_DataList[0].Data18, 1, MidpointRounding.AwayFromZero) : 0;
                    break;

                case 4:    //非华南浮动底薪
                    detail.Pay1 = detail.ActWorkDays > 0 ? Math.Round(PM_Salary[0].BasePay / monthDays * detail.ActWorkDays, 0, MidpointRounding.AwayFromZero) : 0;
                    if (PM_Salary[0]["ISArriveTarget"] != "1" && decimal.Parse(detail["MilkPowderSales"]) >= decimal.Parse(PM_Salary[0]["FloatingTarget"]))
                    {
                        PM_Salary[0]["ISArriveTarget"] = "1";
                        PM_PromotorSalaryBLL _bll = new PM_PromotorSalaryBLL(PM_Salary[0].ID);
                        _bll.Model = PM_Salary[0];
                        _bll.Update();
                    }
                    #region 浮动底薪上限
                    //浮动底薪上限=ROUND(IF(底薪费率*浮动底薪上限任务量<(底薪标准+底薪补贴),(底薪标准+底薪补贴),IF(底薪费率*浮动底薪上限任务量>(底薪标准+底薪补贴)*1.5,(底薪标准+底薪补贴)*1.5,底薪费率*浮动底薪上限任务量)),0)

                    decimal FloatingBasePay = 0m;    //浮动底薪上限
                    if (decimal.Parse(PM_Salary[0]["BaseFeeRate"]) / 100m * decimal.Parse(PM_Salary[0]["FloatingTarget"]) < PM_Salary[0].BasePay + BasePaySubsidy)
                    {
                        FloatingBasePay = PM_Salary[0].BasePay + BasePaySubsidy;
                    }
                    else if (decimal.Parse(PM_Salary[0]["BaseFeeRate"]) / 100m * decimal.Parse(PM_Salary[0]["FloatingTarget"]) > (PM_Salary[0].BasePay + BasePaySubsidy) * 1.5m)
                    {
                        FloatingBasePay = (PM_Salary[0].BasePay + BasePaySubsidy) * 1.5m;
                    }
                    else
                    {
                        FloatingBasePay = decimal.Parse(PM_Salary[0]["BaseFeeRate"]) / 100m * decimal.Parse(PM_Salary[0]["FloatingTarget"]);
                    }
                    #endregion
                    if (PM_Salary[0]["ISArriveTarget"] == "1" && detail.ActWorkDays > 0 && decimal.Parse(PM_Salary[0]["FloatingTarget"]) > 0)
                    {
                        // 浮动底薪补贴= “当月奶粉部实销”÷(“浮动底薪上限任务量”÷会计月天数×实际出勤天数)×浮动底薪上限÷会计月天数×实际出勤天数-(底薪标准+底薪补贴)÷会计月天数×实际出勤天数
                        //a)	当“当月奶粉部实销”÷(“浮动底薪上限任务量”÷会计月天数×实际出勤天数)×浮动底薪上限>“浮动底薪上限”,按“浮动底薪上限”的1.0倍计算;
                        //b)	当“当月奶粉部实销”÷(“浮动底薪上限任务量”÷会计月天数×实际出勤天数)×浮动底薪上限<(“底薪标准”+ “底薪补贴”)的1.0倍,按(“底薪标准”+ “底薪补贴”)的1.0倍计算;

                        decimal compare = decimal.Parse(detail["MilkPowderSales"]) / (decimal.Parse(PM_Salary[0]["FloatingTarget"]) / monthDays * detail.ActWorkDays) * FloatingBasePay;
                        if (compare > FloatingBasePay)
                        {
                            compare = FloatingBasePay;
                        }
                        if (compare < PM_Salary[0].BasePay + BasePaySubsidy)
                        {
                            compare = PM_Salary[0].BasePay + BasePaySubsidy;
                        }

                        detail.Pay9 = (compare > PM_Salary[0].BasePay + BasePaySubsidy) ? ((compare - PM_Salary[0].BasePay - BasePaySubsidy) / monthDays * detail.ActWorkDays) : 0;
                    }
                    else if (detail.ActWorkDays > 0)
                    {
                        //浮动底薪补贴=当月奶粉部实销×底薪费率÷会计月天数×实际出勤天数-(底薪标准+底薪补贴)÷会计月天数×实际出勤天数
                        //a)	当“当月奶粉部实销×底薪费率”>(“底薪标准”+ “底薪补贴”)的1.5倍,按(“底薪标准”+ “底薪补贴”)的1.5倍计算;
                        //b)	当“当月奶粉部实销×底薪费率”<(底薪标准+底薪补贴)的1.0倍,按(“底薪标准”+ “底薪补贴”)的1.0倍计算;
                        decimal compare = decimal.Parse(detail["MilkPowderSales"]) * decimal.Parse(PM_Salary[0]["BaseFeeRate"]) / 100m;
                        if (compare > 1.5m * (PM_Salary[0].BasePay + BasePaySubsidy))
                        {
                            compare = 1.5m * (PM_Salary[0].BasePay + BasePaySubsidy);
                        }
                        if (compare < PM_Salary[0].BasePay + BasePaySubsidy)
                        {
                            compare = PM_Salary[0].BasePay + BasePaySubsidy;
                        }
                        detail.Pay9 = (compare > (PM_Salary[0].BasePay + BasePaySubsidy)) ? ((compare - PM_Salary[0].BasePay - BasePaySubsidy) / monthDays * detail.ActWorkDays) : 0;
                    }
                    //浮动底薪上限: “底薪标准”+“底薪补贴”+ “浮动底薪补贴”的最高限额为“底薪标准”+“底薪补贴”的1.5倍
                    if (PM_Salary[0].BasePay + BasePaySubsidy + detail.Pay9 > FloatingBasePay)
                    {
                        detail.Pay9 = FloatingBasePay - PM_Salary[0].BasePay - BasePaySubsidy;
                    }
                    detail.Pay9 = Math.Round(detail.Pay9, 0, MidpointRounding.AwayFromZero);
                    break;

                case 5:    //华南浮动底薪
                    detail.Pay1 = detail.ActWorkDays > 0 ? Math.Round(PM_Salary[0].BasePay / monthDays * detail.ActWorkDays, 0, MidpointRounding.AwayFromZero) : 0;
                    decimal sales = 0;
                    if (PM_Salary[0]["SalesType"] == "1")
                    {
                        sales = decimal.Parse(detail["MilkPowderSales"]);
                    }
                    else
                    {
                        sales = detail.ActSalesVolume;
                    }
                    //A.	(底薪标准+浮动底薪补贴100元)÷当月实销<=底薪费率
                    //B.	(底薪标准+浮动底薪补贴200元)÷当月实销<=底薪费率
                    //C.	(底薪标准+浮动底薪补贴300元)÷当月实销<=底薪费率
                    decimal FloatingSubsidy = decimal.Parse(PM_Salary[0]["BaseFeeRate"]) / 100m * sales - PM_Salary[0].BasePay;
                    if (FloatingSubsidy < 100)
                    {
                        FloatingSubsidy = 0;
                    }
                    else
                    {
                        FloatingSubsidy = FloatingSubsidy >= 300 ? 300 : (int)Math.Floor(FloatingSubsidy) / 100 * 100;
                    }
                    detail.Pay9 = FloatingSubsidy;
                    break;
                }
                detail.Pay9 = Math.Round(detail.Pay9, 0, MidpointRounding.AwayFromZero);
                #endregion

                #region 计算工龄工资
                //----------------------------工龄工资---------------------------------------------
                //1.陕西营业部-25、云南营业部-29、贵州营业部-31、冀南营业部-34、新疆营业部-30、甘肃营业部-49、冀北营业部-4240,北京营业部-37 销量>=0  50	100	150
                //2.浙江营业部-15、湘北营业部-17、东三省营业部-40、鲁东营业部-48、[黑龙江营业部-41]、[吉林营业部-50]、湘南营业部-4239	,销量>=4000元	 50	100	150
                //3.苏南营业部-12、苏北营业部-13、 湖北营业部-14、四川营业部-23、川南营业部-26、重庆营业部-27,销量>=5000元	                     50	100	150
                //4.皖北营业部-11、江西营业部-18、福建营业部-19、广州营业部-20、粤西营业部-21、粤东营业部-22、广西营业部-24、皖南营业部-4238
                //山西营业部-35、鲁西营业部-36、内蒙营业部-38、豫南营业部-46、豫北营业部-47,豫中营业部-4237,销量>=6000	 50	100	150
                //系统根据导购员的入职时间及福利标准得到工龄补贴标准,再用工龄补贴标准/30*天数(有销量限制的,当不足月的,按销量÷天数×30) 自动计算
                int PMOrganizeCity = TreeTableBLL.GetSuperIDByLevel("MCS_SYS.dbo.Addr_OrganizeCity", p.OrganizeCity, 3);
                if (PM_Salary[0].SeniorityPayMode == 1 && detail.ActWorkDays > 0)
                {
                    int[]    City1   = new int[] { 25, 29, 31, 34, 30, 49, 4240, 37 };
                    int[]    City2   = new int[] { 15, 17, 40, 48, 41, 50, 4239 };
                    int[]    City3   = new int[] { 12, 13, 14, 23, 26, 27 };
                    int[]    City4   = new int[] { 11, 18, 19, 20, 21, 22, 24, 35, 36, 38, 46, 47, 4237, 4238 };
                    DateTime Enddate = p.Dimission == 1 ? month.EndDate : p.EndWorkDate;
                    //计算工龄
                    int SeniorityYear = Enddate.Year - p.BeginWorkDate.Year - 1;

                    if (Enddate >= p.BeginWorkDate.AddYears(Enddate.Year - p.BeginWorkDate.Year))
                    {
                        SeniorityYear++;
                    }

                    SeniorityYear = SeniorityYear > 0 ? SeniorityYear : 0;
                    decimal Seniority = SeniorityYear * 50 > 150 ? 150 : SeniorityYear * 50;

                    if (Array.IndexOf(City1, PMOrganizeCity) != -1 || Array.IndexOf(City2, PMOrganizeCity) != -1 && detail.ActSalesVolume >= 4000 ||
                        (Array.IndexOf(City3, PMOrganizeCity) != -1 && detail.ActSalesVolume >= 5000) || (Array.IndexOf(City4, PMOrganizeCity) != -1 && detail.ActSalesVolume >= 6000))
                    {
                        detail.Pay3 = Math.Round(Seniority / monthDays * detail.ActWorkDays, 0, MidpointRounding.AwayFromZero);
                    }
                    else
                    {
                        detail.Pay3 = 0;
                    }
                }
                else
                {
                    detail.Pay3 = 0;
                }
                #endregion

                //--------------------------我司薪酬明细-----------------------------------------------
                if (InsuranceMode == "1" && PM_Salary[0].InsuranceSubsidy > 0)
                {
                    detail.Pay5 = Math.Round(Convert.ToDecimal(PM_Salary[0].InsuranceSubsidy) / monthDays * detail.ActWorkDays, 0, MidpointRounding.AwayFromZero);
                }
                detail.Pay6  = Math.Round(detail.Bonus * (100 - PromotorAwardRate) / 100, 0, MidpointRounding.AwayFromZero);
                detail.Pay7  = Math.Round(PM_DataList[0].Data10, 1, MidpointRounding.AwayFromZero);                                      //奖惩项
                detail.Pay8  = InsuranceCostList.Count > 0 ? Math.Round(InsuranceCostList[0].StaffCost, 1, MidpointRounding.AwayFromZero) : 0;
                detail.Pay17 = Math.Round(PM_Salary[0].DIFeeSubsidy / monthDays * detail.ActWorkDays, 1, MidpointRounding.AwayFromZero); //我司通讯补贴2014-05-12修改
                for (int i = 1; i < 11; i++)
                {
                    detail.Sum1 += Math.Round(decimal.Parse(detail["Pay" + i.ToString()]), 1);
                }
                detail.Sum1 += detail.Pay17;//我司通讯补贴算导购实得
                //--------------------------我司薪酬明细-----------------------------------------------
                //  社保费用额
                detail.Pay12 = InsuranceCostList.Count > 0 ? Math.Round(InsuranceCostList[0].StaffCost + InsuranceCostList[0].CompanyCost, 1, MidpointRounding.AwayFromZero) : 0;

                if (InsuranceMode == "8")
                {
                    detail.Pay13 = Math.Round(PM_DataList[0].Data17, 1, MidpointRounding.AwayFromZero);                                          //自购保险
                }
                detail.Pay14 = InsuranceCostList.Count > 0 ? Math.Round(InsuranceCostList[0].ServiceCost, 0, MidpointRounding.AwayFromZero) : 0; //派遣服务费

                //--------------------------经销商结构-----------------------------------------------
                detail.Pay16 = Math.Round(PM_Salary[0].DIBasePaySubsidy / monthDays * detail.ActWorkDays, 1, MidpointRounding.AwayFromZero);

                detail.Pay18 = Math.Round(detail.Bonus * PromotorAwardRate / 100, 1, MidpointRounding.AwayFromZero);
                detail.Pay19 = Math.Round(PM_DataList[0].Data19, 1, MidpointRounding.AwayFromZero);

                #region 当总销量为0时,底薪,浮动底薪补贴,我司底薪补贴,工龄工资,保底补贴,社保补贴,我司承担提成,经销商底薪补贴,经销商结构→费用补贴,经销商承担提成 都将数据刷为0
                if (detail.ActSalesVolume == 0)
                {
                    detail.Pay1  = 0;
                    detail.Pay2  = 0;
                    detail.Pay7  = 0;
                    detail.Pay9  = 0;
                    detail.Pay3  = 0;
                    detail.Pay4  = 0;
                    detail.Pay5  = 0;
                    detail.Pay6  = 0;
                    detail.Pay16 = 0;
                    detail.Pay17 = 0;
                    detail.Pay18 = 0;
                }
                #endregion
                //经销商承担薪资合计
                detail.Sum3 = Math.Round(detail.Pay16 + detail.Pay18 + detail.Pay19, 0, MidpointRounding.AwayFromZero);


                #region 计算保底补贴
                //导购实得薪资小计<保底工资       保底补贴=保底标准/30*出勤天数-(底薪+底薪补贴+工龄工资+我司承担提成+浮动底薪补贴+经销薪资合计)
                detail.Sum4 = Math.Round(detail.Pay1 + detail.Pay2 + detail.Pay3 + detail.Pay6 + detail.Pay9 + detail.Sum3, 1, MidpointRounding.AwayFromZero);
                if (detail.ActSalesVolume > 0 && detail.ActWorkDays > 0 && PM_Salary[0].MinimumWageBeginDate <= month.EndDate && detail.Sum4 < PM_Salary[0].MinimumWage &&
                    (PM_Salary[0].MinimumWageEndDate == new DateTime(1900, 1, 1) || PM_Salary[0].MinimumWageEndDate.AddDays(1) > month.BeginDate))
                {
                    detail.Pay4 = Math.Round((PM_Salary[0].MinimumWage / monthDays * detail.ActWorkDays - detail.Sum4), 1, MidpointRounding.AwayFromZero);
                    if (detail.Pay4 < 0)
                    {
                        detail.Pay4 = 0;
                    }
                }

                //重新计算我司实发额
                detail.Sum1 = 0;
                for (int i = 1; i < 11; i++)
                {
                    if (i == 8)
                    {
                        continue;
                    }
                    detail.Sum1 += Math.Round(decimal.Parse(detail["Pay" + i.ToString()]), 1, MidpointRounding.AwayFromZero);
                }
                detail.Sum1 += detail.Pay17;//我司通讯补贴算导购实得
                #endregion
                //含税工资额
                detail.Pay11 = Math.Round(detail.Sum1 - detail.Pay8, 1, MidpointRounding.AwayFromZero);//减社保代扣额
                detail.Tax   = Math.Round(ComputeIncomeTax(detail.Pay11), 0, MidpointRounding.AwayFromZero);
                detail.Sum1  = Math.Round(detail.Pay11 - detail.Tax, 1, MidpointRounding.AwayFromZero);
                detail["PayAdjust_Approve"] = "0";

                if (detail.Sum1 < 0)
                {
                    detail["PayAdjust_Approve"] = (-detail.Sum1).ToString();
                    detail["Remark"]            = "实得薪资小计不能为负,进行冲抵:" + detail["PayAdjust_Approve"];
                    detail.Sum1  = 0;
                    detail.Pay11 = detail.Sum1;
                }
                if (detail.Sum3 < 0)
                {
                    detail.Sum3 = 0;
                }
                //重新计算导购实得薪资小计
                detail.Sum4 = Math.Round(detail.Sum1 + detail.Sum3, 1, MidpointRounding.AwayFromZero);

                #endregion

                //我司导购费用小计
                detail.Sum2 = Math.Round(detail.Pay11 + detail.Pay12 + detail.Pay14 + detail.Pay13, 1, MidpointRounding.AwayFromZero);

                //导购薪资合计
                detail.TotalSalary = Math.Round(detail.Sum2 + detail.Sum3, 1, MidpointRounding.AwayFromZero);
                //----------------------------------管理费明细-----------------------------------------
                #region 判断是否要生成管理费申请单
                DataRow[] rows = promotors.Select("Promotor=" + p.ID);
                if (decimal.Parse(rows[0]["PMFee"].ToString()) > 0)
                {
                    detail["PMFee"]           = detail.ActWorkDays == 0 ? "0" : (Math.Round(decimal.Parse(rows[0]["PMFee"].ToString()) + PM_DataList[0].Data20, 1, MidpointRounding.AwayFromZero)).ToString();
                    detail["IsGeneratePMFee"] = "2";
                }
                else
                {
                    detail["PMFee"] = detail.ActWorkDays == 0 ? "0" : (PM_Salary[0].RTManageCost + PM_DataList[0].Data20).ToString("0.0");
                }
                #endregion

                detail["PMFee1"]     = PM_DataList[0].Data30.ToString("0.0");
                detail["PMFee2"]     = (decimal.Parse(detail["PMFee"]) * (100 - PromotorCostRate) / 100).ToString("0.0");
                detail.CoPMFee       = decimal.Parse(detail["PMFee1"]) + decimal.Parse(detail["PMFee2"]);
                detail.DIPMFee       = decimal.Parse(detail["PMFee"]) * PromotorCostRate / 100;
                detail.PMFeeTotal    = detail.CoPMFee + detail.DIPMFee;
                detail["FlagCancel"] = "2";

                bll.Items.Add(detail);
            }
            #endregion

            if (bll.Items.Count > 0)
            {
                return(bll.Add());
            }
            else
            {
                return(0);
            }
        }
Exemplo n.º 8
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;
            }
        }
    }