//启动流程 public void ApplyForm(APHelper AP, FormTableAdapter FormTA, int? RejectedFormID, FormDS.FormRow formRow, int OrganizationUnitID, string ProcessTemplateName, SystemEnums.FormStatus StatusID, Dictionary<string, object> map) { string email = string.Empty; if (StatusID == SystemEnums.FormStatus.Awaiting) { string ProcID = AP.createProcess(formRow.FormNo + ":" + DateTime.Now.ToString(), ProcessTemplateName, map); formRow.ProcID = ProcID; String inTurnStr = AP.startProcess(ProcID, OrganizationUnitID, ref email, formRow.UserID.ToString(), new AuthorizationBLL().GetStuffUserById(formRow.UserID).StuffName); string[] InTurn = inTurnStr.Split('&');//不同流程角色下的人员和职位 string ids = ""; string pids = ""; for (int a = 0; a < InTurn.Length; a++) { ids += InTurn[a].Split('$')[0].ToString();///人员 pids += InTurn[a].Split('$')[1].ToString();//职位 } formRow.InTurnUserIds = ids;//下一步的人员 formRow.InTurnPositionIds = pids;//下一步的人员职位 formRow.StatusID = (int)SystemEnums.FormStatus.Awaiting; FormTA.Update(formRow); } //作废之前的单据 if (RejectedFormID != null) { FormDS.FormRow oldRow = FormTA.GetDataByID(RejectedFormID.GetValueOrDefault())[0]; if (oldRow.StatusID == (int)SystemEnums.FormStatus.Rejected) { ScrapForm(oldRow.FormID); } } }
public static string GetEnumValue(SystemEnums enumName, int resultValue) { return(enumName switch { SystemEnums.Status => ((Status)resultValue).ToString(), SystemEnums.Login_Status => ((LoginStatus)resultValue).ToString(), _ => _defaultError, });
protected void SaveFormPO(SystemEnums.FormStatus StatusID) { this.FormPurchaseBLL.PurchaseDataSet = this.InnerDS; int? RejectedFormID = null; if (this.ViewState["RejectedObjectID"] != null) { RejectedFormID = (int)this.ViewState["RejectedObjectID"]; } int UserID = (int)this.ViewState["StuffUserID"]; int? ProxyStuffUserId = null; if (Session["ProxyStuffUserId"] != null) { ProxyStuffUserId = int.Parse(Session["ProxyStuffUserId"].ToString()); } int OrganizationUnitID = (int)this.ViewState["DepartmentID"]; int PositionID = (int)this.ViewState["PositionID"]; int ParentFormID = int.Parse(this.ViewState["ParentFormID"].ToString()); PurchaseDS.FormRow formRow = FormPurchaseBLL.GetFormByID(ParentFormID)[0]; if (formRow.StatusID != 2) { PageUtility.ShowModelDlg(this, "不能提交,对应的申请单不是审批完成状态!"); return; } string ParentFormNo = this.ViewState["ParentFormNo"].ToString(); decimal ApplyAmountRMB = decimal.Parse(this.ViewState["ApplyAmountRMB"].ToString()); DateTime Period = DateTime.Parse(this.ViewState["Period"].ToString()); int VendorID = int.Parse(this.ViewState["VendorID"].ToString()); int ItemCategoryID = int.Parse(this.ViewState["ItemCategoryID"].ToString()); int CurrencyID = int.Parse(this.ViewState["CurrencyID"].ToString()); decimal ExchangeRate = decimal.Parse(this.ViewState["ExchangeRate"].ToString()); int PurchaseBudgetTypeID = int.Parse(this.ViewState["PurchaseBudgetTypeID"].ToString()); int PurchaseTypeID = int.Parse(this.PurchaseTypeDDL.SelectedValue); int? CompanyID = null; if (this.CompanyDDL.SelectedValue != "0") { CompanyID = int.Parse(this.CompanyDDL.SelectedValue); } int ShippingTermID = int.Parse(this.ShippingTermDDL.SelectedValue); string PaymentTerms = this.PaymentTermCtl.Text; string Remark = this.RemarkCtl.Text; string AttachedFileName = this.UCFileUpload.AttachmentFileName; string RealAttachedFileName = this.UCFileUpload.RealAttachmentFileName; string RealDeliveryAddress = this.RealDeliveryAddressCtl.Text; try { if (this.ViewState["ObjectId"] == null || RejectedFormID != null) { this.FormPurchaseBLL.AddPOSpecialApply(RejectedFormID, UserID, ProxyStuffUserId, null, OrganizationUnitID, PositionID, SystemEnums.FormType.POApply, StatusID, ParentFormID, ParentFormNo, ApplyAmountRMB, Period, VendorID, ItemCategoryID, CurrencyID, ExchangeRate, PurchaseBudgetTypeID, PurchaseTypeID, CompanyID, ShippingTermID, PaymentTerms, Remark, AttachedFileName, RealAttachedFileName, (int)this.ViewState["POType"], true, RealDeliveryAddress); } else { int FormID = (int)this.ViewState["ObjectId"]; this.FormPurchaseBLL.UpdatePOSpecialApply(FormID, StatusID, PurchaseTypeID, CompanyID, ShippingTermID, PaymentTerms, Remark, AttachedFileName, RealAttachedFileName, RealDeliveryAddress); } this.Page.Response.Redirect("~/Home.aspx"); } catch (Exception ex) { PageUtility.DealWithException(this.Page, ex); } }
protected void SaveFormApply(SystemEnums.FormStatus StatusID) { this.FormSaleBLL.FormDataSet = this.InnerDS; if (this.PaymentTypeDDL.SelectedValue == "0") { PageUtility.ShowModelDlg(this.Page, "请选择支付方式"); return; } if (this.ViewState["FormApplyIds"] != null && this.PaymentTypeDDL.SelectedValue == ((int)SystemEnums.PaymentType.FreeGoods).ToString()) { if (this.ViewState["FormApplyIds"].ToString().IndexOf(',') > 0) { PageUtility.ShowModelDlg(this.Page, "支付方式为货补时,只能有一张申请单!"); return; } } if (FillDetail()) { if (StatusID == SystemEnums.FormStatus.Awaiting) { if (decimal.Parse(this.ViewState["SettlementAmountTotal"].ToString()) <= 0) { PageUtility.ShowModelDlg(this.Page, "结案金额不能为零"); return; } } int? RejectedFormID = null; if (this.ViewState["RejectedObjectID"] != null) { RejectedFormID = (int)this.ViewState["RejectedObjectID"]; } int UserID = (int)this.ViewState["StuffUserID"]; int? ProxyStuffUserId = null; if (Session["ProxyStuffUserId"] != null) { ProxyStuffUserId = int.Parse(Session["ProxyStuffUserId"].ToString()); } int OrganizationUnitID = (int)this.ViewState["DepartmentID"]; int PositionID = (int)this.ViewState["PositionID"]; int CustomerID = int.Parse(this.ViewState["CustomerID"].ToString()); int ExpenseSubCategoryID = int.Parse(this.ViewState["ExpenseSubCategoryID"].ToString()); int CurrencyID = int.Parse(this.ViewState["CurrencyID"].ToString()); int BrandID = int.Parse(this.ViewState["BrandID"].ToString()); string AttachedFileName = this.UCSettlementFile.AttachmentFileName; string RealAttachedFileName = this.UCSettlementFile.RealAttachmentFileName; string Remark = this.RemarkCtl.Text; string FormApplyIds = this.ViewState["FormApplyIds"].ToString(); string FormApplyNos = this.ViewState["FormApplyNos"].ToString(); int PaymentTypeID = int.Parse(this.PaymentTypeDDL.SelectedValue); if (StatusID == SystemEnums.FormStatus.Awaiting) {//再检查一遍有没有结案过 string SettledFormNo = this.FormSaleBLL.GetSettledFormNoByApplyFormIds(FormApplyIds); if (SettledFormNo != "") { PageUtility.ShowModelDlg(this.Page, "申请单已经被结案过,结案单编号为:" + SettledFormNo); return; } } try { if (this.ViewState["ObjectId"] == null || RejectedFormID != null) { this.FormSaleBLL.AddActivitySettlement(RejectedFormID, UserID, ProxyStuffUserId, null, OrganizationUnitID, PositionID, SystemEnums.FormType.SaleSettlement, StatusID, CustomerID, BrandID, ExpenseSubCategoryID, CurrencyID, AttachedFileName, RealAttachedFileName, Remark, FormApplyIds, FormApplyNos, int.Parse(this.ViewState["CostCenterID"].ToString()), PaymentTypeID); } else { int FormID = (int)this.ViewState["ObjectId"]; this.FormSaleBLL.UpdateActivitySettlement(FormID, SystemEnums.FormType.SaleSettlement, StatusID, AttachedFileName, RealAttachedFileName, Remark, PaymentTypeID); } this.Page.Response.Redirect("~/Home.aspx"); } catch (Exception ex) { PageUtility.DealWithException(this.Page, ex); } } }
public void UpdateFormReimburseMoney(int FormID, SystemEnums.FormStatus StatusID, SystemEnums.FormType FormTypeID, string AttachedFileName, string RealAttachedFileName, string Remark, string FlowTemplate) { SqlTransaction transaction = null; try { //事务开始 transaction = TableAdapterHelper.BeginTransaction(this.TAForm); TableAdapterHelper.SetTransaction(this.TAFormReimburse, transaction); TableAdapterHelper.SetTransaction(this.TAFormReimburseDetail, transaction); TableAdapterHelper.SetTransaction(this.TAFormReimburseInvoice, transaction); TableAdapterHelper.SetTransaction(this.TAPKRecord, transaction); FormDS.FormRow formRow = this.TAForm.GetDataByID(FormID)[0]; FormDS.FormReimburseRow FormReimburseRow = this.TAFormReimburse.GetDataByID(FormID)[0]; //处理单据的内容 UtilityBLL utility = new UtilityBLL(); if (StatusID == SystemEnums.FormStatus.Awaiting) { string formTypeString = utility.GetFormTypeString((int)FormTypeID); formRow.FormNo = utility.GetFormNo(formTypeString); } else { formRow.SetFormNoNull(); } formRow.StatusID = (int)StatusID; formRow.SubmitDate = DateTime.Now; formRow.LastModified = DateTime.Now; this.TAForm.Update(formRow); //处理FormReimburseRow的内容 if (AttachedFileName != null && AttachedFileName != string.Empty) { FormReimburseRow.AttachedFileName = AttachedFileName; } else { FormReimburseRow.SetAttachedFileNameNull(); } if (RealAttachedFileName != null && RealAttachedFileName != string.Empty) { FormReimburseRow.RealAttachedFileName = RealAttachedFileName; } else { FormReimburseRow.SetRealAttachedFileNameNull(); } if (Remark != null && Remark != string.Empty) { FormReimburseRow.Remark = Remark; } this.TAFormReimburse.Update(FormReimburseRow); //发票 foreach (FormDS.FormReimburseInvoiceRow invoiceRow in this.FormDataSet.FormReimburseInvoice) { // 与父表绑定 if (invoiceRow.RowState != DataRowState.Deleted) { invoiceRow.FormReimburseID = FormReimburseRow.FormReimburseID; } } this.TAFormReimburseInvoice.Update(this.FormDataSet.FormReimburseInvoice); //处理明细 decimal totalAmount = 0; decimal totalTaxAmount = 0;//总税金 foreach (FormDS.FormReimburseDetailRow detailRow in this.FormDataSet.FormReimburseDetail) { if (detailRow.RowState != DataRowState.Deleted) { totalAmount += detailRow.Amount; totalTaxAmount += detailRow.IsTaxAmountNull() ? 0 : detailRow.TaxAmount; detailRow.FormReimburseID = FormReimburseRow.FormReimburseID; } } this.TAFormReimburseDetail.Update(this.FormDataSet.FormReimburseDetail); FormReimburseRow.Amount = totalAmount; FormReimburseRow.TaxAmount = totalTaxAmount; this.TAFormReimburse.Update(FormReimburseRow); // 正式提交 if (StatusID == SystemEnums.FormStatus.Awaiting) { Dictionary<string, object> dic = new Dictionary<string, object>(); dic["Apply_Amount"] = totalAmount + totalTaxAmount; //dic["Dept"] = new AuthorizationDSTableAdapters.OrganizationUnitTableAdapter().GetOrganizationUnitCodeByOrganizationUnitID(formRow.OrganizationUnitID)[0].OrganizationUnitCode; dic["Expense_Category"] = getExpenseCategoryIDByFormID(int.Parse(FormReimburseRow.FormApplyIds.Split(',')[0])).ToString();//此处待改动 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("Save Fail!" + ex.ToString()); } finally { transaction.Dispose(); } }
public void AddPVSpecialApply(int? RejectedFormID, int UserID, int? ProxyUserID, int? ProxyPositionID, int OrganizationUnitID, int PositionID, SystemEnums.FormType FormTypeID, SystemEnums.FormStatus StatusID, DateTime FPeriod, int VendorID, int ItemCategoryID, int CurrencyID, decimal ExchangeRate, int PurchaseBudgetTypeID, int PurchaseTypeID, string Remark, string AttachedFileName, string RealAttachedFileName, int MethodPaymentID, DateTime? ExpectPaymentDate, decimal TotalBudget, decimal ApprovedAmount, decimal ApprovingAmount, decimal ReimbursedAmount, decimal NonReimbursedAmount, decimal RemainBudget, bool IsUrgent, bool IsPublic, int InvoiceStatusID, int PVType, int? VATRateID, decimal AMTTax, string PaymentTerms, bool IsPTChanged) { SqlTransaction transaction = null; try { //事务开始 transaction = TableAdapterHelper.BeginTransaction(this.TAForm); TableAdapterHelper.SetTransaction(this.TAFormPV, transaction); TableAdapterHelper.SetTransaction(this.TAFormInvoice, transaction); TableAdapterHelper.SetTransaction(this.TAFormPVDetail, transaction); //处理单据的内容 PurchaseDS.FormRow formRow = this.PurchaseDataSet.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.SpecialPV; formRow.CostCenterID = new StuffUserBLL().GetCostCenterIDByPositionID(PositionID); formRow.IsCreateVoucher = false; formRow.IsExportLock = false; formRow.IsCompletePayment = false; this.PurchaseDataSet.Form.AddFormRow(formRow); this.TAForm.Update(formRow); //处理申请表的内容 PurchaseDS.FormPVRow formPVRow = this.PurchaseDataSet.FormPV.NewFormPVRow(); formPVRow.FormPVID = formRow.FormID; formPVRow.FPeriod = FPeriod; formPVRow.VendorID = VendorID; formPVRow.ItemCategoryID = ItemCategoryID; formPVRow.CurrencyID = CurrencyID; formPVRow.ExchangeRate = ExchangeRate; formPVRow.PurchaseBudgetTypeID = PurchaseBudgetTypeID; formPVRow.PurchaseTypeID = PurchaseTypeID; formPVRow.Remark = Remark; if (AttachedFileName != null && AttachedFileName != string.Empty) { formPVRow.AttachedFileName = AttachedFileName; } if (RealAttachedFileName != null && RealAttachedFileName != string.Empty) { formPVRow.RealAttachedFileName = RealAttachedFileName; } formPVRow.MethodPaymentID = MethodPaymentID; if (ExpectPaymentDate != null) { formPVRow.ExpectPaymentDate = ExpectPaymentDate.GetValueOrDefault(); } formPVRow.ApplyAmount = 0; formPVRow.PayedAmount = 0; formPVRow.Amount = 0; formPVRow.AmountRMB = 0; formPVRow.AMTBeforeTax = 0; formPVRow.AMTTax = AMTTax; formPVRow.TotalBudget = TotalBudget; formPVRow.ApprovedAmount = ApprovedAmount; formPVRow.ApprovingAmount = ApprovingAmount; formPVRow.ReimbursedAmount = ReimbursedAmount; formPVRow.NonReimbursedAmount = NonReimbursedAmount; formPVRow.RemainBudget = RemainBudget; formPVRow.IsUrgent = IsUrgent; formPVRow.IsPublic = IsPublic; formPVRow.InvoiceStatusID = InvoiceStatusID; formPVRow.PVType = PVType; if (VATRateID != null) { formPVRow.VatRateID = VATRateID.GetValueOrDefault(); } formPVRow.PaymentTerms = PaymentTerms; formPVRow.IsPTChanged = IsPTChanged; formPVRow.FinalItemCategoryID = ItemCategoryID; this.PurchaseDataSet.FormPV.AddFormPVRow(formPVRow); this.TAFormPV.Update(formPVRow); //发票 if (RejectedFormID != null) { PurchaseDS.FormInvoiceDataTable newInvoiceTable = new PurchaseDS.FormInvoiceDataTable(); foreach (PurchaseDS.FormInvoiceRow invoiceRow in this.PurchaseDataSet.FormInvoice) { if (invoiceRow.RowState != DataRowState.Deleted) { PurchaseDS.FormInvoiceRow newInvoiceRow = newInvoiceTable.NewFormInvoiceRow(); newInvoiceRow.FormID = formRow.FormID; newInvoiceRow.InvoiceNo = invoiceRow.InvoiceNo; newInvoiceRow.InvoiceDate = invoiceRow.InvoiceDate; newInvoiceRow.InvoiceAmount = invoiceRow.InvoiceAmount; newInvoiceRow.Remark = invoiceRow.IsRemarkNull() ? "" : invoiceRow.Remark; newInvoiceRow.SystemInfo = invoiceRow.IsSystemInfoNull() ? "" : invoiceRow.SystemInfo; newInvoiceTable.AddFormInvoiceRow(newInvoiceRow); } this.TAFormInvoice.Update(newInvoiceTable); } } else { foreach (PurchaseDS.FormInvoiceRow invoiceRow in this.PurchaseDataSet.FormInvoice) { // 与父表绑定 if (invoiceRow.RowState != DataRowState.Deleted) { invoiceRow.FormID = formRow.FormID; } } } this.TAFormInvoice.Update(this.PurchaseDataSet.FormInvoice); //处理明细 decimal totalAmount = 0; decimal totalAmountRMB = 0; if (RejectedFormID != null) { PurchaseDS.FormPVDetailDataTable newPVDetailTable = new PurchaseDS.FormPVDetailDataTable(); foreach (PurchaseDS.FormPVDetailRow detailRow in this.PurchaseDataSet.FormPVDetail) { if (detailRow.RowState != DataRowState.Deleted) { PurchaseDS.FormPVDetailRow newPVDetailRow = newPVDetailTable.NewFormPVDetailRow(); newPVDetailRow.FormPVID = formRow.FormID; newPVDetailRow.ItemID = detailRow.ItemID; newPVDetailRow.ItemCode = detailRow.ItemCode; newPVDetailRow.ItemName = detailRow.ItemName; if (!detailRow.IsItemDescriptionNull()) { newPVDetailRow.ItemDescription = detailRow.ItemDescription; } if (!detailRow.IsPackageNull()) { newPVDetailRow.Package = detailRow.Package; } newPVDetailRow.UnitPrice = detailRow.UnitPrice; newPVDetailRow.FinalPrice = detailRow.FinalPrice; newPVDetailRow.Quantity = detailRow.Quantity; newPVDetailRow.Amount = detailRow.Amount; newPVDetailRow.AmountRMB = decimal.Round(detailRow.Amount * ExchangeRate, 2); newPVDetailRow.DeliveryDate = detailRow.DeliveryDate; newPVDetailTable.AddFormPVDetailRow(newPVDetailRow); totalAmount = totalAmountRMB + newPVDetailRow.Amount; totalAmountRMB = totalAmountRMB + newPVDetailRow.AmountRMB; } } this.TAFormPVDetail.Update(newPVDetailTable); } else { foreach (PurchaseDS.FormPVDetailRow detailRow in this.PurchaseDataSet.FormPVDetail) { if (detailRow.RowState != DataRowState.Deleted) { detailRow.FormPVID = formRow.FormID; detailRow.AmountRMB = decimal.Round(detailRow.Amount * ExchangeRate, 2); totalAmountRMB = totalAmountRMB + detailRow.AmountRMB; totalAmount = totalAmount + detailRow.Amount; } } this.TAFormPVDetail.Update(this.PurchaseDataSet.FormPVDetail); } formPVRow.AmountRMB = totalAmountRMB; formPVRow.Amount = totalAmount; formPVRow.AMTBeforeTax = totalAmount - AMTTax; this.TAFormPV.Update(formPVRow); //作废之前的单据 if (RejectedFormID != null) { PurchaseDS.FormRow oldRow = this.TAForm.GetDataByID(RejectedFormID.GetValueOrDefault())[0]; if (oldRow.StatusID == (int)SystemEnums.FormStatus.Rejected) { oldRow.StatusID = (int)SystemEnums.FormStatus.Scrap; this.TAForm.Update(oldRow); } } // 正式提交 if (StatusID == SystemEnums.FormStatus.Awaiting) { Dictionary<string, object> dic = new Dictionary<string, object>(); dic["TotalAmount"] = totalAmountRMB; dic["InvoiceStatus"] = formPVRow.InvoiceStatusID; dic["IsUrgent"] = formPVRow.IsUrgent; APResult result = new APFlowBLL().CreateProcess(new APParameter(formRow.FormID, formRow.FormNo, formRow.OrganizationUnitID, formRow.UserID, (int)StatusID, formRow.FormTypeID, formRow.PositionID, dic)); if (result != null) { formRow.InTurnPositionIds = result.InTurnPositionIds; formRow.InTurnUserIds = result.InTurnUserIds; formRow.SubmitDate = result.ApprovedDate.GetValueOrDefault(); formRow.StatusID = result.StatusID; formRow.ProcID = result.ProcID; formRow.FinanceRemark = formPVRow.Remark; this.TAForm.Update(formRow); } } transaction.Commit(); } catch (ApplicationException ex) { transaction.Rollback(); throw ex; } catch (Exception ex) { transaction.Rollback(); throw new ApplicationException("Save Fail!" + ex.ToString()); } finally { transaction.Dispose(); } }
public void AddPRApply(int? RejectedFormID, int UserID, int? ProxyUserID, int? ProxyPositionID, int OrganizationUnitID, int PositionID, SystemEnums.FormType FormTypeID, SystemEnums.FormStatus StatusID, DateTime FPeriod, int VendorID, int ItemCategoryID, int CurrencyID, decimal ExchangeRate, int PurchaseBudgetTypeID, int PurchaseTypeID, int? CompanyID, int ShippingTermID, string PaymentTerms, string Remark, string AttachedFileName, string RealAttachedFileName, decimal TotalBudget, decimal ApprovedAmount, decimal ApprovingAmount, decimal ReimbursedAmount, decimal NonReimbursedAmount, decimal RemainBudget, string ItemCategoryName, string RealDeliveryAddress) { SqlTransaction transaction = null; try { //事务开始 transaction = TableAdapterHelper.BeginTransaction(this.TAForm); TableAdapterHelper.SetTransaction(this.TAFormPR, transaction); TableAdapterHelper.SetTransaction(this.TAFormPRDetail, transaction); //处理单据的内容 PurchaseDS.FormRow formRow = this.PurchaseDataSet.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.PRApply; formRow.CostCenterID = new StuffUserBLL().GetCostCenterIDByPositionID(PositionID); this.PurchaseDataSet.Form.AddFormRow(formRow); this.TAForm.Update(formRow); //处理申请表的内容 PurchaseDS.FormPRRow formPRRow = this.PurchaseDataSet.FormPR.NewFormPRRow(); formPRRow.FormPRID = formRow.FormID; formPRRow.FPeriod = DateTime.Parse(FPeriod.Year.ToString() + "-" + FPeriod.Month.ToString() + "-01"); formPRRow.VendorID = VendorID; formPRRow.ItemCategoryID = ItemCategoryID; formPRRow.CurrencyID = CurrencyID; formPRRow.ExchangeRate = ExchangeRate; formPRRow.PurchaseBudgetTypeID = PurchaseBudgetTypeID; formPRRow.PurchaseTypeID = PurchaseTypeID; if (CompanyID != null) { formPRRow.CompanyID = CompanyID.GetValueOrDefault(); formPRRow.DeliveryAddress = new MasterDataBLL().GetCompanyById(CompanyID.GetValueOrDefault()).CompanyAddress; } formPRRow.ShippingTermID = ShippingTermID; if (PaymentTerms != null) { formPRRow.PaymentTerms = PaymentTerms; } if (Remark != null) { formPRRow.Remark = Remark; } if (AttachedFileName != null && AttachedFileName != string.Empty) { formPRRow.AttachedFileName = AttachedFileName; } if (RealAttachedFileName != null && RealAttachedFileName != string.Empty) { formPRRow.RealAttachedFileName = RealAttachedFileName; } formPRRow.TotalBudget = TotalBudget; formPRRow.ApprovedAmount = ApprovedAmount; formPRRow.ApprovingAmount = ApprovingAmount; formPRRow.ReimbursedAmount = ReimbursedAmount; formPRRow.NonReimbursedAmount = NonReimbursedAmount; formPRRow.RemainBudget = RemainBudget; formPRRow.IsClose = false; formPRRow.AmountRMB = 0; formPRRow.RealDeliveryAddress = RealDeliveryAddress; this.PurchaseDataSet.FormPR.AddFormPRRow(formPRRow); this.TAFormPR.Update(formPRRow); //处理明细 decimal totalAmountRMB = 0; if (RejectedFormID != null) { PurchaseDS.FormPRDetailDataTable newPRDetailTable = new PurchaseDS.FormPRDetailDataTable(); foreach (PurchaseDS.FormPRDetailRow detailRow in this.PurchaseDataSet.FormPRDetail) { if (detailRow.RowState != DataRowState.Deleted) { PurchaseDS.FormPRDetailRow newPRDetailRow = newPRDetailTable.NewFormPRDetailRow(); newPRDetailRow.FormPRID = formRow.FormID; newPRDetailRow.ItemID = detailRow.ItemID; newPRDetailRow.ItemCode = detailRow.ItemCode; newPRDetailRow.ItemName = detailRow.ItemName; if (!detailRow.IsItemDescriptionNull()) { newPRDetailRow.ItemDescription = detailRow.ItemDescription; } if (!detailRow.IsPackageNull()) { newPRDetailRow.Package = detailRow.Package; } newPRDetailRow.UnitPrice = detailRow.UnitPrice; newPRDetailRow.FinalPrice = detailRow.FinalPrice; newPRDetailRow.Quantity = detailRow.Quantity; newPRDetailRow.Amount = detailRow.Amount; newPRDetailRow.AmountRMB = decimal.Round(detailRow.Amount * ExchangeRate, 2); newPRDetailRow.DeliveryDate = detailRow.DeliveryDate; if (!detailRow.IsDeliveryAddressNull()) { newPRDetailRow.DeliveryAddress = detailRow.DeliveryAddress; } newPRDetailTable.AddFormPRDetailRow(newPRDetailRow); totalAmountRMB = totalAmountRMB + newPRDetailRow.AmountRMB; } } this.TAFormPRDetail.Update(newPRDetailTable); } else { foreach (PurchaseDS.FormPRDetailRow detailRow in this.PurchaseDataSet.FormPRDetail) { if (detailRow.RowState != DataRowState.Deleted) { detailRow.FormPRID = formRow.FormID; detailRow.AmountRMB = decimal.Round(detailRow.Amount * ExchangeRate, 2); totalAmountRMB = totalAmountRMB + detailRow.AmountRMB; } } this.TAFormPRDetail.Update(this.PurchaseDataSet.FormPRDetail); } formPRRow.AmountRMB = totalAmountRMB; this.TAFormPR.Update(formPRRow); //作废之前的单据 if (RejectedFormID != null) { PurchaseDS.FormRow oldRow = this.TAForm.GetDataByID(RejectedFormID.GetValueOrDefault())[0]; if (oldRow.StatusID == (int)SystemEnums.FormStatus.Rejected) { oldRow.StatusID = (int)SystemEnums.FormStatus.Scrap; this.TAForm.Update(oldRow); } } // 正式提交 if (StatusID == SystemEnums.FormStatus.Awaiting) { Dictionary<string, object> dic = new Dictionary<string, object>(); dic["TTLCost"] = totalAmountRMB; dic["ItemCategory"] = ItemCategoryName; APResult result = new APFlowBLL().CreateProcess(new APParameter(formRow.FormID, formRow.FormNo, formRow.OrganizationUnitID, formRow.UserID, (int)StatusID, formRow.FormTypeID, formRow.PositionID, dic)); if (result != null) { formRow.InTurnPositionIds = result.InTurnPositionIds; formRow.InTurnUserIds = result.InTurnUserIds; formRow.SubmitDate = result.ApprovedDate.GetValueOrDefault(); formRow.StatusID = result.StatusID; formRow.ProcID = result.ProcID; this.TAForm.Update(formRow); } } transaction.Commit(); } catch (ApplicationException ex) { transaction.Rollback(); throw ex; } catch (Exception ex) { transaction.Rollback(); throw new ApplicationException("Save Fail!" + ex.ToString()); } finally { transaction.Dispose(); } }
public void UpdatePRApply(int FormID, SystemEnums.FormStatus StatusID, decimal ExchangeRate, int PurchaseTypeID, int? CompanyID, int ShippingTermID, string PaymentTerms, string Remark, string AttachedFileName, string RealAttachedFileName, decimal TotalBudget, decimal ApprovedAmount, decimal ApprovingAmount, decimal ReimbursedAmount, decimal NonReimbursedAmount, decimal RemainBudget, string ItemCategoryName, string RealDeliveryAddress) { SqlTransaction transaction = null; try { //事务开始 transaction = TableAdapterHelper.BeginTransaction(this.TAForm); TableAdapterHelper.SetTransaction(this.TAFormPR, transaction); TableAdapterHelper.SetTransaction(this.TAFormPRDetail, transaction); PurchaseDS.FormRow formRow = this.TAForm.GetDataByID(FormID)[0]; PurchaseDS.FormPRRow formPRRow = this.TAFormPR.GetDataByID(FormID)[0]; //处理单据的内容 UtilityBLL utility = new UtilityBLL(); if (StatusID == SystemEnums.FormStatus.Awaiting) { string formTypeString = utility.GetFormTypeString(formRow.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); //处理申请表的内容 formPRRow.ExchangeRate = ExchangeRate; formPRRow.PurchaseTypeID = PurchaseTypeID; if (CompanyID != null) { formPRRow.CompanyID = CompanyID.GetValueOrDefault(); formPRRow.DeliveryAddress = new MasterDataBLL().GetCompanyById(CompanyID.GetValueOrDefault()).CompanyAddress; } formPRRow.ShippingTermID = ShippingTermID; if (PaymentTerms != null) { formPRRow.PaymentTerms = PaymentTerms; } if (Remark != null) { formPRRow.Remark = Remark; } if (AttachedFileName != null && AttachedFileName != string.Empty) { formPRRow.AttachedFileName = AttachedFileName; } else { formPRRow.SetAttachedFileNameNull(); } if (RealAttachedFileName != null && RealAttachedFileName != string.Empty) { formPRRow.RealAttachedFileName = RealAttachedFileName; } else { formPRRow.SetRealAttachedFileNameNull(); } formPRRow.TotalBudget = TotalBudget; formPRRow.ApprovedAmount = ApprovedAmount; formPRRow.ApprovingAmount = ApprovingAmount; formPRRow.ReimbursedAmount = ReimbursedAmount; formPRRow.NonReimbursedAmount = NonReimbursedAmount; formPRRow.RemainBudget = RemainBudget; formPRRow.AmountRMB = 0; formPRRow.RealDeliveryAddress = RealDeliveryAddress; this.TAFormPR.Update(formPRRow); //处理明细 decimal totalAmountRMB = 0; foreach (PurchaseDS.FormPRDetailRow detailRow in this.PurchaseDataSet.FormPRDetail) { if (detailRow.RowState != DataRowState.Deleted) { detailRow.FormPRID = formRow.FormID; detailRow.AmountRMB = decimal.Round(detailRow.Amount * ExchangeRate, 2); totalAmountRMB = totalAmountRMB + detailRow.AmountRMB; } } this.TAFormPRDetail.Update(this.PurchaseDataSet.FormPRDetail); formPRRow.AmountRMB = totalAmountRMB; this.TAFormPR.Update(formPRRow); // 正式提交 if (StatusID == SystemEnums.FormStatus.Awaiting) { Dictionary<string, object> dic = new Dictionary<string, object>(); dic["TTLCost"] = totalAmountRMB; dic["ItemCategory"] = ItemCategoryName; APResult result = new APFlowBLL().CreateProcess(new APParameter(formRow.FormID, formRow.FormNo, formRow.OrganizationUnitID, formRow.UserID, (int)StatusID, formRow.FormTypeID, formRow.PositionID, dic)); if (result != null) { formRow.InTurnPositionIds = result.InTurnPositionIds; formRow.InTurnUserIds = result.InTurnUserIds; formRow.SubmitDate = result.ApprovedDate.GetValueOrDefault(); formRow.StatusID = result.StatusID; formRow.ProcID = result.ProcID; this.TAForm.Update(formRow); } } transaction.Commit(); } catch (ApplicationException ex) { transaction.Rollback(); throw ex; } catch (Exception ex) { transaction.Rollback(); throw new ApplicationException("Save Fail!" + ex.ToString()); } finally { transaction.Dispose(); } }
protected void SaveFormInvitationReimburseBLL(SystemEnums.FormStatus StatusID) { decimal TotalBudget = 0; decimal ApprovedAmount = 0; decimal ApprovingAmount = 0; decimal RemainBudget = 0; int? RejectedFormID = null; if (this.ViewState["RejectedObjectID"] != null) { RejectedFormID = (int)this.ViewState["RejectedObjectID"]; } int UserID = (int)this.ViewState["StuffUserID"]; int? ProxyStuffUserId = null; if (Session["ProxyStuffUserId"] != null) { ProxyStuffUserId = int.Parse(Session["ProxyStuffUserId"].ToString()); } int OrganizationUnitID = (int)this.ViewState["DepartmentID"]; int PositionID = (int)this.ViewState["PositionID"]; string Remark = this.RemarkCtl.Text; DateTime? Period = null; if (dplPeriod.SelectedValue != null && dplPeriod.SelectedValue != "0") { Period = DateTime.Parse(this.dplPeriod.SelectedItem.Text.ToString() + "-1"); } String CustomerName = this.txtCustomerName.Text; String AttenderNames = this.txtAttenderNames.Text; int AttenderCount = this.txtAttenderCount.Text == "" ? 0 : int.Parse(this.txtAttenderCount.Text); String BusinessRelation = this.txtBusinessRelation.Text; String Place = this.txtPlace.Text; DateTime? OccuredDate = null; if (this.UCOccuredDate.SelectedDate != null && this.UCOccuredDate.SelectedDate != "") { OccuredDate = DateTime.Parse(this.UCOccuredDate.SelectedDate); } String BusinessPurpose = this.txtBusinessPurpose.Text; int CurrencyID = int.Parse(this.dplCurrency.SelectedValue); string InvitationType = this.txtInvitationType.Text; Decimal ExchangeRate = this.txtExchageRate.Text == "" ? 1 : Decimal.Parse(this.txtExchageRate.Text); Decimal Amount = this.txtAmount.Text == "" ? 0 : Decimal.Parse(this.txtAmount.Text); if (StatusID == SystemEnums.FormStatus.Awaiting) { if (ExchangeRate == 0) { PageUtility.ShowModelDlg(this, "汇率不能为0!", "exchange rate should not equal zero"); return; } if (Amount == 0) { PageUtility.ShowModelDlg(this, "申请金额不能为0!", "amount should not equal zero"); return; } decimal[] budgetInfo = new BudgetBLL().GetPersonalBudgetByParameter(PositionID, Period.GetValueOrDefault().Year); TotalBudget = budgetInfo[0]; ApprovedAmount = budgetInfo[1]; ApprovingAmount = budgetInfo[2]; RemainBudget = budgetInfo[3]; if (Amount * ExchangeRate > budgetInfo[3]) { PageUtility.ShowModelDlg(this, "超出预算,不能提交!", "Over budget, Can't submit!"); return; } } int FormInvitationApplyID = this.ViewState["FormInvitationApplyID"] == null ? 0 : (int)this.ViewState["FormInvitationApplyID"]; try { if (this.ViewState["ObjectId"] == null || RejectedFormID != null) { this.FormTEBLL.AddFormInvitationReimburseApply(FormInvitationApplyID, RejectedFormID, UserID, ProxyStuffUserId, null, OrganizationUnitID, PositionID,SystemEnums.FormType.FormInvitationReimburse, StatusID, Period, Remark, CustomerName, AttenderNames, AttenderCount, BusinessRelation, Place, OccuredDate, BusinessPurpose, InvitationType, CurrencyID, ExchangeRate, Amount, TotalBudget, ApprovingAmount, ApprovedAmount, RemainBudget,int.Parse(this.ddlManageExpenseItem.SelectedValue)); } else { this.FormTEBLL.UpdateFormInvitationReimburseApply(RejectedFormID.GetValueOrDefault(), (int)this.ViewState["ObjectId"], (int)SystemEnums.FormType.FormInvitationReimburse, StatusID, Period, Remark, CustomerName, AttenderNames, AttenderCount, BusinessRelation, Place, OccuredDate, BusinessPurpose, InvitationType, CurrencyID, ExchangeRate, Amount, TotalBudget, ApprovingAmount, ApprovedAmount, RemainBudget,int.Parse(this.ddlManageExpenseItem.SelectedValue)); } this.Page.Response.Redirect("~/Home.aspx"); } catch (Exception ex) { PageUtility.DealWithException(this.Page, ex); } }
public void AddFormTravelReimburse(int? RejectedFormID, int UserID, int? ProxyUserID, int? ProxyPositionID, int OrganizationUnitID, int PositionID, SystemEnums.FormType FormTypeID, SystemEnums.FormStatus StatusID, DateTime? Period, string Remark, decimal TotalBudget, decimal ApprovedAmount, decimal ApprovingAmount, decimal RemainAmount, string AttachedFileName, string RealAttachedFileName) { SqlTransaction transaction = null; try { transaction = TableAdapterHelper.BeginTransaction(this.TAForm); TableAdapterHelper.SetTransaction(this.TAFormTravelReimburse, transaction); TableAdapterHelper.SetTransaction(this.TAFormTravelReimburseDetail, 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.InTurnUserIds = "P";//待改动 formRow.InTurnPositionIds = "P";//待改动 formRow.OrganizationUnitID = OrganizationUnitID; formRow.PositionID = PositionID; formRow.FormTypeID = (int)FormTypeID; formRow.StatusID = (int)StatusID; formRow.SubmitDate = DateTime.Now; formRow.LastModified = DateTime.Now; formRow.PageType = (int)SystemEnums.PageType.TravelReimburseApply; formRow.CostCenterID = new StuffUserBLL().GetCostCenterIDByPositionID(PositionID); formRow.IsCreateVoucher = false; formRow.IsExportLock = false; formRow.IsCompletePayment = false; this.FormDataSet.Form.AddFormRow(formRow); this.TAForm.Update(formRow); //处理申请表的内容 FormDS.FormTravelReimburseRow formTravelReimburseRow = this.FormDataSet.FormTravelReimburse.NewFormTravelReimburseRow(); formTravelReimburseRow.FormTravelReimburseID = formRow.FormID; if (Period != null) { formTravelReimburseRow.Period = Period.GetValueOrDefault(); } formTravelReimburseRow.Amount = decimal.Zero; formTravelReimburseRow.Remark = Remark; formTravelReimburseRow.TotalBudget = TotalBudget; formTravelReimburseRow.ApprovedAmount = ApprovedAmount; formTravelReimburseRow.ApprovingAmount = ApprovingAmount; formTravelReimburseRow.RemainAmount = RemainAmount; if (AttachedFileName != null && AttachedFileName != string.Empty) { formTravelReimburseRow.AttachedFileName = AttachedFileName; } if (RealAttachedFileName != null && RealAttachedFileName != string.Empty) { formTravelReimburseRow.RealAttachedFileName = RealAttachedFileName; } this.FormDataSet.FormTravelReimburse.AddFormTravelReimburseRow(formTravelReimburseRow); this.TAFormTravelReimburse.Update(formTravelReimburseRow); //明细表 decimal totalAmountRMB = 0;//计算总申请金额 if (RejectedFormID != null) { FormDS.FormTravelReimburseDetailDataTable newDetailTable = new FormDS.FormTravelReimburseDetailDataTable(); foreach (FormDS.FormTravelReimburseDetailRow detailRow in this.FormDataSet.FormTravelReimburseDetail) { if (detailRow.RowState != System.Data.DataRowState.Deleted) { FormDS.FormTravelReimburseDetailRow newDetailRow = newDetailTable.NewFormTravelReimburseDetailRow(); newDetailRow.FormTravelReimburseID = formTravelReimburseRow.FormTravelReimburseID; newDetailRow.OccurDate = detailRow.OccurDate; newDetailRow.ManageExpenseItemID = detailRow.ManageExpenseItemID; newDetailRow.Cost = detailRow.Cost; newDetailRow.CityID = detailRow.CityID; newDetailRow.CurrencyID = detailRow.CurrencyID; newDetailRow.Destination = detailRow.Destination; newDetailRow.Frequency = detailRow.Frequency; newDetailRow.UnitPrice = detailRow.UnitPrice; newDetailRow.ExchangeRate = detailRow.ExchangeRate; newDetailRow.PayMan = detailRow.PayMan; if (!detailRow.IsRemarkNull()) { newDetailRow.Remark = detailRow.Remark; } totalAmountRMB += newDetailRow.Cost; newDetailTable.AddFormTravelReimburseDetailRow(newDetailRow); } } this.TAFormTravelReimburseDetail.Update(newDetailTable); } else { foreach (FormDS.FormTravelReimburseDetailRow detailRow in this.FormDataSet.FormTravelReimburseDetail) { // 与父表绑定 if (detailRow.RowState != DataRowState.Deleted) { detailRow.FormTravelReimburseID = formTravelReimburseRow.FormTravelReimburseID; totalAmountRMB += detailRow.Cost; } } this.TAFormTravelReimburseDetail.Update(this.FormDataSet.FormTravelReimburseDetail); } formTravelReimburseRow.Amount = totalAmountRMB; this.TAFormTravelReimburse.Update(formTravelReimburseRow); // 正式提交或草稿 if (StatusID == SystemEnums.FormStatus.Awaiting) { Dictionary<string, object> dic = new Dictionary<string, object>(); dic["TotalAmount"] = totalAmountRMB; APResult result = new APFlowBLL().CreateProcess(new APParameter(formRow.FormID, formRow.FormNo, formRow.OrganizationUnitID, formRow.UserID, (int)StatusID, formRow.FormTypeID, formRow.PositionID, dic)); if (result != null) { formRow.InTurnPositionIds = result.InTurnPositionIds; formRow.InTurnUserIds = result.InTurnUserIds; formRow.SubmitDate = result.ApprovedDate.GetValueOrDefault(); formRow.StatusID = result.StatusID; formRow.ProcID = result.ProcID; formRow.FinanceRemark = formTravelReimburseRow.Remark; this.TAForm.Update(formRow); } } //作废之前的单据 if (RejectedFormID != null) { FormDS.FormRow oldRow = TAForm.GetDataByID(RejectedFormID.GetValueOrDefault())[0]; if (oldRow.StatusID == (int)SystemEnums.FormStatus.Rejected) { new APFlowBLL().ScrapForm(oldRow.FormID); } } transaction.Commit(); } catch (Exception ex) { transaction.Rollback(); throw new ApplicationException(ex.Message); } finally { transaction.Dispose(); } }
public void AddFormInvitationApply(int? RejectedFormID, int UserID, int? ProxyUserID, int? ProxyPositionID, int OrganizationUnitID, int PositionID, SystemEnums.FormType FormTypeID, SystemEnums.FormStatus StatusID, DateTime? Period, string Remark, String CustomerName, String AttenderNames, int AttenderCount, String BusinessRelation, String Place, DateTime? OccuredDate, String Purpose, String InvitationType, int CurrencyID, decimal? ExchangeRate, decimal? Amount, decimal? TotalBudget, decimal? ApprovingAmount, decimal? ApprovedAmount, decimal? RemainBudget) { SqlTransaction transaction = null; try { transaction = TableAdapterHelper.BeginTransaction(this.TAForm); TableAdapterHelper.SetTransaction(this.TAFormInvitationApply, transaction); FormDS.FormDataTable tbForm = new FormDS.FormDataTable(); FormDS.FormRow formRow = tbForm.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.FormInvitationApply; formRow.CostCenterID = new StuffUserBLL().GetCostCenterIDByPositionID(PositionID); tbForm.AddFormRow(formRow); this.TAForm.Update(tbForm); //处理申请表的内容 FormDS.FormInvitationApplyDataTable tbFormInvitation = new FormDS.FormInvitationApplyDataTable(); FormDS.FormInvitationApplyRow FormInvitationApplyRow = tbFormInvitation.NewFormInvitationApplyRow(); FormInvitationApplyRow.FormInvitationApplyID = formRow.FormID; if (Period != null) { FormInvitationApplyRow.Period = Period.GetValueOrDefault(); } FormInvitationApplyRow.CustomerName = CustomerName; FormInvitationApplyRow.Remark = Remark; FormInvitationApplyRow.AttenderNames = AttenderNames; FormInvitationApplyRow.AttenderCount = AttenderCount; FormInvitationApplyRow.BusinessRelation = BusinessRelation; FormInvitationApplyRow.Place = Place; if (OccuredDate != null) { FormInvitationApplyRow.OccuredDate = OccuredDate.GetValueOrDefault(); } FormInvitationApplyRow.Purpose = Purpose; FormInvitationApplyRow.InvitationType = InvitationType; FormInvitationApplyRow.CurrencyID = CurrencyID; FormInvitationApplyRow.ExchangeRate = ExchangeRate.GetValueOrDefault(); FormInvitationApplyRow.Amount = Amount.GetValueOrDefault(); FormInvitationApplyRow.TotalBudget = TotalBudget.GetValueOrDefault(); FormInvitationApplyRow.ApprovingAmount = ApprovingAmount.GetValueOrDefault(); FormInvitationApplyRow.ApprovedAmount = ApprovedAmount.GetValueOrDefault(); FormInvitationApplyRow.RemainBudget = RemainBudget.GetValueOrDefault(); tbFormInvitation.AddFormInvitationApplyRow(FormInvitationApplyRow); this.TAFormInvitationApply.Update(tbFormInvitation); //作废之前的单据 if (RejectedFormID != null) { FormDS.FormRow oldRow = TAForm.GetDataByID(RejectedFormID.GetValueOrDefault())[0]; if (oldRow.StatusID == (int)SystemEnums.FormStatus.Rejected) { new APFlowBLL().ScrapForm(oldRow.FormID); } } // 正式提交或草稿 if (StatusID == SystemEnums.FormStatus.Awaiting) { Dictionary<string, object> dic = new Dictionary<string, object>(); dic["TotalAmount"] = FormInvitationApplyRow.AmountRMB; APResult result = new APFlowBLL().CreateProcess(new APParameter(formRow.FormID, formRow.FormNo, formRow.OrganizationUnitID, formRow.UserID, (int)StatusID, formRow.FormTypeID, formRow.PositionID, dic)); if (result != null) { formRow.InTurnPositionIds = result.InTurnPositionIds; formRow.InTurnUserIds = result.InTurnUserIds; formRow.SubmitDate = result.ApprovedDate.GetValueOrDefault(); formRow.StatusID = result.StatusID; formRow.ProcID = result.ProcID; this.TAForm.Update(formRow); } } transaction.Commit(); } catch (Exception ex) { transaction.Rollback(); throw new ApplicationException(ex.Message); } finally { transaction.Dispose(); } }
public void UpdateFormTravelReimburse(int FormID, SystemEnums.FormStatus StatusID, SystemEnums.FormType FormTypeID, DateTime? Period, string Remark, decimal TotalBudget, decimal ApprovedAmount, decimal ApprovingAmount, decimal RemainAmount, string AttachedFileName, string RealAttachedFileName) { SqlTransaction transaction = null; try { ////事务开始 transaction = TableAdapterHelper.BeginTransaction(this.TAForm); TableAdapterHelper.SetTransaction(this.TAFormTravelReimburse, transaction); TableAdapterHelper.SetTransaction(this.TAFormTravelReimburseDetail, transaction); FormDS.FormRow formRow = this.TAForm.GetDataByID(FormID)[0]; UtilityBLL utility = new UtilityBLL(); if (StatusID == SystemEnums.FormStatus.Awaiting) { string formTypeString = utility.GetFormTypeString((int)FormTypeID); formRow.FormNo = utility.GetFormNo(formTypeString); } else { formRow.SetFormNoNull(); } formRow.StatusID = (int)StatusID; formRow.SubmitDate = DateTime.Now; formRow.LastModified = DateTime.Now; this.TAForm.Update(formRow); //处理申请表的内容 FormDS.FormTravelReimburseRow formTravelReimburseRow = this.TAFormTravelReimburse.GetDataByFormTravelReimburseID(FormID)[0]; if (Period != null) { formTravelReimburseRow.Period = Period.GetValueOrDefault(); } formTravelReimburseRow.Amount = decimal.Zero; formTravelReimburseRow.Remark = Remark; formTravelReimburseRow.TotalBudget = TotalBudget; formTravelReimburseRow.ApprovedAmount = ApprovedAmount; formTravelReimburseRow.ApprovingAmount = ApprovingAmount; formTravelReimburseRow.RemainAmount = RemainAmount; if (AttachedFileName != null && AttachedFileName != string.Empty) { formTravelReimburseRow.AttachedFileName = AttachedFileName; } else { formTravelReimburseRow.SetAttachedFileNameNull(); } if (RealAttachedFileName != null && RealAttachedFileName != string.Empty) { formTravelReimburseRow.RealAttachedFileName = RealAttachedFileName; } else { formTravelReimburseRow.SetRealAttachedFileNameNull(); } this.TAFormTravelReimburse.Update(formTravelReimburseRow); //明细表 decimal totalAmount = 0;//计算总申请金额 foreach (FormDS.FormTravelReimburseDetailRow detailRow in this.FormDataSet.FormTravelReimburseDetail) { // 与父表绑定 if (detailRow.RowState != DataRowState.Deleted) { detailRow.FormTravelReimburseID = formTravelReimburseRow.FormTravelReimburseID; totalAmount += detailRow.Cost; } } this.TAFormTravelReimburseDetail.Update(this.FormDataSet.FormTravelReimburseDetail); formTravelReimburseRow.Amount = totalAmount; this.TAFormTravelReimburse.Update(formTravelReimburseRow); // 正式提交或草稿 if (StatusID == SystemEnums.FormStatus.Awaiting) { Dictionary<string, object> dic = new Dictionary<string, object>(); dic["TotalAmount"] = totalAmount; APResult result = new APFlowBLL().CreateProcess(new APParameter(formRow.FormID, formRow.FormNo, formRow.OrganizationUnitID, formRow.UserID, (int)StatusID, formRow.FormTypeID, formRow.PositionID, dic)); if (result != null) { formRow.InTurnPositionIds = result.InTurnPositionIds; formRow.InTurnUserIds = result.InTurnUserIds; formRow.SubmitDate = result.ApprovedDate.GetValueOrDefault(); formRow.StatusID = result.StatusID; formRow.ProcID = result.ProcID; formRow.FinanceRemark = formTravelReimburseRow.Remark; this.TAForm.Update(formRow); } } transaction.Commit(); } catch (Exception ex) { transaction.Rollback(); throw new ApplicationException(ex.Message); } finally { transaction.Dispose(); } }
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(); } }
protected void SaveSalePayment(SystemEnums.FormStatus StatusID) { this.FormSaleBLL.FormDataSet = this.InnerDS; if (FillDetail(StatusID)) { int? RejectedFormID = null; if (this.ViewState["RejectedObjectID"] != null) { RejectedFormID = (int)this.ViewState["RejectedObjectID"]; } int UserID = (int)this.ViewState["StuffUserID"]; int? ProxyStuffUserId = null; if (Session["ProxyStuffUserId"] != null) { ProxyStuffUserId = int.Parse(Session["ProxyStuffUserId"].ToString()); } int OrganizationUnitID = (int)this.ViewState["DepartmentID"]; int PositionID = (int)this.ViewState["PositionID"]; int FormSaleApplyID = int.Parse(this.ViewState["FormSaleApplyID"].ToString()); int InvoiceStatusID = int.Parse(this.InvoiceStatusDDL.SelectedValue); int PaymentTypeID = (int)SystemEnums.PaymentType.Cash; string Remark = this.RemarkCtl.Text; string AttachedFileName = this.UCPaymentFile.AttachmentFileName; string RealAttachedFileName = this.UCPaymentFile.RealAttachmentFileName; int? VendorID = null; if (this.UCVendor.VendorID != string.Empty) { VendorID = int.Parse(this.UCVendor.VendorID); } int? VATTypeID = null; if (this.VATTypeDDL.SelectedValue != "0") { VATTypeID = int.Parse(this.VATTypeDDL.SelectedValue); } if (StatusID == SystemEnums.FormStatus.Awaiting) {//提交时检查,保存草稿不检查 //vendor if (this.UCVendor.VendorID == string.Empty && PaymentTypeID != (int)SystemEnums.PaymentType.Transfer) { PageUtility.ShowModelDlg(this.Page, "请选择供应商!", "please select vendor"); return; } //判断是否录入了发票 MasterData.InvoiceStatusRow row = new InvoiceStatusTableAdapter().GetDataByID(int.Parse(this.InvoiceStatusDDL.SelectedValue))[0]; if (row.NeedInvoice) { if (this.gvInvoice.Rows.Count == 0) { PageUtility.ShowModelDlg(this.Page, "请录入发票信息!", "please key in invoice info"); return; } else { decimal AmountRMB = decimal.Parse(this.ViewState["AmountRMBTotal"].ToString()); if (decimal.Parse(this.ViewState["InvoiceFeeTotal"].ToString()) < AmountRMB) { PageUtility.ShowModelDlg(this.Page, "发票金额不得小于支付金额!", "the amount of invoice should not be less than the payment"); return; } } } //再检查一遍有没有结案过 string SettledFormNo = this.FormSaleBLL.GetSettledFormNoByApplyFormIds(FormSaleApplyID.ToString()); if (SettledFormNo != "") { PageUtility.ShowModelDlg(this.Page, "申请单已经被结案过,结案单编号为:" + SettledFormNo); return; } //检查申请单是否有作废 if (this.FormSaleBLL.GetFormByID(FormSaleApplyID)[0].StatusID != (int)SystemEnums.FormStatus.ApproveCompleted) { PageUtility.ShowModelDlg(this.Page, "申请单已经作废,不能提交,请删除!"); return; } } //PO int FormPOID = 0; int.TryParse(this.UCPO.FormID, out FormPOID); if (StatusID == SystemEnums.FormStatus.Awaiting && (bool)this.ViewState["NeedPO"] == true && decimal.Parse(this.ViewState["AmountRMBTotal"].ToString()) > 5000 && FormPOID <= 0) { PageUtility.ShowModelDlg(this, "请选择PO"); return; } try { if (this.ViewState["ObjectId"] == null || RejectedFormID != null) { this.FormSaleBLL.AddAdvancedPayment(RejectedFormID, UserID, ProxyStuffUserId, null, OrganizationUnitID, PositionID, SystemEnums.FormType.SaleAdvancedPayment, StatusID, SystemEnums.PageType.NoActivityAdvancedPayment, FormSaleApplyID, InvoiceStatusID, PaymentTypeID, Remark, AttachedFileName, RealAttachedFileName, int.Parse(this.ViewState["CostCenterID"].ToString()), VendorID, FormPOID, VATTypeID); } else { int FormID = (int)this.ViewState["ObjectId"]; this.FormSaleBLL.UpdateAdvancedPayment(FormID, SystemEnums.FormType.SaleAdvancedPayment, StatusID, InvoiceStatusID, PaymentTypeID, Remark, AttachedFileName, RealAttachedFileName, VendorID, FormPOID, VATTypeID); } this.Page.Response.Redirect("~/Home.aspx"); } catch (Exception ex) { PageUtility.DealWithException(this.Page, ex); } } }
protected void SaveFormBudgetAllocation(SystemEnums.FormStatus StatusID) { this.BudgetAllocationApplyBLL.FormDataSet = this.InnerDS; int? RejectedFormID = null; if (this.ViewState["RejectedObjectID"] != null) { RejectedFormID = (int)this.ViewState["RejectedObjectID"]; } int UserID = (int)this.ViewState["StuffUserID"]; int? ProxyStuffUserId = null; if (Session["ProxyStuffUserId"] != null) { ProxyStuffUserId = int.Parse(Session["ProxyStuffUserId"].ToString()); } int OrganizationUnitID = (int)this.ViewState["DepartmentID"]; int PositionID = (int)this.ViewState["PositionID"]; string AttachFileName = this.UCFileUpload.AttachmentFileName; string RealAttachFileName = this.UCFileUpload.RealAttachmentFileName; string Remark = this.RemarkCtl.Text; try { if (this.ViewState["ObjectId"] == null || RejectedFormID != null) { this.BudgetAllocationApplyBLL.AddFormBudgetAllocation(RejectedFormID, UserID, ProxyStuffUserId, null, OrganizationUnitID, PositionID, SystemEnums.FormType.BudgetAllocationApply, StatusID, Remark, AttachFileName, RealAttachFileName, this.ViewState["FlowTemplate"].ToString()); } else { int FormID = (int)this.ViewState["ObjectId"]; this.BudgetAllocationApplyBLL.UpdateFormBudgetAllocation(FormID, StatusID, SystemEnums.FormType.BudgetAllocationApply, Remark, AttachFileName, RealAttachFileName,this.ViewState["FlowTemplate"].ToString()); } this.Page.Response.Redirect("~/Home.aspx"); } catch (Exception ex) { PageUtility.DealWithException(this.Page, ex); } }
public void UpdateRDPayment(int FormID, SystemEnums.FormType FormTypeID, SystemEnums.FormStatus StatusID, int InvoiceStatusID, int PaymentTypeID, string PaymentFileName, string PaymentRealFileName, string Remark, int? VATTypeID, int FormPOID) { SqlTransaction transaction = null; try { //事务开始 transaction = TableAdapterHelper.BeginTransaction(this.TAForm); TableAdapterHelper.SetTransaction(this.TAFormRDPayment, transaction); TableAdapterHelper.SetTransaction(this.TAFormRDPaymentDetail, transaction); TableAdapterHelper.SetTransaction(this.TAFormInvoice, transaction); FormDS.FormRow formRow = this.TAForm.GetDataByID(FormID)[0]; FormDS.FormRDPaymentRow formPaymentRow = this.TAFormRDPayment.GetDataByID(FormID)[0]; //处理单据的内容 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); //处理Payment的内容 if (PaymentFileName != null && PaymentFileName != string.Empty) { formPaymentRow.PaymentFileName = PaymentFileName; } if (PaymentRealFileName != null && PaymentRealFileName != string.Empty) { formPaymentRow.PaymentRealFileName = PaymentRealFileName; } if (Remark != null && Remark != string.Empty) { formPaymentRow.Remark = Remark; } formPaymentRow.InvoiceStatusID = InvoiceStatusID; formPaymentRow.PaymentTypeID = PaymentTypeID; if (VATTypeID != null) { formPaymentRow.VATTypeID = VATTypeID.GetValueOrDefault(); } if (FormPOID > 0) { formPaymentRow.FormPOID = FormPOID; } this.TAFormRDPayment.Update(formPaymentRow); //发票 foreach (FormDS.FormInvoiceRow invoiceRow in this.FormDataSet.FormInvoice) { // 与父表绑定 if (invoiceRow.RowState != DataRowState.Deleted) { invoiceRow.FormID = formPaymentRow.FormRDPaymentID; } } this.TAFormInvoice.Update(this.FormDataSet.FormInvoice); //处理明细 decimal totalAmountRMB = 0; decimal totalAmountBeforeTaxtRMB = 0; foreach (FormDS.FormRDPaymentDetailRow detailRow in this.FormDataSet.FormRDPaymentDetail) { if (detailRow.RowState != DataRowState.Deleted) { totalAmountRMB += detailRow.AmountRMB; totalAmountBeforeTaxtRMB += detailRow.IsAmountBeforeTaxNull() ? 0 : detailRow.AmountBeforeTax; detailRow.FormRDPaymentID = formPaymentRow.FormRDPaymentID; } } this.TAFormRDPaymentDetail.Update(this.FormDataSet.FormRDPaymentDetail); formPaymentRow.AmountRMB = totalAmountRMB; formPaymentRow.AmountBeforeTaxRMB = totalAmountBeforeTaxtRMB; this.TAFormRDPayment.Update(formPaymentRow); // 正式提交 if (StatusID == SystemEnums.FormStatus.Awaiting) { Dictionary<string, object> dic = new Dictionary<string, object>(); dic["TotalAmount"] = totalAmountRMB; dic["PaymentTypeID"] = PaymentTypeID; dic["InvoiceStatus"] = formPaymentRow.InvoiceStatusID; APResult result = new APFlowBLL().CreateProcess(new APParameter(formRow.FormID, formRow.FormNo, formRow.OrganizationUnitID, formRow.UserID, (int)StatusID, formRow.FormTypeID, formRow.PositionID, dic)); if (result != null) { formRow.InTurnPositionIds = result.InTurnPositionIds; formRow.InTurnUserIds = result.InTurnUserIds; formRow.SubmitDate = result.ApprovedDate.GetValueOrDefault(); formRow.StatusID = result.StatusID; formRow.ProcID = result.ProcID; formRow.FinanceRemark = formPaymentRow.Remark; this.TAForm.Update(formRow); } } transaction.Commit(); } catch (Exception ex) { transaction.Rollback(); throw new ApplicationException("Save Fail!" + ex.ToString()); } finally { transaction.Dispose(); } }
public void UpdateFormInvitationReimburseApply(int RejectedFormID, int FormID, int FormTypeID, SystemEnums.FormStatus StatusID, DateTime? Period, string Remark, String CustomerName, String AttenderNames, int AttenderCount, String BusinessRelation, String Place, DateTime? OccuredDate, String Purpose, String InvitationType, int CurrencyID, decimal? ExchangeRate, decimal? Amount, decimal? TotalBudget, decimal? ApprovingAmount, decimal? ApprovedAmount, decimal? RemainBudget, int ManageExpenseItemID) { SqlTransaction transaction = null; try { //开始事务 transaction = TableAdapterHelper.BeginTransaction(this.TAForm); TableAdapterHelper.SetTransaction(this.TAFormInvitationApply, transaction); FormDS.FormRow formRow = this.TAForm.GetDataByID(FormID)[0]; FormDS.FormInvitationReimburseRow FormInvitationReimburseRow = this.TAFormInvitationReimburse.GetDataByID(FormID)[0]; //处理表单内容 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); //处理申请表的内容 if (Period != null) { FormInvitationReimburseRow.Period = Period.GetValueOrDefault(); } FormInvitationReimburseRow.CustomerName = CustomerName; FormInvitationReimburseRow.Remark = Remark; FormInvitationReimburseRow.AttenderNames = AttenderNames; FormInvitationReimburseRow.AttenderCount = AttenderCount; FormInvitationReimburseRow.BusinessRelation = BusinessRelation; FormInvitationReimburseRow.Place = Place; if (OccuredDate != null) { FormInvitationReimburseRow.OccuredDate = OccuredDate.GetValueOrDefault(); } FormInvitationReimburseRow.Purpose = Purpose; FormInvitationReimburseRow.InvitationType = InvitationType; FormInvitationReimburseRow.CurrencyID = CurrencyID; FormInvitationReimburseRow.ExchangeRate = ExchangeRate.GetValueOrDefault(); FormInvitationReimburseRow.Amount = Amount.GetValueOrDefault(); FormInvitationReimburseRow.ManageExpenseItemID = ManageExpenseItemID; FormInvitationReimburseRow.TotalBudget = TotalBudget.GetValueOrDefault(); FormInvitationReimburseRow.ApprovingAmount = ApprovingAmount.GetValueOrDefault(); FormInvitationReimburseRow.ApprovedAmount = ApprovedAmount.GetValueOrDefault(); FormInvitationReimburseRow.RemainBudget = RemainBudget.GetValueOrDefault(); this.TAFormInvitationReimburse.Update(FormInvitationReimburseRow); // 正式提交或草稿 if (StatusID == SystemEnums.FormStatus.Awaiting) { Dictionary<string, object> dic = new Dictionary<string, object>(); dic["TotalAmount"] = FormInvitationReimburseRow.AmountRMB; APResult result = new APFlowBLL().CreateProcess(new APParameter(formRow.FormID, formRow.FormNo, formRow.OrganizationUnitID, formRow.UserID, (int)StatusID, formRow.FormTypeID, formRow.PositionID, dic)); if (result != null) { formRow.InTurnPositionIds = result.InTurnPositionIds; formRow.InTurnUserIds = result.InTurnUserIds; formRow.SubmitDate = result.ApprovedDate.GetValueOrDefault(); formRow.StatusID = result.StatusID; formRow.ProcID = result.ProcID; this.TAForm.Update(formRow); } } transaction.Commit(); } catch (Exception ex) { transaction.Rollback(); throw new ApplicationException(ex.Message); } finally { transaction.Dispose(); } }
protected void SaveFormReimburse(SystemEnums.FormStatus StatusID) { this.SalesReimburseBLL.FormDataSet = this.InnerDS; if (FillDetail()) { if (StatusID == SystemEnums.FormStatus.Awaiting) { if (decimal.Parse(this.ViewState["ReimburseFeeTotal"].ToString()) < decimal.Parse(this.ViewState["SKUFeeTotal"].ToString())) { PageUtility.ShowModelDlg(this.Page, "���ò�Ʒ�ܽ��ܴ��ڱ������"); return; } } int? RejectedFormID = null; if (this.ViewState["RejectedObjectID"] != null) { RejectedFormID = (int)this.ViewState["RejectedObjectID"]; } int UserID = (int)this.ViewState["StuffUserID"]; int? ProxyStuffUserId = null; if (Session["ProxyStuffUserId"] != null) { ProxyStuffUserId = int.Parse(Session["ProxyStuffUserId"].ToString()); } int OrganizationUnitID = (int)this.ViewState["DepartmentID"]; int PositionID = (int)this.ViewState["PositionID"]; int CustomerID = int.Parse(this.ViewState["CustomerID"].ToString()); int PaymentTypeID = int.Parse(this.PaymentTypeDDL.SelectedValue); string AttachedFileName = this.UCFileUpload.AttachmentFileName; string RealAttachedFileName = this.UCFileUpload.RealAttachmentFileName; string Remark = this.RemarkCtl.Text; try { if (this.ViewState["ObjectId"] == null || RejectedFormID != null) { this.SalesReimburseBLL.AddFormReimburseGoods(RejectedFormID, UserID, ProxyStuffUserId, null, OrganizationUnitID, PositionID, SystemEnums.FormType.ReimburseApply, StatusID, CustomerID, PaymentTypeID, AttachedFileName, RealAttachedFileName, Remark, this.ViewState["FormApplyIds"].ToString(), this.ViewState["FormApplyNos"].ToString(), this.ViewState["FlowTemplate"].ToString()); } else { int FormID = (int)this.ViewState["ObjectId"]; this.SalesReimburseBLL.UpdateFormReimburseGoods(FormID, StatusID, SystemEnums.FormType.ReimburseApply, AttachedFileName, RealAttachedFileName, Remark, this.ViewState["FlowTemplate"].ToString()); } this.Page.Response.Redirect("~/Home.aspx"); } catch (Exception ex) { PageUtility.DealWithException(this.Page, ex); } } }
protected void SaveFormApply(SystemEnums.FormStatus StatusID) { decimal? CustomerBudget = null; decimal? CustomerBudgetRemain = null; decimal? OUBudget = null; decimal? OUAppovedAmount = null; decimal? OUApprovingAmount = null; decimal? OUCompletedAmount = null; decimal? OUReimbursedAmount = null; decimal? OUBudgetRemain = null; decimal? OUBudgetRate = null; if (StatusID == SystemEnums.FormStatus.Awaiting) {//�ύʱ��飬����ݸ岻��� 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())); if (calculateAssistant[12] < decimal.Parse(this.ViewState["ManualApplyFeeTotal"].ToString())) { PageUtility.ShowModelDlg(this.Page, "���������������Ԥ�㣬�����ύ"); return; } else { CustomerBudget = calculateAssistant[0]; CustomerBudgetRemain = calculateAssistant[5]; OUBudget = calculateAssistant[7]; OUAppovedAmount = calculateAssistant[8]; OUApprovingAmount = calculateAssistant[9]; OUCompletedAmount = calculateAssistant[10]; OUReimbursedAmount = calculateAssistant[11]; OUBudgetRemain = calculateAssistant[12]; OUBudgetRate = calculateAssistant[13]; } } this.SalesApplyBLL.FormDataSet = this.InnerDS; int? RejectedFormID = null; if (this.ViewState["RejectedObjectID"] != null) { RejectedFormID = (int)this.ViewState["RejectedObjectID"]; } int UserID = (int)this.ViewState["StuffUserID"]; int? ProxyStuffUserId = null; if (Session["ProxyStuffUserId"] != null) { ProxyStuffUserId = int.Parse(Session["ProxyStuffUserId"].ToString()); } int OrganizationUnitID = (int)this.ViewState["DepartmentID"]; int PositionID = (int)this.ViewState["PositionID"]; DateTime BeginPeriod = DateTime.Parse(this.ViewState["BeginPeriod"].ToString()); DateTime EndPeriod = DateTime.Parse(this.ViewState["EndPeriod"].ToString()); int CustomerID = int.Parse(this.ViewState["CustomerID"].ToString()); int ShopID = int.Parse(this.ShopDDL.SelectedValue); int PaymentTypeID = int.Parse(this.PaymentTypeDDL.SelectedValue); int ExpenseSubCategoryID = int.Parse(this.ViewState["ExpenseSubCategoryID"].ToString()); string ContractNo = this.ContractNoCtl.Text; string AttachedFileName = this.UCFileUpload.AttachmentFileName; string RealAttachedFileName = this.UCFileUpload.RealAttachmentFileName; string Remark = this.RemarkCtl.Text; string FormApplyName = this.txtFormApplyName.Text; if (this.SalesApplyBLL.GetRebateApplyCountByParameter(CustomerID, BeginPeriod.Year, BeginPeriod.Month, ExpenseSubCategoryID) > 0) { PageUtility.ShowModelDlg(this, "ϵͳ���Ѿ����ڸÿͻ��ķ������룬��������ÿ��ֻ������һ�Σ�"); return; } try { if (this.ViewState["ObjectId"] == null || RejectedFormID != null) { this.SalesApplyBLL.AddFormApplyRebate(RejectedFormID, UserID, ProxyStuffUserId, null, OrganizationUnitID, PositionID, SystemEnums.FormType.SalesApply, StatusID, BeginPeriod, EndPeriod, CustomerID, ShopID, PaymentTypeID, ExpenseSubCategoryID, ContractNo, CustomerBudget, CustomerBudgetRemain, OUBudget, OUAppovedAmount, OUApprovingAmount, OUCompletedAmount, OUReimbursedAmount, OUBudgetRemain, OUBudgetRate, AttachedFileName, RealAttachedFileName, Remark, this.ViewState["FlowTemplate"].ToString(), FormApplyName); } else { int FormID = (int)this.ViewState["ObjectId"]; this.SalesApplyBLL.UpdateFormApplyRebate(FormID, StatusID, SystemEnums.FormType.SalesApply, ShopID, PaymentTypeID, ContractNo, CustomerBudget, CustomerBudgetRemain, OUBudget, OUAppovedAmount, OUApprovingAmount,OUCompletedAmount, OUReimbursedAmount, OUBudgetRemain, OUBudgetRate, AttachedFileName, RealAttachedFileName, Remark, this.ViewState["FlowTemplate"].ToString(), FormApplyName); } this.Page.Response.Redirect("~/SalesForm/SalesApplySelect.aspx"); } catch (Exception ex) { PageUtility.DealWithException(this.Page, ex); } }
public void UpdatePVSpecialApply(int FormID, SystemEnums.FormStatus StatusID, decimal ExchangeRate, int PurchaseTypeID, string Remark, string AttachedFileName, string RealAttachedFileName, int MethodPaymentID, DateTime? ExpectPaymentDate, decimal TotalBudget, decimal ApprovedAmount, decimal ApprovingAmount, decimal ReimbursedAmount, decimal NonReimbursedAmount, decimal RemainBudget, bool IsUrgent, bool IsPublic, int InvoiceStatusID, int? VATRateID, decimal AMTTax, string PaymentTerms, bool IsPTChanged) { SqlTransaction transaction = null; try { //事务开始 transaction = TableAdapterHelper.BeginTransaction(this.TAForm); TableAdapterHelper.SetTransaction(this.TAFormPV, transaction); TableAdapterHelper.SetTransaction(this.TAFormInvoice, transaction); TableAdapterHelper.SetTransaction(this.TAFormPVDetail, transaction); PurchaseDS.FormRow formRow = this.TAForm.GetDataByID(FormID)[0]; PurchaseDS.FormPVRow formPVRow = this.TAFormPV.GetDataByID(FormID)[0]; //处理单据的内容 UtilityBLL utility = new UtilityBLL(); if (StatusID == SystemEnums.FormStatus.Awaiting) { string formTypeString = utility.GetFormTypeString(formRow.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); //处理申请表的内容 formPVRow.ExchangeRate = ExchangeRate; formPVRow.PurchaseTypeID = PurchaseTypeID; if (Remark != null) { formPVRow.Remark = Remark; } if (AttachedFileName != null && AttachedFileName != string.Empty) { formPVRow.AttachedFileName = AttachedFileName; } else { formPVRow.SetAttachedFileNameNull(); } if (RealAttachedFileName != null && RealAttachedFileName != string.Empty) { formPVRow.RealAttachedFileName = RealAttachedFileName; } else { formPVRow.SetRealAttachedFileNameNull(); } formPVRow.MethodPaymentID = MethodPaymentID; if (ExpectPaymentDate != null) { formPVRow.ExpectPaymentDate = ExpectPaymentDate.GetValueOrDefault(); } formPVRow.TotalBudget = TotalBudget; formPVRow.ApprovedAmount = ApprovedAmount; formPVRow.ApprovingAmount = ApprovingAmount; formPVRow.ReimbursedAmount = ReimbursedAmount; formPVRow.NonReimbursedAmount = NonReimbursedAmount; formPVRow.RemainBudget = RemainBudget; formPVRow.IsUrgent = IsUrgent; formPVRow.IsPublic = IsPublic; formPVRow.InvoiceStatusID = InvoiceStatusID; formPVRow.IsUrgent = IsUrgent; formPVRow.IsPublic = IsPublic; formPVRow.InvoiceStatusID = InvoiceStatusID; formPVRow.AMTTax = AMTTax; if (VATRateID != null) { formPVRow.VatRateID = VATRateID.GetValueOrDefault(); } formPVRow.PaymentTerms = PaymentTerms; formPVRow.IsPTChanged = IsPTChanged; this.TAFormPV.Update(formPVRow); //发票 foreach (PurchaseDS.FormInvoiceRow invoiceRow in this.PurchaseDataSet.FormInvoice) { // 与父表绑定 if (invoiceRow.RowState != DataRowState.Deleted) { invoiceRow.FormID = formRow.FormID; } } this.TAFormInvoice.Update(this.PurchaseDataSet.FormInvoice); //处理明细 decimal totalAmount = 0; decimal totalAmountRMB = 0; foreach (PurchaseDS.FormPVDetailRow detailRow in this.PurchaseDataSet.FormPVDetail) { if (detailRow.RowState != DataRowState.Deleted) { detailRow.FormPVID = formRow.FormID; detailRow.AmountRMB = decimal.Round(detailRow.Amount * ExchangeRate, 2); totalAmountRMB = totalAmountRMB + detailRow.AmountRMB; totalAmount = totalAmount + detailRow.Amount; } } this.TAFormPVDetail.Update(this.PurchaseDataSet.FormPVDetail); formPVRow.AmountRMB = totalAmountRMB; formPVRow.Amount = totalAmount; formPVRow.AMTBeforeTax = totalAmount - AMTTax; this.TAFormPV.Update(formPVRow); // 正式提交 if (StatusID == SystemEnums.FormStatus.Awaiting) { Dictionary<string, object> dic = new Dictionary<string, object>(); dic["TotalAmount"] = totalAmountRMB; dic["InvoiceStatus"] = formPVRow.InvoiceStatusID; dic["IsUrgent"] = formPVRow.IsUrgent; APResult result = new APFlowBLL().CreateProcess(new APParameter(formRow.FormID, formRow.FormNo, formRow.OrganizationUnitID, formRow.UserID, (int)StatusID, formRow.FormTypeID, formRow.PositionID, dic)); if (result != null) { formRow.InTurnPositionIds = result.InTurnPositionIds; formRow.InTurnUserIds = result.InTurnUserIds; formRow.SubmitDate = result.ApprovedDate.GetValueOrDefault(); formRow.StatusID = result.StatusID; formRow.ProcID = result.ProcID; formRow.FinanceRemark = formPVRow.Remark; this.TAForm.Update(formRow); } } transaction.Commit(); } catch (ApplicationException ex) { transaction.Rollback(); throw ex; } catch (Exception ex) { transaction.Rollback(); throw new ApplicationException("Save Fail!" + ex.ToString()); } finally { transaction.Dispose(); } }
protected void SaveRDPayment(SystemEnums.FormStatus StatusID) { this.FormRDBLL.FormDataSet = this.InnerDS; if (FillDetail(StatusID)) { int? RejectedFormID = null; if (this.ViewState["RejectedObjectID"] != null) { RejectedFormID = (int)this.ViewState["RejectedObjectID"]; } int UserID = (int)this.ViewState["StuffUserID"]; int? ProxyStuffUserId = null; if (Session["ProxyStuffUserId"] != null) { ProxyStuffUserId = int.Parse(Session["ProxyStuffUserId"].ToString()); } int OrganizationUnitID = (int)this.ViewState["DepartmentID"]; int PositionID = (int)this.ViewState["PositionID"]; int FormRDApplyID = int.Parse(this.ViewState["FormRDApplyID"].ToString()); FormDS.FormRow formRow = FormRDBLL.GetFormByID(FormRDApplyID)[0]; if (formRow.StatusID != 2) { PageUtility.ShowModelDlg(this, "不能提交,对应的方案申请单不是审批完成状态!"); return; } int InvoiceStatusID = int.Parse(this.InvoiceStatusDDL.SelectedValue); int PaymentTypeID = int.Parse(this.PaymentTypeDDL.SelectedValue); string Remark = this.RemarkCtl.Text; int? VATTypeID = null; if (this.VATTypeDDL.SelectedValue != "0") { VATTypeID = int.Parse(this.VATTypeDDL.SelectedValue); } //判断是否录入了发票 if (StatusID == SystemEnums.FormStatus.Awaiting) {//提交时检查,保存草稿不检查 MasterData.InvoiceStatusRow row = new InvoiceStatusTableAdapter().GetDataByID(int.Parse(this.InvoiceStatusDDL.SelectedValue))[0]; if (row.NeedInvoice) { if (this.gvInvoice.Rows.Count == 0) { PageUtility.ShowModelDlg(this.Page, "请录入发票信息!", "please key in invoice info"); return; } else { decimal AmountRMB = decimal.Parse(this.ViewState["AmountRMBTotal"].ToString()); if (decimal.Parse(this.ViewState["InvoiceFeeTotal"].ToString()) < AmountRMB) { PageUtility.ShowModelDlg(this.Page, "发票金额不得小于支付金额!", "the amount of invoice should not be less than the payment"); return; } } } } //PO int FormPOID = 0; int.TryParse(this.UCPO.FormID, out FormPOID); if (StatusID == SystemEnums.FormStatus.Awaiting && (bool)this.ViewState["NeedPO"] == true && decimal.Parse(this.ViewState["AmountRMBTotal"].ToString()) > 5000 && FormPOID <= 0) { PageUtility.ShowModelDlg(this, "请选择PO"); return; } try { if (this.ViewState["ObjectId"] == null || RejectedFormID != null) { this.FormRDBLL.AddRDPayment(RejectedFormID, UserID, ProxyStuffUserId, null, OrganizationUnitID, PositionID, SystemEnums.FormType.RDPayment, StatusID, SystemEnums.PageType.RDPayment, FormRDApplyID, InvoiceStatusID, PaymentTypeID, this.UCFliePayment.AttachmentFileName, this.UCFliePayment.RealAttachmentFileName, Remark, int.Parse(this.ViewState["CostCenterID"].ToString()), VATTypeID, FormPOID); } else { int FormID = (int)this.ViewState["ObjectId"]; this.FormRDBLL.UpdateRDPayment(FormID, SystemEnums.FormType.RDPayment, StatusID, InvoiceStatusID, PaymentTypeID, this.UCFliePayment.AttachmentFileName, this.UCFliePayment.RealAttachmentFileName, Remark, VATTypeID, FormPOID); } this.Page.Response.Redirect("~/Home.aspx"); } catch (Exception ex) { PageUtility.DealWithException(this.Page, ex); } } }
public void AddPVApply(int? RejectedFormID, int UserID, int? ProxyUserID, int? ProxyPositionID, int OrganizationUnitID, int PositionID, SystemEnums.FormType FormTypeID, SystemEnums.FormStatus StatusID, int? FormPRID, int? FormPOID, string ParentFormNo, DateTime FPeriod, int VendorID, int ItemCategoryID, int CurrencyID, decimal ExchangeRate, int PurchaseBudgetTypeID, int PurchaseTypeID, int? CompanyID, int ShippingTermID, string PaymentTerms, string Remark, string AttachedFileName, string RealAttachedFileName, int MethodPaymentID, DateTime? ExpectPaymentDate, decimal ApplyAmount, decimal PayedAmount, decimal AMTBeforeTax, decimal AMTTax, bool IsUrgent, bool IsPublic, int InvoiceStatusID, int PVType, int? VATRateID, string ItemCategoryName, string RealDeliveryAddress) { SqlTransaction transaction = null; try { //事务开始 transaction = TableAdapterHelper.BeginTransaction(this.TAForm); TableAdapterHelper.SetTransaction(this.TAFormPV, transaction); TableAdapterHelper.SetTransaction(this.TAFormInvoice, transaction); //处理单据的内容 PurchaseDS.FormRow formRow = this.PurchaseDataSet.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.NormalPV; formRow.CostCenterID = new StuffUserBLL().GetCostCenterIDByPositionID(PositionID); formRow.IsCreateVoucher = false; formRow.IsExportLock = false; formRow.IsCompletePayment = false; this.PurchaseDataSet.Form.AddFormRow(formRow); this.TAForm.Update(formRow); //处理申请表的内容 PurchaseDS.FormPVRow formPVRow = this.PurchaseDataSet.FormPV.NewFormPVRow(); formPVRow.FormPVID = formRow.FormID; if (FormPRID != null) { formPVRow.FormPRID = FormPRID.GetValueOrDefault(); } if (FormPOID != null) { formPVRow.FormPOID = FormPOID.GetValueOrDefault(); } formPVRow.ParentFormNo = ParentFormNo; formPVRow.FPeriod = FPeriod; formPVRow.VendorID = VendorID; formPVRow.ItemCategoryID = ItemCategoryID; formPVRow.CurrencyID = CurrencyID; formPVRow.ExchangeRate = ExchangeRate; formPVRow.PurchaseBudgetTypeID = PurchaseBudgetTypeID; formPVRow.PurchaseTypeID = PurchaseTypeID; if (CompanyID != null) { formPVRow.CompanyID = CompanyID.GetValueOrDefault(); formPVRow.DeliveryAddress = new MasterDataBLL().GetCompanyById(CompanyID.GetValueOrDefault()).CompanyAddress; } formPVRow.ShippingTermID = ShippingTermID; formPVRow.PaymentTerms = PaymentTerms; formPVRow.Remark = Remark; if (AttachedFileName != null && AttachedFileName != string.Empty) { formPVRow.AttachedFileName = AttachedFileName; } if (RealAttachedFileName != null && RealAttachedFileName != string.Empty) { formPVRow.RealAttachedFileName = RealAttachedFileName; } formPVRow.MethodPaymentID = MethodPaymentID; if (ExpectPaymentDate != null) { formPVRow.ExpectPaymentDate = ExpectPaymentDate.GetValueOrDefault(); } formPVRow.ApplyAmount = ApplyAmount; formPVRow.PayedAmount = PayedAmount; formPVRow.AMTBeforeTax = AMTBeforeTax; formPVRow.AMTTax = AMTTax; formPVRow.Amount = AMTBeforeTax + AMTTax; formPVRow.AmountRMB = decimal.Round(formPVRow.Amount * ExchangeRate, 2); formPVRow.IsUrgent = IsUrgent; formPVRow.IsPublic = IsPublic; formPVRow.InvoiceStatusID = InvoiceStatusID; formPVRow.PVType = PVType; if (VATRateID != null) { formPVRow.VatRateID = VATRateID.GetValueOrDefault(); } formPVRow.RealDeliveryAddress = RealDeliveryAddress; formPVRow.FinalItemCategoryID = ItemCategoryID; //payment term是否改变,只要在此判断即可,是从PO或者PR带入的 string defaultPT = new MasterDataBLL().GetPaymentTermById(new VendorTableAdapter().GetDataByID(VendorID)[0].PaymentTermID)[0].PaymentTermName; if (defaultPT != PaymentTerms) { formPVRow.IsPTChanged = true; } else { formPVRow.IsPTChanged = false; } this.PurchaseDataSet.FormPV.AddFormPVRow(formPVRow); this.TAFormPV.Update(formPVRow); //发票 if (RejectedFormID != null) { PurchaseDS.FormInvoiceDataTable newInvoiceTable = new PurchaseDS.FormInvoiceDataTable(); foreach (PurchaseDS.FormInvoiceRow invoiceRow in this.PurchaseDataSet.FormInvoice) { if (invoiceRow.RowState != DataRowState.Deleted) { PurchaseDS.FormInvoiceRow newInvoiceRow = newInvoiceTable.NewFormInvoiceRow(); newInvoiceRow.FormID = formRow.FormID; newInvoiceRow.InvoiceNo = invoiceRow.InvoiceNo; newInvoiceRow.InvoiceDate = invoiceRow.InvoiceDate; newInvoiceRow.InvoiceAmount = invoiceRow.InvoiceAmount; newInvoiceRow.Remark = invoiceRow.IsRemarkNull() ? "" : invoiceRow.Remark; newInvoiceRow.SystemInfo = invoiceRow.IsSystemInfoNull() ? "" : invoiceRow.SystemInfo; newInvoiceTable.AddFormInvoiceRow(newInvoiceRow); } this.TAFormInvoice.Update(newInvoiceTable); } } else { foreach (PurchaseDS.FormInvoiceRow invoiceRow in this.PurchaseDataSet.FormInvoice) { // 与父表绑定 if (invoiceRow.RowState != DataRowState.Deleted) { invoiceRow.FormID = formRow.FormID; } } } this.TAFormInvoice.Update(this.PurchaseDataSet.FormInvoice); //作废之前的单据 if (RejectedFormID != null) { PurchaseDS.FormRow oldRow = this.TAForm.GetDataByID(RejectedFormID.GetValueOrDefault())[0]; if (oldRow.StatusID == (int)SystemEnums.FormStatus.Rejected) { oldRow.StatusID = (int)SystemEnums.FormStatus.Scrap; this.TAForm.Update(oldRow); } } // 正式提交 if (StatusID == SystemEnums.FormStatus.Awaiting) { Dictionary<string, object> dic = new Dictionary<string, object>(); dic["TTLCost"] = formPVRow.AmountRMB; dic["ItemCategory"] = ItemCategoryName; dic["InvoiceStatus"] = formPVRow.InvoiceStatusID; dic["IsUrgent"] = formPVRow.IsUrgent; APResult result = new APFlowBLL().CreateProcess(new APParameter(formRow.FormID, formRow.FormNo, formRow.OrganizationUnitID, formRow.UserID, (int)StatusID, formRow.FormTypeID, formRow.PositionID, dic)); if (result != null) { formRow.InTurnPositionIds = result.InTurnPositionIds; formRow.InTurnUserIds = result.InTurnUserIds; formRow.SubmitDate = result.ApprovedDate.GetValueOrDefault(); formRow.StatusID = result.StatusID; formRow.ProcID = result.ProcID; formRow.FinanceRemark = formPVRow.Remark; this.TAForm.Update(formRow); } } transaction.Commit(); } catch (ApplicationException ex) { transaction.Rollback(); throw ex; } catch (Exception ex) { transaction.Rollback(); throw new ApplicationException("Save Fail!" + ex.ToString()); } finally { transaction.Dispose(); } }
private bool FillDetail(SystemEnums.FormStatus StatusID) { bool isValid = true; this.ViewState["AmountRMBTotal"] = 0; //先填充产品明细 foreach (GridViewRow row in this.gvPaymentDetails.Rows) { if (row.RowType == DataControlRowType.DataRow) { FormDS.FormRDPaymentDetailRow detailRow = this.InnerDS.FormRDPaymentDetail[row.RowIndex]; TextBox txtAmountBeforeTax = (TextBox)row.FindControl("txtAmountBeforeTax"); if (string.IsNullOrEmpty(txtAmountBeforeTax.Text.Trim())) { detailRow.AmountBeforeTax = 0; } else { decimal AmountBeforeTax = decimal.Parse(txtAmountBeforeTax.Text.Trim()); AmountBeforeTax = decimal.Round(AmountBeforeTax, 2); detailRow.AmountBeforeTax = AmountBeforeTax; } decimal TaxAmount = 0; decimal.TryParse(((TextBox)row.FindControl("txtTaxAmount")).Text, out TaxAmount); if (StatusID == SystemEnums.FormStatus.Awaiting && detailRow.AmountBeforeTax > 0) { //是否有税率 if (new MasterDataBLL().GetVatTypeById(int.Parse(this.VATTypeDDL.SelectedValue))[0].HasTax) { if (TaxAmount <= 0) { PageUtility.ShowModelDlg(this, "税率类型不为VAT0,必须填写税金!"); return false; } } else { if (TaxAmount > 0) { PageUtility.ShowModelDlg(this, "税率类型为VAT0,不能填写税金!"); return false; } } } detailRow.TaxAmount = TaxAmount; TaxAmount = decimal.Round(TaxAmount, 2); UserControls_VendorControl ucVendor = (UserControls_VendorControl)row.FindControl("UCVendor"); if (!string.IsNullOrEmpty(ucVendor.VendorID)) { detailRow.VendorID = int.Parse(ucVendor.VendorID); } decimal AmountRMB = detailRow.AmountBeforeTax + TaxAmount; //提交时再取一遍,防止漏洞 detailRow.PaiedAmount = this.FormRDBLL.GetPaidAmountByFormRDDetailID(detailRow.FormRDApplyDetailID); detailRow.RemainAmount = detailRow.ApplyAmountRMB - detailRow.PaiedAmount; if (AmountRMB > detailRow.RemainAmount) { PageUtility.ShowModelDlg(this.Page, "报销金额不能大于可用金额"); isValid = false; break; } detailRow.AmountRMB = AmountRMB; this.ViewState["AmountRMBTotal"] = decimal.Parse(this.ViewState["AmountRMBTotal"].ToString()) + AmountRMB; } } if (isValid && StatusID == SystemEnums.FormStatus.Awaiting && decimal.Parse(this.ViewState["AmountRMBTotal"].ToString()) <= 0) { PageUtility.ShowModelDlg(this.Page, "报销金额必须大于零!"); isValid = false; } return isValid; }
public void AddFormReimburseMoney(int? RejectedFormID, int UserID, int? ProxyUserID, int? ProxyPositionID, int OrganizationUnitID, int PositionID, SystemEnums.FormType FormTypeID, SystemEnums.FormStatus StatusID, int CustomerID, int PaymentTypeID, string AttachedFileName, string RealAttachedFileName, string Remark, string FormApplyIds, string FormApplyNos, string FlowTemplate) { SqlTransaction transaction = null; try { transaction = TableAdapterHelper.BeginTransaction(this.TAForm); TableAdapterHelper.SetTransaction(this.TAFormReimburse, transaction); TableAdapterHelper.SetTransaction(this.TAFormReimburseDetail, transaction); TableAdapterHelper.SetTransaction(this.TAFormReimburseInvoice, transaction); TableAdapterHelper.SetTransaction(this.TAPKRecord, 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.ReimburseMoneyApply; this.FormDataSet.Form.AddFormRow(formRow); this.TAForm.Update(formRow); //处理PKRecord,如果提交才需要锁定 if (PaymentTypeID == (int)SystemEnums.PaymentType.PiaoKou && StatusID == SystemEnums.FormStatus.Awaiting) { TAPKRecord.LockPKRecord(formRow.FormID, FormApplyNos); } //处理申请表的内容 FormDS.FormReimburseRow FormReimburseRow = this.FormDataSet.FormReimburse.NewFormReimburseRow(); FormReimburseRow.FormReimburseID = formRow.FormID; FormReimburseRow.CustomerID = CustomerID; FormReimburseRow.PaymentTypeID = PaymentTypeID; FormReimburseRow.Amount = 0;//默认值 if (AttachedFileName != null && AttachedFileName != string.Empty) { FormReimburseRow.AttachedFileName = AttachedFileName; } if (RealAttachedFileName != null && RealAttachedFileName != string.Empty) { FormReimburseRow.RealAttachedFileName = RealAttachedFileName; } if (Remark != null && Remark != string.Empty) { FormReimburseRow.Remark = Remark; } FormReimburseRow.FormApplyIds = FormApplyIds; FormReimburseRow.FormApplyNos = FormApplyNos; FormReimburseRow.IsDeliveryComplete = false; this.FormDataSet.FormReimburse.AddFormReimburseRow(FormReimburseRow); this.TAFormReimburse.Update(FormReimburseRow); //发票 if (RejectedFormID != null) { FormDS.FormReimburseInvoiceDataTable newInvoiceTable = new FormDS.FormReimburseInvoiceDataTable(); foreach (FormDS.FormReimburseInvoiceRow invoiceRow in this.FormDataSet.FormReimburseInvoice) { if (invoiceRow.RowState != DataRowState.Deleted) { FormDS.FormReimburseInvoiceRow newInvoiceRow = newInvoiceTable.NewFormReimburseInvoiceRow(); newInvoiceRow.FormReimburseID = FormReimburseRow.FormReimburseID; newInvoiceRow.InvoiceNo = invoiceRow.InvoiceNo; newInvoiceRow.InvoiceAmount = invoiceRow.InvoiceAmount; newInvoiceRow.Remark = invoiceRow.IsRemarkNull() ? "" : invoiceRow.Remark; newInvoiceRow.SystemInfo = invoiceRow.IsSystemInfoNull() ? "" : invoiceRow.SystemInfo; newInvoiceTable.AddFormReimburseInvoiceRow(newInvoiceRow); } this.TAFormReimburseInvoice.Update(newInvoiceTable); } } else { foreach (FormDS.FormReimburseInvoiceRow invoiceRow in this.FormDataSet.FormReimburseInvoice) { // 与父表绑定 if (invoiceRow.RowState != DataRowState.Deleted) { invoiceRow.FormReimburseID = FormReimburseRow.FormReimburseID; } } } this.TAFormReimburseInvoice.Update(this.FormDataSet.FormReimburseInvoice); //明细表 decimal totalAmount = 0;//计算总申请金额 decimal totalTaxAmount = 0;//总税金 FormDS.FormReimburseDetailDataTable newDetailTable = new FormDS.FormReimburseDetailDataTable(); foreach (FormDS.FormReimburseDetailRow detailRow in this.FormDataSet.FormReimburseDetail) { // 与父表绑定 if (detailRow.RowState != DataRowState.Deleted) { totalAmount += detailRow.Amount; totalTaxAmount += detailRow.IsTaxAmountNull() ? 0 : detailRow.TaxAmount; FormDS.FormReimburseDetailRow newDetailRow = newDetailTable.NewFormReimburseDetailRow(); newDetailRow.FormReimburseID = FormReimburseRow.FormReimburseID; newDetailRow.FormApplyExpenseDetailID = detailRow.FormApplyExpenseDetailID; newDetailRow.ApplyFormNo = detailRow.ApplyFormNo; newDetailRow.ApplyPeriod = detailRow.ApplyPeriod; newDetailRow.ShopID = detailRow.ShopID; newDetailRow.SKUID = detailRow.SKUID; newDetailRow.ExpenseItemID = detailRow.ExpenseItemID; newDetailRow.ApplyAmount = detailRow.ApplyAmount; newDetailRow.RemainAmount = detailRow.RemainAmount; newDetailRow.Amount = detailRow.Amount; newDetailRow.TaxAmount = detailRow.IsTaxAmountNull() ? 0 : detailRow.TaxAmount; newDetailRow.PrePaidAmount = detailRow.IsPrePaidAmountNull() ? 0 : detailRow.PrePaidAmount; newDetailRow.ApplyPaymentTypeID = detailRow.ApplyPaymentTypeID; newDetailRow.FormApplyID = detailRow.FormApplyID; newDetailRow.AccruedAmount = detailRow.IsAccruedAmountNull() ? 0 : detailRow.AccruedAmount; newDetailTable.AddFormReimburseDetailRow(newDetailRow); } } this.TAFormReimburseDetail.Update(newDetailTable); FormReimburseRow.Amount = totalAmount; FormReimburseRow.TaxAmount = totalTaxAmount; this.TAFormReimburse.Update(FormReimburseRow); //作废之前的单据 if (RejectedFormID != null) { FormDS.FormRow oldRow = this.TAForm.GetDataByID(RejectedFormID.GetValueOrDefault())[0]; if (oldRow.StatusID == (int)SystemEnums.FormStatus.Rejected) { oldRow.StatusID = (int)SystemEnums.FormStatus.Scrap; this.TAForm.Update(oldRow); } } // 正式提交或草稿 if (StatusID == SystemEnums.FormStatus.Awaiting) { Dictionary<string, object> dic = new Dictionary<string, object>(); dic["Apply_Amount"] = totalAmount + totalTaxAmount; //dic["Dept"] = new AuthorizationDSTableAdapters.OrganizationUnitTableAdapter().GetOrganizationUnitCodeByOrganizationUnitID(formRow.OrganizationUnitID)[0].OrganizationUnitCode; dic["Expense_Category"] = getExpenseCategoryIDByFormID(int.Parse(FormApplyIds.Split(',')[0])).ToString();//此处待改动 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("Save Fail!" + ex.ToString()); } finally { transaction.Dispose(); } }
protected void SaveFormMaterial(SystemEnums.FormStatus StatusID) { this.MaterialApplyBLL.FormDataSet = this.InnerDS; int? RejectedFormID = null; if (this.ViewState["RejectedObjectID"] != null) { RejectedFormID = (int)this.ViewState["RejectedObjectID"]; } int UserID = (int)this.ViewState["StuffUserID"]; int? ProxyStuffUserId = null; if (Session["ProxyStuffUserId"] != null) { ProxyStuffUserId = int.Parse(Session["ProxyStuffUserId"].ToString()); } int OrganizationUnitID = (int)this.ViewState["DepartmentID"]; int PositionID = (int)this.ViewState["PositionID"]; int ShopID = int.Parse(this.UCShop.ShopID); int FirstVolume = int.Parse(this.FirstVolumeCtl.Text); int SecondVolume = int.Parse(this.SecondVolumeCtl.Text); int ThirdVolume = int.Parse(this.ThirdVolumeCtl.Text); string Remark = this.RemarkCtl.Text; try { if (this.ViewState["ObjectId"] == null || RejectedFormID != null) { this.MaterialApplyBLL.AddFormMaterial(RejectedFormID, UserID, ProxyStuffUserId, null, OrganizationUnitID, PositionID, SystemEnums.FormType.MaterialApply, StatusID, ShopID, FirstVolume, SecondVolume, ThirdVolume, Remark, ViewState["FlowTemplate"].ToString()); } else { int FormID = (int)this.ViewState["ObjectId"]; this.MaterialApplyBLL.UpdateFormMaterial(FormID, StatusID, SystemEnums.FormType.MaterialApply, ShopID, FirstVolume, SecondVolume, ThirdVolume, Remark, ViewState["FlowTemplate"].ToString()); } this.Page.Response.Redirect("~/Home.aspx"); } catch (Exception ex) { PageUtility.DealWithException(this.Page, ex); } }
protected void SaveFormContractl(SystemEnums.FormStatus StatusID) { int? RejectedFormID = null; if (this.ViewState["RejectedObjectID"] != null) { RejectedFormID = (int)this.ViewState["RejectedObjectID"]; } int UserID = (int)this.ViewState["StuffUserID"]; int? ProxyStuffUserId = null; if (Session["ProxyStuffUserId"] != null) { ProxyStuffUserId = int.Parse(Session["ProxyStuffUserId"].ToString()); } int OrganizationUnitID = (int)this.ViewState["DepartmentID"]; int PositionID = (int)this.ViewState["PositionID"]; string startPeriod = ((TextBox)(this.UCPeriodBegin.FindControl("txtDate"))).Text.Trim(); string endPeriod = ((TextBox)(this.UCPeriodEnd.FindControl("txtDate"))).Text.Trim(); string ContractName = this.txtContractName.Text; int ContractTypeID = int.Parse(this.dplContractType.SelectedValue.ToString()); decimal ContractAmount = decimal.Parse(this.txtContractAmount.Text.ToString()); int PageNumber = int.Parse(this.txtPageNumber.Text.ToString()); string FirstCompany = this.txtFirstCompany.Text; string SecondCompany = this.txtSecondCompany.Text; string ThirdCompany = this.txtThirdCompany.Text; DateTime BeginDate = DateTime.Parse(startPeriod); DateTime EndDate = DateTime.Parse(endPeriod); string PaymentType = this.txtPaymentType.Text; string MainContent = this.txtMainContent.Text; string ChangePart = this.txtChangePart.Text; string AttachedFileName = this.UCFileUpload.AttachmentFileName; string RealAttachedFileName = this.UCFileUpload.RealAttachmentFileName; try { if (this.ViewState["ObjectId"] == null || RejectedFormID != null) { this.ContractApplyBLL.AddFormContract(RejectedFormID, UserID, ProxyStuffUserId, null, OrganizationUnitID, PositionID, SystemEnums.FormType.ContractApply, StatusID, ContractName, ContractTypeID, ContractAmount, PageNumber, FirstCompany, SecondCompany, ThirdCompany, BeginDate, EndDate, PaymentType, MainContent, ChangePart, AttachedFileName, RealAttachedFileName, this.ViewState["FlowTemplate"].ToString()); } else { int FormID = (int)this.ViewState["ObjectId"]; this.ContractApplyBLL.UpdateFormContract(FormID, StatusID, SystemEnums.FormType.ContractApply, ContractName, ContractTypeID, ContractAmount, PageNumber, FirstCompany, SecondCompany, ThirdCompany, BeginDate, EndDate, PaymentType, MainContent, ChangePart, AttachedFileName, RealAttachedFileName, this.ViewState["FlowTemplate"].ToString()); } this.Page.Response.Redirect("~/Home.aspx"); } catch (Exception ex) { PageUtility.DealWithException(this.Page, ex); } }
public void AddRDApply(int? RejectedFormID, int UserID, int? ProxyUserID, int? ProxyPositionID, int OrganizationUnitID, int PositionID, SystemEnums.FormType FormTypeID, SystemEnums.FormStatus StatusID, DateTime FPeriod, int BrandID, int CustomerChannelID, int CurrencyID, decimal ExchangeRate, string ProjectName, string ProjectDesc, string ApplyFileName, string ApplyRealFileName, DateTime? ActivityBeginDate, DateTime? ActivityEndDate, int? CostCenterID, int ExpenseSubCategoryID, decimal TotalBudget, decimal ApprovedAmount, decimal ApprovingAmount, decimal ReimbursedAmount, decimal RemainBudget) { SqlTransaction transaction = null; try { //事务开始 transaction = TableAdapterHelper.BeginTransaction(this.TAForm); TableAdapterHelper.SetTransaction(this.TAFormRDApply, transaction); TableAdapterHelper.SetTransaction(this.TAFormRDApplyDetail, 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.RDApply; if (CostCenterID != null) { formRow.CostCenterID = CostCenterID.GetValueOrDefault(); } this.FormDataSet.Form.AddFormRow(formRow); this.TAForm.Update(formRow); //处理申请表的内容 FormDS.FormRDApplyRow formApplyRow = this.FormDataSet.FormRDApply.NewFormRDApplyRow(); formApplyRow.FormRDApplyID = formRow.FormID; formApplyRow.FPeriod = DateTime.Parse(FPeriod.Year.ToString() + "-" + FPeriod.Month.ToString() + "-01"); formApplyRow.BrandID = BrandID; formApplyRow.CustomerChannelID = CustomerChannelID; formApplyRow.CurrencyID = CurrencyID; formApplyRow.ExchangeRate = ExchangeRate; if (!string.IsNullOrEmpty(ProjectName)) { formApplyRow.ProjectName = ProjectName; } if (ProjectDesc != null) formApplyRow.ProjectDesc = ProjectDesc; if (ApplyFileName != null && ApplyFileName != string.Empty) { formApplyRow.ApplyFileName = ApplyFileName; } if (ApplyRealFileName != null && ApplyRealFileName != string.Empty) { formApplyRow.ApplyRealFileName = ApplyRealFileName; } if (ActivityBeginDate != null) { formApplyRow.ActivityBeginDate = ActivityBeginDate.GetValueOrDefault(); } if (ActivityEndDate != null) { formApplyRow.ActivityEndDate = ActivityEndDate.GetValueOrDefault(); } formApplyRow.ExpenseSubCategoryID = ExpenseSubCategoryID; formApplyRow.TotalBudget = TotalBudget; formApplyRow.ApprovedAmount = ApprovedAmount; formApplyRow.ApprovingAmount = ApprovingAmount; formApplyRow.ReimbursedAmount = ReimbursedAmount; formApplyRow.RemainBudget = RemainBudget; formApplyRow.AmountRMB = 0; formApplyRow.IsClose = false; this.FormDataSet.FormRDApply.AddFormRDApplyRow(formApplyRow); this.TAFormRDApply.Update(formApplyRow); //处理明细 decimal totalAmountRMB = 0; if (RejectedFormID != null) { FormDS.FormRDApplyDetailDataTable newDetailTable = new FormDS.FormRDApplyDetailDataTable(); foreach (FormDS.FormRDApplyDetailRow detailRow in this.FormDataSet.FormRDApplyDetail) { if (detailRow.RowState != DataRowState.Deleted) { FormDS.FormRDApplyDetailRow newDetailRow = newDetailTable.NewFormRDApplyDetailRow(); newDetailRow.FormRDApplyID = formApplyRow.FormRDApplyID; newDetailRow.VendorID = detailRow.VendorID; newDetailRow.ExpenseItemID = detailRow.ExpenseItemID; newDetailRow.SKUID = detailRow.SKUID; newDetailRow.Amount = detailRow.Amount; newDetailRow.AmountRMB = decimal.Round(detailRow.Amount * ExchangeRate, 2); if (!detailRow.IsRemarkNull()) { newDetailRow.Remark = detailRow.Remark; } newDetailTable.AddFormRDApplyDetailRow(newDetailRow); totalAmountRMB = totalAmountRMB + newDetailRow.AmountRMB; } this.TAFormRDApplyDetail.Update(newDetailTable); } } else { foreach (FormDS.FormRDApplyDetailRow detailRow in this.FormDataSet.FormRDApplyDetail) { if (detailRow.RowState != DataRowState.Deleted) { detailRow.FormRDApplyID = formApplyRow.FormRDApplyID; detailRow.AmountRMB = decimal.Round(detailRow.Amount * ExchangeRate, 2); totalAmountRMB = totalAmountRMB + detailRow.AmountRMB; } } this.TAFormRDApplyDetail.Update(this.FormDataSet.FormRDApplyDetail); } formApplyRow.AmountRMB = totalAmountRMB; TAFormRDApply.Update(formApplyRow); //作废之前的单据 if (RejectedFormID != null) { FormDS.FormRow oldRow = this.TAForm.GetDataByID(RejectedFormID.GetValueOrDefault())[0]; if (oldRow.StatusID == (int)SystemEnums.FormStatus.Rejected) { oldRow.StatusID = (int)SystemEnums.FormStatus.Scrap; this.TAForm.Update(oldRow); } } // 正式提交 if (StatusID == SystemEnums.FormStatus.Awaiting) { Dictionary<string, object> dic = new Dictionary<string, object>(); dic["TotalAmount"] = totalAmountRMB; APResult result = new APFlowBLL().CreateProcess(new APParameter(formRow.FormID, formRow.FormNo, formRow.OrganizationUnitID, formRow.UserID, (int)StatusID, formRow.FormTypeID, formRow.PositionID, dic)); if (result != null) { formRow.InTurnPositionIds = result.InTurnPositionIds; formRow.InTurnUserIds = result.InTurnUserIds; formRow.SubmitDate = result.ApprovedDate.GetValueOrDefault(); formRow.StatusID = result.StatusID; formRow.ProcID = result.ProcID; this.TAForm.Update(formRow); } } transaction.Commit(); } catch (ApplicationException ex) { transaction.Rollback(); throw ex; } catch (Exception ex) { transaction.Rollback(); throw new ApplicationException("Save Fail!" + ex.ToString()); } finally { transaction.Dispose(); } }
public void AddFormVendorApply(int? RejectedFormID, int UserID, int? ProxyStuffUserId, int? ProxyStuffPositionID, int OrganizationUnitID, int PositionID, SystemEnums.FormType FormTypeID, SystemEnums.FormStatus StatusID, int VendorID, string VendorName, string VendorAddress, string City, string Country, string ContactName, int? VendorTypeID, string PhoneNumber, int OneTimeVendor, int HoldVendor, string PurchasingPostalCode, string AlphaSearchKey, string PurchasingContact, string PurchasingAddress, string PurchasingCity, string PurchasingPhoneNumber, int? BankCodeID, int? MethodPaymentID, int? PaymentTermID, int? TransTypeID, int? VatTypeID, string BankName, string AccountNo, string BankNo, int? ACTypeID, string AttachmentFileName, string RealAttachmentFileName, string Remark, string ModifyReason, int ActionType) { SqlTransaction transaction = null; try { transaction = TableAdapterHelper.BeginTransaction(this.TAForm); TableAdapterHelper.SetTransaction(this.TAFormVendor, transaction); PurchaseDS.FormRow formRow = this.PurchaseDataSet.Form.NewFormRow(); if (RejectedFormID != null) { formRow.RejectedFormID = RejectedFormID.GetValueOrDefault(); } formRow.UserID = UserID; UtilityBLL utility = new UtilityBLL(); string formTypeString = utility.GetFormTypeString((int)FormTypeID); formRow.FormNo = utility.GetFormNo(formTypeString); if (ProxyStuffUserId != null) { formRow.ProxyUserID = ProxyStuffUserId.GetValueOrDefault(); } if (ProxyStuffPositionID != null) { formRow.ProxyPositionID = ProxyStuffPositionID.GetValueOrDefault(); } formRow.InTurnUserIds = "P";//待改动 formRow.InTurnPositionIds = "P";//待改动 formRow.OrganizationUnitID = OrganizationUnitID; formRow.PositionID = PositionID; formRow.FormTypeID = (int)FormTypeID; formRow.StatusID = (int)StatusID; formRow.SubmitDate = DateTime.Now; formRow.LastModified = DateTime.Now; formRow.PageType = (int)SystemEnums.PageType.VendorApply; this.PurchaseDataSet.Form.AddFormRow(formRow); this.TAForm.Update(formRow); //处理申请表的内容 PurchaseDS.FormVendorDataTable tbFormVendor = new PurchaseDS.FormVendorDataTable(); PurchaseDS.FormVendorRow FormVendorRow = tbFormVendor.NewFormVendorRow(); FormVendorRow.FormVendorID = formRow.FormID; if (ActionType != 1 && VendorID > 0) { FormVendorRow.VendorID = VendorID; FormVendorRow.VendorCode = new MasterDataBLL().GetVendorByID(VendorID).VendorCode; } FormVendorRow.VendorName = VendorName; FormVendorRow.VendorAddress = VendorAddress; FormVendorRow.City = City; FormVendorRow.Postal = Country; FormVendorRow.ContactName = ContactName; if (VendorTypeID != null) { FormVendorRow.VendorTypeID = VendorTypeID.GetValueOrDefault(); } FormVendorRow.PhoneNumber = PhoneNumber; FormVendorRow.OneTimeVendor = OneTimeVendor == 1; FormVendorRow.HoldVendor = HoldVendor == 1; FormVendorRow.PurchaseingPostalCode = PurchasingPostalCode; FormVendorRow.AlphaSearchKey = AlphaSearchKey; FormVendorRow.PurchasingContact = PurchasingContact; FormVendorRow.PurchasingAddress = PurchasingAddress; FormVendorRow.PurchasingCity = PurchasingCity; FormVendorRow.PurchasePhoneNumber = PurchasingPhoneNumber; if (BankCodeID != null && BankCodeID != 0) { FormVendorRow.BankCodeID = BankCodeID.GetValueOrDefault(); MasterData.BankCodeRow rowBankCode = new MasterDataBLL().GetBankCodeById(BankCodeID.GetValueOrDefault())[0]; FormVendorRow.BankCode = rowBankCode.BankCode + rowBankCode.Description; } if (MethodPaymentID != null) { FormVendorRow.MethodPaymentID = MethodPaymentID.GetValueOrDefault(); } if (PaymentTermID != null) { FormVendorRow.PaymentTermID = PaymentTermID.GetValueOrDefault(); } if (TransTypeID != null) { FormVendorRow.TransTypeID = TransTypeID.GetValueOrDefault(); } if (VatTypeID != null) { FormVendorRow.VATTypeID = VatTypeID.GetValueOrDefault(); } FormVendorRow.BankName = BankName; FormVendorRow.AccountNo = AccountNo; FormVendorRow.BankNo = BankNo; if (ACTypeID != null) { FormVendorRow.ACTypeID = ACTypeID.GetValueOrDefault(); } FormVendorRow.AttachmentFileName = AttachmentFileName; FormVendorRow.RealAttachmentFileName = RealAttachmentFileName; FormVendorRow.Remark = Remark; FormVendorRow.ModifyReason = ModifyReason; FormVendorRow.ActionType = ActionType; tbFormVendor.AddFormVendorRow(FormVendorRow); this.TAFormVendor.Update(tbFormVendor); // 正式提交或草稿 if (StatusID == SystemEnums.FormStatus.Awaiting) { Dictionary<string, object> dic = new Dictionary<string, object>(); dic["ActionType"] = FormVendorRow.ActionType; APResult result = new APFlowBLL().CreateProcess(new APParameter(formRow.FormID, formRow.FormNo, formRow.OrganizationUnitID, formRow.UserID, (int)StatusID, formRow.FormTypeID, formRow.PositionID, dic)); if (result != null) { formRow.InTurnPositionIds = result.InTurnPositionIds; formRow.InTurnUserIds = result.InTurnUserIds; formRow.SubmitDate = result.ApprovedDate.GetValueOrDefault(); formRow.StatusID = result.StatusID; formRow.ProcID = result.ProcID; this.TAForm.Update(formRow); } } //作废之前的单据 if (RejectedFormID != null) { PurchaseDS.FormRow oldRow = TAForm.GetDataByID(RejectedFormID.GetValueOrDefault())[0]; if (oldRow.StatusID == (int)SystemEnums.FormStatus.Rejected) { new APFlowBLL().ScrapForm(oldRow.FormID); } } transaction.Commit(); } catch (Exception ex) { transaction.Rollback(); throw new ApplicationException(ex.Message); } finally { transaction.Dispose(); } }
public void AddRDPayment(int? RejectedFormID, int UserID, int? ProxyUserID, int? ProxyPositionID, int OrganizationUnitID, int PositionID, SystemEnums.FormType FormTypeID, SystemEnums.FormStatus StatusID, SystemEnums.PageType PageType, int FormRDApplyID, int InvoiceStatusID, int PaymentTypeID, string PaymentFileName, string PaymentRealFileName, string Remark, int CostCenterID, int? VATTypeID, int FormPOID) { SqlTransaction transaction = null; try { //事务开始 transaction = TableAdapterHelper.BeginTransaction(this.TAForm); TableAdapterHelper.SetTransaction(this.TAFormRDPayment, transaction); TableAdapterHelper.SetTransaction(this.TAFormRDPaymentDetail, transaction); TableAdapterHelper.SetTransaction(this.TAFormInvoice, transaction); //处理Form的内容 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)PageType; formRow.CostCenterID = CostCenterID; formRow.IsCreateVoucher = false; formRow.IsExportLock = false; formRow.IsCompletePayment = false; formRow.IsInvoiceReturned = false; this.FormDataSet.Form.AddFormRow(formRow); this.TAForm.Update(formRow); //处理Payment的内容 FormDS.FormRDPaymentRow formPaymentRow = this.FormDataSet.FormRDPayment.NewFormRDPaymentRow(); formPaymentRow.FormRDPaymentID = formRow.FormID; formPaymentRow.FormRDApplyID = FormRDApplyID; formPaymentRow.InvoiceStatusID = InvoiceStatusID; formPaymentRow.PaymentTypeID = PaymentTypeID; if (PaymentFileName != null && PaymentFileName != string.Empty) { formPaymentRow.PaymentFileName = PaymentFileName; } if (PaymentRealFileName != null && PaymentRealFileName != string.Empty) { formPaymentRow.PaymentRealFileName = PaymentRealFileName; } if (Remark != null && Remark != string.Empty) { formPaymentRow.Remark = Remark; } formPaymentRow.AmountRMB = 0; if (VATTypeID != null) { formPaymentRow.VATTypeID = VATTypeID.GetValueOrDefault(); } if (FormPOID > 0) { formPaymentRow.FormPOID = FormPOID; } this.FormDataSet.FormRDPayment.AddFormRDPaymentRow(formPaymentRow); this.TAFormRDPayment.Update(formPaymentRow); //发票 if (RejectedFormID != null) { FormDS.FormInvoiceDataTable newInvoiceTable = new FormDS.FormInvoiceDataTable(); foreach (FormDS.FormInvoiceRow invoiceRow in this.FormDataSet.FormInvoice) { if (invoiceRow.RowState != DataRowState.Deleted) { FormDS.FormInvoiceRow newInvoiceRow = newInvoiceTable.NewFormInvoiceRow(); newInvoiceRow.FormID = formPaymentRow.FormRDPaymentID; newInvoiceRow.InvoiceNo = invoiceRow.InvoiceNo; newInvoiceRow.InvoiceDate = invoiceRow.InvoiceDate; newInvoiceRow.InvoiceAmount = invoiceRow.InvoiceAmount; newInvoiceRow.Remark = invoiceRow.IsRemarkNull() ? "" : invoiceRow.Remark; newInvoiceRow.SystemInfo = invoiceRow.IsSystemInfoNull() ? "" : invoiceRow.SystemInfo; newInvoiceTable.AddFormInvoiceRow(newInvoiceRow); } this.TAFormInvoice.Update(newInvoiceTable); } } else { foreach (FormDS.FormInvoiceRow invoiceRow in this.FormDataSet.FormInvoice) { // 与父表绑定 if (invoiceRow.RowState != DataRowState.Deleted) { invoiceRow.FormID = formPaymentRow.FormRDPaymentID; } } } this.TAFormInvoice.Update(this.FormDataSet.FormInvoice); //处理明细 //先取得方案申请单 FormDS.FormRDApplyRow rowRDApply = this.TAFormRDApply.GetDataByID(FormRDApplyID)[0]; FormDS.FormRow rowApplyForm = this.TAForm.GetDataByID(FormRDApplyID)[0]; decimal totalAmountRMB = 0; decimal totalAmountBeforeTaxtRMB = 0; FormDS.FormRDPaymentDetailDataTable newDetailTable = new FormDS.FormRDPaymentDetailDataTable(); foreach (FormDS.FormRDPaymentDetailRow detailRow in this.FormDataSet.FormRDPaymentDetail) { // 与父表绑定 if (detailRow.RowState != DataRowState.Deleted) { totalAmountRMB += detailRow.AmountRMB; totalAmountBeforeTaxtRMB += detailRow.IsAmountBeforeTaxNull() ? 0 : detailRow.AmountBeforeTax; FormDS.FormRDPaymentDetailRow newDetailRow = newDetailTable.NewFormRDPaymentDetailRow(); newDetailRow.FormRDPaymentID = formPaymentRow.FormRDPaymentID; newDetailRow.FormRDApplyDetailID = detailRow.FormRDApplyDetailID; newDetailRow.VendorID = detailRow.VendorID; newDetailRow.ExpenseItemID = detailRow.ExpenseItemID; newDetailRow.SKUID = detailRow.SKUID; newDetailRow.PaiedAmount = detailRow.PaiedAmount; newDetailRow.ApplyAmount = detailRow.ApplyAmount; newDetailRow.ApplyAmountRMB = detailRow.ApplyAmountRMB; newDetailRow.RemainAmount = detailRow.RemainAmount; newDetailRow.AmountBeforeTax = detailRow.AmountBeforeTax; newDetailRow.TaxAmount = detailRow.TaxAmount; newDetailRow.AmountRMB = detailRow.AmountRMB; newDetailTable.AddFormRDPaymentDetailRow(newDetailRow); } } this.TAFormRDPaymentDetail.Update(newDetailTable); formPaymentRow.AmountRMB = totalAmountRMB; formPaymentRow.AmountBeforeTaxRMB = totalAmountBeforeTaxtRMB; this.TAFormRDPayment.Update(formPaymentRow); //作废之前的单据 if (RejectedFormID != null) { FormDS.FormRow oldRow = this.TAForm.GetDataByID(RejectedFormID.GetValueOrDefault())[0]; if (oldRow.StatusID == (int)SystemEnums.FormStatus.Rejected) { oldRow.StatusID = (int)SystemEnums.FormStatus.Scrap; this.TAForm.Update(oldRow); } } // 正式提交 if (StatusID == SystemEnums.FormStatus.Awaiting) { Dictionary<string, object> dic = new Dictionary<string, object>(); dic["TotalAmount"] = totalAmountRMB; dic["PaymentTypeID"] = PaymentTypeID; dic["InvoiceStatus"] = formPaymentRow.InvoiceStatusID; APResult result = new APFlowBLL().CreateProcess(new APParameter(formRow.FormID, formRow.FormNo, formRow.OrganizationUnitID, formRow.UserID, (int)StatusID, formRow.FormTypeID, formRow.PositionID, dic)); if (result != null) { formRow.InTurnPositionIds = result.InTurnPositionIds; formRow.InTurnUserIds = result.InTurnUserIds; formRow.SubmitDate = result.ApprovedDate.GetValueOrDefault(); formRow.StatusID = result.StatusID; formRow.ProcID = result.ProcID; formRow.FinanceRemark = formPaymentRow.Remark; this.TAForm.Update(formRow); } } transaction.Commit(); } catch (Exception ex) { transaction.Rollback(); throw new ApplicationException("Save Fail!" + ex.ToString()); } finally { transaction.Dispose(); } }
protected void SaveFormApply(SystemEnums.FormStatus StatusID) { decimal TotalBudget = 0; decimal ApprovedAmount = 0; decimal ApprovingAmount = 0; decimal ReimbursedAmount = 0; decimal RemainBudget = 0; if (StatusID == SystemEnums.FormStatus.Awaiting) {//提交时检查,保存草稿不检查 decimal[] calculateAssistant = new decimal[5]; calculateAssistant = new BudgetBLL().GetRDBudgetByParameter((int)this.ViewState["PositionID"], DateTime.Parse(ViewState["FPeriod"].ToString()), int.Parse(ViewState["CustomerChannelID"].ToString()), int.Parse(this.ViewState["BrandID"].ToString()), int.Parse(this.ViewState["ExpenseSubCategoryID"].ToString())); if (calculateAssistant[4] < decimal.Parse(this.ViewState["TotalApplyAmount"].ToString())) { PageUtility.ShowModelDlg(this.Page, "本次申请金额超过可用预算,不能提交", "the amount of this application is more than remain budget"); return; } else { TotalBudget = calculateAssistant[0]; ApprovedAmount = calculateAssistant[1]; ApprovingAmount = calculateAssistant[2]; ReimbursedAmount = calculateAssistant[3]; RemainBudget = calculateAssistant[4]; } } this.FormRDApplyBLL.FormDataSet = this.InnerDS; int? RejectedFormID = null; if (this.ViewState["RejectedObjectID"] != null) { RejectedFormID = (int)this.ViewState["RejectedObjectID"]; } int UserID = (int)this.ViewState["StuffUserID"]; int? ProxyStuffUserId = null; if (Session["ProxyStuffUserId"] != null) { ProxyStuffUserId = int.Parse(Session["ProxyStuffUserId"].ToString()); } int OrganizationUnitID = (int)this.ViewState["DepartmentID"]; int PositionID = (int)this.ViewState["PositionID"]; DateTime FPeriod = DateTime.Parse(this.ViewState["FPeriod"].ToString()); int CurrencyID = int.Parse(this.ViewState["CurrencyID"].ToString()); string ProjectName = this.txtProjectName.Text; string ProjectDesc = this.ProjectDescCtl.Text; string ApplyFileName = this.UCFileUpload.AttachmentFileName; string ApplyRealFileName = this.UCFileUpload.RealAttachmentFileName; DateTime? ActivityBeginDate = null; DateTime? ActivityEndDate = null; if (this.UCActivityBegin.SelectedDate != string.Empty) { ActivityBeginDate = DateTime.Parse(this.UCActivityBegin.SelectedDate); } if (this.UCActivityEnd.SelectedDate != string.Empty) { ActivityEndDate = DateTime.Parse(this.UCActivityEnd.SelectedDate); } int? CostCenterID = null; if (this.CostCenterDDL.SelectedValue != "0") { CostCenterID = int.Parse(CostCenterDDL.SelectedValue); } try { if (this.ViewState["ObjectId"] == null || RejectedFormID != null) { this.FormRDApplyBLL.AddRDApply(RejectedFormID, UserID, ProxyStuffUserId, null, OrganizationUnitID, PositionID, SystemEnums.FormType.RDApply, StatusID, FPeriod, int.Parse(ViewState["BrandID"].ToString()), int.Parse(ViewState["CustomerChannelID"].ToString()), CurrencyID, decimal.Parse(this.ViewState["ExchangeRate"].ToString()), ProjectName, ProjectDesc, ApplyFileName, ApplyRealFileName, ActivityBeginDate, ActivityEndDate, CostCenterID, int.Parse(ViewState["ExpenseSubCategoryID"].ToString()), TotalBudget, ApprovedAmount, ApprovingAmount, ReimbursedAmount, RemainBudget); } else { int FormID = (int)this.ViewState["ObjectId"]; this.FormRDApplyBLL.UpdateRDApply(FormID, SystemEnums.FormType.RDApply, StatusID, decimal.Parse(this.ViewState["ExchangeRate"].ToString()), ProjectName, ProjectDesc, ApplyFileName, ApplyRealFileName, ActivityBeginDate, ActivityEndDate, CostCenterID, TotalBudget, ApprovedAmount, ApprovingAmount, ReimbursedAmount, RemainBudget); } this.Page.Response.Redirect("~/Home.aspx"); } catch (Exception ex) { PageUtility.DealWithException(this.Page, ex); } }
public void UpdateRDApply(int FormID, SystemEnums.FormType FormTypeID, SystemEnums.FormStatus StatusID, decimal ExchangeRate, string ProjectName, string ProjectDesc, string ApplyFileName, string ApplyRealFileName, DateTime? ActivityBeginDate, DateTime? ActivityEndDate, int? CostCenterID, decimal TotalBudget, decimal ApprovedAmount, decimal ApprovingAmount, decimal ReimbursedAmount, decimal RemainBudget) { SqlTransaction transaction = null; try { //事务开始 transaction = TableAdapterHelper.BeginTransaction(this.TAForm); TableAdapterHelper.SetTransaction(this.TAFormRDApply, transaction); TableAdapterHelper.SetTransaction(this.TAFormRDApplyDetail, transaction); FormDS.FormRow formRow = this.TAForm.GetDataByID(FormID)[0]; FormDS.FormRDApplyRow formApplyRow = this.TAFormRDApply.GetDataByID(FormID)[0]; //处理单据的内容 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; if (CostCenterID != null) { formRow.CostCenterID = CostCenterID.GetValueOrDefault(); } this.TAForm.Update(formRow); //处理申请表的内容 formApplyRow.ExchangeRate = ExchangeRate; if (ProjectName != null) { formApplyRow.ProjectName = ProjectName; } if (ProjectDesc != null) { formApplyRow.ProjectDesc = ProjectDesc; } if (ApplyFileName != null && ApplyFileName != string.Empty) { formApplyRow.ApplyFileName = ApplyFileName; } if (ApplyRealFileName != null && ApplyRealFileName != string.Empty) { formApplyRow.ApplyRealFileName = ApplyRealFileName; } if (ActivityBeginDate != null) formApplyRow.ActivityBeginDate = ActivityBeginDate.GetValueOrDefault(); if (ActivityEndDate != null) formApplyRow.ActivityEndDate = ActivityEndDate.GetValueOrDefault(); formApplyRow.TotalBudget = TotalBudget; formApplyRow.ApprovedAmount = ApprovedAmount; formApplyRow.ApprovingAmount = ApprovingAmount; formApplyRow.ReimbursedAmount = ReimbursedAmount; formApplyRow.RemainBudget = RemainBudget; this.TAFormRDApply.Update(formApplyRow); //处理明细 decimal totalAmountRMB = 0; foreach (FormDS.FormRDApplyDetailRow detailRow in this.FormDataSet.FormRDApplyDetail) { if (detailRow.RowState != DataRowState.Deleted) { detailRow.FormRDApplyID = formApplyRow.FormRDApplyID; detailRow.AmountRMB = decimal.Round(detailRow.Amount * ExchangeRate, 2); totalAmountRMB = totalAmountRMB + detailRow.AmountRMB; } } this.TAFormRDApplyDetail.Update(this.FormDataSet.FormRDApplyDetail); formApplyRow.AmountRMB = totalAmountRMB; TAFormRDApply.Update(formApplyRow); // 正式提交 if (StatusID == SystemEnums.FormStatus.Awaiting) { Dictionary<string, object> dic = new Dictionary<string, object>(); dic["TotalAmount"] = totalAmountRMB; APResult result = new APFlowBLL().CreateProcess(new APParameter(formRow.FormID, formRow.FormNo, formRow.OrganizationUnitID, formRow.UserID, (int)StatusID, formRow.FormTypeID, formRow.PositionID, dic)); if (result != null) { formRow.InTurnPositionIds = result.InTurnPositionIds; formRow.InTurnUserIds = result.InTurnUserIds; formRow.SubmitDate = result.ApprovedDate.GetValueOrDefault(); formRow.StatusID = result.StatusID; formRow.ProcID = result.ProcID; this.TAForm.Update(formRow); } } transaction.Commit(); } catch (ApplicationException ex) { transaction.Rollback(); throw ex; } catch (Exception ex) { transaction.Rollback(); throw new ApplicationException("Save Fail!" + ex.ToString()); } finally { transaction.Dispose(); } }