Beispiel #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        base.Page_Load(sender, e);
        if (!this.IsPostBack)
        {
            PageUtility.SetContentTitle(this.Page, "方案申请");
            this.Page.Title = "方案申请";


            // 用户信息,职位信息
            AuthorizationDS.StuffUserRow stuffUser       = (AuthorizationDS.StuffUserRow)Session["StuffUser"];
            AuthorizationDS.PositionRow  rowUserPosition = (AuthorizationDS.PositionRow)Session["Position"];
            this.ViewState["StuffUserID"]  = stuffUser.StuffUserId;
            this.ViewState["PositionID"]   = rowUserPosition.PositionId;
            this.ViewState["FlowTemplate"] = new AuthorizationBLL().GetFlowTemplate((int)SystemEnums.BusinessUseCase.FormApply, stuffUser.StuffUserId);

            this.StuffNameCtl.Text         = stuffUser.StuffName;
            this.PositionNameCtl.Text      = rowUserPosition.PositionName;
            this.DepartmentNameCtl.Text    = new OUTreeBLL().GetOrganizationUnitById(rowUserPosition.OrganizationUnitId).OrganizationUnitName;
            this.ViewState["DepartmentID"] = rowUserPosition.OrganizationUnitId;
            this.AttendDateCtl.Text        = stuffUser.AttendDate.ToShortDateString();

            if (this.Request["RejectObjectID"] != null)
            {
                this.ViewState["RejectedObjectID"] = int.Parse(this.Request["RejectObjectID"].ToString());
            }
            //如果是草稿进行赋值
            if (Request["ObjectId"] != null)
            {
                this.ViewState["ObjectId"] = int.Parse(Request["ObjectId"]);
                if (this.Request["RejectObjectID"] == null)
                {
                    this.DeleteBtn.Visible = true;
                }
                else
                {
                    this.DeleteBtn.Visible = false;
                }
                OpenForm(int.Parse(this.ViewState["ObjectId"].ToString()));
            }
            else
            {
                this.DeleteBtn.Visible = false;
                if (Request["CustomerID"] != null)
                {
                    this.ViewState["CustomerID"] = Request["CustomerID"];
                }
                else
                {
                    this.Session["ErrorInfor"] = "未找到客户,请联系管理员";
                    Response.Redirect("~/ErrorPage/SystemErrorPage.aspx");
                }
                if (Request["BeginPeriod"] != null && Request["EndPeriod"] != null)
                {
                    this.ViewState["BeginPeriod"] = Request["BeginPeriod"];
                    this.ViewState["EndPeriod"]   = Request["EndPeriod"];
                }
                else
                {
                    this.Session["ErrorInfor"] = "没有费用期间,请联系管理员";
                    Response.Redirect("~/ErrorPage/SystemErrorPage.aspx");
                }
                if (Request["ExpenseSubCategoryID"] != null)
                {
                    this.ViewState["ExpenseSubCategoryID"] = Request["ExpenseSubCategoryID"];
                }
                else
                {
                    this.Session["ErrorInfor"] = "未找到费用小类,请联系管理员";
                    Response.Redirect("~/ErrorPage/SystemErrorPage.aspx");
                }

                this.BeginPeriodCtl.Text        = DateTime.Parse(this.ViewState["BeginPeriod"].ToString()).ToString("yyyy-MM");
                this.EndPeriodCtl.Text          = DateTime.Parse(this.ViewState["EndPeriod"].ToString()).ToString("yyyy-MM");
                this.ExpenseSubCategoryCtl.Text = new MasterDataBLL().GetExpenseSubCateNameById(int.Parse(this.ViewState["ExpenseSubCategoryID"].ToString()));
                ERS.CustomerRow customer = new MasterDataBLL().GetCustomerById(int.Parse(this.ViewState["CustomerID"].ToString()));
                this.CustomerNameCtl.Text = customer.CustomerName;
                //this.CustomerTypeCtl.Text = new MasterDataBLL().GetCustomerTypeById(customer.CustomerTypeID).CustomerTypeName;
                this.odsShop.SelectParameters["CustomerID"].DefaultValue = customer.CustomerID.ToString();
            }
            //判断费用期间是否正确
            MasterDataBLL bll = new MasterDataBLL();
            if (!bll.IsValidApplyYear(DateTime.Parse(this.ViewState["BeginPeriod"].ToString()).AddMonths(-3).Year))
            {
                this.SubmitBtn.Visible = false;
                PageUtility.ShowModelDlg(this, "不允许申请本财年项目,请联系财务部!");
                return;
            }

            //预算信息
            decimal[] calculateAssistant = new decimal[14];
            calculateAssistant                = new BudgetBLL().GetSalesBudgetByParameter(int.Parse(this.ViewState["CustomerID"].ToString()), DateTime.Parse(this.ViewState["BeginPeriod"].ToString()), int.Parse(this.ViewState["ExpenseSubCategoryID"].ToString()));
            this.CustomerBudgetCtl.Text       = calculateAssistant[0].ToString("N");
            this.CustomerBudgetRemainCtl.Text = calculateAssistant[5].ToString("N");
            this.OUBudgetCtl.Text             = calculateAssistant[7].ToString("N");
            this.OUApprovedAmountCtl.Text     = calculateAssistant[8].ToString("N");
            this.OUApprovingAmountCtl.Text    = calculateAssistant[9].ToString("N");
            this.OUCompletedAmountCtl.Text    = calculateAssistant[10].ToString("N");
            this.OUReimbursedAmountCtl.Text   = calculateAssistant[11].ToString("N");
            this.OUBudgetRemainCtl.Text       = calculateAssistant[12].ToString("N");
            this.OUBudgetRateCtl.Text         = ((decimal)(calculateAssistant[13] * 100)).ToString("N") + "%";

            if (Session["ProxyStuffUserId"] != null)
            {
                this.SubmitBtn.Visible = false;
            }
        }
        // 打开明细表
        FormApplyDetailViewTableAdapter taDetail = new FormApplyDetailViewTableAdapter();
        int      customerID = int.Parse(this.ViewState["CustomerID"].ToString());
        DateTime period     = DateTime.Parse(this.ViewState["BeginPeriod"].ToString());

        taDetail.FillDataFromRebate(this.InnerDS.FormApplyDetailView, customerID, period.Year, period.Month);
        //隐藏预算信息
        this.OUBudgetCtl.Text           = "";
        this.OUApprovedAmountCtl.Text   = "";
        this.OUApprovingAmountCtl.Text  = "";
        this.OUCompletedAmountCtl.Text  = "";
        this.OUReimbursedAmountCtl.Text = "";
        this.OUBudgetRemainCtl.Text     = "";
        this.OUBudgetRateCtl.Text       = "";
    }
Beispiel #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        base.Page_Load(sender, e);
        if (!this.IsPostBack)
        {
            PageUtility.SetContentTitle(this.Page, "方案申请");
            this.Page.Title = "方案申请";


            // 用户信息,职位信息
            AuthorizationDS.StuffUserRow stuffUser       = (AuthorizationDS.StuffUserRow)Session["StuffUser"];
            AuthorizationDS.PositionRow  rowUserPosition = (AuthorizationDS.PositionRow)Session["Position"];
            this.ViewState["StuffUserID"]  = stuffUser.StuffUserId;
            this.ViewState["PositionID"]   = rowUserPosition.PositionId;
            this.ViewState["FlowTemplate"] = new AuthorizationBLL().GetFlowTemplate((int)SystemEnums.BusinessUseCase.FormApply, stuffUser.StuffUserId);

            this.StuffNameCtl.Text         = stuffUser.StuffName;
            this.PositionNameCtl.Text      = rowUserPosition.PositionName;
            this.DepartmentNameCtl.Text    = new OUTreeBLL().GetOrganizationUnitById(rowUserPosition.OrganizationUnitId).OrganizationUnitName;
            this.ViewState["DepartmentID"] = rowUserPosition.OrganizationUnitId;
            this.AttendDateCtl.Text        = stuffUser.AttendDate.ToShortDateString();

            if (this.Request["RejectObjectID"] != null)
            {
                this.ViewState["RejectedObjectID"] = int.Parse(this.Request["RejectObjectID"].ToString());
            }
            //如果是草稿进行赋值
            if (Request["ObjectId"] != null)
            {
                this.ViewState["ObjectId"] = int.Parse(Request["ObjectId"]);
                if (this.Request["RejectObjectID"] == null)
                {
                    this.DeleteBtn.Visible = true;
                }
                else
                {
                    this.DeleteBtn.Visible = false;
                }
                OpenForm(int.Parse(this.ViewState["ObjectId"].ToString()));
            }
            else
            {
                this.DeleteBtn.Visible = false;
                if (Request["CustomerID"] != null)
                {
                    this.ViewState["CustomerID"] = Request["CustomerID"];
                }
                else
                {
                    this.Session["ErrorInfor"] = "未找到客户,请联系管理员";
                    Response.Redirect("~/ErrorPage/SystemErrorPage.aspx");
                }
                if (Request["BeginPeriod"] != null && Request["EndPeriod"] != null)
                {
                    this.ViewState["BeginPeriod"] = Request["BeginPeriod"];
                    this.ViewState["EndPeriod"]   = Request["EndPeriod"];
                }
                else
                {
                    this.Session["ErrorInfor"] = "没有费用期间,请联系管理员";
                    Response.Redirect("~/ErrorPage/SystemErrorPage.aspx");
                }
                if (Request["ExpenseSubCategoryID"] != null)
                {
                    this.ViewState["ExpenseSubCategoryID"] = Request["ExpenseSubCategoryID"];
                }
                else
                {
                    this.Session["ErrorInfor"] = "未找到费用小类,请联系管理员";
                    Response.Redirect("~/ErrorPage/SystemErrorPage.aspx");
                }
                if (Request["PromotionPriceType"] != null)
                {
                    this.ViewState["PromotionPriceType"] = Request["PromotionPriceType"];
                }
                else
                {
                    this.Session["ErrorInfor"] = "未找到产品促销类型,请联系管理员";
                    Response.Redirect("~/ErrorPage/SystemErrorPage.aspx");
                }
                this.BeginPeriodCtl.Text        = DateTime.Parse(this.ViewState["BeginPeriod"].ToString()).ToString("yyyy-MM");
                this.EndPeriodCtl.Text          = DateTime.Parse(this.ViewState["EndPeriod"].ToString()).ToString("yyyy-MM");
                this.ExpenseSubCategoryCtl.Text = new MasterDataBLL().GetExpenseSubCateNameById(int.Parse(this.ViewState["ExpenseSubCategoryID"].ToString()));
                ERS.CustomerRow customer = new MasterDataBLL().GetCustomerById(int.Parse(this.ViewState["CustomerID"].ToString()));
                this.CustomerNameCtl.Text = customer.CustomerName;
                //this.CustomerTypeCtl.Text = new MasterDataBLL().GetCustomerTypeById(customer.CustomerTypeID).CustomerTypeName;
                this.odsShop.SelectParameters["CustomerID"].DefaultValue = customer.CustomerID.ToString();
                CommonUtility.InitSplitRate(InnerDS.FormApplySplitRate, DateTime.Parse(this.ViewState["BeginPeriod"].ToString()), DateTime.Parse(this.ViewState["EndPeriod"].ToString()));
            }
            //判断费用期间是否正确
            MasterDataBLL bll = new MasterDataBLL();
            if (!bll.IsValidApplyYear(DateTime.Parse(this.ViewState["BeginPeriod"].ToString()).AddMonths(-3).Year))
            {
                this.SubmitBtn.Visible = false;
                PageUtility.ShowModelDlg(this, "不允许申请本财年项目,请联系财务部!");
                return;
            }

            //处理促销供货价和买送哪个可以填写
            if (this.ViewState["PromotionPriceType"].ToString() == ((int)SystemEnums.PromotionPriceType.Promotion).ToString())
            {
                this.IsPromotionReadOnly = false;
                this.IsGiveReadOnly      = true;
            }
            else
            {
                this.IsPromotionReadOnly = true;
                this.IsGiveReadOnly      = false;
            }
            this.ExpenseSubCategoryID.Value = this.ViewState["ExpenseSubCategoryID"].ToString();

            if (InnerDS.FormApplySplitRate != null && InnerDS.FormApplySplitRate.Count > 0)
            {
                this.divSplitRate.Visible   = true;
                this.gvSplitRate.Visible    = true;
                this.gvSplitRate.DataSource = InnerDS.FormApplySplitRate;
                this.gvSplitRate.DataBind();
            }

            //预算信息
            decimal[] calculateAssistant = new decimal[14];
            calculateAssistant                = new BudgetBLL().GetSalesBudgetByParameter(int.Parse(this.ViewState["CustomerID"].ToString()), DateTime.Parse(this.ViewState["BeginPeriod"].ToString()), int.Parse(this.ViewState["ExpenseSubCategoryID"].ToString()));
            this.CustomerBudgetCtl.Text       = calculateAssistant[0].ToString("N");
            this.CustomerBudgetRemainCtl.Text = calculateAssistant[5].ToString("N");
            this.OUBudgetCtl.Text             = calculateAssistant[7].ToString("N");
            this.OUApprovedAmountCtl.Text     = calculateAssistant[8].ToString("N");
            this.OUApprovingAmountCtl.Text    = calculateAssistant[9].ToString("N");
            this.OUCompletedAmountCtl.Text    = calculateAssistant[10].ToString("N");
            this.OUReimbursedAmountCtl.Text   = calculateAssistant[11].ToString("N");
            this.OUBudgetRemainCtl.Text       = calculateAssistant[12].ToString("N");
            this.OUBudgetRateCtl.Text         = ((decimal)(calculateAssistant[13] * 100)).ToString("N") + "%";
            InitCustomerTimesLimit();

            if (Session["ProxyStuffUserId"] != null)
            {
                this.SubmitBtn.Visible = false;
            }
        }
        else
        {
            this.ExpenseItemRemainTimes = (Dictionary <int, object[]>) this.ViewState["ExpenseItemRemainTimes"];
        }
        //隐藏预算信息
        this.OUBudgetCtl.Text           = "";
        this.OUApprovedAmountCtl.Text   = "";
        this.OUApprovingAmountCtl.Text  = "";
        this.OUCompletedAmountCtl.Text  = "";
        this.OUReimbursedAmountCtl.Text = "";
        this.OUBudgetRemainCtl.Text     = "";
        this.OUBudgetRateCtl.Text       = "";

        if (setEditRowIndex)
        {
            this.SKUListView.EditIndex = this.SKUListView.DataKeys.Count - 1;
            setEditRowIndex            = false;
        }
    }
    protected void NextButton_Click(object sender, EventArgs e)
    {
        string startPeriod = ((TextBox)(this.UCPeriodBegin.FindControl("txtDate"))).Text.Trim();
        string endPeriod   = ((TextBox)(this.UCPeriodEnd.FindControl("txtDate"))).Text.Trim();

        if (startPeriod == string.Empty)
        {
            PageUtility.ShowModelDlg(this, "请选择起始费用期间!");
            return;
        }
        if (endPeriod == string.Empty)
        {
            PageUtility.ShowModelDlg(this, "请选择截止费用期间!");
            return;
        }
        DateTime dtstartPeriod = DateTime.Parse(startPeriod.Substring(0, 4) + "-" + startPeriod.Substring(4, 2) + "-01");
        DateTime dtendPeriod   = DateTime.Parse(endPeriod.Substring(0, 4) + "-" + endPeriod.Substring(4, 2) + "-01");

        if (dtstartPeriod > dtendPeriod)
        {
            PageUtility.ShowModelDlg(this, "起始费用期间大于截止费用期间!");
            return;
        }
        MasterDataBLL bll = new MasterDataBLL();

        if (dtstartPeriod.AddMonths(-3).Year != dtendPeriod.AddMonths(-3).Year)
        {
            PageUtility.ShowModelDlg(this, "起始和截止费用期间必须在同一财年内!");
            return;
        }
        if (!bll.IsValidApplyYear(dtstartPeriod.AddMonths(-3).Year))
        {
            PageUtility.ShowModelDlg(this, "不允许申请本财年项目,请联系财务部!");
            return;
        }

        if (this.CustomerDDL.SelectedValue == null || this.CustomerDDL.SelectedValue == string.Empty)
        {
            PageUtility.ShowModelDlg(this, "请选择客户!");
            return;
        }

        if (this.SubCategoryDDL.SelectedValue == "0")
        {
            PageUtility.ShowModelDlg(this, "请选择费用小类!");
            return;
        }

        ERS.ExpenseSubCategoryRow subCategory = bll.GetExpenseSubCategoryById(int.Parse(this.SubCategoryDDL.SelectedValue));
        //检查如果是返利,只能填写一个月的
        if (subCategory.PageType == (int)SystemEnums.PageType.RebateApply)
        {
            if (dtstartPeriod.Year != dtendPeriod.Year || dtstartPeriod.Month != dtendPeriod.Month)
            {
                PageUtility.ShowModelDlg(this, "返利申请不能跨月!");
                return;
            }
            if (new SalesApplyBLL().GetRebateApplyCountByParameter(int.Parse(this.CustomerDDL.SelectedValue), dtstartPeriod.Year, dtstartPeriod.Month, int.Parse(this.SubCategoryDDL.SelectedValue)) > 0)
            {
                PageUtility.ShowModelDlg(this, "系统中已经存在该客户的返利申请,返利申请每月只能申请一次!");
                return;
            }
        }
        switch (subCategory.PageType)
        {
        case (int)SystemEnums.PageType.PromotionApply:
            this.Response.Redirect("~/SalesForm/SalesPromotionApply.aspx?CustomerID=" + this.CustomerDDL.SelectedValue + "&ExpenseSubCategoryID=" + this.SubCategoryDDL.SelectedValue + "&BeginPeriod=" + dtstartPeriod.ToShortDateString() + "&EndPeriod=" + dtendPeriod.ToShortDateString() + "&PromotionPriceType=" + this.PromotionPriceTypeDDL.SelectedValue);
            break;

        case (int)SystemEnums.PageType.GeneralApply:
            this.Response.Redirect("~/SalesForm/SalesGeneralApply.aspx?CustomerID=" + this.CustomerDDL.SelectedValue + "&ExpenseSubCategoryID=" + this.SubCategoryDDL.SelectedValue + "&BeginPeriod=" + dtstartPeriod.ToShortDateString() + "&EndPeriod=" + dtendPeriod.ToShortDateString());
            break;

        case (int)SystemEnums.PageType.RebateApply:
            this.Response.Redirect("~/SalesForm/SalesRebateApply.aspx?CustomerID=" + this.CustomerDDL.SelectedValue + "&ExpenseSubCategoryID=" + this.SubCategoryDDL.SelectedValue + "&BeginPeriod=" + dtstartPeriod.ToShortDateString() + "&EndPeriod=" + dtendPeriod.ToShortDateString());
            break;
        }
    }