Esempio n. 1
0
 protected void gvApplyList_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "scrap")
     {
         int            FormID = Int32.Parse(e.CommandArgument.ToString());
         FormDS.FormRow row    = new SalesApplyBLL().GetFormByID(FormID)[0];
         int            count  = new SalesApplyBLL().GetEnabledFormReimburseByApplyID(FormID);
         if (count > 0)
         {
             PageUtility.ShowModelDlg(this, "不能作废单据,此单据有相关报销单!");
         }
         else
         {
             if (row.StatusID != 2)
             {
                 PageUtility.ShowModelDlg(this, "只能作废审批完成状态的单据!");
             }
             else
             {
                 new APFlowBLL().ScrapForm(FormID);
                 gvApplyList.DataBind();
             }
         }
     }
 }
Esempio n. 2
0
    public static string GetNameByFormID(int FormTypeID, int FormID)
    {
        string ApplyName = string.Empty;

        if (FormTypeID == (int)SystemEnums.FormType.SalesApply)
        {
            FormDS.FormApplyRow applyRow = new SalesApplyBLL().GetFormApplyByID(FormID)[0];
            if (!applyRow.IsFormApplyNameNull())
            {
                ApplyName = applyRow.FormApplyName.Length > 10 ? applyRow.FormApplyName.Substring(0, 10) : applyRow.FormApplyName;
            }
        }

        if (FormTypeID == (int)SystemEnums.FormType.ContractApply)
        {
            FormDS.FormContractRow applyRow = new ContractApplyBLL().GetFormContractByID(FormID)[0];
            ApplyName = applyRow.ContractName.Length > 10 ? applyRow.ContractName.Substring(0, 10) : applyRow.ContractName;
        }

        return(ApplyName);
    }
Esempio n. 3
0
    protected void odsExpense_ObjectCreated(object sender, ObjectDataSourceEventArgs e)
    {
        SalesApplyBLL bll = (SalesApplyBLL)e.ObjectInstance;

        bll.FormDataSet = this.InnerDS;
    }
Esempio n. 4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        base.Page_Load(sender, e);
        if (!this.IsPostBack)
        {
            PageUtility.SetContentTitle(this.Page, "方案申请审批");
            this.Page.Title = "方案申请审批";

            int formID = int.Parse(Request["ObjectId"]);
            this.ViewState["ObjectId"] = formID;
            FormDS.FormRow      rowForm      = this.SalesApplyBLL.GetFormByID(formID)[0];
            FormDS.FormApplyRow rowFormApply = this.SalesApplyBLL.GetFormApplyByID(formID)[0];
            if (rowForm.IsProcIDNull())
            {
                ViewState["ProcID"] = "";
            }
            else
            {
                ViewState["ProcID"] = rowForm.ProcID;
            }
            ViewState["OrganizationUnitID"] = rowForm.OrganizationUnitID;
            this.FormNoCtl.Text             = rowForm.FormNo;
            this.ApplyDateCtl.Text          = rowForm.SubmitDate.ToShortDateString();
            AuthorizationDS.StuffUserRow applicant = new AuthorizationBLL().GetStuffUserById(rowForm.UserID);
            this.StuffNameCtl.Text    = applicant.StuffName;
            this.PositionNameCtl.Text = new OUTreeBLL().GetPositionById(rowForm.PositionID).PositionName;
            if (new OUTreeBLL().GetOrganizationUnitById(rowForm.OrganizationUnitID) != null)
            {
                this.DepartmentNameCtl.Text = new OUTreeBLL().GetOrganizationUnitById(rowForm.OrganizationUnitID).OrganizationUnitName;
            }
            this.AttendDateCtl.Text  = applicant.AttendDate.ToShortDateString();
            this.BeginPeriodCtl.Text = rowFormApply.BeginPeriod.ToString("yyyy-MM");
            this.EndPeriodCtl.Text   = rowFormApply.EndPeriod.ToString("yyyy-MM");
            MasterDataBLL masterBll = new MasterDataBLL();
            this.ExpenseSubCategoryCtl.Text = masterBll.GetExpenseSubCateNameById(rowFormApply.ExpenseSubCategoryID);
            ERS.CustomerRow customer = masterBll.GetCustomerById(rowFormApply.CustomerID);
            this.CustomerNameCtl.Text = customer.CustomerName;
            //this.CustomerTypeCtl.Text = masterBll.GetCustomerTypeById(customer.CustomerTypeID).CustomerTypeName;
            this.ShopNameCtl.Text    = masterBll.GetShopByID(rowFormApply.ShopID).ShopName;
            this.PaymentTypeCtl.Text = masterBll.GetPaymentTypeById(rowFormApply.PaymentTypeID).PaymentTypeName;
            if (!rowFormApply.IsContractNoNull())
            {
                this.ContractNoCtl.Text = rowFormApply.ContractNo;
            }
            this.AmountCtl.Text = rowFormApply.Amount.ToString("N");
            if (!rowFormApply.IsRemarkNull())
            {
                this.RemarkCtl.Text = rowFormApply.Remark;
            }
            if (!rowFormApply.IsAttachedFileNameNull())
            {
                this.UCFileUpload.AttachmentFileName = rowFormApply.AttachedFileName;
            }
            if (!rowFormApply.IsRealAttachedFileNameNull())
            {
                this.UCFileUpload.RealAttachmentFileName = rowFormApply.RealAttachedFileName;
            }

            if (!rowFormApply.IsPromotionBeginDateNull())
            {
                this.PromotionBeginCtl.Text = rowFormApply.PromotionBeginDate.ToString("yyyy-MM-dd");
            }
            if (!rowFormApply.IsPromotionEndDateNull())
            {
                this.PromotionEndCtl.Text = rowFormApply.PromotionEndDate.ToString("yyyy-MM-dd");
            }
            if (!rowFormApply.IsDeliveryBeginDateNull())
            {
                this.DeliveryBeginCtl.Text = rowFormApply.DeliveryBeginDate.ToString("yyyy-MM-dd");
            }
            if (!rowFormApply.IsDeliveryEndDateNull())
            {
                this.DeliveryEndCtl.Text = rowFormApply.DeliveryEndDate.ToString("yyyy-MM-dd");
            }
            if (!rowFormApply.IsFormApplyNameNull())
            {
                this.txtFormApplyName.Text = rowFormApply.FormApplyName;
            }
            this.PromotionScopeCtl.Text = masterBll.GetPromotionScopeById(rowFormApply.PromotionScopeID).PromotionScopeName;
            this.PromotionTypeCtl.Text  = masterBll.GetPromotionTypeById(rowFormApply.PromotionTypeID).PromotionTypeName;
            if (!rowFormApply.IsPromotionDescNull())
            {
                this.PromotionDescCtl.Text = rowFormApply.PromotionDesc;
            }
            this.ShelfTypeCtl.Text = masterBll.GetShelfTypeById(rowFormApply.ShelfTypeID).ShelfTypeName;
            if (!rowFormApply.IsFirstVolumeNull())
            {
                this.FirstVolumeCtl.Text = rowFormApply.FirstVolume.ToString();
            }
            if (!rowFormApply.IsSecondVolumeNull())
            {
                this.SecondVolumeCtl.Text = rowFormApply.SecondVolume.ToString();
            }
            if (!rowFormApply.IsThirdVolumeNull())
            {
                this.ThirdVolumeCtl.Text = rowFormApply.ThirdVolume.ToString();
            }
            if (!rowFormApply.IsAverageVolumeNull())
            {
                this.AverageVolumeCtl.Text = rowFormApply.AverageVolume.ToString();
            }

            if (!rowFormApply.IsReimburseRequirementsNull())
            {
                int ReimburseRequirement = rowFormApply.ReimburseRequirements;
                if ((ReimburseRequirement & (int)SystemEnums.ReimburseRequirements.Picture) == (int)SystemEnums.ReimburseRequirements.Picture)
                {
                    chkListReimburseRequirements.Items[0].Selected = true;
                }
                if ((ReimburseRequirement & (int)SystemEnums.ReimburseRequirements.Agreement) == (int)SystemEnums.ReimburseRequirements.Agreement)
                {
                    chkListReimburseRequirements.Items[1].Selected = true;
                }
                if ((ReimburseRequirement & (int)SystemEnums.ReimburseRequirements.DeliveryOrder) == (int)SystemEnums.ReimburseRequirements.DeliveryOrder)
                {
                    chkListReimburseRequirements.Items[2].Selected = true;
                }
                if ((ReimburseRequirement & (int)SystemEnums.ReimburseRequirements.Contract) == (int)SystemEnums.ReimburseRequirements.Contract)
                {
                    chkListReimburseRequirements.Items[3].Selected = true;
                }
                if ((ReimburseRequirement & (int)SystemEnums.ReimburseRequirements.DM) == (int)SystemEnums.ReimburseRequirements.DM)
                {
                    chkListReimburseRequirements.Items[4].Selected = true;
                }
                if ((ReimburseRequirement & (int)SystemEnums.ReimburseRequirements.Other) == (int)SystemEnums.ReimburseRequirements.Other)
                {
                    chkListReimburseRequirements.Items[5].Selected = true;
                }
            }

            //历史单据
            if (rowForm.IsRejectedFormIDNull())
            {
                lblRejectFormNo.Text = "无";
            }
            else
            {
                FormDS.FormRow rejectedForm = new SalesApplyBLL().GetFormByID(rowForm.RejectedFormID)[0];
                this.lblRejectFormNo.Text        = rejectedForm.FormNo;
                this.lblRejectFormNo.NavigateUrl = "javascript:window.showModalDialog('" + System.Configuration.ConfigurationManager.AppSettings["WebSiteUrl"] + "/SalesForm/SalesGeneralApproval.aspx?ShowDialog=1&ObjectId=" + rejectedForm.FormID + "','', 'dialogWidth:1000px;dialogHeight:750px;resizable:yes;')";
            }

            //查看预算信息按钮
            this.btnViewBudget.NavigateUrl = "javascript:window.showModalDialog('" + System.Configuration.ConfigurationManager.AppSettings["WebSiteUrl"] + "/ReportManage/SalesBudgetByPosition.aspx?ShowDialog=1','', 'dialogWidth:918px;dialogHeight:660px;resizable:yes;')";

            //预算信息
            this.CustomerBudgetCtl.Text       = rowFormApply.CustomerBudget.ToString("N");
            this.CustomerBudgetRemainCtl.Text = rowFormApply.CustomerBudgetRemain.ToString("N");
            this.OUBudgetCtl.Text             = rowFormApply.OUBudget.ToString("N");
            this.OUApprovedAmountCtl.Text     = rowFormApply.OUAppovedAmount.ToString("N");
            this.OUApprovingAmountCtl.Text    = rowFormApply.OUApprovingAmount.ToString("N");
            this.OUCompletedAmountCtl.Text    = rowFormApply.OUCompletedAmount.ToString("N");
            this.OUReimbursedAmountCtl.Text   = rowFormApply.OUReimbursedAmount.ToString("N");
            this.OUBudgetRemainCtl.Text       = rowFormApply.OUBudgetRemain.ToString("N");
            this.OUBudgetRateCtl.Text         = ((decimal)(rowFormApply.OUBudgetRate * 100)).ToString("N") + "%";

            this.odsSKU.SelectParameters["FormApplyID"].DefaultValue = rowFormApply.FormApplyID.ToString();

            //审批页面处理&按钮处理
            AuthorizationDS.StuffUserRow stuffUser = (AuthorizationDS.StuffUserRow)Session["StuffUser"];
            this.ViewState["StuffUserID"] = stuffUser.StuffUserId;
            if (rowForm.InTurnUserIds.Contains("P" + stuffUser.StuffUserId + "P"))
            {
                this.SubmitBtn.Visible   = true;
                this.cwfAppCheck.IsView  = false;
                this.ViewState["IsView"] = false;
            }
            else
            {
                this.SubmitBtn.Visible   = false;
                this.cwfAppCheck.IsView  = true;
                this.ViewState["IsView"] = true;
            }

            if (rowForm.StatusID == (int)SystemEnums.FormStatus.Rejected && stuffUser.StuffUserId == rowForm.UserID)
            {
                this.EditBtn.Visible  = true;
                this.ScrapBtn.Visible = true;
            }
            else
            {
                this.EditBtn.Visible  = false;
                this.ScrapBtn.Visible = false;
            }

            //是否显示复制按钮
            if (rowForm.StatusID == (int)SystemEnums.FormStatus.ApproveCompleted && stuffUser.StuffUserId == rowForm.UserID)
            {
                this.UCBeginPeriod.Visible = true;
                this.UCEndPeriod.Visible   = true;
                this.lblSignal.Visible     = true;
                this.CopyBtn.Visible       = true;
            }
            else
            {
                this.UCBeginPeriod.Visible = false;
                this.UCEndPeriod.Visible   = false;
                this.lblSignal.Visible     = false;
                this.CopyBtn.Visible       = false;
            }
            //是否显示打印信息
            if (((stuffUser.StuffUserId == rowForm.UserID || base.IsBusinessProxy(rowForm.UserID, rowForm.SubmitDate) && (rowForm.StatusID == (int)SystemEnums.FormStatus.ApproveCompleted) || rowForm.StatusID == (int)SystemEnums.FormStatus.Scrap && rowFormApply.IsAutoSplit)))
            {
                this.PrintBtn.Visible = true;
            }
            else
            {
                this.PrintBtn.Visible = false;
            }

            if (rowForm.StatusID == (int)SystemEnums.FormStatus.ApproveCompleted || (rowForm.StatusID == (int)SystemEnums.FormStatus.Scrap && rowFormApply.IsAutoSplit))
            {
                this.PrintInfor.Visible = true;
                int printCount = rowFormApply.IsPrintCountNull() ? 0 : rowFormApply.PrintCount;
                this.PrintInfor.Text = "该方案已经被打印" + printCount + "次";
            }
            else
            {
                this.PrintInfor.Visible = false;
            }

            //如果是弹出,取消按钮不可见
            if (this.Request["ShowDialog"] != null)
            {
                if (this.Request["ShowDialog"].ToString() == "1")
                {
                    this.upButton.Visible = false;
                    this.Master.FindControl("divMenu").Visible       = false;
                    this.Master.FindControl("tbCurrentPage").Visible = false;
                    this.PrintInfor.Visible = false;
                    this.PrintBtn.Visible   = false;
                }
            }
            //如果是申请人则隐藏预算信息
            if (stuffUser.StuffUserId == rowForm.UserID)
            {
                this.OUBudgetCtl.Text           = "";
                this.OUApprovedAmountCtl.Text   = "";
                this.OUApprovingAmountCtl.Text  = "";
                this.OUCompletedAmountCtl.Text  = "";
                this.OUReimbursedAmountCtl.Text = "";
                this.OUBudgetRemainCtl.Text     = "";
                this.OUBudgetRateCtl.Text       = "";
                this.btnViewBudget.Visible      = false;
            }
            //分摊比例
            new FormApplySplitRateTableAdapter().FillByApplyID(InnerDS.FormApplySplitRate, formID);
            if (InnerDS.FormApplySplitRate != null && InnerDS.FormApplySplitRate.Count > 0)
            {
                this.divSplitRate.Visible   = true;
                this.gvSplitRate.Visible    = true;
                this.gvSplitRate.DataSource = InnerDS.FormApplySplitRate;
                this.gvSplitRate.DataBind();
            }
        }
        this.cwfAppCheck.FormID = (int)this.ViewState["ObjectId"];
        this.cwfAppCheck.ProcID = this.ViewState["ProcID"].ToString();
        this.cwfAppCheck.IsView = (bool)this.ViewState["IsView"];
    }
Esempio n. 5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        base.Page_Load(sender, e);
        if (!this.IsPostBack)
        {
            PageUtility.SetContentTitle(this.Page, "方案申请审批");
            this.Page.Title = "方案申请审批";

            int formID = int.Parse(Request["ObjectId"]);
            this.ViewState["ObjectId"] = formID;
            FormDS.FormRow      rowForm      = this.SalesApplyBLL.GetFormByID(formID)[0];
            FormDS.FormApplyRow rowFormApply = this.SalesApplyBLL.GetFormApplyByID(formID)[0];
            if (rowForm.IsProcIDNull())
            {
                ViewState["ProcID"] = "";
            }
            else
            {
                ViewState["ProcID"] = rowForm.ProcID;
            }
            ViewState["OrganizationUnitID"] = rowForm.OrganizationUnitID;
            this.FormNoCtl.Text             = rowForm.FormNo;
            this.ApplyDateCtl.Text          = rowForm.SubmitDate.ToShortDateString();
            AuthorizationDS.StuffUserRow applicant = new AuthorizationBLL().GetStuffUserById(rowForm.UserID);
            this.StuffNameCtl.Text    = applicant.StuffName;
            this.PositionNameCtl.Text = new OUTreeBLL().GetPositionById(rowForm.PositionID).PositionName;
            if (new OUTreeBLL().GetOrganizationUnitById(rowForm.OrganizationUnitID) != null)
            {
                this.DepartmentNameCtl.Text = new OUTreeBLL().GetOrganizationUnitById(rowForm.OrganizationUnitID).OrganizationUnitName;
            }
            this.AttendDateCtl.Text  = applicant.AttendDate.ToShortDateString();
            this.BeginPeriodCtl.Text = rowFormApply.BeginPeriod.ToShortDateString();
            this.EndPeriodCtl.Text   = rowFormApply.EndPeriod.ToShortDateString();
            MasterDataBLL masterBll = new MasterDataBLL();
            this.ExpenseSubCategoryCtl.Text = masterBll.GetExpenseSubCateNameById(rowFormApply.ExpenseSubCategoryID);
            ERS.CustomerRow customer = masterBll.GetCustomerById(rowFormApply.CustomerID);
            this.CustomerNameCtl.Text = customer.CustomerName;
            this.CustomerTypeCtl.Text = masterBll.GetCustomerTypeById(customer.CustomerTypeID).CustomerTypeName;
            this.ShopNameCtl.Text     = masterBll.GetShopByID(rowFormApply.ShopID).ShopName;
            this.PaymentTypeCtl.Text  = masterBll.GetPaymentTypeById(rowFormApply.PaymentTypeID).PaymentTypeName;
            if (!rowFormApply.IsContractNoNull())
            {
                this.ContractNoCtl.Text = rowFormApply.ContractNo;
            }
            this.AmountCtl.Text = rowFormApply.Amount.ToString("N");
            if (!rowFormApply.IsRemarkNull())
            {
                this.RemarkCtl.Text = rowFormApply.Remark;
            }
            if (!rowFormApply.IsAttachedFileNameNull())
            {
                this.UCFileUpload.AttachmentFileName = rowFormApply.AttachedFileName;
            }
            if (!rowFormApply.IsRealAttachedFileNameNull())
            {
                this.UCFileUpload.RealAttachmentFileName = rowFormApply.RealAttachedFileName;
            }

            //历史单据
            if (rowForm.IsRejectedFormIDNull())
            {
                lblRejectFormNo.Text = "无";
            }
            else
            {
                FormDS.FormRow rejectedForm = new SalesApplyBLL().GetFormByID(rowForm.RejectedFormID)[0];
                this.lblRejectFormNo.Text        = rejectedForm.FormNo;
                this.lblRejectFormNo.NavigateUrl = "javascript:window.showModalDialog('" + System.Configuration.ConfigurationManager.AppSettings["WebSiteUrl"] + "/SalesForm/SalesRebateApproval.aspx?ShowDialog=1&ObjectId=" + rejectedForm.FormID + "','', 'dialogWidth:1000px;dialogHeight:750px;resizable:yes;')";
            }

            //查看预算信息按钮
            this.btnViewBudget.NavigateUrl = "javascript:window.showModalDialog('" + System.Configuration.ConfigurationManager.AppSettings["WebSiteUrl"] + "/ReportManage/SalesFeeByPosition.aspx?ShowDialog=1','', 'dialogWidth:918px;dialogHeight:660px;resizable:yes;')";

            //预算信息
            this.CustomerBudgetCtl.Text       = rowFormApply.CustomerBudget.ToString("N");
            this.CustomerBudgetRemainCtl.Text = rowFormApply.CustomerBudgetRemain.ToString("N");
            this.OUBudgetCtl.Text             = rowFormApply.OUBudget.ToString("N");
            this.OUApprovedAmountCtl.Text     = rowFormApply.OUAppovedAmount.ToString("N");
            this.OUApprovingAmountCtl.Text    = rowFormApply.OUApprovingAmount.ToString("N");
            this.OUCompletedAmountCtl.Text    = rowFormApply.OUCompletedAmount.ToString("N");
            this.OUReimbursedAmountCtl.Text   = rowFormApply.OUReimbursedAmount.ToString("N");
            this.OUBudgetRemainCtl.Text       = rowFormApply.OUBudgetRemain.ToString("N");
            this.OUBudgetRateCtl.Text         = ((decimal)(rowFormApply.OUBudgetRate * 100)).ToString("N") + "%";

            this.odsApplyDetails.SelectParameters["FormID"].DefaultValue = rowFormApply.FormApplyID.ToString();

            //审批页面处理&按钮处理
            AuthorizationDS.StuffUserRow stuffUser = (AuthorizationDS.StuffUserRow)Session["StuffUser"];
            this.ViewState["StuffUserID"] = stuffUser.StuffUserId;
            if (rowForm.InTurnUserIds.Contains("P" + stuffUser.StuffUserId + "P"))
            {
                this.SubmitBtn.Visible   = true;
                this.cwfAppCheck.IsView  = false;
                this.ViewState["IsView"] = false;
            }
            else
            {
                this.SubmitBtn.Visible   = false;
                this.cwfAppCheck.IsView  = true;
                this.ViewState["IsView"] = true;
            }

            if (rowForm.StatusID == (int)SystemEnums.FormStatus.Rejected && stuffUser.StuffUserId == rowForm.UserID)
            {
                this.EditBtn.Visible  = true;
                this.ScrapBtn.Visible = true;
            }
            else
            {
                this.EditBtn.Visible  = false;
                this.ScrapBtn.Visible = false;
            }

            //关闭按钮
            if ((!rowFormApply.IsClose) && rowForm.StatusID == (int)SystemEnums.FormStatus.ApproveCompleted)
            {
                if (stuffUser.StuffUserId == rowForm.UserID || new MasterDataBLL().GetProxyReimburseByParameter(rowForm.UserID, stuffUser.StuffUserId, rowForm.SubmitDate).Count > 0)
                {
                    this.CloseBtn.Visible = true;
                }
                else
                {
                    this.CloseBtn.Visible = false;
                }
            }
            else
            {
                this.CloseBtn.Visible = false;
            }

            //如果是弹出,取消按钮不可见
            if (this.Request["ShowDialog"] != null)
            {
                if (this.Request["ShowDialog"].ToString() == "1")
                {
                    this.upButton.Visible = false;
                    this.Master.FindControl("divMenu").Visible       = false;
                    this.Master.FindControl("tbCurrentPage").Visible = false;
                }
            }
            //如果是申请人则隐藏预算信息
            if (stuffUser.StuffUserId == rowForm.UserID)
            {
                this.OUBudgetCtl.Text           = "";
                this.OUApprovedAmountCtl.Text   = "";
                this.OUApprovingAmountCtl.Text  = "";
                this.OUCompletedAmountCtl.Text  = "";
                this.OUReimbursedAmountCtl.Text = "";
                this.OUBudgetRemainCtl.Text     = "";
                this.OUBudgetRateCtl.Text       = "";
                this.btnViewBudget.Visible      = false;
            }
        }
        this.cwfAppCheck.FormID = (int)this.ViewState["ObjectId"];
        this.cwfAppCheck.ProcID = this.ViewState["ProcID"].ToString();
        this.cwfAppCheck.IsView = (bool)this.ViewState["IsView"];
    }
Esempio n. 6
0
    //protected void gvApplyList_PageIndexChanging(object sender, GridViewPageEventArgs e) {
    //    this.ViewState["CheckedFormIds"] = this.GetCheckedFormIds();
    //}

    //protected void gvApplyList_DataBound(object sender, EventArgs e) {
    //    List<int> checkedFormIds = (List<int>)this.ViewState["CheckedFormIds"];
    //    if (checkedFormIds == null) {
    //        checkedFormIds = new List<int>();
    //    }
    //    foreach (GridViewRow gridViewRow in this.gvApplyList.Rows) {
    //        if (gridViewRow.RowType == DataControlRowType.DataRow) {
    //            int FormId = (int)this.gvApplyList.DataKeys[gridViewRow.RowIndex].Value;
    //            CheckBox checkCtl = (CheckBox)gridViewRow.FindControl("CheckCtl");
    //            if (checkedFormIds.Contains(FormId)) {
    //                checkCtl.Checked = true;
    //            } else {
    //                checkCtl.Checked = false;
    //            }
    //        }
    //    }
    //}

    //private List<int> GetCheckedFormIds() {
    //    List<int> checkedFormIds = (List<int>)this.ViewState["CheckedFormIds"];
    //    if (checkedFormIds == null) {
    //        checkedFormIds = new List<int>();
    //    }
    //    foreach (GridViewRow gridViewRow in this.gvApplyList.Rows) {
    //        if (gridViewRow.RowType == DataControlRowType.DataRow) {
    //            int FormId = (int)this.gvApplyList.DataKeys[gridViewRow.RowIndex].Value;
    //            CheckBox checkCtl = (CheckBox)gridViewRow.FindControl("CheckCtl");
    //            if (checkCtl.Checked) {
    //                if (!checkedFormIds.Contains(FormId)) {
    //                    checkedFormIds.Add(FormId);
    //                }
    //            } else {
    //                if (checkedFormIds.Contains(FormId)) {
    //                    checkedFormIds.Remove(FormId);
    //                }
    //            }
    //        }
    //    }

    //    return checkedFormIds;
    //}

    protected void CreateBtn_Click(object sender, EventArgs e)
    {
        string        strFormID         = string.Empty;
        string        strFormNo         = string.Empty;
        bool          isSameCustID      = true;
        bool          isSamePaymentType = true;
        bool          isSameYear        = true;
        bool          isSameCategory    = true;
        int           paymentTypeID     = 0;
        int           custID            = 0;
        int           year       = 0;
        int           categoryID = 0;
        MasterDataBLL masterBLL  = new MasterDataBLL();
        string        intFormID  = string.Empty;

        foreach (GridViewRow row in this.gvApplyList.Rows)
        {
            CheckBox CheckCtl = (CheckBox)row.FindControl("CheckCtl");
            if (CheckCtl.Checked)
            {
                FormDS.FormApplyRow formApply = new SalesApplyBLL().GetFormApplyByID((int)this.gvApplyList.DataKeys[row.RowIndex].Value)[0];
                FormDS.FormRow      form      = new SalesApplyBLL().GetFormByID((int)this.gvApplyList.DataKeys[row.RowIndex].Value)[0];
                intFormID = formApply.FormApplyID.ToString();
                if (custID == 0)
                {
                    custID = formApply.CustomerID;
                }
                else
                {
                    if (custID != formApply.CustomerID)
                    {
                        isSameCustID = false;
                        break;
                    }
                }
                if (paymentTypeID == 0)
                {
                    paymentTypeID = formApply.PaymentTypeID;
                }
                else
                {
                    if (paymentTypeID != formApply.PaymentTypeID)
                    {
                        isSamePaymentType = false;
                        break;
                    }
                }
                if (year == 0)
                {
                    year = formApply.Period.AddMonths(-3).Year;
                }
                else
                {
                    if (year != formApply.Period.AddMonths(-3).Year)
                    {
                        isSameYear = false;
                        break;
                    }
                }
                if (categoryID == 0)
                {
                    categoryID = masterBLL.GetExpenseSubCategoryById(formApply.ExpenseSubCategoryID).ExpenseCategoryID;
                }
                else
                {
                    if (categoryID != masterBLL.GetExpenseSubCategoryById(formApply.ExpenseSubCategoryID).ExpenseCategoryID)
                    {
                        isSameCategory = false;
                        break;
                    }
                }
                if (strFormID == string.Empty)
                {
                    strFormID = this.gvApplyList.DataKeys[row.RowIndex].Value.ToString();
                }
                else
                {
                    strFormID = strFormID + "," + this.gvApplyList.DataKeys[row.RowIndex].Value.ToString();
                }
                if (strFormNo == string.Empty)
                {
                    strFormNo = "P" + form.FormNo + "P";
                }
                else
                {
                    strFormNo = strFormNo + "P" + form.FormNo + "P";;
                }
            }
        }

        if (strFormID == string.Empty)
        {
            PageUtility.ShowModelDlg(this, "请选择申请单!");
            return;
        }

        if (!isSameCustID)
        {
            PageUtility.ShowModelDlg(this, "请选择相同客户的申请单!");
            return;
        }
        if (!isSamePaymentType)
        {
            PageUtility.ShowModelDlg(this, "请选择相同支付方式的申请单!");
            return;
        }
        if (!isSameYear)
        {
            PageUtility.ShowModelDlg(this, "请选择同一年的申请单!");
            return;
        }
        if (!isSameCategory)
        {
            PageUtility.ShowModelDlg(this, "请选择同一费用大类的申请单!");
            return;
        }


        string url = string.Empty;

        if (paymentTypeID == (int)SystemEnums.PaymentType.ShiWu)
        {
            //如果支付方式是实物,那么只能对应一张申请单
            if (strFormID.Contains(","))
            {
                PageUtility.ShowModelDlg(this, "实物报销只能对应一张申请单!");
                return;
            }
            //如果有多个费用项,不能报销
            if (new SalesReimburseBLL().QueryExpenseItemCountByReimburseID(int.Parse(strFormID)) > 1)
            {
                PageUtility.ShowModelDlg(this, "实物报销对应申请单只能有一个费用项!");
                return;
            }
            if (this.ViewState["SearchCondition"] != null)
            {
                url = "~/SalesForm/ReimburseGoodsApply.aspx?FormApplyIds=" + strFormID +
                      "&CustomerID=" + custID.ToString() + "&PaymentTypeID=" + paymentTypeID.ToString() + "&FormApplyNos=" + strFormNo + "&Source=" + HttpUtility.UrlEncode("~/SalesForm/FormApplySelectList.aspx?" + this.ViewState["SearchCondition"].ToString());
            }
            else
            {
                url = "~/SalesForm/ReimburseGoodsApply.aspx?FormApplyIds=" + strFormID +
                      "&CustomerID=" + custID.ToString() + "&PaymentTypeID=" + paymentTypeID.ToString() + "&FormApplyNos=" + strFormNo + "&Source=" + HttpUtility.UrlEncode("~/SalesForm/FormApplySelectList.aspx");
            }
        }
        else
        {
            if (this.ViewState["SearchCondition"] != null)
            {
                url = "~/SalesForm/ReimburseMoneyApply.aspx?FormApplyIds=" + strFormID +
                      "&CustomerID=" + custID.ToString() + "&PaymentTypeID=" + paymentTypeID.ToString() + "&FormApplyNos=" + strFormNo + "&Source=" + HttpUtility.UrlEncode("~/SalesForm/FormApplySelectList.aspx?" + this.ViewState["SearchCondition"].ToString());
            }
            else
            {
                url = "~/SalesForm/ReimburseMoneyApply.aspx?FormApplyIds=" + strFormID +
                      "&CustomerID=" + custID.ToString() + "&PaymentTypeID=" + paymentTypeID.ToString() + "&FormApplyNos=" + strFormNo + "&Source=" + HttpUtility.UrlEncode("~/SalesForm/FormApplySelectList.aspx");
            }
        }
        Response.Redirect(url);
    }