コード例 #1
0
    private void Bind()
    {
        CM_ContractBLL _cmbll = new CM_ContractBLL((int)ViewState["ContractID"]);
        lb_Code.Text = _cmbll.Model.ContractCode;
        lb_Supplier.InnerText = lb_Supplier2.InnerText = getSupplier(_cmbll.Model.Client);

        CM_ClientBLL _client = new CM_ClientBLL(_cmbll.Model.Client);
        lb_Client.InnerText = lb_Client3.InnerText = _client.Model.FullName;
        if (_client.Model["IsRMSClient"] != "2" && _client.Model["IsRMSClient"] != "0")
        {
            lbl_fjfjp.InnerHtml = "      α金装袋装400G 、能慧全品项、新配方全品项、米粉全品项      ";
            lbl_fjffl.InnerHtml = "      17      ";
            lbl_fjfxdcp.InnerHtml = "      α金装三联包      ";
            lbl_fjfxdcpfl.InnerHtml = "      10      ";
            lbl_jfcp.InnerHtml = "                                    /                                                      ";
            lbl_jffl.InnerHtml = "      /      ";
            lbl_wfljf.InnerHtml = "    雅士利金装、超级金装、普装安贝慧全品项、α金装罐装900G及盒装400G    ";
        }
        else
        {
            lbl_fjfjp.InnerHtml = "      α金装袋装400G 、能慧全品项、新配方全品项、米粉全品项      ";
            lbl_fjffl.InnerHtml = "      17      ";
            lbl_fjfxdcp.InnerHtml = "      α金装三联包      ";
            lbl_fjfxdcpfl.InnerHtml = "      10      ";
            lbl_jfcp.InnerHtml = "    普装安贝慧全品项、α金装罐装900G及盒装400G     ";
            lbl_jffl.InnerHtml = "      10      ";
            lbl_wfljf.InnerHtml = "    雅士利金装及超级金装     ";
        }
        lb_StartTime.InnerText = _cmbll.Model.BeginDate.ToString("yyyy年MM月dd日");
        lb_EndTime.InnerText = _cmbll.Model.EndDate.ToString("yyyy年MM月dd日");
        lb_ClientAccount.InnerText = _cmbll.Model["BankAccountNo"].ToString();
        lb_AccountName.InnerText = _cmbll.Model["BankName"].ToString();
        lb_Client2.InnerText = _cmbll.Model["AccountName"];
        //lb_Percent.InnerText = "甲方:" + _cmbll.Model["RebateRate"] + "+" + "乙方:" + _cmbll.Model["DIRebateRate"] + "=" + ((decimal.Parse(_cmbll.Model["RebateRate"]) + decimal.Parse(_cmbll.Model["DIRebateRate"])).ToString("0.##"));
    }
コード例 #2
0
    protected void ddl_Contract_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (ddl_Contract.SelectedValue != "" && ddl_Contract.SelectedValue != "0")
        {
            CM_ContractBLL bll = new CM_ContractBLL(int.Parse(ddl_Contract.SelectedValue));
            if (bll.Items.Count == 0)
            {
                return;
            }

            if (bll.Items[0]["PayEndDate"] == "")
            {
                tbx_BeginDate.Text = bll.Model.BeginDate.ToString("yyyy-MM-dd");
            }
            else
            {
                tbx_BeginDate.Text = DateTime.Parse(bll.Items[0]["PayEndDate"]).AddDays(1).ToString("yyyy-MM-dd");
            }

            tbx_BeginDate.Enabled = false;

            DateTime enddate = DateTime.Parse(tbx_BeginDate.Text).AddMonths(bll.Items[0].PayMode).AddDays(-1);
            if (enddate > bll.Model.EndDate)
            {
                enddate = bll.Model.EndDate;
            }
            tbx_EndDate.Text = enddate.ToString("yyyy-MM-dd");
        }
    }
コード例 #3
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;
            }
        }
    }
コード例 #4
0
    protected string GetContractPageURL(int contractdetailid)
    {
        if (contractdetailid > 0)
        {
            CM_ContractDetail d = new CM_ContractBLL().GetDetailModel(contractdetailid);
            if (d == null)
            {
                return("");
            }
            CM_Contract c = new CM_ContractBLL(d.ContractID).Model;
            if (c != null)
            {
                switch (c.Classify)
                {
                case 1:
                case 2:
                case 3:
                    return("~/SubModule/CM/RT/RetailerContractDetail.aspx?ContractID=" + c.ID.ToString());

                case 21:
                    return("~/SubModule/CM/PD/PropertyContractDetail.aspx?ContractID=" + c.ID.ToString());
                }
            }
        }
        return("");
    }
コード例 #5
0
    protected void bt_Export_Click(object sender, EventArgs e)
    {
        string condition = "";

        if (tbx_ContractID.Text.Trim() != "")
        {
            int id = 0;
            if (int.TryParse(tbx_ContractID.Text, out id))
            {
                condition = " AND CM_Contract.ID=" + id;
            }
            else
            {
                MessageBox.Show(this, "协议ID填写有问题!");
                tbx_ContractID.Focus();
            }
        }
        else
        {
            if (select_OrgSupplier.SelectValue != "" && select_OrgSupplier.SelectValue != "0")
            {
                condition = " AND CM_Contract.Client=" + select_OrgSupplier.SelectValue;
            }
        }
        DataTable dt = CM_ContractBLL.GetApproveSummary(int.Parse(tr_OrganizeCity.SelectValue), int.Parse(ddl_State.SelectedValue), (int)Session["UserID"], int.Parse(MCSTabControl1.SelectedTabItem.Value), int.Parse(ddl_PayMode.SelectedValue), condition);;

        //string name = "";
        //if (MCSTabControl1.SelectedIndex == 0)
        //    name = "零售商导购协议导出";
        //else name = "零售商返利协议导出";
        // CreateExcel(dt, "Export-" + name + DateTime.Now.ToString("yyyyMMdd-HHmmss"));
        getExcel(dt);
    }
コード例 #6
0
    protected void cb_Selected_CheckedChanged(object sender, EventArgs e)
    {
        //81,80,82 常规导购管理费(月付类)临时导购管理费(工服工卡等费用项)兼职导购工资次次月核销10日核销
        //SuperID IN (176,73)陈列费 月付,季度付 次月10号才能核销

        CheckBox           t              = (CheckBox)sender;
        GridViewRow        drv            = (GridViewRow)t.NamingContainer;
        int                rowIndex       = drv.RowIndex;
        int                applydetailid  = (int)gv_FeeAplyList.DataKeys[rowIndex]["FNA_FeeApplyDetail_ID"];
        FNA_FeeApplyDetail applydetail    = new FNA_FeeApplyBLL().GetDetailModel(applydetailid);
        CM_ContractDetail  contractdetail = new CM_ContractBLL().GetDetailModel(applydetail.RelateContractDetail);

        try
        {
            if (applydetail.AccountTitle == 81 && applydetail.Remark.IndexOf("合同编号") >= 0)
            {
                return;
            }
            if (applydetail.AccountTitle >= 80 && applydetail.AccountTitle <= 82)
            {
                t.Checked = CheckLimitWriteOffDate(applydetail.BeginMonth + 2);
            }
            else if (AC_AccountTitleBLL.GetModelList("SuperID IN (176,73)").Where(p => p.ID == applydetail.AccountTitle).ToList().Count > 0 &&
                     contractdetail != null && contractdetail.PayMode != 12 && contractdetail.PayMode != 6 && contractdetail.BearMode == 1)
            {
                t.Checked = CheckLimitWriteOffDate(applydetail.BeginMonth + 1);
            }
        }
        catch (Exception)
        {
            throw;
        }
    }
コード例 #7
0
    /// <summary>
    /// 获取最早的付款截止日期
    /// </summary>
    /// <param name="bll"></param>
    /// <returns></returns>
    private DateTime GetMinPayDate(CM_ContractBLL bll)
    {
        DateTime minpaydate = bll.Model.EndDate;

        foreach (CM_ContractDetail item in bll.Items)
        {
            IList <FNA_FeeApplyDetail> feeapplydetails = new FNA_FeeApplyBLL().GetDetail
                                                             ("Client = " + select_Client.SelectValue + " AND RelateContractDetail = " + item.ID.ToString() +
                                                             " AND Flag<>3");
            if (feeapplydetails.Count == 0)
            {
                minpaydate = bll.Model.BeginDate;
                break;
            }
            else
            {
                DateTime _date = feeapplydetails.Max(p => p.EndDate).AddDays(1);
                if (_date < minpaydate)
                {
                    minpaydate = _date;
                }
            }
        }

        return(minpaydate);
    }
コード例 #8
0
    protected void bt_del_Click(object sender, EventArgs e)
    {
        CM_ContractBLL _bll   = new CM_ContractBLL((int)ViewState["ContractID"]);
        int            Client = _bll.Model.Client;

        _bll.Delete();
        MessageBox.ShowAndRedirect(this, "删除成功!", "PropertyDetail.aspx?ClientID=" + Client.ToString());
    }
コード例 #9
0
    protected void bt_Disable_Click(object sender, EventArgs e)
    {
        CM_ContractBLL _bll = new CM_ContractBLL((int)ViewState["ContractID"]);

        if (_bll != null && _bll.Model.ApproveFlag == 1 && _bll.Model.State == 3)
        {
            _bll.Disable((int)Session["UserID"]);
            MessageBox.ShowAndRedirect(this, "协议中止成功!", "PropertyDetail.aspx?ClientID=" + _bll.Model.Client.ToString());
        }
    }
コード例 #10
0
    private void BindGrid()
    {
        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);

        gv_List.Visible       = (MCSTabControl1.SelectedIndex == 0);
        gv_ListDetail.Visible = (MCSTabControl1.SelectedIndex == 1);
        bt_Approved.Visible   = (MCSTabControl1.SelectedIndex == 0);
        bt_UnApproved.Visible = (MCSTabControl1.SelectedIndex == 1);

        switch (MCSTabControl1.SelectedTabItem.Value)
        {
        case "0":
        {
            #region 显示统计分析
            DataTable dtSummary = CM_ContractBLL.GetPMSummary(organizecity, level, state, (int)Session["UserID"], rtchannel);
            if (dtSummary.Rows.Count == 0)
            {
                gv_List.DataBind();
            }

            gv_List.DataSource = dtSummary;
            gv_List.DataBind();
            MatrixTable.GridViewMatric(gv_List);
            #endregion
        }
        break;

        case "1":
        {
            DataTable dtList = CM_ContractBLL.GetPMListDetail(organizecity, level, state, (int)Session["UserID"], rtchannel);
            gv_ListDetail.DataSource = dtList;
            gv_ListDetail.BindGrid();
        }
        break;
        }

        #region 是否可以批量审批
        if (state != 1)
        {
            bt_Approved.Visible   = false;
            bt_UnApproved.Visible = false;
            if (gv_ListDetail.Visible)
            {
                gv_ListDetail.Columns[0].Visible = false;
                gv_ListDetail.Columns[1].Visible = false;
            }
        }


        #endregion
    }
コード例 #11
0
    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();
    }
コード例 #12
0
    protected void bt_Generate_Click(object sender, EventArgs e)
    {
        int month        = int.Parse(ddl_Month.SelectedValue);
        int organizectiy = 0;
        int client       = 0;

        int.TryParse(tr_OrganizeCity.SelectValue, out organizectiy);
        int.TryParse(select_Client.SelectValue, out client);

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

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

        int FeeType = 0;

        if (rbl_IsNKA.SelectedValue == "1")
        {
            FeeType = ConfigHelper.GetConfigInt("ContractFeeType-KA");
        }
        else
        {
            FeeType = ConfigHelper.GetConfigInt("ContractFeeType");
        }

        int id = CM_ContractBLL.CreateCLFeeApply(organizectiy, month, client, (int)Session["UserID"], rbl_IsNKA.SelectedValue == "1", FeeType);

        if (id > 0)
        {
            MessageBox.ShowAndRedirect(this, "陈列费用申请单生成成功!", "FeeApplyDetail3.aspx?ID=" + id.ToString());
        }
        else if (id == 0)
        {
            MessageBox.Show(this, "对不起,目前尚无陈列合同需要申请费用!");
        }
        else if (id == -1)
        {
            MessageBox.Show(this, "对不起,已经生成过陈列合同费用申请单,请勿重复申请!");
        }
        else
        {
            MessageBox.Show(this, "对不起,陈列合同费用申请单生成失败!错误码:" + id.ToString());
        }
    }
コード例 #13
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            #region 获取页面参数
            if (Request.QueryString["ClientID"] != null)
            {
                ViewState["ClientID"] = Int32.Parse(Request.QueryString["ClientID"]);
                Session["ClientID"]   = ViewState["ClientID"];
            }
            else if (Session["ClientID"] != null)
            {
                ViewState["ClientID"] = Int32.Parse(Session["ClientID"].ToString());
            }

            ViewState["ContractID"] = Request.QueryString["ContractID"] == null ? 0 : int.Parse(Request.QueryString["ContractID"]);
            #endregion

            BindDropDown();

            if ((int)ViewState["ContractID"] != 0)
            {
                CM_Contract _contract = new CM_ContractBLL((int)ViewState["ContractID"]).Model;
                if (_contract != null)
                {
                    ViewState["ClientID"] = _contract.Client;
                }
            }

            if (ViewState["ClientID"] != null && (int)ViewState["ClientID"] > 0)
            {
                CM_Client c = new CM_ClientBLL((int)ViewState["ClientID"]).Model;
                select_Client.SelectText  = c.FullName;
                select_Client.SelectValue = c.ID.ToString();
                select_Client_SelectChange(null, null);
                //tr_OrganizeCity.SelectValue = c.OrganizeCity.ToString();
            }

            if ((int)ViewState["ContractID"] != 0)
            {
                ListItem item = ddl_Contract.Items.FindByValue(ViewState["ContractID"].ToString());
                if (item != null)
                {
                    ddl_Contract.ClearSelection();
                    item.Selected = true;
                    ddl_Contract_SelectedIndexChanged(null, null);
                }
            }
        }
    }
コード例 #14
0
    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
        }
    }
コード例 #15
0
    protected void bt_Submit_Click(object sender, EventArgs e)
    {
        CM_ContractBLL _bll   = new CM_ContractBLL((int)ViewState["ContractID"]);
        CM_Client      client = new CM_ClientBLL(_bll.Model.Client).Model;

        if (_bll.Items.Count == 0)
        {
            MessageBox.Show(this, "对不起,物业租赁合同必须要录入合同具体的付款科目才能提交申请!");
            return;
        }
        decimal applycost = _bll.Items.Sum(p => p.ApplyLimit);

        NameValueCollection dataobjects = new NameValueCollection();

        dataobjects.Add("ID", _bll.Model.ID.ToString());
        dataobjects.Add("Classify", _bll.Model.Classify.ToString());
        dataobjects.Add("ApplyCost", applycost.ToString("0.##"));

        dataobjects.Add("OrganizeCityID", client.OrganizeCity.ToString());
        dataobjects.Add("PDClassify", client["PDClassify"]);        //物业类别

        #region 组织任务标题
        string _title    = "";
        Label  lb_Client = (Label)pl_detail.FindControl("CM_Contract_Client");
        if (lb_Client != null)
        {
            _title += "物业名称:" + lb_Client.Text;
        }

        if (_bll.Model.ContractCode != "")
        {
            _title += " 合同编码:" + _bll.Model.ContractCode;
        }
        #endregion

        int TaskID = EWF_TaskBLL.NewTask("CM_Contract_Flow", (int)Session["UserID"], _title,
                                         "~/SubModule/CM/PD/PropertyDetail.aspx?ClientID=" + _bll.Model.Client.ToString(), dataobjects);
        if (TaskID > 0)
        {
            _bll.Model.State       = 2;
            _bll.Model.ApproveTask = TaskID;
            _bll.Update();
            new EWF_TaskBLL(TaskID).Start();        //直接启动流程
        }

        Response.Redirect("~/SubModule/EWF/TaskDetail.aspx?TaskID=" + TaskID.ToString());
    }
コード例 #16
0
    private string GetNeedMeApproveTaskIDs()
    {
        if (MCSTabControl1.SelectedIndex == 0)
        {
            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);
            string taskids      = "";

            DataTable dt = CM_ContractBLL.GetPMList(organizecity, level, state, (int)Session["UserID"], rtchannel);

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (dt.Rows[i]["ApproveTask"].ToString() != "" && dt.Rows[i]["ApproveTask"].ToString() != "NULL")
                {
                    taskids += dt.Rows[i]["ApproveTask"].ToString() + ",";
                }
            }

            if (taskids.EndsWith(","))
            {
                taskids = taskids.Substring(0, taskids.Length - 1);
            }

            return(taskids);
        }
        else if (MCSTabControl1.SelectedIndex == 1)
        {
            string ids = "";
            foreach (GridViewRow row in gv_ListDetail.Rows)
            {
                Object cbx = row.FindControl("chk_ID");
                if (cbx != null && ((CheckBox)cbx).Checked)
                {
                    if (ids != "")
                    {
                        ids += ",";
                    }
                    ids += gv_ListDetail.DataKeys[row.RowIndex][1].ToString();
                }
            }
            return(ids);
        }
        return("");
    }
コード例 #17
0
    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 = "该门店有未提交或审批中导购协议,请先处理完再新增";
            }
        }
    }
コード例 #18
0
    protected void bt_Generate_Click(object sender, EventArgs e)
    {
        int month        = int.Parse(ddl_Month.SelectedValue);
        int organizecity = 0;
        int client       = 0;

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

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

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


        int FeeType = 0;

        FeeType = ConfigHelper.GetConfigInt("ContractFeeType-PM");

        int id = CM_ContractBLL.CreatePMFeeApply(organizecity, month, client, (int)Session["UserID"], FeeType);

        if (id > 0)
        {
            MessageBox.ShowAndRedirect(this, "导购管理费申请单生成成功!", "FeeApplyDetail3.aspx?ID=" + id.ToString());
        }
        else if (id == 0)
        {
            MessageBox.Show(this, "对不起,目前尚无返利合同需要申请费用!");
        }
        else if (id == -1)
        {
            MessageBox.Show(this, "对不起,无导购管理费用生成!请检查是否之前已经生成该月的导购管理费用!");
        }
        else
        {
            MessageBox.Show(this, "对不起,导购管理费申请单生成失败!错误码:" + id.ToString());
        }
    }
コード例 #19
0
 private void BindData()
 {
     CM_ContractBLL _cmbll = new CM_ContractBLL((int)ViewState["ContractID"]);
     lb_client.Text = new CM_ClientBLL(_cmbll.Model.Client).Model.FullName;
     lbl_partyB.Text = new CM_ClientBLL(_cmbll.Model.Client).Model.FullName;
     IList<CM_ContractDetail> _listDetail = _cmbll.Items;
     foreach (CM_ContractDetail detail in _listDetail)
     {
         chk_BZ.Checked = (detail.AccountTitle == 142 || detail.AccountTitle == 186);//包柱
         chk_ZG.Checked = (detail.AccountTitle == 143 || detail.AccountTitle == 187);//专柜
         chk_DJ.Checked = (detail.AccountTitle == 144 || detail.AccountTitle == 188);//端架
         chk_DT.Checked = (detail.AccountTitle == 145 || detail.AccountTitle == 189);//端架
     }
     lbl_time.Text = _cmbll.Model.BeginDate.ToString("yyyy年MM月dd日") + "-----" + _cmbll.Model.EndDate.ToString("yyyy年MM月dd日");
     lb_TotalCost.Text = _listDetail.Sum(p => p.ApplyLimit).ToString("0.##");
     lb_TotalCostCN.Text = MCSFramework.Common.Rmb.CmycurD(lb_TotalCost.Text);
     lbl_SignMan.Text = _cmbll.Model.SignMan != "" ? _cmbll.Model.SignMan : "_________________";
 }
コード例 #20
0
    protected void bt_Export_Click(object sender, EventArgs e)
    {
        switch (MCSTabControl1.SelectedTabItem.Value)
        {
        case "0":
        {
            gv_List.AllowPaging = false;
            BindGrid();
            Response.Clear();
            string filename = HttpUtility.UrlEncode("预付导购管理费用汇总单导出_" + DateTime.Now.ToString("yyyyMMddHHmmss"));
            Response.Charset         = "UTF-8";
            Response.ContentEncoding = System.Text.Encoding.UTF8;
            Response.ContentType     = "application/vnd.ms-excel";
            Response.BufferOutput    = true;
            Response.AppendHeader("Content-Disposition", "attachment;filename=" + filename + ".xls");
            Page.EnableViewState = false;
            StringWriter   tw = new System.IO.StringWriter();
            HtmlTextWriter hw = new HtmlTextWriter(tw);
            gv_List.RenderControl(hw);
            StringBuilder outhtml = new StringBuilder(tw.ToString());
            outhtml = outhtml.Replace("&nbsp;", "");
            Response.Write(outhtml.ToString());
            Response.End();
            Page.EnableViewState = true;
            gv_List.AllowPaging  = true;
            break;
        }

        case "1":
        {
            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);
            DataTable dtList       = CM_ContractBLL.GetPMListDetail(organizecity, level, state, (int)Session["UserID"], rtchannel);
            dtList.Columns["ApproveTask"].ColumnName = "流程ID";
            string filename = HttpUtility.UrlEncode("预付导购管理费用明细导出_" + DateTime.Now.ToString("yyyyMMddHHmmss"));
            DataTableToExcel(dtList, filename);
            break;
        }
        }
        BindGrid();
    }
コード例 #21
0
    private void BindData()
    {
        CM_ContractBLL _cmbll = new CM_ContractBLL((int)ViewState["ContractID"]);

        lb_client.Text  = new CM_ClientBLL(_cmbll.Model.Client).Model.FullName;
        lbl_partyB.Text = new CM_ClientBLL(_cmbll.Model.Client).Model.FullName;
        IList <CM_ContractDetail> _listDetail = _cmbll.Items;

        foreach (CM_ContractDetail detail in _listDetail)
        {
            chk_BZ.Checked = (detail.AccountTitle == 142 || detail.AccountTitle == 186); //包柱
            chk_ZG.Checked = (detail.AccountTitle == 143 || detail.AccountTitle == 187); //专柜
            chk_DJ.Checked = (detail.AccountTitle == 144 || detail.AccountTitle == 188); //端架
            chk_DT.Checked = (detail.AccountTitle == 145 || detail.AccountTitle == 189); //端架
        }
        lbl_time.Text       = _cmbll.Model.BeginDate.ToString("yyyy年MM月dd日") + "-----" + _cmbll.Model.EndDate.ToString("yyyy年MM月dd日");
        lb_TotalCost.Text   = _listDetail.Sum(p => p.ApplyLimit).ToString("0.##");
        lb_TotalCostCN.Text = MCSFramework.Common.Rmb.CmycurD(lb_TotalCost.Text);
        lbl_SignMan.Text    = _cmbll.Model.SignMan != "" ? _cmbll.Model.SignMan : "_________________";
    }
コード例 #22
0
    protected void bt_SetEndDate_Click(object sender, EventArgs e)
    {
        AC_AccountMonth maxendmonth = new AC_AccountMonthBLL(AC_AccountMonthBLL.GetCurrentMonth() + 1).Model;
        CM_ContractBLL  _bll        = new CM_ContractBLL((int)ViewState["ContractID"]);

        if (_bll != null && _bll.Model.ApproveFlag == 1 && _bll.Model.State == 3)
        {
            if (Convert.ToDateTime(txt_EndDate.Text.ToString().Trim()) > _bll.Model.EndDate)
            {
                MessageBox.Show(this, "设定截止日期不能大于原有截止日期!");
                return;
            }
            if (_bll.Model.EndDate <= _bll.Model.BeginDate)
            {
                MessageBox.Show(this, "对不起,合同起始日期不能大于截止日期!");
                return;
            }
            _bll.Model.EndDate = Convert.ToDateTime(txt_EndDate.Text.ToString().Trim());

            if (_bll.Model.EndDate > maxendmonth.EndDate)
            {
                MessageBox.Show(this, "对不起,截止日期最大值为" + maxendmonth.EndDate.ToString("yyyy-MM-dd") + "。");
                return;
            }
            //导购工资
            if (_bll.Model.Classify == 3)
            {
                int lastmonth   = _bll.CheckPMFeeApplyLastMonth();
                int conendmonth = AC_AccountMonthBLL.GetMonthByDate(_bll.Model.EndDate.AddDays(1));
                if (conendmonth <= lastmonth)
                {
                    MessageBox.Show(this, "对不起,该协议已生成预付管理费申请单,请重新填写终止日期(截止日期最小值为" + new AC_AccountMonthBLL(lastmonth).Model.EndDate.ToString("yyyy-MM-dd") + ")!");
                    return;
                }
            }

            _bll.Update();
            _bll.Disable((int)Session["UserID"]);
            MessageBox.ShowAndClose(this, "协议中止成功!");
        }
    }
コード例 #23
0
    private void Approve(int state)
    {
        int userid = (int)Session["UserID"];

        foreach (GridViewRow row in gv_List.Rows)
        {
            Object cbx = row.FindControl("chk_ID");
            if (cbx != null && ((CheckBox)cbx).Checked)
            {
                Object tbx    = row.FindControl("tbx_Remark");
                string Remark = "";
                if (tbx != null && !string.IsNullOrEmpty(((TextBox)tbx).Text))
                {
                    Remark = ((TextBox)tbx).Text;
                }
                else
                {
                    Remark = state == 2 ? "汇总单批量审批通过!" : "汇总单批量审批不通过!";
                }
                int            contractid = (int)gv_List.DataKeys[row.RowIndex]["ID"];
                CM_ContractBLL con        = new CM_ContractBLL(contractid);
                int            taskid     = con.Model.ApproveTask;
                if (taskid > 0)
                {
                    int jobid = EWF_TaskBLL.StaffCanApproveTask(taskid, userid);
                    if (jobid > 0)
                    {
                        EWF_Task_JobBLL job = new EWF_Task_JobBLL(jobid);
                        if (job != null)
                        {
                            int decisionid = job.StaffCanDecide(userid);
                            if (decisionid > 0)
                            {
                                job.Decision(decisionid, userid, state, Remark);
                            }
                        }
                    }
                }
            }
        }
    }
コード例 #24
0
    public void BindData()
    {
        CM_Contract c = new CM_ContractBLL((int)ViewState["ContractID"]).Model;

        if (c != null)
        {
            ViewState["ClientID"] = c.Client;
            pl_detail.BindData(c);
            BindGrid();
            UploadFile1.RelateID = c.ID;

            if (c.ApproveFlag == 1 || c.State > 1)
            {
                //已审核
                pl_detail.SetControlsEnable(false);
                bt_Submit.Visible    = false;
                bt_OK.Visible        = false;
                tr_AddDetail.Visible = false;
                bt_AddDetail.Visible = false;
                gv_Detail.Columns[gv_Detail.Columns.Count - 1].Visible = false;
                bt_del.Visible = false;

                UploadFile1.CanDelete = false;
                //UploadFile1.CanUpload = false;
            }

            if (c.State != 3)
            {
                bt_FeeApply.Visible = false;
                bt_Disable.Visible  = false;
            }
            ///审批过程中,可以修改编码 Decision参数为在审批过程中传进来的参数
            //if (Request.QueryString["Decision"] != "" && Request.QueryString["Decision"] == "Y")
            //{
            //    bt_OK.Visible = true;
            //    gv_Detail.Enabled = false;
            //    pl_detail.SetControlsEnable(true);
            //}
        }
    }
コード例 #25
0
    protected void bt_SetEndDate_Click(object sender, EventArgs e)
    {
        AC_AccountMonth maxendmonth = new AC_AccountMonthBLL(AC_AccountMonthBLL.GetCurrentMonth() + 1).Model;
        CM_ContractBLL _bll = new CM_ContractBLL((int)ViewState["ContractID"]);
        if (_bll != null && _bll.Model.ApproveFlag == 1 && _bll.Model.State == 3)
        {
            if (Convert.ToDateTime(txt_EndDate.Text.ToString().Trim()) > _bll.Model.EndDate)
            {
                MessageBox.Show(this, "设定截止日期不能大于原有截止日期!");
                return;
            }
            if (_bll.Model.EndDate <= _bll.Model.BeginDate)
            {
                MessageBox.Show(this, "对不起,合同起始日期不能大于截止日期!");
                return;
            }
            _bll.Model.EndDate =Convert.ToDateTime(txt_EndDate.Text.ToString().Trim());

            if (_bll.Model.EndDate > maxendmonth.EndDate)
            {
                MessageBox.Show(this, "对不起,截止日期最大值为" + maxendmonth.EndDate.ToString("yyyy-MM-dd") + "。");
                return;
            }
            //导购工资
            if (_bll.Model.Classify == 3)
            {
                int lastmonth = _bll.CheckPMFeeApplyLastMonth();
                int conendmonth =AC_AccountMonthBLL.GetMonthByDate(_bll.Model.EndDate.AddDays(1));
                if (conendmonth <= lastmonth)
                {
                    MessageBox.Show(this, "对不起,该协议已生成预付管理费申请单,请重新填写终止日期(截止日期最小值为" + new AC_AccountMonthBLL(lastmonth).Model.EndDate.ToString("yyyy-MM-dd") + ")!");
                    return;
                }
            }

            _bll.Update();
            _bll.Disable((int)Session["UserID"]);
            MessageBox.ShowAndClose(this, "协议中止成功!");
        }
    }
コード例 #26
0
    public void BindData()
    {
        CM_Contract c = new CM_ContractBLL((int)ViewState["ContractID"]).Model;
        if (c != null)
        {
            ViewState["ClientID"] = c.Client;
            pl_detail.BindData(c);
            BindGrid();
            UploadFile1.RelateID = c.ID;

            if (c.ApproveFlag == 1 || c.State > 1)
            {
                //已审核
                pl_detail.SetControlsEnable(false);
                bt_Submit.Visible = false;
                bt_OK.Visible = false;
                tr_AddDetail.Visible = false;
                bt_AddDetail.Visible = false;
                gv_Detail.Columns[gv_Detail.Columns.Count - 1].Visible = false;
                bt_del.Visible = false;

                UploadFile1.CanDelete = false;
                //UploadFile1.CanUpload = false;
            }

            if (c.State != 3)
            {
                bt_FeeApply.Visible = false;
                bt_Disable.Visible = false;
            }
            ///审批过程中,可以修改编码 Decision参数为在审批过程中传进来的参数
            //if (Request.QueryString["Decision"] != "" && Request.QueryString["Decision"] == "Y")
            //{
            //    bt_OK.Visible = true;
            //    gv_Detail.Enabled = false;
            //    pl_detail.SetControlsEnable(true);
            //}
        }
    }
コード例 #27
0
    private void Bind()
    {
        CM_ContractBLL _cmbll = new CM_ContractBLL((int)ViewState["ContractID"]);

        lb_Code.Text          = _cmbll.Model.ContractCode;
        lb_Supplier.InnerText = lb_Supplier2.InnerText = getSupplier(_cmbll.Model.Client);

        CM_ClientBLL _client = new CM_ClientBLL(_cmbll.Model.Client);

        lb_Client.InnerText = lb_Client3.InnerText = _client.Model.FullName;
        if (_client.Model["IsRMSClient"] != "2" && _client.Model["IsRMSClient"] != "0")
        {
            lbl_fjfjp.InnerHtml     = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;α金装袋装400G 、能慧全品项、新配方全品项、米粉全品项&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
            lbl_fjffl.InnerHtml     = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;17&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
            lbl_fjfxdcp.InnerHtml   = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;α金装三联包&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
            lbl_fjfxdcpfl.InnerHtml = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;10&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
            lbl_jfcp.InnerHtml      = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
            lbl_jffl.InnerHtml      = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
            lbl_wfljf.InnerHtml     = "&nbsp;&nbsp;&nbsp;&nbsp;雅士利金装、超级金装、普装安贝慧全品项、α金装罐装900G及盒装400G&nbsp;&nbsp;&nbsp;&nbsp;";
        }
        else
        {
            lbl_fjfjp.InnerHtml     = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;α金装袋装400G 、能慧全品项、新配方全品项、米粉全品项&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
            lbl_fjffl.InnerHtml     = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;17&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
            lbl_fjfxdcp.InnerHtml   = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;α金装三联包&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
            lbl_fjfxdcpfl.InnerHtml = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;10&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
            lbl_jfcp.InnerHtml      = "&nbsp;&nbsp;&nbsp;&nbsp;普装安贝慧全品项、α金装罐装900G及盒装400G &nbsp;&nbsp;&nbsp;&nbsp;";
            lbl_jffl.InnerHtml      = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;10&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
            lbl_wfljf.InnerHtml     = "&nbsp;&nbsp;&nbsp;&nbsp;雅士利金装及超级金装 &nbsp;&nbsp;&nbsp;&nbsp;";
        }
        lb_StartTime.InnerText     = _cmbll.Model.BeginDate.ToString("yyyy年MM月dd日");
        lb_EndTime.InnerText       = _cmbll.Model.EndDate.ToString("yyyy年MM月dd日");
        lb_ClientAccount.InnerText = _cmbll.Model["BankAccountNo"].ToString();
        lb_AccountName.InnerText   = _cmbll.Model["BankName"].ToString();
        lb_Client2.InnerText       = _cmbll.Model["AccountName"];
        //lb_Percent.InnerText = "甲方:" + _cmbll.Model["RebateRate"] + "+" + "乙方:" + _cmbll.Model["DIRebateRate"] + "=" + ((decimal.Parse(_cmbll.Model["RebateRate"]) + decimal.Parse(_cmbll.Model["DIRebateRate"])).ToString("0.##"));
    }
コード例 #28
0
    private void BindGrid()
    {
        if (ddl_State.SelectedValue != "1")
        {
            btn_Approve.Visible   = false;
            btn_UnApprove.Visible = false;
        }
        string condition = "";

        if (tbx_ContractID.Text.Trim() != "")
        {
            int id = 0;
            if (int.TryParse(tbx_ContractID.Text, out id))
            {
                condition = " AND CM_Contract.ID=" + id;
            }
            else
            {
                MessageBox.Show(this, "协议ID填写有问题!");
                tbx_ContractID.Focus();
            }
        }
        else
        {
            if (select_OrgSupplier.SelectValue != "" && select_OrgSupplier.SelectValue != "0")
            {
                condition = " AND CM_Contract.Client=" + select_OrgSupplier.SelectValue;
            }
        }
        gv_List.DataSource = CM_ContractBLL.GetApproveSummary(int.Parse(tr_OrganizeCity.SelectValue), int.Parse(ddl_State.SelectedValue), (int)Session["UserID"], int.Parse(MCSTabControl1.SelectedTabItem.Value), int.Parse(ddl_PayMode.SelectedValue), condition);
        if (ddl_State.SelectedValue != "1")
        {
            gv_List.Columns[1].Visible = false;
        }
        gv_List.BindGrid();
    }
コード例 #29
0
 protected void bt_Disable_Click(object sender, EventArgs e)
 {
     CM_ContractBLL _bll = new CM_ContractBLL((int)ViewState["ContractID"]);
     if (_bll != null && _bll.Model.ApproveFlag == 1 && _bll.Model.State == 3)
     {
         _bll.Disable((int)Session["UserID"]);
         MessageBox.ShowAndRedirect(this, "协议中止成功!", "PropertyDetail.aspx?ClientID=" + _bll.Model.Client.ToString());
     }
 }
コード例 #30
0
    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());
        }
    }
コード例 #31
0
    protected void bt_Submit_Click(object sender, EventArgs e)
    {
        bt_OK_Click(null, null);
        if (ViewState["SaveResult"] != null && (bool)ViewState["SaveResult"])
        {
            CM_ContractBLL _bll = new CM_ContractBLL((int)ViewState["ContractID"]);
            if (_bll.Model.ApproveTask > 0 && _bll.Model.State == 2)
            {
                MessageBox.Show(this, "对不起,该协议已发起过流程,请勿重发!");
                return;
            }
            CM_Client client = new CM_ClientBLL(_bll.Model.Client).Model;

            if (_bll.Model.Classify == 1 && _bll.Items.Count == 0)
            {
                MessageBox.Show(this, "对不起,陈列合同必须要录入合同具体的付款科目才能提交申请!");
                return;
            }

            _bll.Items.Sum(p => p.ApplyLimit);

            NameValueCollection dataobjects = new NameValueCollection();
            dataobjects.Add("ID", _bll.Model.ID.ToString());
            dataobjects.Add("Classify", _bll.Model.Classify.ToString());
            dataobjects.Add("PromotorAwardRate", _bll.Model["PromotorAwardRate"]);
            dataobjects.Add("OrganizeCityID", client.OrganizeCity.ToString());
            dataobjects.Add("RTChannel", client["RTChannel"]);
            dataobjects.Add("RTClassify", client["RTClassify"]);
            dataobjects.Add("ApplyCost", _bll.Items.Sum(p => p.ApplyLimit).ToString("0.##"));

            #region 最长一个周期的付款方式
            if (_bll.Items.Count > 0)
            {
                int paymode = _bll.Items.Max(p => p.PayMode);
                dataobjects.Add("PayMode", paymode.ToString());
            }
            #endregion
            decimal clientavgsales = new CM_ClientBLL(_bll.Model.Client).GetSalesVolumeAvg(AC_AccountMonthBLL.GetCurrentMonth(), 3);
            decimal FeeRate = 0;
            if (clientavgsales > 0)
            {
                FeeRate = Math.Round(_bll.Items.Sum(p => p.ApplyLimit) / clientavgsales * 100, 2);
            }
            dataobjects.Add("FeeRate", FeeRate.ToString());
            #region 判断是否首次新增该类型的合同
            if (CM_ContractBLL.GetModelList("Client=" + client.ID + " AND Classify=" + _bll.Model.Classify + " AND State IN (3,9)").Count == 0)
                dataobjects.Add("IsFirstContract", "Y");
            else
            {
                dataobjects.Add("IsFirstContract", "N");

                //返利合同,如果银行帐户信息发生变更,识为新增合同-----2013-11-16日注释去除限制
                //if (_bll.Model.Classify == 2)
                //    if (_bll.Model["BankName"] != client["BankName"] ||
                //        _bll.Model["BankAccountNo"] != client["BankAccountNo"] ||
                //        _bll.Model["AccountName"] != client["AccountName"])
                //        dataobjects["IsFirstContract"] = "Y";
            }
            #endregion

            #region 组织任务标题
            string _title = "";
            Label lb_Client = (Label)pl_detail.FindControl("CM_Contract_Client");
            if (lb_Client != null) _title += "门店名称:" + lb_Client.Text;

            DropDownList ddl_Classify = (DropDownList)pl_detail.FindControl("CM_Contract_Classify");
            if (ddl_Classify != null) _title += " 合同类别:" + ddl_Classify.SelectedItem.Text;

            if (_bll.Model.ContractCode != "") _title += " 合同编码:" + _bll.Model.ContractCode;
            #endregion

            int TaskID = EWF_TaskBLL.NewTask("CM_Contract_Flow", (int)Session["UserID"], _title,
                "~/SubModule/CM/RT/RetailerContractDetail.aspx?ContractID=" + ViewState["ContractID"].ToString(), dataobjects);

            if (TaskID > 0)
            {
                _bll.Model.State = 2;
                _bll.Model.ApproveTask = TaskID;
                _bll.Update();
                new EWF_TaskBLL(TaskID).Start();        //直接启动流程
            }

            Response.Redirect("~/SubModule/EWF/TaskDetail.aspx?TaskID=" + TaskID.ToString());
        }
    }
コード例 #32
0
    protected void bt_Approve_Click(object sender, EventArgs e)
    {
        bt_OK_Click(null, null);
        if (ViewState["SaveResult"] != null && (bool)ViewState["SaveResult"])
        {
            CM_ContractBLL _bll = new CM_ContractBLL((int)ViewState["ContractID"]);

            _bll.Approve(3, (int)Session["UserID"]);

            MessageBox.ShowAndRedirect(this, "审核成功!", "RetailerDetail.aspx?ClientID=" + _bll.Model.Client.ToString());
        }
    }
コード例 #33
0
 protected string GetContractPageURL(int contractdetailid)
 {
     if (contractdetailid > 0)
     {
         CM_ContractDetail d = new CM_ContractBLL().GetDetailModel(contractdetailid);
         if (d == null) return "";
         CM_Contract c = new CM_ContractBLL(d.ContractID).Model;
         if (c != null)
         {
             switch (c.Classify)
             {
                 case 1:
                 case 2:
                 case 3:
                     return "~/SubModule/CM/RT/RetailerContractDetail.aspx?ContractID=" + c.ID.ToString();
                 case 21:
                     return "~/SubModule/CM/PD/PropertyContractDetail.aspx?ContractID=" + c.ID.ToString();
             }
         }
     }
     return "";
 }
コード例 #34
0
    protected string GetDisplayCount(int RelateContractDetail)
    {
        CM_ContractDetail _m = new CM_ContractBLL().GetDetailModel(RelateContractDetail);

        return(_m != null ? _m["DiaplayCount"] : "0");
    }
コード例 #35
0
 private void Approve(int state)
 {
     int userid = (int)Session["UserID"];
     foreach (GridViewRow row in gv_List.Rows)
     {
         Object cbx = row.FindControl("chk_ID");
         if (cbx != null && ((CheckBox)cbx).Checked)
         {
             Object tbx = row.FindControl("tbx_Remark");
             string Remark = "";
             if (tbx != null && !string.IsNullOrEmpty(((TextBox)tbx).Text))
                 Remark = ((TextBox)tbx).Text;
             else Remark = state == 2 ? "汇总单批量审批通过!" : "汇总单批量审批不通过!";
             int contractid = (int)gv_List.DataKeys[row.RowIndex]["ID"];
             CM_ContractBLL con = new CM_ContractBLL(contractid);
             int taskid = con.Model.ApproveTask;
             if (taskid > 0)
             {
                 int jobid = EWF_TaskBLL.StaffCanApproveTask(taskid, userid);
                 if (jobid > 0)
                 {
                     EWF_Task_JobBLL job = new EWF_Task_JobBLL(jobid);
                     if (job != null)
                     {
                         int decisionid = job.StaffCanDecide(userid);
                         if (decisionid > 0)
                             job.Decision(decisionid, userid, state, Remark);
                     }
                 }
             }
         }
     }
 }
コード例 #36
0
    protected void ddl_Contract_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (ddl_Contract.SelectedValue != "" && ddl_Contract.SelectedValue != "0")
        {
            CM_ContractBLL bll = new CM_ContractBLL(int.Parse(ddl_Contract.SelectedValue));
            if (bll.Items.Count == 0) return;

            if (bll.Items[0]["PayEndDate"] == "")
                tbx_BeginDate.Text = bll.Model.BeginDate.ToString("yyyy-MM-dd");
            else
                tbx_BeginDate.Text = DateTime.Parse(bll.Items[0]["PayEndDate"]).AddDays(1).ToString("yyyy-MM-dd");

            tbx_BeginDate.Enabled = false;

            DateTime enddate = DateTime.Parse(tbx_BeginDate.Text).AddMonths(bll.Items[0].PayMode).AddDays(-1);
            if (enddate > bll.Model.EndDate) enddate = bll.Model.EndDate;
            tbx_EndDate.Text = enddate.ToString("yyyy-MM-dd");
        }
    }
    protected void bt_OK_Click(object sender, EventArgs e)
    {
        int ApproveCount=0, UnApproveCount=0,errcount=0;
        if (txt_UnApproveContractID.Text.Trim() != "")
        {
            string[] UnApproveID = Regex.Split(txt_UnApproveContractID.Text.Trim(), "\r\n", RegexOptions.IgnoreCase);

            if (txt_ApproveContractID.Text.Trim() != "")
            {
                string[] ApproveID = Regex.Split(txt_ApproveContractID.Text.Trim(), "\r\n", RegexOptions.IgnoreCase);
                foreach (string contractid in UnApproveID)
                {
                    if (ApproveID.Contains(contractid))
                    {
                        MessageBox.Show(this, "ID为【" + contractid + "】的返利协议同时出现在了【审批通过】与【审批不通过】编辑框中!");
                        return;
                    }
                }
            }
        }
        if (txt_ApproveContractID.Text.Trim() != "")
        {
            string[] ApproveID = Regex.Split(txt_ApproveContractID.Text.Trim(), "\r\n", RegexOptions.IgnoreCase);
            CM_ContractBLL _bll;
            StringBuilder approvebuild = new StringBuilder("");

            for (int i = 0; i < ApproveID.Length; i++)
            {
                int ContractID;
                if (!ApproveID[i].Trim().Equals("") && int.TryParse(ApproveID[i].Trim(), out ContractID))
                {
                    _bll = new CM_ContractBLL(ContractID);
                    if (_bll.Model != null)
                    {
                        int jobid = EWF_TaskBLL.StaffCanApproveTask(_bll.Model.ApproveTask, 7394);
                        if (jobid > 0)
                        {
                            EWF_Task_JobBLL job = new EWF_Task_JobBLL(jobid);
                            if (job != null)
                            {
                                int decisionid = job.StaffCanDecide(7394);
                                if (decisionid > 0)
                                {
                                    ApproveCount++;
                                    job.Decision(decisionid, (int)Session["UserID"], 2, "批量审批通过!");       //2:审批已通过
                                    approvebuild.Append("ID为【" + ContractID.ToString() + "】的返利协议审批通过  ");

                                }
                            }
                        }
                        else
                        {
                            approvebuild.Append("<span style='color: Red'>ID为【" + ContractID.ToString() + "】的返利协议未到客服确认环节   </span>");
                            errcount++;
                        }

                    }
                    else
                    {
                        approvebuild.Append("<span style='color: Red'>ID为【" + ContractID.ToString() + "】的返利协议未能在系统中找到  </span> ");
                        errcount++;
                    }

                }
                else if (!ApproveID[i].Trim().Equals("") && !int.TryParse(ApproveID[i].Trim(), out ContractID))
                {
                    approvebuild.Append("<span style='color: Red'>【" + ContractID.ToString() + "】不是一个有效的返利协议ID  </span> ");
                    errcount++;
                }
                if (i % 5 == 0&&i!=0) approvebuild.Append("<br/>");
            }
            lb_ApproveErrorInfo.Text = approvebuild.ToString();
        }
        if (txt_UnApproveContractID.Text.Trim() != "")
        {
            string[] UnApproveID = Regex.Split(txt_UnApproveContractID.Text.Trim(), "\r\n", RegexOptions.IgnoreCase);
            CM_ContractBLL _bll;
            StringBuilder unapprovebuild = new StringBuilder("");
            for (int i = 0; i < UnApproveID.Length; i++)
            {
                int ContractID;
                if (!UnApproveID[i].Trim().Equals("") && int.TryParse(UnApproveID[i].Trim(), out ContractID))
                {
                    _bll = new CM_ContractBLL(ContractID);
                    if (_bll.Model != null)
                    {
                        int jobid = EWF_TaskBLL.StaffCanApproveTask(_bll.Model.ApproveTask, 7394);
                        if (jobid > 0)
                        {
                            EWF_Task_JobBLL job = new EWF_Task_JobBLL(jobid);
                            if (job != null)
                            {
                                int decisionid = job.StaffCanDecide(7394);
                                if (decisionid > 0)
                                {
                                    UnApproveCount++;
                                    job.Decision(decisionid, (int)Session["UserID"], 3, "批量审批不通过!");       //3:审批不通过
                                    unapprovebuild.Append("ID为【" + ContractID.ToString() + "】的返利协议审批未通过  ");
                                }
                            }
                        }
                        else
                        {
                            unapprovebuild.Append("<span style='color: Red'>ID为【" + ContractID.ToString() + "】的返利协议未到客服确认环节  </span>");
                            errcount++;
                        }
                    }
                    else
                    {
                        errcount++;
                        unapprovebuild.Append("<span style='color: Red'>ID为【" + ContractID.ToString() + "】的返利协议未能在系统中找到  </span>");
                    }

                }
                else if (!UnApproveID[i].Trim().Equals("") && !int.TryParse(UnApproveID[i].Trim(), out ContractID))
                {
                    unapprovebuild.Append("<span style='color: Red'>【" + ContractID.ToString() + "】不是一个有效的返利协议ID  </span>");
                    errcount++;
                }
                if (i % 5 == 0 && i != 0) unapprovebuild.Append("<br/>");

            }
            lb_UnApproveErrorInfo.Text = unapprovebuild.ToString();
        }

        MessageBox.Show(this, "审批通过协议个数:" + ApproveCount.ToString() +   @"\n审批未通过协议个数:" + UnApproveCount.ToString() +
            @"\n未能导入协议个数:" + errcount.ToString()  );
        return;
    }
コード例 #38
0
    /// <summary>
    /// 获取最早的付款截止日期
    /// </summary>
    /// <param name="bll"></param>
    /// <returns></returns>
    private DateTime GetMinPayDate(CM_ContractBLL bll)
    {
        DateTime minpaydate = bll.Model.EndDate;
        foreach (CM_ContractDetail item in bll.Items)
        {
            IList<FNA_FeeApplyDetail> feeapplydetails = new FNA_FeeApplyBLL().GetDetail
                ("Client = " + select_Client.SelectValue + " AND RelateContractDetail = " + item.ID.ToString() +
                " AND Flag<>3");
            if (feeapplydetails.Count == 0)
            {
                minpaydate = bll.Model.BeginDate;
                break;
            }
            else
            {
                DateTime _date = feeapplydetails.Max(p => p.EndDate).AddDays(1);
                if (_date < minpaydate) minpaydate = _date;
            }
        }

        return minpaydate;
    }
コード例 #39
0
    protected void select_Client_SelectChange(object sender, MCSControls.MCSWebControls.SelectChangeEventArgs e)
    {
        bt_Generate.Enabled = false;
        if (select_Client.SelectValue != "")
        {
            ViewState["ClientID"] = int.Parse(select_Client.SelectValue);
            ddl_Contract.Items.Clear();
            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)
            {
                if ((int)ViewState["ContractID"] == 0) ddl_Contract_SelectedIndexChanged(null, null);
                bt_Generate.Enabled = true;
            }
        }
    }
コード例 #40
0
    protected void bt_Submit_Click(object sender, EventArgs e)
    {
        CM_ContractBLL _bll = new CM_ContractBLL((int)ViewState["ContractID"]);
        CM_Client client = new CM_ClientBLL(_bll.Model.Client).Model;

        if (_bll.Items.Count == 0)
        {
            MessageBox.Show(this, "对不起,物业租赁合同必须要录入合同具体的付款科目才能提交申请!");
            return;
        }
        decimal applycost = _bll.Items.Sum(p => p.ApplyLimit);

        NameValueCollection dataobjects = new NameValueCollection();
        dataobjects.Add("ID", _bll.Model.ID.ToString());
        dataobjects.Add("Classify", _bll.Model.Classify.ToString());
        dataobjects.Add("ApplyCost", applycost.ToString("0.##"));

        dataobjects.Add("OrganizeCityID", client.OrganizeCity.ToString());
        dataobjects.Add("PDClassify", client["PDClassify"]);        //物业类别

        #region 组织任务标题
        string _title = "";
        Label lb_Client = (Label)pl_detail.FindControl("CM_Contract_Client");
        if (lb_Client != null) _title += "物业名称:" + lb_Client.Text;

        if (_bll.Model.ContractCode != "") _title += " 合同编码:" + _bll.Model.ContractCode;
        #endregion

        int TaskID = EWF_TaskBLL.NewTask("CM_Contract_Flow", (int)Session["UserID"], _title,
            "~/SubModule/CM/PD/PropertyDetail.aspx?ClientID=" + _bll.Model.Client.ToString(), dataobjects);
        if (TaskID > 0)
        {
            _bll.Model.State = 2;
            _bll.Model.ApproveTask = TaskID;
            _bll.Update();
            new EWF_TaskBLL(TaskID).Start();        //直接启动流程
        }

        Response.Redirect("~/SubModule/EWF/TaskDetail.aspx?TaskID=" + TaskID.ToString());
    }
コード例 #41
0
    protected void cb_Selected_CheckedChanged(object sender, EventArgs e)
    {
        //81,80,82 常规导购管理费(月付类)临时导购管理费(工服工卡等费用项)兼职导购工资次次月核销10日核销
        //SuperID IN (176,73)陈列费 月付,季度付 次月10号才能核销

        CheckBox t = (CheckBox)sender;
        GridViewRow drv = (GridViewRow)t.NamingContainer;
        int rowIndex = drv.RowIndex;
        int applydetailid = (int)gv_FeeAplyList.DataKeys[rowIndex]["FNA_FeeApplyDetail_ID"];
        FNA_FeeApplyDetail applydetail = new FNA_FeeApplyBLL().GetDetailModel(applydetailid);
        CM_ContractDetail contractdetail= new CM_ContractBLL().GetDetailModel(applydetail.RelateContractDetail);
        try
        {
            if (applydetail.AccountTitle == 81 && applydetail.Remark.IndexOf("合同编号")>=0)
            {
                return;
            }
            if (applydetail.AccountTitle >= 80 && applydetail.AccountTitle <= 82)
            {
                t.Checked = CheckLimitWriteOffDate(applydetail.BeginMonth + 2);
            }
            else if (AC_AccountTitleBLL.GetModelList("SuperID IN (176,73)").Where(p => p.ID == applydetail.AccountTitle).ToList().Count > 0
                && contractdetail != null && contractdetail.PayMode != 12 && contractdetail.PayMode != 6 && contractdetail.BearMode==1)
            {
                t.Checked = CheckLimitWriteOffDate(applydetail.BeginMonth + 1);
            }
        }
        catch (Exception)
        {

            throw;
        }
    }
コード例 #42
0
 protected void bt_del_Click(object sender, EventArgs e)
 {
     CM_ContractBLL _bll = new CM_ContractBLL((int)ViewState["ContractID"]);
     int Client = _bll.Model.Client;
     _bll.Delete();
     MessageBox.ShowAndRedirect(this, "删除成功!", "PropertyDetail.aspx?ClientID=" + Client.ToString());
 }
コード例 #43
0
    protected void bt_Generate_Click(object sender, EventArgs e)
    {
        if (ddl_Contract.SelectedValue != "" && ddl_Contract.SelectedValue != "0")
        {
            CM_ContractBLL contractbll = new CM_ContractBLL(int.Parse(ddl_Contract.SelectedValue));

            DateTime begindate = DateTime.Parse(tbx_BeginDate.Text);
            DateTime enddate = DateTime.Parse(tbx_EndDate.Text);
            if (enddate <= begindate)
            {
                MessageBox.Show(this, "开始日期必需小于截止日期!");
                return;
            }

            if (enddate > contractbll.Model.EndDate)
            {
                MessageBox.Show(this, "截止日期不能大于租赁合同的截止日期" + contractbll.Model.EndDate.ToString("yyyy-MM-dd") + "!");
                return;
            }

            #region 判断该合同是否已生成过费用申请
            if (FNA_FeeApplyBLL.GetModelList(string.Format("State IN (1,2,3) AND FeeType=3 AND ID IN (SELECT ApplyID FROM FNA_FeeApplyDetail WHERE Client={0} AND RelateContractDetail={1} AND BeginDate='{2:yyyy-MM-dd}')",
        contractbll.Model.Client, contractbll.Items[0].ID, begindate)).Count > 0)
            {
                MessageBox.Show(this, "该租赁合同已申请过费用了,请勿重复申请!");
                return;
            }
            #endregion

            #region 计算开始日期及截止日期间月份及天数
            enddate = enddate.AddDays(1);
            DateTime tmpdate = begindate;
            int months = 0, days = 0;

            while (tmpdate.AddMonths(1) <= enddate)
            {
                tmpdate = tmpdate.AddMonths(1);
                months++;
            }
            if (tmpdate < enddate) days = (enddate - tmpdate).Days;
            enddate = enddate.AddDays(-1);
            #endregion

            #region 关联全品项
            string relatebrands = "";
            foreach (PDT_Brand brand in PDT_BrandBLL.GetModelList("IsOpponent=1"))
            {
                relatebrands += brand.ID + ",";
            }
            #endregion

            FNA_FeeApplyBLL bll = new FNA_FeeApplyBLL();

            bll.Model.OrganizeCity = int.Parse(tr_OrganizeCity.SelectValue);
            bll.Model.AccountMonth = int.Parse(ddl_Month.SelectedValue);

            bll.Model.FeeType = 3;      //管理费-租赁费
            bll.Model.State = 1;        //草稿
            bll.Model.ApproveFlag = 2;  //未审核
            bll.Model.InsertStaff = (int)Session["UserID"];
            bll.Model["Title"] = ddl_Month.SelectedItem.Text + " 租赁费申请单" + " " + select_Client.SelectText + " " + Session["UserRealName"].ToString();

            foreach (CM_ContractDetail item in contractbll.Items)
            {
                FNA_FeeApplyDetail detail = new FNA_FeeApplyDetail();
                detail.Client = int.Parse(select_Client.SelectValue);
                detail.AccountTitle = item.AccountTitle;
                detail.ApplyCost = Math.Round(item.ApplyLimit * months + item.ApplyLimit * days / DateTime.DaysInMonth(enddate.Year, enddate.Month), 1, MidpointRounding.AwayFromZero);
                detail.BeginDate = begindate;
                detail.EndDate = enddate;
                detail.BeginMonth = AC_AccountMonthBLL.GetMonthByDate(begindate);
                detail.EndMonth = AC_AccountMonthBLL.GetMonthByDate(enddate);
                detail.RelateContractDetail = item.ID;
                detail.Remark = "合同编号:" + contractbll.Model["Code"] + " 日期范围:" + begindate.ToString("yyyy-MM-dd") + "~" + enddate.ToString("yyyy-MM-dd");
                detail.RelateBrands = relatebrands;
                detail.Flag = 1;  //未报销
                detail["FeeApplyType"] = (begindate == contractbll.Model.BeginDate ? "1" : "2");
                bll.Items.Add(detail);
            }

            bll.Model.SheetCode = FNA_FeeApplyBLL.GenerateSheetCode(bll.Model.OrganizeCity, bll.Model.AccountMonth);
            int applyid = bll.Add();

            MessageBox.ShowAndRedirect(this, "费用申请成功!", ResolveUrl("~/SubModule/FNA/FeeApply/FeeApplyDetail3.aspx?ID=" + applyid.ToString()));
        }
    }
コード例 #44
0
    protected void bt_Generate_Click(object sender, EventArgs e)
    {
        int month        = int.Parse(ddl_Month.SelectedValue);
        int organizecity = 0;
        int client       = 0;

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

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

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

        #region 判断指定区域下是否还有门店销量未审核
        string citys = new Addr_OrganizeCityBLL(organizecity).GetAllChildNodeIDs();
        if (citys == "")
        {
            citys = organizecity.ToString();
        }
        else
        {
            citys += "," + organizecity.ToString();
        }
        string condition = "Type=3 AND Supplier=" + client.ToString() + " AND AccountMonth=" + month.ToString() +
                           " AND OrganizeCity IN (" + citys + ") AND ApproveFlag=2 AND Flag=1 AND EXISTS (SELECT 1 FROM MCS_CM.dbo.CM_Client WHERE ClientType=3 AND CM_Client.ID=SVM_SalesVolume.Client)";

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

        int FeeType = 0;
        FeeType = ConfigHelper.GetConfigInt("ContractFeeType-FL");

        int id = CM_ContractBLL.CreateFLFeeApply(organizecity, month, client, (int)Session["UserID"], FeeType);

        if (id > 0)
        {
            MessageBox.ShowAndRedirect(this, "返利费用申请单生成成功!", "FeeApplyDetail3.aspx?ID=" + id.ToString());
        }
        else if (id == 0)
        {
            MessageBox.Show(this, "对不起,目前尚无返利合同需要申请费用!");
        }
        else if (id == -1)
        {
            MessageBox.Show(this, "对不起,无返利费用生成!请检查是否有返利店有销量,或是之前已经生成该月的返利费用!");
        }
        else
        {
            MessageBox.Show(this, "对不起,返利合同费用申请单生成失败!错误码:" + id.ToString());
        }
    }
コード例 #45
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);
            }
        }
コード例 #46
0
    protected void gv_List_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            int applydetailid = (int)((UC_GridView)sender).DataKeys[e.Row.RowIndex]["ApplyDetailID"];
            int writeoffdetailid = (int)((UC_GridView)sender).DataKeys[e.Row.RowIndex]["ID"];
            if (applydetailid > 0)
            {
                Label lb_ApplySheetCode = (Label)e.Row.FindControl("lb_ApplySheetCode");
                if (lb_ApplySheetCode != null)
                    lb_ApplySheetCode.Text = FNA_FeeApplyBLL.GetSheetCodeByDetailID(applydetailid);
                FNA_FeeApplyDetail _detail = new FNA_FeeApplyBLL().GetDetailModel(applydetailid);
                Label lb_AllCost = (Label)e.Row.FindControl("lb_AllCost");
                if (lb_AllCost != null)
                    lb_AllCost.Text = Math.Round(decimal.Parse(_detail["DICost"] == "" ? "0" : _detail["DICost"]) + _detail.ApplyCost, 1).ToString("0.##");
                Label lb_Remark = (Label)e.Row.FindControl("lb_Remark");
                Label lb_ContractCode = (Label)e.Row.FindControl("lb_ContractCode");
                FNA_FeeWriteOffDetail _writeoffdetail = new FNA_FeeWriteOffBLL().GetDetailModel(writeoffdetailid);//(int)gv_ListDetail.DataKeys[e.Row.RowIndex][0]
                if (_detail.RelateContractDetail != 0)
                {
                    CM_ContractDetail detail = new CM_ContractBLL().GetDetailModel(_detail.RelateContractDetail);
                    if (detail != null)
                    {
                        CM_Contract _mContract = new CM_ContractBLL(detail.ContractID).Model;
                        lb_ContractCode.Text = "合同编码:" + _mContract.ContractCode;
                    }
                    else lb_ContractCode.Text = "合同编码:【未找到指定合同】";
                }
                if (lb_Remark != null)
                {
                    try
                    {
                        if (_detail.AccountTitle == 80) //导购工资
                        {
                            lb_Remark.Text = _detail.Remark.Replace("-", "<br/>");
                        }
                        else if (_detail.AccountTitle == 82)//无导返利
                        {
                            lb_Remark.Text = _detail["FLRemark"];
                            if (ViewState["FLPurchase"] != null)
                                lb_Remark.Text = "进货额:" + ((DataTable)ViewState["FLPurchase"]).Compute("Sum(PurchaseVolume)", "ID=" + _writeoffdetail.ID).ToString() + ";" + _detail["FLRemark"];

                        }
                        else if (_writeoffdetail.Remark.IndexOf("是否CA") > 0)
                        {
                            lb_Remark.Text = _writeoffdetail.Remark;
                        }
                        else
                        {
                            lb_Remark.Text = _detail.Remark;
                        }
                    }
                    catch (Exception)
                    {
                        lb_Remark.Text = _detail.Remark;
                    }
                }
                Label lb_RelateBrand = (Label)e.Row.FindControl("lb_RelateBrand");
                if (lb_RelateBrand != null)
                {
                    string[] brands = new FNA_FeeApplyBLL().GetDetailModel(applydetailid).RelateBrands.Split
                        (new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    lb_RelateBrand.Text = "";

                    foreach (string b in brands)
                    {
                        lb_RelateBrand.Text += new PDT_BrandBLL(int.Parse(b)).Model.Name + ",";
                    }
                }
            }

            int client = (int)((UC_GridView)sender).DataKeys[e.Row.RowIndex]["Client"];

            if (client > 0)
            {
                Label lb_RTChannel = (Label)e.Row.FindControl("lb_RTChannel");
                CM_Client c = new CM_ClientBLL(client).Model;
                if (c != null && c.ClientType == 3 && c["RTChannel"] != "" && lb_RTChannel != null)
                {
                    if (DictionaryBLL.GetDicCollections("CM_RT_Channel").Keys.Contains(c["RTChannel"]))
                        lb_RTChannel.Text = DictionaryBLL.GetDicCollections("CM_RT_Channel")[c["RTChannel"]].ToString();
                }
            }
            else
            {
                Label lb_RTChannel = (Label)e.Row.FindControl("lb_CanWriteOffCost");
                lb_RTChannel.Visible = false;
            }

        }
    }
コード例 #47
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();
    }
コード例 #48
0
    protected void gv_List_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            int applydetailid    = (int)((UC_GridView)sender).DataKeys[e.Row.RowIndex]["ApplyDetailID"];
            int writeoffdetailid = (int)((UC_GridView)sender).DataKeys[e.Row.RowIndex]["ID"];
            if (applydetailid > 0)
            {
                Label lb_ApplySheetCode = (Label)e.Row.FindControl("lb_ApplySheetCode");
                if (lb_ApplySheetCode != null)
                {
                    lb_ApplySheetCode.Text = FNA_FeeApplyBLL.GetSheetCodeByDetailID(applydetailid);
                }
                FNA_FeeApplyDetail _detail = new FNA_FeeApplyBLL().GetDetailModel(applydetailid);
                Label lb_AllCost           = (Label)e.Row.FindControl("lb_AllCost");
                if (lb_AllCost != null)
                {
                    lb_AllCost.Text = Math.Round(decimal.Parse(_detail["DICost"] == "" ? "0" : _detail["DICost"]) + _detail.ApplyCost, 1).ToString("0.##");
                }
                Label lb_Remark       = (Label)e.Row.FindControl("lb_Remark");
                Label lb_ContractCode = (Label)e.Row.FindControl("lb_ContractCode");
                FNA_FeeWriteOffDetail _writeoffdetail = new FNA_FeeWriteOffBLL().GetDetailModel(writeoffdetailid);//(int)gv_ListDetail.DataKeys[e.Row.RowIndex][0]
                if (_detail.RelateContractDetail != 0)
                {
                    CM_ContractDetail detail = new CM_ContractBLL().GetDetailModel(_detail.RelateContractDetail);
                    if (detail != null)
                    {
                        CM_Contract _mContract = new CM_ContractBLL(detail.ContractID).Model;
                        lb_ContractCode.Text = "合同编码:" + _mContract.ContractCode;
                    }
                    else
                    {
                        lb_ContractCode.Text = "合同编码:【未找到指定合同】";
                    }
                }
                if (lb_Remark != null)
                {
                    try
                    {
                        if (_detail.AccountTitle == 80) //导购工资
                        {
                            lb_Remark.Text = _detail.Remark.Replace("-", "<br/>");
                        }
                        else if (_detail.AccountTitle == 82)//无导返利
                        {
                            lb_Remark.Text = _detail["FLRemark"];
                            if (ViewState["FLPurchase"] != null)
                            {
                                lb_Remark.Text = "进货额:" + ((DataTable)ViewState["FLPurchase"]).Compute("Sum(PurchaseVolume)", "ID=" + _writeoffdetail.ID).ToString() + ";" + _detail["FLRemark"];
                            }
                        }
                        else if (_writeoffdetail.Remark.IndexOf("是否CA") > 0)
                        {
                            lb_Remark.Text = _writeoffdetail.Remark;
                        }
                        else
                        {
                            lb_Remark.Text = _detail.Remark;
                        }
                    }
                    catch (Exception)
                    {
                        lb_Remark.Text = _detail.Remark;
                    }
                }
                Label lb_RelateBrand = (Label)e.Row.FindControl("lb_RelateBrand");
                if (lb_RelateBrand != null)
                {
                    string[] brands = new FNA_FeeApplyBLL().GetDetailModel(applydetailid).RelateBrands.Split
                                          (new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    lb_RelateBrand.Text = "";

                    foreach (string b in brands)
                    {
                        lb_RelateBrand.Text += new PDT_BrandBLL(int.Parse(b)).Model.Name + ",";
                    }
                }
            }

            int client = (int)((UC_GridView)sender).DataKeys[e.Row.RowIndex]["Client"];

            if (client > 0)
            {
                Label     lb_RTChannel = (Label)e.Row.FindControl("lb_RTChannel");
                CM_Client c            = new CM_ClientBLL(client).Model;
                if (c != null && c.ClientType == 3 && c["RTChannel"] != "" && lb_RTChannel != null)
                {
                    if (DictionaryBLL.GetDicCollections("CM_RT_Channel").Keys.Contains(c["RTChannel"]))
                    {
                        lb_RTChannel.Text = DictionaryBLL.GetDicCollections("CM_RT_Channel")[c["RTChannel"]].ToString();
                    }
                }
            }
            else
            {
                Label lb_RTChannel = (Label)e.Row.FindControl("lb_CanWriteOffCost");
                lb_RTChannel.Visible = false;
            }
        }
    }
コード例 #49
0
 protected string GetDisplayCount(int RelateContractDetail)
 {
     CM_ContractDetail _m = new CM_ContractBLL().GetDetailModel(RelateContractDetail);
     return _m != null ? _m["DiaplayCount"] : "0";
 }
コード例 #50
0
    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());
        }
    }
コード例 #51
0
 protected void bt_Delete_Click(object sender, EventArgs e)
 {
     CM_ContractBLL _bll = new CM_ContractBLL((int)ViewState["ContractID"]);
     if (_bll != null && _bll.Model.ApproveFlag != 1)
     {
         int Client = _bll.Model.Client;
         _bll.Delete();
         MessageBox.ShowAndRedirect(this, "删除成功!", "RetailerDetail.aspx?ClientID=" + Client.ToString());
     }
 }
コード例 #52
0
    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);
        if (((int)ViewState["Classify"] == 2 || (int)ViewState["Classify"] == 3) && (int)ViewState["ContractID"] == 0)
        {
            AC_AccountMonth minbegainmonth = new AC_AccountMonthBLL(AC_AccountMonthBLL.GetCurrentMonth() - 1).Model;
            if (_bll.Model.BeginDate < minbegainmonth.BeginDate)
            {
                MessageBox.Show(this, "对不起,新增协议的合作日期最小值为" + minbegainmonth.BeginDate.ToString("yyyy-MM-dd") + "。");
                return;
            }
        }

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

            IList<CM_Contract> _listcontract = CM_ContractBLL.GetModelList("ID!=" + ViewState["ContractID"].ToString() + " AND State IN(1,2,3,9) AND Classify=" + ViewState["Classify"].ToString() + " AND Client=" + ViewState["ClientID"].ToString() + " Order By EndDate DESC");
            if (_listcontract.Count > 0)
            {
                AC_AccountMonth month = new AC_AccountMonthBLL(AC_AccountMonthBLL.GetMonthByDate(_listcontract[0].EndDate)).Model;
                AC_AccountMonth bemonth = new AC_AccountMonthBLL(AC_AccountMonthBLL.GetMonthByDate(_listcontract[0].BeginDate)).Model;
                if (month == null)
                {
                     MessageBox.Show(this, "对不起,新增协议的合作日期与原有协议重复");
                    return;
                }
                if (_bll.Model.BeginDate <= month.EndDate && _bll.Model.EndDate >= bemonth.BeginDate)
                {
                    MessageBox.Show(this, "对不起,新增协议的合作日期与原有协议重复,请重新确认!建议的开始日期为" + new AC_AccountMonthBLL(month.ID + 1).Model.BeginDate.ToString("yyyy-MM-dd"));
                    return;
                }
            }
        }
        //导购工资
        #region 导购工资单独判断 2014-05-07 Jace
        if ((int)ViewState["Classify"] == 3)
        {
            //A、若开始日期范围在过去的最新一个会计月且单月管理费用已随工资流程生成,则该导购协议无法进行保存,并由系统提示:“本协议开始日期需重新填写,导购工资已生成过该笔费用”,若开始日期包含过去的最新一个会计月,但工资流程中并未产生该笔费用,则可以进行保存。
            int month = AC_AccountMonthBLL.GetMonthByDate(_bll.Model.BeginDate);
            int applyedmonth = _bll.CheckPMFeeApplyLastMonth(int.Parse(ViewState["ClientID"].ToString()));
            CM_ClientBLL cm = new CM_ClientBLL(int.Parse(ViewState["ClientID"].ToString()));
            if (month <= applyedmonth)
            {
                MessageBox.Show(this, "本协议开始日期需重新填写,导购工资已生成过该笔费用(最大可提前至" + new AC_AccountMonthBLL(applyedmonth + 1).Model.BeginDate + ")!");
                return;
            }
            //C、导购协议合同周期最多不超过2年。
            if (_bll.Model.BeginDate.AddYears(2) < _bll.Model.EndDate)
            {
                MessageBox.Show(this, "导购协议合同周期最多不超过2年!");
                return;
            }
            //B、导购人数录入的数量 不得超过当时申请时门店实际关联的导购人数,但可以少于门店实际人数,最小的基数为1。
            //若门店没有关联导购员或业务员,该门店不得添加导购费用协议,系统提示:“门店没有关联导购员或业务员,请关联后再做申请”。
            int conpmcount = 0, actpmcount = 0;
            int.TryParse(_bll.Model["PromotorCount"],out conpmcount);
            actpmcount = PM_PromotorInRetailerBLL.GetModelList("Client=" + ViewState["ClientID"].ToString()).Count(p => (new PM_PromotorBLL(p.Promotor).Model.Dimission == 1 || new PM_PromotorBLL(p.Promotor).Model.EndWorkDate < new AC_AccountMonthBLL(month).Model.BeginDate));
            if (actpmcount > 0)
            {
                if (actpmcount < conpmcount)
                {
                    MessageBox.Show(this, "导购人数录入的数量不得超过当时申请时门店实际关联的导购人数!");
                    return;
                }
            }
            else
            {
                MessageBox.Show(this, "门店没有关联导购员或业务员,请关联后再做申请!");
                return;
            }

            //该门店为LKA或NKA门店,但KA系统没有填写,同样不得添加导购费用协议,系统提示:“门店为KA店,KA系统没有填写,需填写后再做申请”。
            if (cm.Model["RTChannel"] == "1" || cm.Model["RTChannel"] == "2")
            {
                if (cm.Model["VestKA"] == "" || cm.Model["VestKA"] == "0")
                {
                    MessageBox.Show(this, "门店为KA店,KA系统没有填写,需填写后再做申请!");
                    return;
                }
            }
            //门店为非LKA或NKA门店,但KA系统有填写内容,不得添加导购费用协议,系统提示“门店为非KA店,但KA系统错填写内容,请修改后再做申请”。
            else if (cm.Model["VestKA"] != "" && cm.Model["VestKA"] != "0")
            {
                MessageBox.Show(this, "门店为非KA店,但KA系统错填写内容,请修改后再做申请!");
                return;
            }

        #endregion

        }
        if (ViewState["ClientID"] != null && (int)ViewState["Classify"] == 2)
        {
            IList<PM_Promotor> pmlist = PM_PromotorBLL.GetModelList("EXISTS (SELECT 1 FROM MCS_Promotor.dbo.PM_PromotorInRetailer WHERE PM_PromotorInRetailer.Promotor=PM_Promotor.ID AND Client=" + ViewState["ClientID"].ToString()
                                                                    + ")AND Dimission=2 AND ApproveFlag=1 ORDER BY EndWorkDate DESC");

            if (pmlist.Count > 0 )
            {
                AC_AccountMonth month = new AC_AccountMonthBLL(AC_AccountMonthBLL.GetMonthByDate(pmlist[0].EndWorkDate)).Model;
                if (month!=null&&_bll.Model.BeginDate <= month.EndDate)
                {
                    MessageBox.Show(this, "对不起,该开始日期期间为导购店,请重新确认!建议的开始日期为" + new AC_AccountMonthBLL(month.ID + 1).Model.BeginDate.ToString("yyyy-MM-dd"));
                    return;
                }

            }

        }

        ListTable<CM_ContractDetail> _details = ViewState["Details"] as ListTable<CM_ContractDetail>;

        int cycle = GetContractcycle();
        #region 判断必填字段
        //if (_bll.Model.BeginDate < DateTime.Today)
        //{
        //    MessageBox.Show(this, "对不起,合同起始日期不能小于今天!");
        //    return;
        //}
        if (_bll.Model.EndDate <= _bll.Model.BeginDate)
        {
            MessageBox.Show(this, "对不起,合同起始日期不能大于截止日期!");
            return;
        }

        if (_bll.Model.EndDate != _bll.Model.BeginDate.AddMonths(cycle).AddDays(-1))
        {
            MessageBox.Show(this, "提醒,合同截止日期与开始日期不足月匹配,请确认输入是否正确!建议的截止日期为" +
               _bll.Model.BeginDate.AddMonths(cycle).AddDays(-1).ToString("yyyy-MM-dd"));
            return;
        }

        if (_bll.Model.Classify==1 && (_bll.Model["IsKA"] == "" || _bll.Model["IsKA"] == "0"))
        {
            MessageBox.Show(this, "对不起请正确选择是否KA费用!");
            return;
        }

        if (_bll.Model.Classify == 2)
        {
            if (_bll.Model["RebateLevel"] == "0")
            {
                MessageBox.Show(this, "对不起请正确选择返利标准!");
                return;
            }
        }

        if (_bll.Model.Classify == 3)
        {
            if (_bll.Model["PromotorCostPayMode"] == "0")
            {
                MessageBox.Show(this, "对不起,请正确选择【导购管理费付款方式】!");
                return;
            }
            #region 增加导购管理费科目明细
            CM_ContractDetail item;
            int accounttitle = ConfigHelper.GetConfigInt("ContractAccountTitle-PromotorCost");
            item = _details.GetListItem().FirstOrDefault(p => p.AccountTitle == accounttitle);
            if (item == null)
            {
                //新增科目
                item = new CM_ContractDetail();
                item.AccountTitle = accounttitle;
                _details.Add(item);
            }
            else
            {
                //修改科目
                _details.Update(item);
            }

            item.ApplyLimit = decimal.Parse(_bll.Model["PromotorCost"]) * int.Parse(_bll.Model["PromotorCount"]);
            item.Amount = item.ApplyLimit * cycle;
            item.FeeCycle = cycle;
            item.BearPercent = 100 - decimal.Parse(_bll.Model["PromotorCostRate"]);
            item.PayMode = int.Parse(_bll.Model["PromotorCostPayMode"]);
            item.Remark = "导购管理费";
            #endregion
        }
        #endregion

        if ((int)ViewState["ContractID"] == 0)
        {

            _bll.Model.State = 1;
            _bll.Model.ApproveFlag = 2;
            _bll.Model.InsertStaff = (int)Session["UserID"];
            _bll.Model.Client = int.Parse(ViewState["ClientID"].ToString());
            CM_ClientBLL _cm = new CM_ClientBLL(_bll.Model.Client);
            //导购店添加返利协议
            if (_cm.Model["RTClassify"] == "3" && (int)ViewState["Classify"] == 2)
            {
                MessageBox.Show(this, _cm.CheckRealClassifyShowMessage(1));
                return;
            }
            _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);
            }

            foreach (CM_ContractDetail d in _details.GetListItem())
            {
                if (d.PayMode == 20)
                {
                    //一次性支付
                    if (d.ApplyLimit != d.Amount)
                    {
                        d.ApplyLimit = d.Amount;
                        _details.Update(d);
                    }
                }
                else
                {
                    //非一次性支付
                    if (d.ApplyLimit != 0 && d.Amount / d.ApplyLimit != cycle)
                    {
                        d.Amount = d.ApplyLimit * cycle;
                        _details.Update(d);
                    }
                }
            }
            _bll.Items = _details.GetListItem(ItemState.Modified);

            _bll.UpdateDetail();

            #endregion
        }

        if (sender != null)
        {
            if (Request.QueryString["Decision"] != "" && Request.QueryString["Decision"] == "Y")
                MessageBox.Show(this, "合同编码保存成功!");
            else
                MessageBox.ShowAndRedirect(this, "保存零售商合同详细信息成功!", "RetailerContractDetail.aspx?ContractID=" + ViewState["ContractID"].ToString());
        }
        else
            ViewState["SaveResult"] = true;
    }
コード例 #53
0
    public void BindData()
    {
        CM_Contract c = new CM_ContractBLL((int)ViewState["ContractID"]).Model;
        if (c != null)
        {
            if (c["Classify"] == "") c["Classify"] = "1";
            pl_detail.BindData(c);
            if (c["Classify"] != "1" && c["Classify"] != "2") bt_print.Visible = false;
            ViewState["ClientID"] = c.Client;
            ViewState["Classify"] = int.Parse(c["Classify"]);     //合同类别
            BindContractClassify((int)ViewState["Classify"]);
            if (c.Classify == 2 && ddl_RebateLevel != null)
            {
                ddl_RebateLevel.SelectedValue = c["RebateLevel"];
                //ddl_RebateLevel_SelectedIndexChanged(null, null);
            }
            BindGrid();
            UploadFile1.RelateID = c.ID;

            #region 绑定丙方负责人
            if (ddl_PartyC != null) ddl_PartyC_SelectedIndexChanged(ddl_PartyC, null);
            if (ddl_PartyCSignMan != null) ddl_PartyCSignMan.SelectedValue = c["PartyCSignMan"];
            #endregion

            if (c.ApproveFlag == 1 || c.State == 2 || c.State == 3)
            {
                //已审核
                pl_detail.SetControlsEnable(false);
                bt_Submit.Visible = false;
                bt_Approve.Visible = false;
                bt_OK.Visible = false;
                bt_AddDetail.Visible = false;
                bt_Delete.Visible = false;

                tr_AddDetail.Visible = false;
                gv_Detail.Columns[gv_Detail.Columns.Count - 1].Visible = false;

                UploadFile1.CanDelete = false;
                //UploadFile1.CanUpload = false;
            }
            if (c.State != 3)
            {
                bt_Disable.Visible = false;
                bt_FeeApply.Visible = false;
            }

            if (Right_Assign_BLL.GetAccessRight(Session["UserName"].ToString(), 1101, "EditEndDate") && (c.State == 3 || c.State == 9))
            {
                tbx_EndDate.Enabled = true;
                bt_OK.Visible = true;
            }
            if (Right_Assign_BLL.GetAccessRight(Session["UserName"].ToString(), 1101, "EditBeginDate") && (c.State == 3 || c.State == 9))
            {
                tbx_BeginDate.Enabled = true;
                bt_OK.Visible = true;
            }
            if (c.State == 9) UploadFile1.CanDelete = false;

            ///审批过程中,可以修改编码 Decision参数为在审批过程中传进来的参数
            if (c.State == 2 && Request.QueryString["Decision"] != "" && Request.QueryString["Decision"] == "Y")
            {
                bt_OK.Visible = true;
                //gv_Detail.Enabled = false;
                pl_detail.SetControlsEnable(false);
            }

            if (tr_AddDetail.Visible)
                lbl_FeeCycle.Text = GetContractcycle().ToString();

            if (pl_detail.FindControl("hy_ViewTradeInPrice") != null)
            {
                ((HyperLink)pl_detail.FindControl("hy_ViewTradeInPrice")).Enabled = true;
            }

            bt_Disable.OnClientClick = "javascript:PopSetEndDate(" + ViewState["ContractID"].ToString() + ")";
        }
    }
コード例 #54
0
    protected void bt_Generate_Click(object sender, EventArgs e)
    {
        if (ddl_Contract.SelectedValue != "" && ddl_Contract.SelectedValue != "0")
        {
            #region 本次合同费用支付的开始及截止日期
            CM_ContractBLL contractbll = new CM_ContractBLL(int.Parse(ddl_Contract.SelectedValue));

            #region 获取最早的付款截止日期,再次获取,是防止同时打开多个该页面后,分别点申请费用
            DateTime begindate = GetMinPayDate(contractbll);

            if (begindate >= contractbll.Model.EndDate)
            {
                MessageBox.Show(this, "对不起,该合同没有需要付款的明细科目!");
                bt_Generate.Enabled = false;
                return;
            }

            lb_PayDateRegion.Text = begindate.ToString("yyyy年MM月dd日");
            #endregion

            DateTime enddate = contractbll.Model.EndDate;

            DateTime monthenddate = new AC_AccountMonthBLL(int.Parse(ddl_EndMonth.SelectedValue) + 1).Model.EndDate;
            while (enddate > monthenddate)
            {
                enddate = enddate.AddMonths(-1);
            }
            if (enddate <= begindate)
            {
                MessageBox.Show(this, "该合同所有范围的款项均已支付完成!" + enddate.ToString());
                return;
            }
            #endregion

            #region 求出当前客户的直销总经销商
            CM_Client client = new CM_ClientBLL((int)ViewState["ClientID"]).Model;
            if (client == null) return;
            int supplier = 0;

            while (client != null)
            {
                client = new CM_ClientBLL(client.Supplier).Model;
                if (client == null) break;
                if (client.ClientType == 2 && client["DIClassify"] == "1")
                {
                    supplier = client.ID;
                    break;
                }
            }
            #endregion

            FNA_FeeApplyBLL bll = new FNA_FeeApplyBLL();

            bll.Model.OrganizeCity = int.Parse(tr_OrganizeCity.SelectValue);
            bll.Model.AccountMonth = int.Parse(ddl_Month.SelectedValue);
            bll.Model.Client = supplier;       //费用代垫客户
            bll.Model.State = 1;               //草稿
            bll.Model.ApproveFlag = 2;         //未审核
            bll.Model.InsertStaff = (int)Session["UserID"];
            bll.Model["Title"] = ddl_Month.SelectedItem.Text + " 合同费用提前预支付申请单" + " " + select_Client.SelectText + " " + Session["UserRealName"].ToString();

            #region 判断合同类型
            switch (contractbll.Model.Classify)
            {
                case 1:         //陈列合同
                    if (new CM_ClientBLL((int)ViewState["ClientID"]).Model["RTChannel"] == "1")
                        //NKA合同费用
                        bll.Model.FeeType = ConfigHelper.GetConfigInt("ContractFeeType-KA");
                    else
                        //非NKA合同费用
                        bll.Model.FeeType = ConfigHelper.GetConfigInt("ContractFeeType");
                    break;
                case 3:         //导购管理费
                    bll.Model.FeeType = ConfigHelper.GetConfigInt("ContractFeeType-PromotorCost");
                    break;
                case 21:        //租赁合同
                    bll.Model.FeeType = ConfigHelper.GetConfigInt("ContractFeeType-PD");
                    break;
                default:
                    MessageBox.Show(this, "对不起,该合同类型暂不支持费用申请!合同类别:" + contractbll.Model.Classify.ToString());
                    return;
            }
            if (contractbll.Model.Classify != 21)
            {
                if (contractbll.Items.Where(p => p.PayMode > 1).ToList().Count == 0)
                {
                    //非租赁费的合同,不可申请逐月支付的科目费用
                    MessageBox.Show(this, "对不起,付款方式为每月付的科目不可提前申请费用!");
                    return;
                }
            }
            #endregion

            foreach (CM_ContractDetail item in contractbll.Items)
            {
                if (contractbll.Model.Classify != 21)
                {
                    //非租赁费的合同,不可申请逐月支付的科目费用
                    if (item.PayMode == 1) continue;
                }

                DateTime d = begindate;
                while (d < enddate)
                {
                    FNA_FeeApplyDetail detail = new FNA_FeeApplyDetail();
                    detail.Client = (int)ViewState["ClientID"];
                    detail.AccountTitle = item.AccountTitle;
                    detail.BeginDate = d;

                    if (d.AddMonths(1).AddDays(-1) <= contractbll.Model.EndDate)
                    {
                        detail.EndDate = d.AddMonths(1).AddDays(-1);
                        detail.ApplyCost = item.ApplyLimit * item.BearPercent / 100;
                        detail.DICost = item.ApplyLimit * (100 - item.BearPercent) / 100;
                    }
                    else
                    {
                        #region 最后一个月不足一个月时的处理
                        detail.EndDate = contractbll.Model.EndDate;
                        int days = (detail.EndDate - detail.BeginDate).Days + 1;
                        detail.ApplyCost = Math.Round(item.ApplyLimit * days / 30, 1, MidpointRounding.AwayFromZero) * item.BearPercent / 100;
                        detail.DICost = Math.Round(item.ApplyLimit * days / 30, 1, MidpointRounding.AwayFromZero) * (100 - item.BearPercent) / 100;
                        #endregion
                    }
                    detail.BeginMonth = AC_AccountMonthBLL.GetMonthByDate(detail.BeginDate);
                    detail.EndMonth = detail.BeginMonth;
                    detail.LastWriteOffMonth = bll.Model.AccountMonth + 1;

                    #region 不可申请之前月的费用
                    if (detail.BeginMonth < bll.Model.AccountMonth)
                    {
                        d = d.AddMonths(1);
                        continue;
                    }
                    #endregion

                    #region 判断当月费用是否已申请过
                    string condition = "Client = " + detail.Client.ToString() + " AND RelateContractDetail = " + item.ID.ToString() + " AND Flag<>3";
                    if (item.PayMode != 20) condition += "AND BeginMonth=" + detail.BeginMonth.ToString();

                    if (new FNA_FeeApplyBLL().GetDetail(condition).Count > 0)
                    {
                        d = d.AddMonths(1);
                        continue;
                    }
                    #endregion

                    detail.RelateContractDetail = item.ID;
                    detail.Remark = "合同编号:" + contractbll.Model["Code"] + " 日期范围:" + detail.BeginDate.ToString("yyyy-MM-dd") + "~" + detail.EndDate.ToString("yyyy-MM-dd");
                    detail.RelateBrands = item["RelateBrand"];
                    if (string.IsNullOrEmpty(detail.RelateBrands))
                    {
                        foreach (PDT_Brand brand in PDT_BrandBLL.GetModelList("IsOpponent=1"))
                        {
                            detail.RelateBrands += brand.ID.ToString() + ",";
                        }
                    }
                    detail.Flag = 1;  //未报销
                    detail["FeeApplyType"] = (d == contractbll.Model.BeginDate ? "1" : "2");
                    bll.Items.Add(detail);

                    d = d.AddMonths(1);

                    #region 以协议里该科目付款周期为准
                    if (item.PayMode != 20)
                    {
                        DateTime maxpaydate = begindate.AddMonths(item.PayMode).AddDays(-1);
                        if (d > maxpaydate) break;
                    }
                    else
                    {
                        break;
                    }
                    #endregion
                }
            }

            bll.Model.SheetCode = FNA_FeeApplyBLL.GenerateSheetCode(bll.Model.OrganizeCity, bll.Model.AccountMonth);
            int applyid = bll.Add();

            MessageBox.ShowAndRedirect(this, "费用申请成功!", ResolveUrl("~/SubModule/FNA/FeeApply/FeeApplyDetail3.aspx?ID=" + applyid.ToString()));
        }
    }
コード例 #55
0
    protected void gv_Detail_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            ListTable<CM_ContractDetail> _details = ViewState["Details"] as ListTable<CM_ContractDetail>;
            int accounttitle = int.Parse(gv_Detail.DataKeys[e.Row.RowIndex]["AccountTitle"].ToString());
            int _id = int.Parse(gv_Detail.DataKeys[e.Row.RowIndex]["ID"].ToString());
            Label lb_RelateBrand = (Label)e.Row.FindControl("lb_RelateBrand");
            if (lb_RelateBrand != null)
            {
                foreach (string brand in _details[_id.ToString()]["RelateBrand"].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
                {
                    PDT_Brand b = new PDT_BrandBLL(int.Parse(brand)).Model;
                    if (b != null) lb_RelateBrand.Text += b.Name + ",";
                }
            }
            int ContractFeeType = ConfigHelper.GetConfigInt("ContractFeeType");
            int ContractAccountTitle = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["ContractAccountTitle"]);

            #region 判断是否NKA店,如是NKA店,则获取NKA的会计科目
            int client = 0;
            if (ViewState["ContractID"] == null && ViewState["ClientID"] == null) return;
            if (ViewState["ClientID"] != null)
            {
                client = (int)ViewState["ClientID"];
            }
            else
            {
                CM_Contract c = new CM_ContractBLL((int)ViewState["ContractID"]).Model;
                if (c != null) client = c.Client;
            }

            if (client > 0)
            {
                CM_Client c = new CM_ClientBLL(client).Model;
                if (c != null && c["RTChannel"] == "1" && ConfigHelper.GetConfigInt("ContractFeeType-KA") > 0)
                {
                    ContractFeeType = ConfigHelper.GetConfigInt("ContractFeeType-KA");
                    ContractAccountTitle = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["ContractAccountTitle-KA"]);
                }
            }
            #endregion

        }
    }
コード例 #56
0
    protected void ddl_Contract_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (ddl_Contract.SelectedValue != "" && ddl_Contract.SelectedValue != "0")
        {
            CM_ContractBLL bll = new CM_ContractBLL(int.Parse(ddl_Contract.SelectedValue));
            if (bll.Items.Count == 0)
            {
                MessageBox.Show(this, "对不起,该合同没有需要付款的明细科目!");
                bt_Generate.Enabled = false;
                return;
            }

            #region 获取最早的付款截止日期
            DateTime minpaydate = GetMinPayDate(bll);

            if (minpaydate >= bll.Model.EndDate)
            {
                MessageBox.Show(this, "对不起,该合同没有需要付款的明细科目!");
                bt_Generate.Enabled = false;
                return;
            }
            lb_PayDateRegion.Text = minpaydate.ToString("yyyy年MM月dd日");

            DateTime monthenddate = new AC_AccountMonthBLL(int.Parse(ddl_Month.SelectedValue)).Model.EndDate;
            if (minpaydate > monthenddate)
            {
                MessageBox.Show(this, "对不起,该合同的付款明细科目尚未到请款时间,可以请款时间:" + lb_PayDateRegion.Text);
                bt_Generate.Enabled = false;
                return;
            }
            #endregion

            #region 获取允许预付的截止日期
            DateTime maxpaydate;
            int paymode = bll.Items.Where(p => p.PayMode <= 20).Max(p => p.PayMode);
            if (paymode == 20)
                maxpaydate = bll.Model.EndDate;
            else
            {
                maxpaydate = minpaydate.AddMonths(paymode).AddDays(-1);
                if (maxpaydate > bll.Model.EndDate) maxpaydate = bll.Model.EndDate;
            }
            lb_PayDateRegion.Text += "至" + maxpaydate.ToString("yyyy年MM月dd日");
            #endregion

            ddl_BeginMonth.DataSource = AC_AccountMonthBLL.GetModelList
                ("EndDate>='" + minpaydate.ToString("yyyy-MM-dd") +
                "' AND BeginDate<='" + maxpaydate.ToString("yyyy-MM-dd") + "'");
            ddl_BeginMonth.DataBind();
            ddl_BeginMonth.Enabled = false;

            ddl_EndMonth.DataSource = AC_AccountMonthBLL.GetModelList
                ("EndDate>='" + minpaydate.ToString("yyyy-MM-dd") +
                "' AND BeginDate<='" + maxpaydate.ToString("yyyy-MM-dd") +
                "' AND ID<=" + (int.Parse(ddl_Month.SelectedValue) + paymode - 1).ToString());
            ddl_EndMonth.DataBind();
            if (ddl_EndMonth.Items.Count > 0)
                ddl_EndMonth.Items[ddl_EndMonth.Items.Count - 1].Selected = true;

            bt_Generate.Enabled = true;
        }
    }
コード例 #57
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();
    }
コード例 #58
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            #region 获取页面参数
            if (Request.QueryString["ClientID"] != null)
            {
                ViewState["ClientID"] = Int32.Parse(Request.QueryString["ClientID"]);
                Session["ClientID"] = ViewState["ClientID"];
            }
            else if (Session["ClientID"] != null)
            {
                ViewState["ClientID"] = Int32.Parse(Session["ClientID"].ToString());
            }

            ViewState["ContractID"] = Request.QueryString["ContractID"] == null ? 0 : int.Parse(Request.QueryString["ContractID"]);
            #endregion

            BindDropDown();

            if ((int)ViewState["ContractID"] != 0)
            {
                CM_Contract _contract = new CM_ContractBLL((int)ViewState["ContractID"]).Model;
                if (_contract != null)
                {
                    ViewState["ClientID"] = _contract.Client;
                }
            }

            if (ViewState["ClientID"] != null && (int)ViewState["ClientID"] > 0)
            {
                CM_Client c = new CM_ClientBLL((int)ViewState["ClientID"]).Model;
                select_Client.SelectText = c.FullName;
                select_Client.SelectValue = c.ID.ToString();
                select_Client_SelectChange(null, null);
                //tr_OrganizeCity.SelectValue = c.OrganizeCity.ToString();
            }

            if ((int)ViewState["ContractID"] != 0)
            {
                ListItem item = ddl_Contract.Items.FindByValue(ViewState["ContractID"].ToString());
                if (item != null)
                {
                    ddl_Contract.ClearSelection();
                    item.Selected = true;
                    ddl_Contract_SelectedIndexChanged(null, null);
                }
            }
        }
    }