Exemplo n.º 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());

            }
            //����Dzݸ���и�ֵ
            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;
        }
    }
Exemplo n.º 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());

            }
            //����Dzݸ���и�ֵ
            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 = "";
    }
Exemplo n.º 3
0
    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;
        }
    }