protected void OpenForm(int formID) { FormTableAdapter taForm = new FormTableAdapter(); taForm.FillByID(this.InnerDS.Form, formID); FormDS.FormRow rowForm = this.InnerDS.Form[0]; FormPersonalReimburseTableAdapter taFormTravelReimburse = new FormPersonalReimburseTableAdapter(); taFormTravelReimburse.FillByID(this.InnerDS.FormPersonalReimburse, formID); FormDS.FormPersonalReimburseRow rowFormTravelReimburse = this.InnerDS.FormPersonalReimburse[0]; this.ViewState["FormTravelApplyID"] = rowFormTravelReimburse.FormTravelApplyID; //赋值 this.PeriodDDL.DataSourceID = "odsPeriod"; this.PeriodDDL.DataBind(); ListItem item = this.PeriodDDL.Items.FindByText(rowFormTravelReimburse.Period.ToString("yyyy-MM")); if (item != null) { this.PeriodDDL.SelectedValue = item.Value; } if (!rowFormTravelReimburse.IsRemarkNull()) { this.RemarkCtl.Text = rowFormTravelReimburse.Remark; } if (!rowFormTravelReimburse.IsAttachedFileNameNull()) { this.UCFileUpload.AttachmentFileName = rowFormTravelReimburse.AttachedFileName; } if (!rowFormTravelReimburse.IsRealAttachedFileNameNull()) { this.UCFileUpload.RealAttachmentFileName = rowFormTravelReimburse.RealAttachedFileName; } OpenTravelApplyForm(rowFormTravelReimburse.FormTravelApplyID); // 打开明细表 FormPersonalReimburseDetailTableAdapter taDetail = new FormPersonalReimburseDetailTableAdapter(); taDetail.FillByFormID(this.InnerDS.FormPersonalReimburseDetail, formID); }
public void SaveRealAmountForPersonalReimburse(int FormID) { SqlTransaction transaction = null; try { ////事务开始 transaction = TableAdapterHelper.BeginTransaction(this.TAForm); TableAdapterHelper.SetTransaction(this.TAFormPersonalReimburse, transaction); TableAdapterHelper.SetTransaction(this.TAFormPersonalReimburseDetail, transaction); //处理申请表的内容 FormDS.FormPersonalReimburseRow formPersonalReimburseRow = this.TAFormPersonalReimburse.GetDataByID(FormID)[0]; this.TAFormPersonalReimburse.Update(formPersonalReimburseRow); //明细表 decimal totalRealAmount = 0;//计算总申请金额 foreach (FormDS.FormPersonalReimburseDetailRow detailRow in this.FormDataSet.FormPersonalReimburseDetail) { // 与父表绑定 if (detailRow.RowState != DataRowState.Deleted) { totalRealAmount += detailRow.RealAmount; } } this.TAFormPersonalReimburseDetail.Update(this.FormDataSet.FormPersonalReimburseDetail); formPersonalReimburseRow.Amount = totalRealAmount; this.TAFormPersonalReimburse.Update(formPersonalReimburseRow); transaction.Commit(); } catch (Exception ex) { transaction.Rollback(); throw new ApplicationException(ex.Message); } finally { transaction.Dispose(); } }
public void UpdateFormPersonalReimburse(int FormID, SystemEnums.FormStatus StatusID, SystemEnums.FormType FormTypeID, DateTime?Period, string Remark, string AttachedFileName, string RealAttachedFileName, string FlowTemplate) { SqlTransaction transaction = null; try { ////事务开始 transaction = TableAdapterHelper.BeginTransaction(this.TAForm); TableAdapterHelper.SetTransaction(this.TAFormPersonalReimburse, transaction); TableAdapterHelper.SetTransaction(this.TAFormPersonalReimburseDetail, transaction); FormDS.FormRow formRow = this.TAForm.GetDataByID(FormID)[0]; decimal[] calculateAssistant = this.GetPersonalBudgetByParameter(formRow.PositionID, Period); UtilityBLL utility = new UtilityBLL(); if (StatusID == SystemEnums.FormStatus.Awaiting) { string formTypeString = utility.GetFormTypeString((int)FormTypeID); formRow.FormNo = utility.GetFormNo(formTypeString); formRow.InTurnUserIds = "P"; //待改动 formRow.InTurnPositionIds = "P"; //待改动 } else { formRow.SetFormNoNull(); } formRow.StatusID = (int)StatusID; formRow.SubmitDate = DateTime.Now; formRow.LastModified = DateTime.Now; this.TAForm.Update(formRow); //处理申请表的内容 FormDS.FormPersonalReimburseRow formPersonalReimburseRow = this.TAFormPersonalReimburse.GetDataByID(FormID)[0]; formPersonalReimburseRow.FormPersonalReimburseID = formRow.FormID; formPersonalReimburseRow.Period = Period.GetValueOrDefault(); formPersonalReimburseRow.Amount = decimal.Zero; formPersonalReimburseRow.Remark = Remark; formPersonalReimburseRow.TotalBudget = calculateAssistant[0]; formPersonalReimburseRow.ApprovedAmount = calculateAssistant[1]; formPersonalReimburseRow.ApprovingAmount = calculateAssistant[2]; formPersonalReimburseRow.RemainAmount = calculateAssistant[3]; if (AttachedFileName != null) { formPersonalReimburseRow.AttachedFileName = AttachedFileName; } if (RealAttachedFileName != null) { formPersonalReimburseRow.RealAttachedFileName = RealAttachedFileName; } this.TAFormPersonalReimburse.Update(formPersonalReimburseRow); //明细表 decimal totalAmount = 0;//计算总申请金额 foreach (FormDS.FormPersonalReimburseDetailRow detailRow in this.FormDataSet.FormPersonalReimburseDetail) { // 与父表绑定 if (detailRow.RowState != DataRowState.Deleted) { detailRow.FormPersonalReimburseID = formPersonalReimburseRow.FormPersonalReimburseID; totalAmount += detailRow.Amount; } } this.TAFormPersonalReimburseDetail.Update(this.FormDataSet.FormPersonalReimburseDetail); formPersonalReimburseRow.Amount = totalAmount; this.TAFormPersonalReimburse.Update(formPersonalReimburseRow); // 正式提交或草稿 Dictionary <string, object> dic = new Dictionary <string, object>(); if (StatusID == SystemEnums.FormStatus.Awaiting) { if (formPersonalReimburseRow.Amount > calculateAssistant[3]) //如果是减少预算,要做检查 { throw new ApplicationException("申请报销总额超出部门可用余额,不能提交!"); } dic["Apply_Amount"] = totalAmount;//金额 AuthorizationDS.OrganizationUnitDataTable OUTable = new AuthorizationDSTableAdapters.OrganizationUnitTableAdapter().GetOrganizationUnitCodeByOrganizationUnitID(formRow.OrganizationUnitID); if (OUTable.Count == 0) { throw new ApplicationException("没有找到您所在部门的流程,请联系管理员"); } dic["Department"] = OUTable[0].OrganizationUnitCode; APHelper AP = new APHelper(); new APFlowBLL().ApplyForm(AP, TAForm, null, formRow, formRow.OrganizationUnitID, FlowTemplate, StatusID, dic); } transaction.Commit(); } catch (Exception ex) { transaction.Rollback(); throw new ApplicationException(ex.Message); } finally { transaction.Dispose(); } }
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.PersonalReimburseBLL.GetFormByID(formID)[0]; FormDS.FormPersonalReimburseRow rowPersonalReimburse = this.PersonalReimburseBLL.GetFormPersonalReimburseByID(formID)[0]; if (rowForm.IsProcIDNull()) { ViewState["ProcID"] = ""; } else { ViewState["ProcID"] = rowForm.ProcID; } ViewState["OrganizationUnitID"] = rowForm.OrganizationUnitID; //对控件进行赋值 this.txtFormNo.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.txtPeriod.Text = rowPersonalReimburse.Period.ToString("yyyyMM"); if (!rowPersonalReimburse.IsRemarkNull()) { this.RemarkCtl.Text = rowPersonalReimburse.Remark; } //出差申请信息 FormDS.FormTravelApplyRow rowTravelApply = this.PersonalReimburseBLL.GetFormTravelApplyByID(rowPersonalReimburse.FormTravelApplyID); if (!rowTravelApply.IsTransportFeeNull()) { this.txtTransportFee.Text = rowTravelApply.TransportFee.ToString("N"); } if (!rowTravelApply.IsHotelFeeNull()) { this.txtHotelFee.Text = rowTravelApply.HotelFee.ToString("N"); } if (!rowTravelApply.IsMealFeeNull()) { this.txtMealFee.Text = rowTravelApply.MealFee.ToString("N"); } if (!rowTravelApply.IsOtherFeeNull()) { this.txtOtherFee.Text = rowTravelApply.OtherFee.ToString("N"); } if (!rowTravelApply.IsTotalFeeNull()) { this.txtTotal.Text = rowTravelApply.TotalFee.ToString("N"); } //赋值 if (!rowTravelApply.IsRemarkNull()) { this.RemarkCtl.Text = rowTravelApply.Remark; } FormDS.FormRow rowApplyForm = PersonalReimburseBLL.GetFormByID(rowTravelApply.FormTravelApplyID)[0]; hlTravelApply.Text = rowApplyForm.FormNo; this.hlTravelApply.NavigateUrl = "javascript:window.showModalDialog('" + System.Configuration.ConfigurationManager.AppSettings["WebSiteUrl"] + "/OtherForm/TravelApproval.aspx?ShowDialog=1&ObjectId=" + rowApplyForm.FormID + "','', 'dialogWidth:1000px;dialogHeight:750px;resizable:yes;')"; //历史单据 if (rowForm.IsRejectedFormIDNull()) { lblRejectFormNo.Text = "无"; } else { FormDS.FormRow rejectedForm = new ContractApplyBLL().GetFormByID(rowForm.RejectedFormID)[0]; this.lblRejectFormNo.Text = rejectedForm.FormNo; this.lblRejectFormNo.NavigateUrl = "javascript:window.showModalDialog('" + System.Configuration.ConfigurationManager.AppSettings["WebSiteUrl"] + "/OtherForm/PersonalReimburseApproval.aspx?ShowDialog=1&ObjectId=" + rejectedForm.FormID + "','', 'dialogWidth:1000px;dialogHeight:750px;resizable:yes;')"; } //审批页面处理&按钮处理&预算信息 this.txtTotalBudget.Text = rowPersonalReimburse.TotalBudget.ToString("N"); this.txtApprovingAmount.Text = rowPersonalReimburse.ApprovingAmount.ToString("N"); this.txtApprovedAmount.Text = rowPersonalReimburse.ApprovedAmount.ToString("N"); this.txtRemainAmount.Text = rowPersonalReimburse.RemainAmount.ToString("N"); 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.UserID == stuffUser.StuffUserId) { this.BudgetTitleDIV.Visible = false; this.BudgetInfoDIV.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; } } //保存实报金额按钮 int opSaveId = BusinessUtility.GetBusinessOperateId(SystemEnums.BusinessUseCase.FormPersonalReimburse, SystemEnums.OperateEnum.Other); AuthorizationDS.PositionRow position = (AuthorizationDS.PositionRow) this.Session["Position"]; if (new PositionRightBLL().CheckPositionRight(position.PositionId, opSaveId) && (rowForm.StatusID == 1 || rowForm.StatusID == 2)) { HasSaveRight = true; } else { HasSaveRight = false; } if (HasSaveRight) { this.SaveBtn.Visible = true; } else { this.SaveBtn.Visible = false; } //超预算提示 if (rowPersonalReimburse.Amount > rowTravelApply.TotalFee) { this.imgOverBudget.Visible = true; } // 打开明细表 new FormPersonalReimburseDetailTableAdapter().FillByFormID(InnerDS.FormPersonalReimburseDetail, rowForm.FormID); this.gvTravelReimburseDetails.DataSource = new FormPersonalReimburseDetailTableAdapter().GetDataByFormID(rowForm.FormID); this.gvTravelReimburseDetails.DataBind(); this.gvFormTravelApplyDetails.DataSource = new FormTravelApplyDetailTableAdapter().GetDataByApplyID(rowTravelApply.FormTravelApplyID); this.gvFormTravelApplyDetails.DataBind(); } this.cwfAppCheck.FormID = (int)this.ViewState["ObjectId"]; this.cwfAppCheck.ProcID = this.ViewState["ProcID"].ToString(); this.cwfAppCheck.IsView = (bool)this.ViewState["IsView"]; }