protected void gvTravelReimburseDetails_RowDataBound(object sender, GridViewRowEventArgs e) { // 对数据列进行赋值 if (e.Row.RowType == DataControlRowType.DataRow) { if ((e.Row.RowState & DataControlRowState.Edit) != DataControlRowState.Edit) { DataRowView drvDetail = (DataRowView)e.Row.DataItem; FormDS.FormPersonalReimburseDetailRow row = (FormDS.FormPersonalReimburseDetailRow)drvDetail.Row; TotalFee = decimal.Round((TotalFee + row.Amount), 2); } } this.ViewState["ManualApplyFeeTotal"] = TotalFee; if (e.Row.RowType == DataControlRowType.Footer) { Label sumlbl = new Label(); sumlbl.Text = "合计:"; sumlbl.ID = "sumlbl"; e.Row.Cells[2].Controls.Add(sumlbl); e.Row.Cells[2].CssClass = "RedTextAlignCenter"; e.Row.Cells[2].HorizontalAlign = HorizontalAlign.Center; e.Row.Cells[2].Width = new Unit("250px"); Label totallbl = new Label(); totallbl.ID = "totallbl"; totallbl.Text = TotalFee.ToString("N"); e.Row.Cells[3].Controls.Add(totallbl); e.Row.Cells[3].CssClass = "RedTextAlignCenter"; e.Row.Cells[3].HorizontalAlign = HorizontalAlign.Center; e.Row.Cells[3].Width = new Unit("150px"); } }
public void AddFormPersonalReimburseDetail(AuthorizationDS.StuffUserRow User, int?FormPersonalReimburseID, DateTime?OccurDate, int ExpenseManageTypeID, decimal Amount, string Remark) { switch (ExpenseManageTypeID) { case 1: if (Amount > User.TrafficFeeLimit) { throw new ApplicationException("交通费用超过个人交通费用报销限制!"); } break; case 2: if (Amount > User.TelephoneFeeLimit) { throw new ApplicationException("电话费用超过个人电话费用报销限制!"); } break; } FormDS.FormPersonalReimburseDetailRow rowDetail = this.FormDataSet.FormPersonalReimburseDetail.NewFormPersonalReimburseDetailRow(); rowDetail.FormPersonalReimburseID = FormPersonalReimburseID.GetValueOrDefault(); rowDetail.OccurDate = OccurDate.GetValueOrDefault(); rowDetail.ExpenseManageTypeID = ExpenseManageTypeID; rowDetail.Amount = Amount; rowDetail.RealAmount = Amount; rowDetail.Remark = Remark; // 填加行并进行更新处理 this.FormDataSet.FormPersonalReimburseDetail.AddFormPersonalReimburseDetailRow(rowDetail); }
private bool FillDetail() { bool isValid = true; foreach (GridViewRow row in this.gvTravelReimburseDetails.Rows) { if (row.RowType == DataControlRowType.DataRow) { FormDS.FormPersonalReimburseDetailRow detailRow = this.InnerDS.FormPersonalReimburseDetail[row.RowIndex]; TextBox txtRealAmount = (TextBox)row.FindControl("txtRealAmount"); if (string.IsNullOrEmpty(txtRealAmount.Text.Trim())) { txtRealAmount.Text = "0"; } decimal RealAmount = decimal.Parse(txtRealAmount.Text.Trim()); if (RealAmount < 0) { PageUtility.ShowModelDlg(this.Page, "不能录入负数"); isValid = false; break; } if (RealAmount > detailRow.Amount) { PageUtility.ShowModelDlg(this.Page, "实报金额不能大于报销金额"); isValid = false; break; } detailRow.RealAmount = RealAmount; } } return(isValid); }
protected void gvTravelReimburseDetails_RowDataBound(object sender, GridViewRowEventArgs e) { // 对数据列进行赋值 if (e.Row.RowType == DataControlRowType.DataRow) { if ((e.Row.RowState & DataControlRowState.Edit) != DataControlRowState.Edit) { DataRowView drvDetail = (DataRowView)e.Row.DataItem; FormDS.FormPersonalReimburseDetailRow row = (FormDS.FormPersonalReimburseDetailRow)drvDetail.Row; TotalFee = decimal.Round((TotalFee + row.Amount), 2); TotalRealFee = decimal.Round((TotalRealFee + row.RealAmount), 2); TextBox txtRealAmount = (TextBox)e.Row.FindControl("txtRealAmount"); if (HasSaveRight) { txtRealAmount.Attributes.Add("onBlur", "PlusTotal('totalRealAmountLbl',this);"); txtRealAmount.Attributes.Add("onFocus", "MinusTotal('totalRealAmountLbl',this)"); } else { txtRealAmount.ReadOnly = true; } } } this.ViewState["ManualApplyFeeTotal"] = TotalFee; if (e.Row.RowType == DataControlRowType.Footer) { Label sumlbl = new Label(); sumlbl.Text = "合计:"; sumlbl.ID = "sumlbl"; e.Row.Cells[2].Controls.Add(sumlbl); e.Row.Cells[2].CssClass = "RedTextAlignCenter"; e.Row.Cells[2].HorizontalAlign = HorizontalAlign.Center; e.Row.Cells[2].Width = new Unit("250px"); Label totallbl = new Label(); totallbl.ID = "totallbl"; totallbl.Text = TotalFee.ToString("N"); e.Row.Cells[3].Controls.Add(totallbl); e.Row.Cells[3].CssClass = "RedTextAlignCenter"; e.Row.Cells[3].HorizontalAlign = HorizontalAlign.Center; e.Row.Cells[3].Width = new Unit("150px"); Label totalRealAmountLbl = (Label)e.Row.FindControl("totalRealAmountLbl"); totalRealAmountLbl.Text = TotalRealFee.ToString("N"); } }
public void AddFormPersonalReimburse(int?RejectedFormID, int UserID, int?ProxyUserID, int?ProxyPositionID, int OrganizationUnitID, int PositionID, SystemEnums.FormType FormTypeID, SystemEnums.FormStatus StatusID, 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.FormDataSet.Form.NewFormRow(); if (RejectedFormID != null) { formRow.RejectedFormID = RejectedFormID.GetValueOrDefault(); } formRow.UserID = UserID; UtilityBLL utility = new UtilityBLL(); if (StatusID == SystemEnums.FormStatus.Awaiting) { string formTypeString = utility.GetFormTypeString((int)FormTypeID); formRow.FormNo = utility.GetFormNo(formTypeString); } else { formRow.SetFormNoNull(); } if (ProxyUserID != null) { formRow.ProxyUserID = ProxyUserID.GetValueOrDefault(); } if (ProxyPositionID != null) { formRow.ProxyPositionID = ProxyPositionID.GetValueOrDefault(); } formRow.OrganizationUnitID = OrganizationUnitID; formRow.PositionID = PositionID; formRow.FormTypeID = (int)FormTypeID; formRow.StatusID = (int)StatusID; formRow.SubmitDate = DateTime.Now; formRow.LastModified = DateTime.Now; formRow.InTurnUserIds = "P"; //待改动 formRow.InTurnPositionIds = "P"; //待改动 formRow.PageType = (int)SystemEnums.PageType.PersonalReimburseApply; this.FormDataSet.Form.AddFormRow(formRow); this.TAForm.Update(formRow); //处理申请表的内容 FormDS.FormPersonalReimburseRow formPersonalReimburseRow = this.FormDataSet.FormPersonalReimburse.NewFormPersonalReimburseRow(); formPersonalReimburseRow.FormPersonalReimburseID = formRow.FormID; formPersonalReimburseRow.Period = Period.GetValueOrDefault(); formPersonalReimburseRow.Amount = decimal.Zero; formPersonalReimburseRow.Remark = Remark; decimal[] calculateAssistant = this.GetPersonalBudgetByParameter(PositionID, Period); 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.FormDataSet.FormPersonalReimburse.AddFormPersonalReimburseRow(formPersonalReimburseRow); this.TAFormPersonalReimburse.Update(formPersonalReimburseRow); //明细表 decimal totalAmount = 0;//计算总申请金额 if (RejectedFormID != null) { FormDS.FormPersonalReimburseDetailDataTable newDetailTable = new FormDS.FormPersonalReimburseDetailDataTable(); foreach (FormDS.FormPersonalReimburseDetailRow detailRow in this.FormDataSet.FormPersonalReimburseDetail) { if (detailRow.RowState != System.Data.DataRowState.Deleted) { FormDS.FormPersonalReimburseDetailRow newDetailRow = newDetailTable.NewFormPersonalReimburseDetailRow(); newDetailRow.FormPersonalReimburseID = formPersonalReimburseRow.FormPersonalReimburseID; newDetailRow.OccurDate = detailRow.OccurDate; newDetailRow.ExpenseManageTypeID = detailRow.ExpenseManageTypeID; newDetailRow.Amount = detailRow.Amount; newDetailRow.RealAmount = detailRow.RealAmount; if (!detailRow.IsRemarkNull()) { newDetailRow.Remark = detailRow.Remark; } totalAmount += newDetailRow.Amount; newDetailTable.AddFormPersonalReimburseDetailRow(newDetailRow); } } this.TAFormPersonalReimburseDetail.Update(newDetailTable); } else { 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, RejectedFormID, formRow, OrganizationUnitID, FlowTemplate, StatusID, dic); } transaction.Commit(); } catch (Exception ex) { transaction.Rollback(); throw new ApplicationException(ex.Message); } finally { transaction.Dispose(); } }