public FormDS.FormBudgetAllocationDetailDataTable GetFormBudgetAllocationDetail(int FormBudgetAllocationID, SystemEnums.AllocationType AllocationType) { FormDS.FormBudgetAllocationDetailDataTable table = new FormDS.FormBudgetAllocationDetailDataTable(); DataRow[] rows = this.TAFormBudgetAllocationDetail.GetDataByFormID(FormBudgetAllocationID).Select("AllocationType=" + (int)AllocationType); foreach (FormDS.FormBudgetAllocationDetailRow item in rows) { table.ImportRow(item); } return(table); }
public void AddFormBudgetAllocation(int? RejectedFormID, int UserID, int? ProxyUserID, int? ProxyPositionID, int OrganizationUnitID, int PositionID, SystemEnums.FormType FormTypeID, SystemEnums.FormStatus StatusID, string Remark, string AttachFileName, string RealAttachFileName, string FlowTemplate) { SqlTransaction transaction = null; try { transaction = TableAdapterHelper.BeginTransaction(this.TAForm); TableAdapterHelper.SetTransaction(this.TAFormBudgetAllocation, transaction); TableAdapterHelper.SetTransaction(this.TAFormBudgetAllocationDetail, 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.BudgetAllocationApply; this.FormDataSet.Form.AddFormRow(formRow); this.TAForm.Update(formRow); //处理申请表的内容 FormDS.FormBudgetAllocationRow formBudgetAllocationRow = this.FormDataSet.FormBudgetAllocation.NewFormBudgetAllocationRow(); formBudgetAllocationRow.FormBudgetAllocationID = formRow.FormID; formBudgetAllocationRow.Amount = decimal.Zero; formBudgetAllocationRow.AttachFileName = AttachFileName; formBudgetAllocationRow.RealAttachFileName = RealAttachFileName; formBudgetAllocationRow.Remark = Remark; this.FormDataSet.FormBudgetAllocation.AddFormBudgetAllocationRow(formBudgetAllocationRow); this.TAFormBudgetAllocation.Update(formBudgetAllocationRow); //明细表 decimal totalAmount = 0;//计算总申请金额 decimal totalInAmount = 0;//计算调入总金额 decimal totalOutAmount = 0;//计算调出总金额 if (RejectedFormID != null) { FormDS.FormBudgetAllocationDetailDataTable newDetailTable = new FormDS.FormBudgetAllocationDetailDataTable(); foreach (FormDS.FormBudgetAllocationDetailRow detailRow in this.FormDataSet.FormBudgetAllocationDetail) { if (detailRow.RowState != System.Data.DataRowState.Deleted) { FormDS.FormBudgetAllocationDetailRow newDetailRow = newDetailTable.NewFormBudgetAllocationDetailRow(); newDetailRow.FormBudgetAllocationID = formBudgetAllocationRow.FormBudgetAllocationID; newDetailRow.CustomerID = detailRow.CustomerID; newDetailRow.CustomerName = detailRow.CustomerName; newDetailRow.ExpenseItemID = detailRow.ExpenseItemID; newDetailRow.ExpenseItemName = detailRow.ExpenseItemName; newDetailRow.Period = detailRow.Period; newDetailRow.OriginalBudget = detailRow.OriginalBudget; newDetailRow.NormalBudget = detailRow.NormalBudget; newDetailRow.AdjustBudget = detailRow.AdjustBudget; newDetailRow.TotalBudget = detailRow.TotalBudget; newDetailRow.TransferBudget = detailRow.TransferBudget; newDetailRow.AllocationType = detailRow.AllocationType; newDetailRow.BudgetSalesFeeId = detailRow.BudgetSalesFeeId; totalAmount += newDetailRow.TransferBudget; if (detailRow.AllocationType == (int)SystemEnums.AllocationType.In) { totalInAmount += detailRow.TransferBudget; } else { totalOutAmount += detailRow.TransferBudget; } newDetailTable.AddFormBudgetAllocationDetailRow(newDetailRow); } } this.TAFormBudgetAllocationDetail.Update(newDetailTable); } else { foreach (FormDS.FormBudgetAllocationDetailRow detailRow in this.FormDataSet.FormBudgetAllocationDetail) { // 与父表绑定 if (detailRow.RowState != DataRowState.Deleted) { detailRow.FormBudgetAllocationID = formBudgetAllocationRow.FormBudgetAllocationID; if (detailRow.AllocationType == (int)SystemEnums.AllocationType.In) { totalInAmount += detailRow.TransferBudget; } else { totalOutAmount += detailRow.TransferBudget; } totalAmount += detailRow.TransferBudget; } } this.TAFormBudgetAllocationDetail.Update(this.FormDataSet.FormBudgetAllocationDetail); } formBudgetAllocationRow.Amount = totalOutAmount; this.TAFormBudgetAllocation.Update(formBudgetAllocationRow); // 正式提交或草稿 Dictionary<string, object> dic = new Dictionary<string, object>(); dic["Apply_Amount"] = totalOutAmount;//调拨金额 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(); } }
public void AddFormBudgetAllocation(int?RejectedFormID, int UserID, int?ProxyUserID, int?ProxyPositionID, int OrganizationUnitID, int PositionID, SystemEnums.FormType FormTypeID, SystemEnums.FormStatus StatusID, string Remark, string AttachFileName, string RealAttachFileName, string FlowTemplate) { SqlTransaction transaction = null; try { transaction = TableAdapterHelper.BeginTransaction(this.TAForm); TableAdapterHelper.SetTransaction(this.TAFormBudgetAllocation, transaction); TableAdapterHelper.SetTransaction(this.TAFormBudgetAllocationDetail, 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.BudgetAllocationApply; this.FormDataSet.Form.AddFormRow(formRow); this.TAForm.Update(formRow); //处理申请表的内容 FormDS.FormBudgetAllocationRow formBudgetAllocationRow = this.FormDataSet.FormBudgetAllocation.NewFormBudgetAllocationRow(); formBudgetAllocationRow.FormBudgetAllocationID = formRow.FormID; formBudgetAllocationRow.Amount = decimal.Zero; formBudgetAllocationRow.AttachFileName = AttachFileName; formBudgetAllocationRow.RealAttachFileName = RealAttachFileName; formBudgetAllocationRow.Remark = Remark; this.FormDataSet.FormBudgetAllocation.AddFormBudgetAllocationRow(formBudgetAllocationRow); this.TAFormBudgetAllocation.Update(formBudgetAllocationRow); //明细表 decimal totalAmount = 0; //计算总申请金额 decimal totalInAmount = 0; //计算调入总金额 decimal totalOutAmount = 0; //计算调出总金额 if (RejectedFormID != null) { FormDS.FormBudgetAllocationDetailDataTable newDetailTable = new FormDS.FormBudgetAllocationDetailDataTable(); foreach (FormDS.FormBudgetAllocationDetailRow detailRow in this.FormDataSet.FormBudgetAllocationDetail) { if (detailRow.RowState != System.Data.DataRowState.Deleted) { FormDS.FormBudgetAllocationDetailRow newDetailRow = newDetailTable.NewFormBudgetAllocationDetailRow(); newDetailRow.FormBudgetAllocationID = formBudgetAllocationRow.FormBudgetAllocationID; newDetailRow.CustomerID = detailRow.CustomerID; newDetailRow.CustomerName = detailRow.CustomerName; newDetailRow.ExpenseItemID = detailRow.ExpenseItemID; newDetailRow.ExpenseItemName = detailRow.ExpenseItemName; newDetailRow.Period = detailRow.Period; newDetailRow.OriginalBudget = detailRow.OriginalBudget; newDetailRow.NormalBudget = detailRow.NormalBudget; newDetailRow.AdjustBudget = detailRow.AdjustBudget; newDetailRow.TotalBudget = detailRow.TotalBudget; newDetailRow.TransferBudget = detailRow.TransferBudget; newDetailRow.AllocationType = detailRow.AllocationType; newDetailRow.BudgetSalesFeeId = detailRow.BudgetSalesFeeId; totalAmount += newDetailRow.TransferBudget; if (detailRow.AllocationType == (int)SystemEnums.AllocationType.In) { totalInAmount += detailRow.TransferBudget; } else { totalOutAmount += detailRow.TransferBudget; } newDetailTable.AddFormBudgetAllocationDetailRow(newDetailRow); } } this.TAFormBudgetAllocationDetail.Update(newDetailTable); } else { foreach (FormDS.FormBudgetAllocationDetailRow detailRow in this.FormDataSet.FormBudgetAllocationDetail) { // 与父表绑定 if (detailRow.RowState != DataRowState.Deleted) { detailRow.FormBudgetAllocationID = formBudgetAllocationRow.FormBudgetAllocationID; if (detailRow.AllocationType == (int)SystemEnums.AllocationType.In) { totalInAmount += detailRow.TransferBudget; } else { totalOutAmount += detailRow.TransferBudget; } totalAmount += detailRow.TransferBudget; } } this.TAFormBudgetAllocationDetail.Update(this.FormDataSet.FormBudgetAllocationDetail); } formBudgetAllocationRow.Amount = totalOutAmount; this.TAFormBudgetAllocation.Update(formBudgetAllocationRow); // 正式提交或草稿 Dictionary <string, object> dic = new Dictionary <string, object>(); dic["Apply_Amount"] = totalOutAmount; //调拨金额 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(); } }
public FormDS.FormBudgetAllocationDetailDataTable GetFormBudgetAllocationDetail(int FormBudgetAllocationID, SystemEnums.AllocationType AllocationType) { FormDS.FormBudgetAllocationDetailDataTable table = new FormDS.FormBudgetAllocationDetailDataTable(); DataRow[] rows = this.TAFormBudgetAllocationDetail.GetDataByFormID(FormBudgetAllocationID).Select("AllocationType=" + (int)AllocationType); foreach (FormDS.FormBudgetAllocationDetailRow item in rows) { table.ImportRow(item); } return table; }