コード例 #1
0
ファイル: APFlowBLL.cs プロジェクト: huaminglee/VSL_ERS
        public void GenerateRebateReimburse(int FormApplyID)
        {
            FormDS.FormRow form           = new FormTableAdapter().GetDataByID(FormApplyID)[0];
            UtilityBLL     utility        = new UtilityBLL();
            string         formTypeString = utility.GetFormTypeString((int)SystemEnums.FormType.ReimburseApply);

            new FormApplyTableAdapter().GenerateRebateReimburse(FormApplyID, form.FormNo, utility.GetFormNo(formTypeString));
        }
コード例 #2
0
ファイル: FormPurchaseBLL.cs プロジェクト: hijoy/CPL_ERS
        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();
            }
        }
コード例 #3
0
        public void UpdateFormBudgetAllocation(int FormID, SystemEnums.FormStatus StatusID, SystemEnums.FormType FormTypeID, string Remark, string AttachFileName, string RealAttachFileName, string FlowTemplate)
        {
            SqlTransaction transaction = null;

            try {
                ////事务开始
                transaction = TableAdapterHelper.BeginTransaction(this.TAForm);
                TableAdapterHelper.SetTransaction(this.TAFormBudgetAllocation, transaction);
                TableAdapterHelper.SetTransaction(this.TAFormBudgetAllocationDetail, transaction);

                FormDS.FormRow formRow = this.TAForm.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);

                //处理申请表的内容
                FormDS.FormBudgetAllocationRow formBudgetAllocationRow = this.TAFormBudgetAllocation.GetDataByID(FormID)[0];
                formBudgetAllocationRow.Amount             = decimal.Zero;
                formBudgetAllocationRow.AttachFileName     = AttachFileName;
                formBudgetAllocationRow.RealAttachFileName = RealAttachFileName;
                formBudgetAllocationRow.Remark             = Remark;
                this.TAFormBudgetAllocation.Update(formBudgetAllocationRow);

                //明细表
                decimal totalAmount    = 0; //计算总申请金额
                decimal totalInAmount  = 0; //计算调入总金额
                decimal totalOutAmount = 0; //计算调出总金额

                foreach (FormDS.FormBudgetAllocationDetailRow detailRow in this.FormDataSet.FormBudgetAllocationDetail)
                {
                    // 与父表绑定
                    if (detailRow.RowState != DataRowState.Deleted)
                    {
                        detailRow.FormBudgetAllocationID = formBudgetAllocationRow.FormBudgetAllocationID;
                        if (detailRow.AllocationType == (int)SystemEnums.AllocationType.In)
                        {
                            totalInAmount += detailRow.TransferBudget;
                        }
                        else
                        {
                            totalOutAmount += detailRow.TransferBudget;
                        }
                        totalAmount += detailRow.TransferBudget;
                    }
                }

                this.TAFormBudgetAllocationDetail.Update(this.FormDataSet.FormBudgetAllocationDetail);

                formBudgetAllocationRow.Amount = totalOutAmount;
                this.TAFormBudgetAllocation.Update(formBudgetAllocationRow);

                // 正式提交或草稿

                Dictionary <string, object> dic = new Dictionary <string, object>();
                dic["Apply_Amount"] = totalOutAmount;    //调拨金额

                APHelper AP = new APHelper();
                new APFlowBLL().ApplyForm(AP, TAForm, null, formRow, formRow.OrganizationUnitID, FlowTemplate, StatusID, dic);


                transaction.Commit();
            } catch (Exception ex) {
                transaction.Rollback();
                throw new ApplicationException(ex.Message);
            } finally {
                transaction.Dispose();
            }
        }
コード例 #4
0
ファイル: FormRDBLL.cs プロジェクト: hijoy/CPL_ERS
        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();
            }
        }
コード例 #5
0
ファイル: FormRDBLL.cs プロジェクト: hijoy/CPL_ERS
        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();
            }
        }
コード例 #6
0
ファイル: FormTEBLL.cs プロジェクト: hijoy/CPL_ERS
        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();
            }
        }
コード例 #7
0
        public void UpdateFormReimburseGoods(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.TAFormReimburseSKUDetail, 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);

                //处理free goods明细
                foreach (FormDS.FormReimburseSKUDetailRow detailFGRow in this.FormDataSet.FormReimburseSKUDetail)
                {
                    // 与父表绑定
                    if (detailFGRow.RowState != DataRowState.Deleted)
                    {
                        detailFGRow.FormReimburseID = FormReimburseRow.FormReimburseID;
                    }
                }
                this.TAFormReimburseSKUDetail.Update(this.FormDataSet.FormReimburseSKUDetail);

                //处理明细
                decimal totalAmount = 0;
                foreach (FormDS.FormReimburseDetailRow detailRow in this.FormDataSet.FormReimburseDetail)
                {
                    if (detailRow.RowState != DataRowState.Deleted)
                    {
                        totalAmount += detailRow.Amount;
                        detailRow.FormReimburseID = FormReimburseRow.FormReimburseID;
                    }
                }
                this.TAFormReimburseDetail.Update(this.FormDataSet.FormReimburseDetail);

                FormReimburseRow.Amount = totalAmount;
                this.TAFormReimburse.Update(FormReimburseRow);

                // 正式提交
                if (StatusID == SystemEnums.FormStatus.Awaiting)
                {
                    Dictionary <string, object> dic = new Dictionary <string, object>();
                    dic["Apply_Amount"] = totalAmount;
                    //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();
            }
        }
コード例 #8
0
        public void UpdateFormPersonalReimburse(int FormID, SystemEnums.FormStatus StatusID, SystemEnums.FormType FormTypeID, DateTime?Period, string Remark,
                                                string AttachedFileName, string RealAttachedFileName, string FlowTemplate)
        {
            SqlTransaction transaction = null;

            try {
                ////事务开始
                transaction = TableAdapterHelper.BeginTransaction(this.TAForm);
                TableAdapterHelper.SetTransaction(this.TAFormPersonalReimburse, transaction);
                TableAdapterHelper.SetTransaction(this.TAFormPersonalReimburseDetail, transaction);

                FormDS.FormRow formRow = this.TAForm.GetDataByID(FormID)[0];

                decimal[]  calculateAssistant = this.GetPersonalBudgetByParameter(formRow.PositionID, Period);
                UtilityBLL utility            = new UtilityBLL();
                if (StatusID == SystemEnums.FormStatus.Awaiting)
                {
                    string formTypeString = utility.GetFormTypeString((int)FormTypeID);
                    formRow.FormNo            = utility.GetFormNo(formTypeString);
                    formRow.InTurnUserIds     = "P"; //待改动
                    formRow.InTurnPositionIds = "P"; //待改动
                }
                else
                {
                    formRow.SetFormNoNull();
                }
                formRow.StatusID     = (int)StatusID;
                formRow.SubmitDate   = DateTime.Now;
                formRow.LastModified = DateTime.Now;
                this.TAForm.Update(formRow);

                //处理申请表的内容
                FormDS.FormPersonalReimburseRow formPersonalReimburseRow = this.TAFormPersonalReimburse.GetDataByID(FormID)[0];
                formPersonalReimburseRow.FormPersonalReimburseID = formRow.FormID;
                formPersonalReimburseRow.Period = Period.GetValueOrDefault();
                formPersonalReimburseRow.Amount = decimal.Zero;
                formPersonalReimburseRow.Remark = Remark;

                formPersonalReimburseRow.TotalBudget     = calculateAssistant[0];
                formPersonalReimburseRow.ApprovedAmount  = calculateAssistant[1];
                formPersonalReimburseRow.ApprovingAmount = calculateAssistant[2];
                formPersonalReimburseRow.RemainAmount    = calculateAssistant[3];

                if (AttachedFileName != null)
                {
                    formPersonalReimburseRow.AttachedFileName = AttachedFileName;
                }
                if (RealAttachedFileName != null)
                {
                    formPersonalReimburseRow.RealAttachedFileName = RealAttachedFileName;
                }

                this.TAFormPersonalReimburse.Update(formPersonalReimburseRow);

                //明细表
                decimal totalAmount = 0;//计算总申请金额
                foreach (FormDS.FormPersonalReimburseDetailRow detailRow in this.FormDataSet.FormPersonalReimburseDetail)
                {
                    // 与父表绑定
                    if (detailRow.RowState != DataRowState.Deleted)
                    {
                        detailRow.FormPersonalReimburseID = formPersonalReimburseRow.FormPersonalReimburseID;
                        totalAmount += detailRow.Amount;
                    }
                }
                this.TAFormPersonalReimburseDetail.Update(this.FormDataSet.FormPersonalReimburseDetail);

                formPersonalReimburseRow.Amount = totalAmount;
                this.TAFormPersonalReimburse.Update(formPersonalReimburseRow);

                // 正式提交或草稿
                Dictionary <string, object> dic = new Dictionary <string, object>();
                if (StatusID == SystemEnums.FormStatus.Awaiting)
                {
                    if (formPersonalReimburseRow.Amount > calculateAssistant[3])  //如果是减少预算,要做检查
                    {
                        throw new ApplicationException("申请报销总额超出部门可用余额,不能提交!");
                    }
                    dic["Apply_Amount"] = totalAmount;//金额
                    AuthorizationDS.OrganizationUnitDataTable OUTable = new AuthorizationDSTableAdapters.OrganizationUnitTableAdapter().GetOrganizationUnitCodeByOrganizationUnitID(formRow.OrganizationUnitID);
                    if (OUTable.Count == 0)
                    {
                        throw new ApplicationException("没有找到您所在部门的流程,请联系管理员");
                    }
                    dic["Department"] = OUTable[0].OrganizationUnitCode;
                    APHelper AP = new APHelper();
                    new APFlowBLL().ApplyForm(AP, TAForm, null, formRow, formRow.OrganizationUnitID, FlowTemplate, StatusID, dic);
                }
                transaction.Commit();
            } catch (Exception ex) {
                transaction.Rollback();
                throw new ApplicationException(ex.Message);
            } finally {
                transaction.Dispose();
            }
        }
コード例 #9
0
ファイル: SalesApplyBLL.cs プロジェクト: hijoy/VSL_ERS
        public void UpdateFormApply(int FormID, SystemEnums.FormStatus StatusID, SystemEnums.FormType FormTypeID, int ShopID, int PaymentTypeID, string ContractNo, DateTime PromotionBeginDate,
                        DateTime PromotionEndDate, DateTime DeliveryBeginDate, DateTime DeliveryEndDate, int PromotionScopeID, int PromotionTypeID, string PromotionDesc, int ShelfTypeID, int? FirstVolume, int? SecondVolume, int? ThirdVolume,
                        decimal? CustomerBudget, decimal? CustomerBudgetRemain, decimal? OUBudget, decimal? OUAppovedAmount, decimal? OUApprovingAmount, decimal? OUCompletedAmount, decimal? OUReimbursedAmount,
                        decimal? OUBudgetRemain, decimal? OUBudgetRate, string AttachedFileName, string RealAttachedFileName, string Remark, int ReimburseRequirements, string FlowTemplate, string FormApplyName)
        {
            SqlTransaction transaction = null;

            try {
                ////事务开始
                transaction = TableAdapterHelper.BeginTransaction(this.TAForm);
                TableAdapterHelper.SetTransaction(this.TAFormApply, transaction);
                TableAdapterHelper.SetTransaction(this.TAFormApplySKUDetail, transaction);
                TableAdapterHelper.SetTransaction(this.TAFormApplyExpenseDetail, transaction);
                TableAdapterHelper.SetTransaction(this.TAFormApplySplitRate, transaction);

                FormDS.FormRow formRow = this.TAForm.GetDataByID(FormID)[0];
                FormDS.FormApplyRow formApplyRow = this.TAFormApply.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;
                //申请单内容
                formApplyRow.ShopID = ShopID;
                formApplyRow.PaymentTypeID = PaymentTypeID;
                if (ContractNo != "") {
                    formApplyRow.ContractNo = ContractNo;
                }
                formApplyRow.PromotionBeginDate = PromotionBeginDate;
                formApplyRow.PromotionEndDate = PromotionEndDate;
                formApplyRow.DeliveryBeginDate = DeliveryBeginDate;
                formApplyRow.DeliveryEndDate = DeliveryEndDate;
                formApplyRow.PromotionScopeID = PromotionScopeID;
                formApplyRow.PromotionTypeID = PromotionTypeID;
                if (PromotionDesc != "") {
                    formApplyRow.PromotionDesc = PromotionDesc;
                }
                formApplyRow.ShelfTypeID = ShelfTypeID;
                if (FirstVolume != null) {
                    formApplyRow.FirstVolume = FirstVolume.GetValueOrDefault();
                }
                if (SecondVolume != null) {
                    formApplyRow.SecondVolume = SecondVolume.GetValueOrDefault();
                }
                if (ThirdVolume != null) {
                    formApplyRow.ThirdVolume = ThirdVolume.GetValueOrDefault();
                }
                if (CustomerBudget != null) {
                    formApplyRow.CustomerBudget = CustomerBudget.GetValueOrDefault();
                }
                if (CustomerBudgetRemain != null) {
                    formApplyRow.CustomerBudgetRemain = CustomerBudgetRemain.GetValueOrDefault();
                }
                if (OUBudget != null) {
                    formApplyRow.OUBudget = OUBudget.GetValueOrDefault();
                }
                if (OUAppovedAmount != null) {
                    formApplyRow.OUAppovedAmount = OUAppovedAmount.GetValueOrDefault();
                }
                if (OUApprovingAmount != null) {
                    formApplyRow.OUApprovingAmount = OUApprovingAmount.GetValueOrDefault();
                }
                if (OUCompletedAmount != null) {
                    formApplyRow.OUCompletedAmount = OUCompletedAmount.GetValueOrDefault();
                }
                if (OUReimbursedAmount != null) {
                    formApplyRow.OUReimbursedAmount = OUReimbursedAmount.GetValueOrDefault();
                }
                if (OUBudgetRemain != null) {
                    formApplyRow.OUBudgetRemain = OUBudgetRemain.GetValueOrDefault();
                }
                if (OUBudgetRate != null) {
                    formApplyRow.OUBudgetRate = OUBudgetRate.GetValueOrDefault();
                }
                if (AttachedFileName != null && AttachedFileName != string.Empty) {
                    formApplyRow.AttachedFileName = AttachedFileName;
                }
                if (RealAttachedFileName != null && RealAttachedFileName != string.Empty) {
                    formApplyRow.RealAttachedFileName = RealAttachedFileName;
                }
                if (Remark != null && Remark != string.Empty) {
                    formApplyRow.Remark = Remark;
                }
                formApplyRow.FormApplyName = FormApplyName;
                formApplyRow.ReimburseRequirements = ReimburseRequirements;

                this.TAForm.Update(formRow);
                this.TAFormApply.Update(formApplyRow);

                ArrayList deletedSKURows = new ArrayList();//save sku rows and expense rows that not deleted
                decimal totalAmount = 0;//计算总申请金额
                foreach (FormDS.FormApplySKUDetailRow skuRow in this.FormDataSet.FormApplySKUDetail) {
                    // 与父表绑定
                    if (skuRow.RowState != DataRowState.Deleted) {
                        int oldID = skuRow.FormApplySKUDetailID;
                        this.TAFormApplySKUDetail.Update(skuRow);
                        int newID = skuRow.FormApplySKUDetailID;
                        FormDS.FormApplyExpenseDetailRow[] dr = (FormDS.FormApplyExpenseDetailRow[])this.FormDataSet.FormApplyExpenseDetail.Select("FormApplySKUDetailID = " + oldID.ToString());
                        for (int i = 0; i < dr.Length; i++) {
                            dr[i].FormApplySKUDetailID = newID;
                            if (dr[i].RowState != DataRowState.Deleted) {
                                totalAmount += dr[i].Amount;
                            }
                            dr[i].RepeatFormInfo = UtilityBLL.GenerateRepeatFormStr(this.TAForm.GetRepeatFormApplyNo(formApplyRow.PromotionBeginDate, formApplyRow.PromotionEndDate, dr[i].ExpenseItemID, formApplyRow.ShopID, formApplyRow.FormApplyID));
                        }
                    } else {
                        deletedSKURows.Add(skuRow);
                    }
                }
                //save expense detail rows

                foreach (FormDS.FormApplyExpenseDetailRow expenseRow in this.FormDataSet.FormApplyExpenseDetail) {
                    if (expenseRow.RowState != DataRowState.Deleted) {
                        expenseRow.RepeatFormInfo = UtilityBLL.GenerateRepeatFormStr(this.TAForm.GetRepeatFormApplyNo(formApplyRow.PromotionBeginDate, formApplyRow.PromotionEndDate, expenseRow.ExpenseItemID, formApplyRow.ShopID, formApplyRow.FormApplyID));
                    }
                }

                this.TAFormApplyExpenseDetail.Update(this.FormDataSet.FormApplyExpenseDetail);
                //save deleted sku rows
                foreach (FormDS.FormApplySKUDetailRow skuRow in deletedSKURows) {
                    if (skuRow.RowState == DataRowState.Deleted) {
                        this.TAFormApplySKUDetail.Update(skuRow);
                    }
                }
                formApplyRow.Amount = totalAmount;
                this.TAFormApply.Update(formApplyRow);

                this.TAFormApplySplitRate.Update(FormDataSet.FormApplySplitRate);

                // 正式提交或草稿
                Dictionary<string, object> dic = new Dictionary<string, object>();
                dic["Apply_Amount"] = totalAmount;
                dic["Expense_Category"] = getExpenseCategoryIDByExpenseSubCategoryID(formApplyRow.ExpenseSubCategoryID).ToString();
                //dic["Dept"] = new AuthorizationDSTableAdapters.OrganizationUnitTableAdapter().GetOrganizationUnitCodeByOrganizationUnitID(formRow.OrganizationUnitID)[0].OrganizationUnitCode;
                APHelper AP = new APHelper();
                new APFlowBLL().ApplyForm(AP, TAForm, null, formRow, formRow.OrganizationUnitID, FlowTemplate, StatusID, dic);

                transaction.Commit();
            } catch (Exception ex) {
                transaction.Rollback();
                throw new ApplicationException("Save Fail!" + ex.ToString());
            } finally {
                transaction.Dispose();
            }
        }
コード例 #10
0
        public void UpdateFormMaterial(int FormID, SystemEnums.FormStatus StatusID, SystemEnums.FormType FormTypeID, int ShopID, int FirstVolume, int SecondVolume, int ThirdVolume, string Remark, string FlowTemplate)
        {
            SqlTransaction transaction = null;

            try {
                ////事务开始
                transaction = TableAdapterHelper.BeginTransaction(this.TAForm);
                TableAdapterHelper.SetTransaction(this.TAFormMaterial, transaction);
                TableAdapterHelper.SetTransaction(this.TAFormMaterialDetail, 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);
                    formRow.InTurnUserIds     = "P"; //待改动
                    formRow.InTurnPositionIds = "P"; //待改动
                }
                else
                {
                    formRow.SetFormNoNull();
                }
                formRow.StatusID     = (int)StatusID;
                formRow.SubmitDate   = DateTime.Now;
                formRow.LastModified = DateTime.Now;
                this.TAForm.Update(formRow);

                //处理申请表的内容
                FormDS.FormMaterialRow formMaterialRow = this.TAFormMaterial.GetDataByID(FormID)[0];
                formMaterialRow.ShopID       = ShopID;
                formMaterialRow.FirstVolume  = FirstVolume;
                formMaterialRow.SecondVolume = SecondVolume;
                formMaterialRow.ThirdVolume  = ThirdVolume;
                formMaterialRow.Remark       = Remark;
                this.TAFormMaterial.Update(formMaterialRow);

                //明细表
                decimal totalAmount = 0;//计算总申请金额
                foreach (FormDS.FormMaterialDetailRow detailRow in this.FormDataSet.FormMaterialDetail)
                {
                    // 与父表绑定
                    if (detailRow.RowState != DataRowState.Deleted)
                    {
                        detailRow.FormMaterialID = formMaterialRow.FormMaterialID;
                        totalAmount += detailRow.Amount;
                    }
                }
                this.TAFormMaterialDetail.Update(this.FormDataSet.FormMaterialDetail);

                formMaterialRow.Amount = totalAmount;
                this.TAFormMaterial.Update(formMaterialRow);
                // 正式提交或草稿
                if (StatusID == SystemEnums.FormStatus.Awaiting)
                {
                    Dictionary <string, object> dic = new Dictionary <string, object>();
                    dic["Apply_Amount"] = totalAmount;//金额
                    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();
            }
        }
コード例 #11
0
        public void AddFormMaterial(int?RejectedFormID, int UserID, int?ProxyUserID, int?ProxyPositionID, int OrganizationUnitID, int PositionID, SystemEnums.FormType FormTypeID,
                                    SystemEnums.FormStatus StatusID, int ShopID, int FirstVolume, int SecondVolume, int ThirdVolume, string Remark, string FlowTemplate)
        {
            SqlTransaction transaction = null;

            try {
                transaction = TableAdapterHelper.BeginTransaction(this.TAForm);
                TableAdapterHelper.SetTransaction(this.TAFormMaterial, transaction);
                TableAdapterHelper.SetTransaction(this.TAFormMaterialDetail, 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.MaterialApply;
                this.FormDataSet.Form.AddFormRow(formRow);
                this.TAForm.Update(formRow);

                //处理申请表的内容
                FormDS.FormMaterialRow formMaterialRow = this.FormDataSet.FormMaterial.NewFormMaterialRow();
                formMaterialRow.FormMaterialID = formRow.FormID;
                formMaterialRow.ShopID         = ShopID;
                formMaterialRow.FirstVolume    = FirstVolume;
                formMaterialRow.SecondVolume   = SecondVolume;
                formMaterialRow.ThirdVolume    = ThirdVolume;
                formMaterialRow.Amount         = 0;//默认值
                formMaterialRow.Remark         = Remark;

                this.FormDataSet.FormMaterial.AddFormMaterialRow(formMaterialRow);
                this.TAFormMaterial.Update(formMaterialRow);

                //明细表
                decimal totalAmount = 0;//计算总申请金额

                if (RejectedFormID != null)
                {
                    FormDS.FormMaterialDetailDataTable newDetailTable = new FormDS.FormMaterialDetailDataTable();
                    foreach (FormDS.FormMaterialDetailRow detailRow in this.FormDataSet.FormMaterialDetail)
                    {
                        if (detailRow.RowState != System.Data.DataRowState.Deleted)
                        {
                            FormDS.FormMaterialDetailRow newDetailRow = newDetailTable.NewFormMaterialDetailRow();
                            newDetailRow.FormMaterialID = formMaterialRow.FormMaterialID;
                            newDetailRow.MaterialID     = detailRow.MaterialID;
                            ERS.MaterialRow material = new MasterDataBLL().GetMaterialById(detailRow.MaterialID);
                            newDetailRow.MaterialName  = material.MaterialName;
                            newDetailRow.UOM           = material.UOM;
                            newDetailRow.Description   = material.Description;
                            newDetailRow.MaterialPrice = material.MaterialPrice;
                            newDetailRow.Quantity      = detailRow.Quantity;
                            newDetailRow.Amount        = newDetailRow.MaterialPrice * detailRow.Quantity;
                            if (!detailRow.IsRemarkNull())
                            {
                                newDetailRow.Remark = detailRow.Remark;
                            }
                            totalAmount += newDetailRow.Amount;
                            newDetailTable.AddFormMaterialDetailRow(newDetailRow);
                        }
                    }
                    this.TAFormMaterialDetail.Update(newDetailTable);
                }
                else
                {
                    foreach (FormDS.FormMaterialDetailRow detailRow in this.FormDataSet.FormMaterialDetail)
                    {
                        // 与父表绑定
                        if (detailRow.RowState != DataRowState.Deleted)
                        {
                            detailRow.FormMaterialID = formMaterialRow.FormMaterialID;
                            totalAmount += detailRow.Amount;
                        }
                    }
                    this.TAFormMaterialDetail.Update(this.FormDataSet.FormMaterialDetail);
                }

                formMaterialRow.Amount = totalAmount;
                this.TAFormMaterial.Update(formMaterialRow);

                // 正式提交或草稿

                Dictionary <string, object> dic = new Dictionary <string, object>();
                dic["Apply_Amount"] = totalAmount;    //金额
                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("Save Fail!" + ex.ToString());
            } finally {
                transaction.Dispose();
            }
        }
コード例 #12
0
ファイル: MaterialApplyBLL.cs プロジェクト: hijoy/VSL_ERS
        public void AddFormMaterial(int? RejectedFormID, int UserID, int? ProxyUserID, int? ProxyPositionID, int OrganizationUnitID, int PositionID, SystemEnums.FormType FormTypeID,
                SystemEnums.FormStatus StatusID, int ShopID, int FirstVolume, int SecondVolume, int ThirdVolume, string Remark, string FlowTemplate)
        {
            SqlTransaction transaction = null;
            try {
                transaction = TableAdapterHelper.BeginTransaction(this.TAForm);
                TableAdapterHelper.SetTransaction(this.TAFormMaterial, transaction);
                TableAdapterHelper.SetTransaction(this.TAFormMaterialDetail, 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.MaterialApply;
                this.FormDataSet.Form.AddFormRow(formRow);
                this.TAForm.Update(formRow);

                //处理申请表的内容
                FormDS.FormMaterialRow formMaterialRow = this.FormDataSet.FormMaterial.NewFormMaterialRow();
                formMaterialRow.FormMaterialID = formRow.FormID;
                formMaterialRow.ShopID = ShopID;
                formMaterialRow.FirstVolume = FirstVolume;
                formMaterialRow.SecondVolume = SecondVolume;
                formMaterialRow.ThirdVolume = ThirdVolume;
                formMaterialRow.Amount = 0;//默认值
                formMaterialRow.Remark = Remark;

                this.FormDataSet.FormMaterial.AddFormMaterialRow(formMaterialRow);
                this.TAFormMaterial.Update(formMaterialRow);

                //明细表
                decimal totalAmount = 0;//计算总申请金额

                if (RejectedFormID != null) {
                    FormDS.FormMaterialDetailDataTable newDetailTable = new FormDS.FormMaterialDetailDataTable();
                    foreach (FormDS.FormMaterialDetailRow detailRow in this.FormDataSet.FormMaterialDetail) {
                        if (detailRow.RowState != System.Data.DataRowState.Deleted) {
                            FormDS.FormMaterialDetailRow newDetailRow = newDetailTable.NewFormMaterialDetailRow();
                            newDetailRow.FormMaterialID = formMaterialRow.FormMaterialID;
                            newDetailRow.MaterialID = detailRow.MaterialID;
                            ERS.MaterialRow material = new MasterDataBLL().GetMaterialById(detailRow.MaterialID);
                            newDetailRow.MaterialName = material.MaterialName;
                            newDetailRow.UOM = material.UOM;
                            newDetailRow.Description = material.Description;
                            newDetailRow.MaterialPrice = material.MaterialPrice;
                            newDetailRow.Quantity = detailRow.Quantity;
                            newDetailRow.Amount = newDetailRow.MaterialPrice * detailRow.Quantity;
                            if (!detailRow.IsRemarkNull()) {
                                newDetailRow.Remark = detailRow.Remark;
                            }
                            totalAmount += newDetailRow.Amount;
                            newDetailTable.AddFormMaterialDetailRow(newDetailRow);
                        }
                    }
                    this.TAFormMaterialDetail.Update(newDetailTable);
                } else {
                    foreach (FormDS.FormMaterialDetailRow detailRow in this.FormDataSet.FormMaterialDetail) {
                        // 与父表绑定
                        if (detailRow.RowState != DataRowState.Deleted) {
                            detailRow.FormMaterialID = formMaterialRow.FormMaterialID;
                            totalAmount += detailRow.Amount;
                        }
                    }
                    this.TAFormMaterialDetail.Update(this.FormDataSet.FormMaterialDetail);
                }

                formMaterialRow.Amount = totalAmount;
                this.TAFormMaterial.Update(formMaterialRow);

                // 正式提交或草稿

                    Dictionary<string, object> dic = new Dictionary<string, object>();
                    dic["Apply_Amount"] = totalAmount;//金额
                    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("Save Fail!" + ex.ToString());
            } finally {
                transaction.Dispose();
            }
        }
コード例 #13
0
ファイル: MaterialApplyBLL.cs プロジェクト: hijoy/VSL_ERS
        public void UpdateFormMaterial(int FormID, SystemEnums.FormStatus StatusID, SystemEnums.FormType FormTypeID, int ShopID, int FirstVolume, int SecondVolume, int ThirdVolume, string Remark, string FlowTemplate)
        {
            SqlTransaction transaction = null;
            try {
                ////事务开始
                transaction = TableAdapterHelper.BeginTransaction(this.TAForm);
                TableAdapterHelper.SetTransaction(this.TAFormMaterial, transaction);
                TableAdapterHelper.SetTransaction(this.TAFormMaterialDetail, 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);
                    formRow.InTurnUserIds = "P";//待改动
                    formRow.InTurnPositionIds = "P";//待改动
                } else {
                    formRow.SetFormNoNull();
                }
                formRow.StatusID = (int)StatusID;
                formRow.SubmitDate = DateTime.Now;
                formRow.LastModified = DateTime.Now;
                this.TAForm.Update(formRow);

                //处理申请表的内容
                FormDS.FormMaterialRow formMaterialRow = this.TAFormMaterial.GetDataByID(FormID)[0];
                formMaterialRow.ShopID = ShopID;
                formMaterialRow.FirstVolume = FirstVolume;
                formMaterialRow.SecondVolume = SecondVolume;
                formMaterialRow.ThirdVolume = ThirdVolume;
                formMaterialRow.Remark = Remark;
                this.TAFormMaterial.Update(formMaterialRow);

                //明细表
                decimal totalAmount = 0;//计算总申请金额
                foreach (FormDS.FormMaterialDetailRow detailRow in this.FormDataSet.FormMaterialDetail) {
                    // 与父表绑定
                    if (detailRow.RowState != DataRowState.Deleted) {
                        detailRow.FormMaterialID = formMaterialRow.FormMaterialID;
                        totalAmount += detailRow.Amount;
                    }
                }
                this.TAFormMaterialDetail.Update(this.FormDataSet.FormMaterialDetail);

                formMaterialRow.Amount = totalAmount;
                this.TAFormMaterial.Update(formMaterialRow);
                // 正式提交或草稿
                if (StatusID == SystemEnums.FormStatus.Awaiting) {
                    Dictionary<string, object> dic = new Dictionary<string, object>();
                    dic["Apply_Amount"] = totalAmount;//金额
                    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();
            }
        }
コード例 #14
0
        public void AddFormContract(int?RejectedFormID, int UserID, int?ProxyUserID, int?ProxyPositionID, int OrganizationUnitID, int PositionID, SystemEnums.FormType FormTypeID,
                                    SystemEnums.FormStatus StatusID, string ContractName, int ContractTypeID, Decimal?ContractAmount, int?PageNumber, string FirstCompany, string SecondCompany, string ThirdCompany, DateTime?BeginDate, DateTime?EndDate, string PaymentType, string MainContent, string ChangePart, string AttachedFileName, string RealAttachedFileName, string FlowTemplate)
        {
            SqlTransaction transaction = null;

            try {
                transaction = TableAdapterHelper.BeginTransaction(this.TAForm);
                TableAdapterHelper.SetTransaction(this.TAFormContract, 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.ContractApply;
                this.FormDataSet.Form.AddFormRow(formRow);
                this.TAForm.Update(formRow);

                //处理申请表的内容
                FormDS.FormContractRow formContractRow = this.FormDataSet.FormContract.NewFormContractRow();
                formContractRow.ContractName         = ContractName;
                formContractRow.FormContractID       = formRow.FormID;
                formContractRow.ContractTypeID       = ContractTypeID;
                formContractRow.ContractAmount       = ContractAmount.GetValueOrDefault();
                formContractRow.PageNumber           = PageNumber.GetValueOrDefault();
                formContractRow.FirstCompany         = FirstCompany;
                formContractRow.SecondCompany        = SecondCompany;
                formContractRow.ThirdCompany         = ThirdCompany;
                formContractRow.BeginDate            = BeginDate.GetValueOrDefault();
                formContractRow.EndDate              = EndDate.GetValueOrDefault();
                formContractRow.PaymentType          = PaymentType;
                formContractRow.MainContent          = MainContent;
                formContractRow.ChangePart           = ChangePart;
                formContractRow.AttachedFileName     = AttachedFileName;
                formContractRow.RealAttachedFileName = RealAttachedFileName;
                if (StatusID == SystemEnums.FormStatus.Awaiting)
                {
                    formContractRow.ContractNo = GetContractNo(ContractTypeID);
                }
                this.FormDataSet.FormContract.AddFormContractRow(formContractRow);
                this.TAFormContract.Update(formContractRow);

                // 正式提交或草稿

                Dictionary <string, object> dic = new Dictionary <string, object>();
                dic["Apply_Amount"] = ContractAmount;    //合同金额
                dic["ContractType"] = new MasterDataBLL().GetContractTypeById(ContractTypeID).ContractTypeName;
                APHelper AP = new APHelper();
                new APFlowBLL().ApplyForm(AP, TAForm, RejectedFormID, formRow, OrganizationUnitID, FlowTemplate, StatusID, dic);

                //this.TAFormContract.Update(formContractRow);
                transaction.Commit();
            } catch (Exception ex) {
                transaction.Rollback();
                throw new ApplicationException("Save Fail!" + ex.ToString());
            } finally {
                transaction.Dispose();
            }
        }
コード例 #15
0
ファイル: FormPurchaseBLL.cs プロジェクト: hijoy/CPL_ERS
        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();
            }
        }
コード例 #16
0
ファイル: SalesReimburseBLL.cs プロジェクト: hijoy/VSL_ERS
        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();
            }
        }
コード例 #17
0
ファイル: SalesApplyBLL.cs プロジェクト: hijoy/VSL_ERS
        public void AddFormApply(int? RejectedFormID, int UserID, int? ProxyUserID, int? ProxyPositionID, int OrganizationUnitID, int PositionID, SystemEnums.FormType FormTypeID, SystemEnums.FormStatus StatusID,
                        DateTime BeginPeriod, DateTime EndPeriod, int CustomerID, int ShopID, int PaymentTypeID, int ExpenseSubCategoryID, string ContractNo, DateTime PromotionBeginDate, DateTime PromotionEndDate,
                        DateTime DeliveryBeginDate, DateTime DeliveryEndDate, int PromotionScopeID, int PromotionTypeID, string PromotionDesc, int ShelfTypeID, int? FirstVolume, int? SecondVolume, int? ThirdVolume,
                        decimal? CustomerBudget, decimal? CustomerBudgetRemain, decimal? OUBudget, decimal? OUAppovedAmount, decimal? OUApprovingAmount, decimal? OUCompletedAmount, decimal? OUReimbursedAmount, decimal? OUBudgetRemain, decimal? OUBudgetRate,
                        string AttachedFileName, string RealAttachedFileName, string Remark, int PromotionPriceType, int ReimburseRequirements, string FlowTemplate, string FormApplyName)
        {
            SqlTransaction transaction = null;

            try {
                ////事务开始
                transaction = TableAdapterHelper.BeginTransaction(this.TAForm);
                TableAdapterHelper.SetTransaction(this.TAFormApply, transaction);
                TableAdapterHelper.SetTransaction(this.TAFormApplySKUDetail, transaction);
                TableAdapterHelper.SetTransaction(this.TAFormApplyExpenseDetail, transaction);
                TableAdapterHelper.SetTransaction(this.TAFormApplySplitRate, 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.PromotionApply;
                this.FormDataSet.Form.AddFormRow(formRow);
                this.TAForm.Update(formRow);

                //处理申请表的内容
                FormDS.FormApplyRow formApplyRow = this.FormDataSet.FormApply.NewFormApplyRow();
                formApplyRow.FormApplyID = formRow.FormID;
                formApplyRow.Period = DateTime.Parse(BeginPeriod.Year.ToString() + "-" + BeginPeriod.Month.ToString() + "-01");
                formApplyRow.BeginPeriod = DateTime.Parse(BeginPeriod.Year.ToString() + "-" + BeginPeriod.Month.ToString() + "-01");
                formApplyRow.EndPeriod = DateTime.Parse(EndPeriod.Year.ToString() + "-" + EndPeriod.Month.ToString() + "-01");
                formApplyRow.ShopID = ShopID;
                formApplyRow.CustomerID = CustomerID;
                formApplyRow.PaymentTypeID = PaymentTypeID;
                formApplyRow.ExpenseSubCategoryID = ExpenseSubCategoryID;
                if (ContractNo != "") {
                    formApplyRow.ContractNo = ContractNo;
                }
                formApplyRow.PromotionBeginDate = PromotionBeginDate;
                formApplyRow.PromotionEndDate = PromotionEndDate;
                formApplyRow.DeliveryBeginDate = DeliveryBeginDate;
                formApplyRow.DeliveryEndDate = DeliveryEndDate;
                formApplyRow.PromotionScopeID = PromotionScopeID;
                formApplyRow.PromotionTypeID = PromotionTypeID;
                if (PromotionDesc != "") {
                    formApplyRow.PromotionDesc = PromotionDesc;
                }
                formApplyRow.ShelfTypeID = ShelfTypeID;
                if (FirstVolume != null) {
                    formApplyRow.FirstVolume = FirstVolume.GetValueOrDefault();
                }
                if (SecondVolume != null) {
                    formApplyRow.SecondVolume = SecondVolume.GetValueOrDefault();
                }
                if (ThirdVolume != null) {
                    formApplyRow.ThirdVolume = ThirdVolume.GetValueOrDefault();
                }
                if (CustomerBudget != null) {
                    formApplyRow.CustomerBudget = CustomerBudget.GetValueOrDefault();
                }
                if (CustomerBudgetRemain != null) {
                    formApplyRow.CustomerBudgetRemain = CustomerBudgetRemain.GetValueOrDefault();
                }
                if (OUBudget != null) {
                    formApplyRow.OUBudget = OUBudget.GetValueOrDefault();
                }
                if (OUAppovedAmount != null) {
                    formApplyRow.OUAppovedAmount = OUAppovedAmount.GetValueOrDefault();
                }
                if (OUApprovingAmount != null) {
                    formApplyRow.OUApprovingAmount = OUApprovingAmount.GetValueOrDefault();
                }
                if (OUCompletedAmount != null) {
                    formApplyRow.OUCompletedAmount = OUCompletedAmount.GetValueOrDefault();
                }
                if (OUReimbursedAmount != null) {
                    formApplyRow.OUReimbursedAmount = OUReimbursedAmount.GetValueOrDefault();
                }
                if (OUBudgetRemain != null) {
                    formApplyRow.OUBudgetRemain = OUBudgetRemain.GetValueOrDefault();
                }
                if (OUBudgetRate != null) {
                    formApplyRow.OUBudgetRate = OUBudgetRate.GetValueOrDefault();
                }
                if (AttachedFileName != null && AttachedFileName != string.Empty) {
                    formApplyRow.AttachedFileName = AttachedFileName;
                }
                if (RealAttachedFileName != null && RealAttachedFileName != string.Empty) {
                    formApplyRow.RealAttachedFileName = RealAttachedFileName;
                }
                if (Remark != null && Remark != string.Empty) {
                    formApplyRow.Remark = Remark;
                }
                formApplyRow.FormApplyName = FormApplyName;
                formApplyRow.PromotionPriceType = PromotionPriceType;
                formApplyRow.ReimburseRequirements = ReimburseRequirements;

                formApplyRow.Amount = 0;//先赋默认值
                formApplyRow.IsClose = false;
                formApplyRow.IsComplete = false;
                formApplyRow.IsAutoSplit = false;
                this.FormDataSet.FormApply.AddFormApplyRow(formApplyRow);
                this.TAFormApply.Update(formApplyRow);

                //处理明细
                decimal totalAmount = 0;//计算总申请金额
                if (RejectedFormID != null) {
                    FormDS.FormApplyExpenseDetailDataTable newExpenseTable = new FormDS.FormApplyExpenseDetailDataTable();
                    foreach (FormDS.FormApplySKUDetailRow skuRow in this.FormDataSet.FormApplySKUDetail) {
                        if (skuRow.RowState != System.Data.DataRowState.Deleted) {
                            FormDS.FormApplySKUDetailDataTable newSKUTable = new FormDS.FormApplySKUDetailDataTable();
                            FormDS.FormApplySKUDetailRow newSKURow = newSKUTable.NewFormApplySKUDetailRow();
                            newSKURow.FormApplyID = formApplyRow.FormApplyID;
                            newSKURow.SKUID = skuRow.SKUID;
                            newSKURow.SupplyPrice = skuRow.SupplyPrice;
                            newSKURow.PromotionPrice = skuRow.PromotionPrice;
                            newSKURow.BuyQuantity = skuRow.BuyQuantity;
                            newSKURow.GiveQuantity = skuRow.GiveQuantity;
                            newSKURow.EstimatedSaleVolume = skuRow.EstimatedSaleVolume;
                            if (!skuRow.IsAmountNull()) {
                                newSKURow.Amount = skuRow.Amount;
                            }
                            if (!skuRow.IsRemarkNull()) {
                                newSKURow.Remark = skuRow.Remark;
                            }
                            newSKUTable.AddFormApplySKUDetailRow(newSKURow);
                            this.TAFormApplySKUDetail.Update(newSKUTable);
                            int newID = newSKURow.FormApplySKUDetailID;
                            FormDS.FormApplyExpenseDetailRow[] dr = (FormDS.FormApplyExpenseDetailRow[])this.FormDataSet.FormApplyExpenseDetail.Select("FormApplySKUDetailID = " + skuRow.FormApplySKUDetailID.ToString());
                            for (int i = 0; i < dr.Length; i++) {
                                FormDS.FormApplyExpenseDetailRow newExpenseRow = newExpenseTable.NewFormApplyExpenseDetailRow();
                                newExpenseRow.FormApplySKUDetailID = newID;
                                newExpenseRow.ExpenseItemID = dr[i].ExpenseItemID;
                                newExpenseRow.Amount = dr[i].Amount;
                                newExpenseRow.PackageUnitPrice = dr[i].PackageUnitPrice;
                                newExpenseRow.RepeatFormInfo = UtilityBLL.GenerateRepeatFormStr(this.TAForm.GetRepeatFormApplyNo(formApplyRow.PromotionBeginDate, formApplyRow.PromotionEndDate, newExpenseRow.ExpenseItemID, formApplyRow.ShopID, formApplyRow.FormApplyID));
                                newExpenseTable.AddFormApplyExpenseDetailRow(newExpenseRow);
                                if (dr[i].RowState != DataRowState.Deleted) {
                                    totalAmount += dr[i].Amount;
                                }
                            }
                        }
                    }
                    this.TAFormApplyExpenseDetail.Update(newExpenseTable);
                } else {
                    foreach (FormDS.FormApplySKUDetailRow skuRow in this.FormDataSet.FormApplySKUDetail) {
                        // 与父表绑定
                        if (skuRow.RowState != DataRowState.Deleted) {
                            skuRow.FormApplyID = formApplyRow.FormApplyID;
                            int oldID = skuRow.FormApplySKUDetailID;
                            this.TAFormApplySKUDetail.Update(skuRow);
                            int newID = skuRow.FormApplySKUDetailID;
                            FormDS.FormApplyExpenseDetailRow[] dr = (FormDS.FormApplyExpenseDetailRow[])this.FormDataSet.FormApplyExpenseDetail.Select("FormApplySKUDetailID = " + oldID.ToString());
                            for (int i = 0; i < dr.Length; i++) {
                                dr[i].FormApplySKUDetailID = newID;
                                dr[i].PackageUnitPrice = dr[i].Amount / skuRow.EstimatedSaleVolume;
                                if (dr[i].RowState != DataRowState.Deleted) {
                                    totalAmount += dr[i].Amount;
                                }
                                dr[i].RepeatFormInfo = UtilityBLL.GenerateRepeatFormStr(this.TAForm.GetRepeatFormApplyNo(formApplyRow.PromotionBeginDate, formApplyRow.PromotionEndDate, dr[i].ExpenseItemID, formApplyRow.ShopID, formApplyRow.FormApplyID));
                            }
                        }
                    }
                    this.TAFormApplyExpenseDetail.Update(this.FormDataSet.FormApplyExpenseDetail);
                }

                //分摊比例
                foreach (FormDS.FormApplySplitRateRow item in FormDataSet.FormApplySplitRate) {
                    item.FormApplyID = formApplyRow.FormApplyID;
                }
                this.TAFormApplySplitRate.Update(FormDataSet.FormApplySplitRate);

                formApplyRow.Amount = totalAmount;
                TAFormApply.Update(formApplyRow);

                // 正式提交或草稿

                Dictionary<string, object> dic = new Dictionary<string, object>();
                dic["Apply_Amount"] = totalAmount;
                //dic["Dept"] = new AuthorizationDSTableAdapters.OrganizationUnitTableAdapter().GetOrganizationUnitCodeByOrganizationUnitID(formRow.OrganizationUnitID)[0].OrganizationUnitCode;
                dic["Expense_Category"] = getExpenseCategoryIDByExpenseSubCategoryID(ExpenseSubCategoryID).ToString();//此处待改动(目前市场部的ID为7)
                APHelper AP = new APHelper();
                new APFlowBLL().ApplyForm(AP, TAForm, RejectedFormID, formRow, OrganizationUnitID, FlowTemplate, StatusID, dic);

                transaction.Commit();
            } catch (ApplicationException ex) {
                transaction.Rollback();
                throw ex;
            } catch (Exception ex) {
                transaction.Rollback();
                throw new ApplicationException("Save Fail!" + ex.ToString());
            } finally {
                transaction.Dispose();
            }
        }
コード例 #18
0
ファイル: FormVendorBLL.cs プロジェクト: hijoy/CPL_ERS
        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();
            }
        }
コード例 #19
0
ファイル: SalesApplyBLL.cs プロジェクト: hijoy/VSL_ERS
        public void UpdateFormApplyGeneral(int FormID, SystemEnums.FormStatus StatusID, SystemEnums.FormType FormTypeID, int ShopID, int PaymentTypeID, string ContractNo, DateTime PromotionBeginDate,
                        DateTime PromotionEndDate, int PromotionScopeID, int PromotionTypeID, string PromotionDesc, int ShelfTypeID, int? FirstVolume, int? SecondVolume, int? ThirdVolume, int? EstimatedSaleVolume,
                        decimal? CustomerBudget, decimal? CustomerBudgetRemain, decimal? OUBudget, decimal? OUAppovedAmount, decimal? OUApprovingAmount, decimal? OUCompletedAmount, decimal? OUReimbursedAmount,
                        decimal? OUBudgetRemain, decimal? OUBudgetRate, string AttachedFileName, string RealAttachedFileName, string Remark, int ReimburseRequirements, string FlowTemplate, string FormApplyName)
        {
            SqlTransaction transaction = null;

            try {
                //事务开始
                transaction = TableAdapterHelper.BeginTransaction(this.TAForm);
                TableAdapterHelper.SetTransaction(this.TAFormApply, transaction);
                TableAdapterHelper.SetTransaction(this.TAFormApplySKUDetail, transaction);
                TableAdapterHelper.SetTransaction(this.TAFormApplyExpenseDetail, transaction);
                TableAdapterHelper.SetTransaction(this.TAFormApplySplitRate, transaction);

                FormDS.FormRow formRow = this.TAForm.GetDataByID(FormID)[0];
                FormDS.FormApplyRow formApplyRow = this.TAFormApply.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;
                //申请单内容
                formApplyRow.ShopID = ShopID;
                formApplyRow.PaymentTypeID = PaymentTypeID;
                if (ContractNo != "") {
                    formApplyRow.ContractNo = ContractNo;
                }
                formApplyRow.PromotionBeginDate = PromotionBeginDate;
                formApplyRow.PromotionEndDate = PromotionEndDate;
                formApplyRow.PromotionScopeID = PromotionScopeID;
                formApplyRow.PromotionTypeID = PromotionTypeID;
                if (PromotionDesc != "") {
                    formApplyRow.PromotionDesc = PromotionDesc;
                }
                formApplyRow.ShelfTypeID = ShelfTypeID;
                if (FirstVolume != null) {
                    formApplyRow.FirstVolume = FirstVolume.GetValueOrDefault();
                }
                if (SecondVolume != null) {
                    formApplyRow.SecondVolume = SecondVolume.GetValueOrDefault();
                }
                if (ThirdVolume != null) {
                    formApplyRow.ThirdVolume = ThirdVolume.GetValueOrDefault();
                }
                if (EstimatedSaleVolume != null) {
                    formApplyRow.PackageUnitPrice = EstimatedSaleVolume.GetValueOrDefault();
                }
                if (CustomerBudget != null) {
                    formApplyRow.CustomerBudget = CustomerBudget.GetValueOrDefault();
                }
                if (CustomerBudgetRemain != null) {
                    formApplyRow.CustomerBudgetRemain = CustomerBudgetRemain.GetValueOrDefault();
                }
                if (OUBudget != null) {
                    formApplyRow.OUBudget = OUBudget.GetValueOrDefault();
                }
                if (OUAppovedAmount != null) {
                    formApplyRow.OUAppovedAmount = OUAppovedAmount.GetValueOrDefault();
                }
                if (OUApprovingAmount != null) {
                    formApplyRow.OUApprovingAmount = OUApprovingAmount.GetValueOrDefault();
                }
                if (OUCompletedAmount != null) {
                    formApplyRow.OUCompletedAmount = OUCompletedAmount.GetValueOrDefault();
                }
                if (OUReimbursedAmount != null) {
                    formApplyRow.OUReimbursedAmount = OUReimbursedAmount.GetValueOrDefault();
                }
                if (OUBudgetRemain != null) {
                    formApplyRow.OUBudgetRemain = OUBudgetRemain.GetValueOrDefault();
                }
                if (OUBudgetRate != null) {
                    formApplyRow.OUBudgetRate = OUBudgetRate.GetValueOrDefault();
                }
                if (AttachedFileName != null && AttachedFileName != string.Empty) {
                    formApplyRow.AttachedFileName = AttachedFileName;
                }
                if (RealAttachedFileName != null && RealAttachedFileName != string.Empty) {
                    formApplyRow.RealAttachedFileName = RealAttachedFileName;
                }
                if (Remark != null && Remark != string.Empty) {
                    formApplyRow.Remark = Remark;
                }
                formApplyRow.FormApplyName = FormApplyName;
                formApplyRow.ReimburseRequirements = ReimburseRequirements;

                this.TAForm.Update(formRow);
                this.TAFormApply.Update(formApplyRow);

                ArrayList deletedSKURows = new ArrayList();//save sku rows and expense rows that not deleted
                decimal totalAmount = 0;//计算总申请金额
                //先删除所有明细记录
                //FormDS.FormApplyExpenseDetailDataTable deleteExpenseTable = this.TAFormApplyExpenseDetail.GetDataByFormApplyID(formApplyRow.FormApplyID);
                //foreach (FormDS.FormApplyExpenseDetailRow deleteExpenseRow in deleteExpenseTable) {
                //    deleteExpenseRow.Delete();
                //}
                //this.TAFormApplyExpenseDetail.Update(deleteExpenseTable);

                //FormDS.FormApplySKUDetailDataTable deleteSKUTable = this.TAFormApplySKUDetail.GetDataByFormApplyID(formApplyRow.FormApplyID);
                //foreach (FormDS.FormApplySKUDetailRow deleteSKURow in deleteSKUTable) {
                //    deleteSKURow.Delete();
                //}
                //this.TAFormApplySKUDetail.Update(deleteSKUTable);

                this.TAFormApplyExpenseDetail.DeleteByFormApplyID(FormID);
                this.TAFormApplySKUDetail.DeleteByFormApplyID(FormID);

                //再插入新的表
                foreach (FormDS.FormApplyDetailViewRow viewRow in this.FormDataSet.FormApplyDetailView) {
                    if (viewRow.RowState != DataRowState.Deleted) {
                        FormDS.FormApplySKUDetailRow skuRow = this.FormDataSet.FormApplySKUDetail.NewFormApplySKUDetailRow();
                        skuRow.FormApplyID = formApplyRow.FormApplyID;
                        skuRow.SKUID = viewRow.SKUID;
                        skuRow.Remark = viewRow.Remark;
                        this.FormDataSet.FormApplySKUDetail.AddFormApplySKUDetailRow(skuRow);
                        this.TAFormApplySKUDetail.Update(skuRow);

                        FormDS.FormApplyExpenseDetailRow expenseRow = this.FormDataSet.FormApplyExpenseDetail.NewFormApplyExpenseDetailRow();
                        expenseRow.FormApplySKUDetailID = skuRow.FormApplySKUDetailID;
                        expenseRow.ExpenseItemID = viewRow.ExpenseItemID;
                        expenseRow.Amount = viewRow.Amount;
                        expenseRow.RepeatFormInfo = UtilityBLL.GenerateRepeatFormStr(this.TAForm.GetRepeatFormApplyNo(formApplyRow.PromotionBeginDate, formApplyRow.PromotionEndDate, expenseRow.ExpenseItemID, formApplyRow.ShopID, formApplyRow.FormApplyID));
                        this.FormDataSet.FormApplyExpenseDetail.AddFormApplyExpenseDetailRow(expenseRow);
                        this.TAFormApplyExpenseDetail.Update(expenseRow);

                        totalAmount += viewRow.Amount;
                    }
                }

                this.TAFormApplySplitRate.Update(FormDataSet.FormApplySplitRate);

                formApplyRow.Amount = totalAmount;
                if (!formApplyRow.IsEstimatedSaleVolumeNull()) {
                    formApplyRow.PackageUnitPrice = decimal.Round(formApplyRow.Amount / formApplyRow.EstimatedSaleVolume, 2);
                }
                this.TAFormApply.Update(formApplyRow);

                // 正式提交或草稿

                Dictionary<string, object> dic = new Dictionary<string, object>();
                dic["Apply_Amount"] = totalAmount;
                //  dic["Dept"] = new AuthorizationDSTableAdapters.OrganizationUnitTableAdapter().GetOrganizationUnitCodeByOrganizationUnitID(formRow.OrganizationUnitID)[0].OrganizationUnitCode;
                dic["Expense_Category"] = getExpenseCategoryIDByExpenseSubCategoryID(formApplyRow.ExpenseSubCategoryID).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();
            }
        }
コード例 #20
0
ファイル: FormTEBLL.cs プロジェクト: hijoy/CPL_ERS
        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();
            }
        }
コード例 #21
0
ファイル: SalesApplyBLL.cs プロジェクト: hijoy/VSL_ERS
        public void AddFormApplyRebate(int? RejectedFormID, int UserID, int? ProxyUserID, int? ProxyPositionID, int OrganizationUnitID, int PositionID, SystemEnums.FormType FormTypeID, SystemEnums.FormStatus StatusID,
                        DateTime BeginPeriod, DateTime EndPeriod, int CustomerID, int ShopID, int PaymentTypeID, int ExpenseSubCategoryID, string ContractNo, decimal? CustomerBudget,
                        decimal? CustomerBudgetRemain, decimal? OUBudget, decimal? OUAppovedAmount, decimal? OUApprovingAmount, decimal? OUCompletedAmount, decimal? OUReimbursedAmount, decimal? OUBudgetRemain,
                        decimal? OUBudgetRate, string AttachedFileName, string RealAttachedFileName, string Remark, string FlowTemplate, string FormApplyName)
        {
            SqlTransaction transaction = null;

            try {
                //事务开始
                transaction = TableAdapterHelper.BeginTransaction(this.TAForm);
                TableAdapterHelper.SetTransaction(this.TAFormApply, transaction);
                TableAdapterHelper.SetTransaction(this.TAFormApplySKUDetail, transaction);
                TableAdapterHelper.SetTransaction(this.TAFormApplyExpenseDetail, 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.RebateApply;
                this.FormDataSet.Form.AddFormRow(formRow);
                this.TAForm.Update(formRow);

                //处理申请表的内容
                FormDS.FormApplyRow formApplyRow = this.FormDataSet.FormApply.NewFormApplyRow();
                formApplyRow.FormApplyID = formRow.FormID;
                formApplyRow.Period = DateTime.Parse(BeginPeriod.Year.ToString() + "-" + BeginPeriod.Month.ToString() + "-01");
                formApplyRow.BeginPeriod = DateTime.Parse(BeginPeriod.Year.ToString() + "-" + BeginPeriod.Month.ToString() + "-01");
                formApplyRow.EndPeriod = DateTime.Parse(EndPeriod.Year.ToString() + "-" + EndPeriod.Month.ToString() + "-01");
                formApplyRow.ShopID = ShopID;
                formApplyRow.CustomerID = CustomerID;
                formApplyRow.PaymentTypeID = PaymentTypeID;
                formApplyRow.ExpenseSubCategoryID = ExpenseSubCategoryID;
                if (ContractNo != "") {
                    formApplyRow.ContractNo = ContractNo;
                }
                if (CustomerBudget != null) {
                    formApplyRow.CustomerBudget = CustomerBudget.GetValueOrDefault();
                }
                if (CustomerBudgetRemain != null) {
                    formApplyRow.CustomerBudgetRemain = CustomerBudgetRemain.GetValueOrDefault();
                }
                if (OUBudget != null) {
                    formApplyRow.OUBudget = OUBudget.GetValueOrDefault();
                }
                if (OUAppovedAmount != null) {
                    formApplyRow.OUAppovedAmount = OUAppovedAmount.GetValueOrDefault();
                }
                if (OUApprovingAmount != null) {
                    formApplyRow.OUApprovingAmount = OUApprovingAmount.GetValueOrDefault();
                }
                if (OUCompletedAmount != null) {
                    formApplyRow.OUCompletedAmount = OUCompletedAmount.GetValueOrDefault();
                }
                if (OUReimbursedAmount != null) {
                    formApplyRow.OUReimbursedAmount = OUReimbursedAmount.GetValueOrDefault();
                }
                if (OUBudgetRemain != null) {
                    formApplyRow.OUBudgetRemain = OUBudgetRemain.GetValueOrDefault();
                }
                if (OUBudgetRate != null) {
                    formApplyRow.OUBudgetRate = OUBudgetRate.GetValueOrDefault();
                }
                if (AttachedFileName != null && AttachedFileName != string.Empty) {
                    formApplyRow.AttachedFileName = AttachedFileName;
                }
                if (RealAttachedFileName != null && RealAttachedFileName != string.Empty) {
                    formApplyRow.RealAttachedFileName = RealAttachedFileName;
                }
                if (Remark != null && Remark != string.Empty) {
                    formApplyRow.Remark = Remark;
                }

                formApplyRow.Amount = 0;//先赋默认值
                formApplyRow.IsClose = false;
                formApplyRow.IsComplete = false;
                formApplyRow.IsAutoSplit = false;

                formApplyRow.FormApplyName = FormApplyName;
                this.FormDataSet.FormApply.AddFormApplyRow(formApplyRow);
                this.TAFormApply.Update(formApplyRow);

                //处理明细
                decimal totalAmount = 0;//计算总申请金额
                //处理子表
                foreach (FormDS.FormApplyDetailViewRow viewRow in this.FormDataSet.FormApplyDetailView) {
                    if (viewRow.RowState != DataRowState.Deleted) {
                        FormDS.FormApplySKUDetailRow skuRow = this.FormDataSet.FormApplySKUDetail.NewFormApplySKUDetailRow();
                        skuRow.FormApplyID = formApplyRow.FormApplyID;
                        skuRow.SKUID = viewRow.SKUID;
                        if (!viewRow.IsSalesAmountNull()) {
                            skuRow.SalesAmount = viewRow.SalesAmount;
                        }
                        this.FormDataSet.FormApplySKUDetail.AddFormApplySKUDetailRow(skuRow);
                        this.TAFormApplySKUDetail.Update(skuRow);

                        FormDS.FormApplyExpenseDetailRow expenseRow = this.FormDataSet.FormApplyExpenseDetail.NewFormApplyExpenseDetailRow();
                        expenseRow.FormApplySKUDetailID = skuRow.FormApplySKUDetailID;
                        expenseRow.ExpenseItemID = viewRow.ExpenseItemID;
                        expenseRow.Amount = viewRow.Amount;
                        this.FormDataSet.FormApplyExpenseDetail.AddFormApplyExpenseDetailRow(expenseRow);
                        this.TAFormApplyExpenseDetail.Update(expenseRow);

                        totalAmount += viewRow.Amount;
                    }
                }
                formApplyRow.Amount = totalAmount;
                TAFormApply.Update(formApplyRow);

                // 正式提交或草稿

                Dictionary<string, object> dic = new Dictionary<string, object>();
                dic["Apply_Amount"] = totalAmount;
                // dic["Dept"] = new AuthorizationDSTableAdapters.OrganizationUnitTableAdapter().GetOrganizationUnitCodeByOrganizationUnitID(formRow.OrganizationUnitID)[0].OrganizationUnitCode;
                dic["Expense_Category"] = getExpenseCategoryIDByExpenseSubCategoryID(formApplyRow.ExpenseSubCategoryID).ToString();//此处待改动
                APHelper AP = new APHelper();
                new APFlowBLL().ApplyForm(AP, TAForm, null, formRow, formRow.OrganizationUnitID, FlowTemplate, StatusID, dic);

                transaction.Commit();
            } catch (ApplicationException ex) {
                transaction.Rollback();
                throw ex;
            } catch (Exception ex) {
                transaction.Rollback();
                throw new ApplicationException("Save Fail!" + ex.ToString());
            } finally {
                transaction.Dispose();
            }
        }
コード例 #22
0
ファイル: FormRDBLL.cs プロジェクト: hijoy/CPL_ERS
        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();
            }
        }
コード例 #23
0
ファイル: FormInviteBLL.cs プロジェクト: hijoy/CPL_ERS
        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,String
CustomerName,String
AttenderNames,String
BusinessRelation,String
Place,String
OccuredDate, DateTime
Purpose,String
InviteType,String
CurrencyID,decimal?
ExchangeRate,decimal?
AmountRMB)
        {
            SqlTransaction transaction = null;
            try {
                transaction = TableAdapterHelper.BeginTransaction(this.TAForm);
                TableAdapterHelper.SetTransaction(this.TAFormInviteApply, 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.TravelReimburseApply;
                this.TAForm.Update(formRow);

                //处理申请表的内容
                FormDS.FormInviteApplyDataTable tbFormInvite = new FormDS.FormInviteApplyDataTable();
                FormDS.FormInviteApplyRow formInviteApplyRow = tbFormInvite.NewFormInviteApplyRow();
                //formInviteApplyRow.FormTravelReimburseID = formRow.FormID;
                //formInviteApplyRow.Period = Period.GetValueOrDefault();
                //formInviteApplyRow.Amount = decimal.Zero;
                //formInviteApplyRow.Remark = Remark;

                //decimal[] calculateAssistant = this.GetPersonalBudgetByOUID(OrganizationUnitID, Period);
                //formTravelReimburseRow.TotalBudget = calculateAssistant[0];
                //formTravelReimburseRow.ApprovedAmount = calculateAssistant[1];
                //formTravelReimburseRow.ApprovingAmount = calculateAssistant[2];
                //formTravelReimburseRow.RemainAmount = calculateAssistant[3];

                //this.FormDataSet.FormTravelReimburse.AddFormTravelReimburseRow(formTravelReimburseRow);
                //this.TAFormTravelReimburse.Update(formTravelReimburseRow);

                ////明细表
                //decimal totalAmount = 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;
                //            }
                //            totalAmount += newDetailRow.Cost;
                //            newDetailTable.AddFormTravelReimburseDetailRow(newDetailRow);
                //        }
                //    }
                //    this.TAFormTravelReimburseDetail.Update(newDetailTable);
                //}

                //// 正式提交或草稿
                //if (StatusID == SystemEnums.FormStatus.Awaiting) {

                //    //如果申请总额大于可用余额,不能提交
                //    if (formTravelReimburseRow.Amount > calculateAssistant[3]) {//如果是减少预算,要做检查
                //        throw new ApplicationException("申请报销总额超出部门可用余额,不能提交!");
                //    }
                //}
                //formTravelReimburseRow.Amount = totalAmount;
                //this.TAFormTravelReimburse.Update(formTravelReimburseRow);
                //Dictionary<string, object> dic = new Dictionary<string, object>();
                //dic["Apply_Amount"] = totalAmount;//金额

                //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();
            }
        }
コード例 #24
0
ファイル: FormRDBLL.cs プロジェクト: hijoy/CPL_ERS
        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();
            }
        }
コード例 #25
0
ファイル: FormSaleBLL.cs プロジェクト: hijoy/CPL_ERS
        public void AddPaymentFreeGoods(int? RejectedFormID, int UserID, int? ProxyUserID, int? ProxyPositionID, int OrganizationUnitID, int PositionID, SystemEnums.FormType FormTypeID, SystemEnums.FormStatus StatusID,
                        SystemEnums.PageType PageType, int FormSaleSettlementID, int InvoiceStatusID, int PaymentTypeID, string Remark, string AttachedFileName, string RealAttachedFileName, int CostCenterID, int? VendorID)
        {
            SqlTransaction transaction = null;
            try {
                //事务开始
                transaction = TableAdapterHelper.BeginTransaction(this.TAForm);
                TableAdapterHelper.SetTransaction(this.TAFormSalePayment, transaction);
                TableAdapterHelper.SetTransaction(this.TAFormSalePaymentDetail, transaction);
                TableAdapterHelper.SetTransaction(this.TAFormSalePaymentFreeGoods, 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.FormSalePaymentRow formPaymentRow = this.FormDataSet.FormSalePayment.NewFormSalePaymentRow();
                formPaymentRow.FormSalePaymentID = formRow.FormID;
                formPaymentRow.FormSaleSettlementID = FormSaleSettlementID;
                formPaymentRow.InvoiceStatusID = InvoiceStatusID;
                formPaymentRow.PaymentTypeID = PaymentTypeID;
                if (Remark != null && Remark != string.Empty) {
                    formPaymentRow.Remark = Remark;
                }
                if (AttachedFileName != null && AttachedFileName != string.Empty) {
                    formPaymentRow.AttachedFileName = AttachedFileName;
                }
                if (RealAttachedFileName != null && RealAttachedFileName != string.Empty) {
                    formPaymentRow.RealAttachedFileName = RealAttachedFileName;
                }
                formPaymentRow.AmountRMB = 0;
                formPaymentRow.IsAdvanced = false;
                if (VendorID != null) {
                    formPaymentRow.VendorID = VendorID.GetValueOrDefault();
                }

                this.FormDataSet.FormSalePayment.AddFormSalePaymentRow(formPaymentRow);
                this.TAFormSalePayment.Update(formPaymentRow);

                //处理报销明细
                decimal totalAmountRMB = 0;
                FormDS.FormSalePaymentDetailDataTable newDetailTable = new FormDS.FormSalePaymentDetailDataTable();
                foreach (FormDS.FormSalePaymentDetailRow detailRow in this.FormDataSet.FormSalePaymentDetail) {
                    // 与父表绑定
                    if (detailRow.RowState != DataRowState.Deleted) {
                        totalAmountRMB += detailRow.AmountRMB;
                        FormDS.FormSalePaymentDetailRow newDetailRow = newDetailTable.NewFormSalePaymentDetailRow();
                        newDetailRow.FormSalePaymentID = formPaymentRow.FormSalePaymentID;
                        newDetailRow.FormSaleApplyID = detailRow.FormSaleApplyID;
                        newDetailRow.FormSaleExpenseDetailID = detailRow.FormSaleExpenseDetailID;
                        newDetailRow.ApplyFormNo = detailRow.ApplyFormNo;
                        newDetailRow.ApplyPeriod = detailRow.ApplyPeriod;
                        if (!detailRow.IsApplyProjectNameNull()) {
                            newDetailRow.ApplyProjectName = detailRow.ApplyProjectName;
                        }
                        newDetailRow.ExpenseItemID = detailRow.ExpenseItemID;
                        if (!detailRow.IsShopNameNull()) {
                            newDetailRow.ShopName = detailRow.ShopName;
                        }
                        if (!detailRow.IsSKUIDNull()) {
                            newDetailRow.SKUID = detailRow.SKUID;
                        }
                        newDetailRow.ApplyAmount = detailRow.ApplyAmount;
                        newDetailRow.ApplyAmountRMB = detailRow.ApplyAmountRMB;
                        if (!detailRow.IsSettlementAmountNull()) {
                            newDetailRow.SettlementAmount = detailRow.SettlementAmount;
                        }
                        if (!detailRow.IsPayedAmountNull()) {
                            newDetailRow.PayedAmount = detailRow.PayedAmount;
                        }
                        if (!detailRow.IsRemainAmountNull()) {
                            newDetailRow.RemainAmount = detailRow.RemainAmount;
                        }
                        newDetailRow.AmountRMB = detailRow.AmountRMB;

                        newDetailTable.AddFormSalePaymentDetailRow(newDetailRow);
                    }
                }
                this.TAFormSalePaymentDetail.Update(newDetailTable);

                formPaymentRow.AmountRMB = totalAmountRMB;
                this.TAFormSalePayment.Update(formPaymentRow);

                //处理free goods明细
                if (RejectedFormID != null) {
                    FormDS.FormSaleSettlementRow settlement = this.GetFormSaleSettlementByID(formPaymentRow.FormSaleSettlementID);
                    MasterData.CustomerRow customer = new MasterDataBLL().GetCustomerById(settlement.CustomerID)[0];
                    FormDS.FormSalePaymentFreeGoodsDataTable newFGTable = new FormDS.FormSalePaymentFreeGoodsDataTable();
                    foreach (FormDS.FormSalePaymentFreeGoodsRow detailFGRow in this.FormDataSet.FormSalePaymentFreeGoods) {
                        // 与父表绑定
                        if (detailFGRow.RowState != DataRowState.Deleted) {
                            FormDS.FormSalePaymentFreeGoodsRow newDetailFGRow = newFGTable.NewFormSalePaymentFreeGoodsRow();
                            newDetailFGRow.FormSalePaymentID = formPaymentRow.FormSalePaymentID;
                            newDetailFGRow.SKUID = detailFGRow.SKUID;
                            newDetailFGRow.PackPerCase = detailFGRow.PackPerCase;
                            decimal deliveryPrice = new MasterDataBLL().GetSKUPriceByParameter(detailFGRow.SKUID, customer.CustomerTypeID, customer.CustomerChannelID);
                            newDetailFGRow.DeliveryPrice = deliveryPrice;
                            newDetailFGRow.Quantity = detailFGRow.Quantity;
                            newDetailFGRow.AmountRMB = decimal.Round(newDetailFGRow.Quantity * newDetailFGRow.DeliveryPrice, 2);
                            if (!detailFGRow.IsRemarkNull()) {
                                newDetailFGRow.Remark = detailFGRow.Remark;
                            }
                            newFGTable.AddFormSalePaymentFreeGoodsRow(newDetailFGRow);
                        }
                    }
                    this.TAFormSalePaymentFreeGoods.Update(newFGTable);
                } else {
                    foreach (FormDS.FormSalePaymentFreeGoodsRow detailFGRow in this.FormDataSet.FormSalePaymentFreeGoods) {
                        // 与父表绑定
                        if (detailFGRow.RowState != DataRowState.Deleted) {
                            detailFGRow.FormSalePaymentID = formPaymentRow.FormSalePaymentID;
                        }
                    }
                    this.TAFormSalePaymentFreeGoods.Update(this.FormDataSet.FormSalePaymentFreeGoods);
                }

                //作废之前的单据
                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;
                    MasterData.CustomerRow customer = new MasterDataBLL().GetCustomerById(this.TAFormSaleSettlement.GetDataByID(FormSaleSettlementID)[0].CustomerID)[0];
                    dic["CustomerChannel"] = new MasterDataBLL().GetCustomerChannelById(customer.CustomerChannelID)[0].CustomerChannelCode;
                    dic["KAType"] = customer.IsKaTypeNull() ? "" : customer.KaType;
                    dic["PaymentTypeID"] = PaymentTypeID;
                    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();
            }
        }
コード例 #26
0
        public void AddFormBudgetAllocation(int?RejectedFormID, int UserID, int?ProxyUserID, int?ProxyPositionID, int OrganizationUnitID, int PositionID, SystemEnums.FormType FormTypeID,
                                            SystemEnums.FormStatus StatusID, string Remark, string AttachFileName, string RealAttachFileName, string FlowTemplate)
        {
            SqlTransaction transaction = null;

            try {
                transaction = TableAdapterHelper.BeginTransaction(this.TAForm);
                TableAdapterHelper.SetTransaction(this.TAFormBudgetAllocation, transaction);
                TableAdapterHelper.SetTransaction(this.TAFormBudgetAllocationDetail, transaction);

                FormDS.FormRow formRow = this.FormDataSet.Form.NewFormRow();
                if (RejectedFormID != null)
                {
                    formRow.RejectedFormID = RejectedFormID.GetValueOrDefault();
                }
                formRow.UserID = UserID;
                UtilityBLL utility = new UtilityBLL();
                if (StatusID == SystemEnums.FormStatus.Awaiting)
                {
                    string formTypeString = utility.GetFormTypeString((int)FormTypeID);
                    formRow.FormNo = utility.GetFormNo(formTypeString);
                }
                else
                {
                    formRow.SetFormNoNull();
                }
                if (ProxyUserID != null)
                {
                    formRow.ProxyUserID = ProxyUserID.GetValueOrDefault();
                }
                if (ProxyPositionID != null)
                {
                    formRow.ProxyPositionID = ProxyPositionID.GetValueOrDefault();
                }
                formRow.OrganizationUnitID = OrganizationUnitID;
                formRow.PositionID         = PositionID;
                formRow.FormTypeID         = (int)FormTypeID;
                formRow.StatusID           = (int)StatusID;
                formRow.SubmitDate         = DateTime.Now;
                formRow.LastModified       = DateTime.Now;
                formRow.InTurnUserIds      = "P"; //待改动
                formRow.InTurnPositionIds  = "P"; //待改动
                formRow.PageType           = (int)SystemEnums.PageType.BudgetAllocationApply;
                this.FormDataSet.Form.AddFormRow(formRow);
                this.TAForm.Update(formRow);

                //处理申请表的内容
                FormDS.FormBudgetAllocationRow formBudgetAllocationRow = this.FormDataSet.FormBudgetAllocation.NewFormBudgetAllocationRow();
                formBudgetAllocationRow.FormBudgetAllocationID = formRow.FormID;
                formBudgetAllocationRow.Amount             = decimal.Zero;
                formBudgetAllocationRow.AttachFileName     = AttachFileName;
                formBudgetAllocationRow.RealAttachFileName = RealAttachFileName;
                formBudgetAllocationRow.Remark             = Remark;


                this.FormDataSet.FormBudgetAllocation.AddFormBudgetAllocationRow(formBudgetAllocationRow);
                this.TAFormBudgetAllocation.Update(formBudgetAllocationRow);

                //明细表
                decimal totalAmount    = 0; //计算总申请金额
                decimal totalInAmount  = 0; //计算调入总金额
                decimal totalOutAmount = 0; //计算调出总金额

                if (RejectedFormID != null)
                {
                    FormDS.FormBudgetAllocationDetailDataTable newDetailTable = new FormDS.FormBudgetAllocationDetailDataTable();
                    foreach (FormDS.FormBudgetAllocationDetailRow detailRow in this.FormDataSet.FormBudgetAllocationDetail)
                    {
                        if (detailRow.RowState != System.Data.DataRowState.Deleted)
                        {
                            FormDS.FormBudgetAllocationDetailRow newDetailRow = newDetailTable.NewFormBudgetAllocationDetailRow();
                            newDetailRow.FormBudgetAllocationID = formBudgetAllocationRow.FormBudgetAllocationID;
                            newDetailRow.CustomerID             = detailRow.CustomerID;
                            newDetailRow.CustomerName           = detailRow.CustomerName;
                            newDetailRow.ExpenseItemID          = detailRow.ExpenseItemID;
                            newDetailRow.ExpenseItemName        = detailRow.ExpenseItemName;
                            newDetailRow.Period           = detailRow.Period;
                            newDetailRow.OriginalBudget   = detailRow.OriginalBudget;
                            newDetailRow.NormalBudget     = detailRow.NormalBudget;
                            newDetailRow.AdjustBudget     = detailRow.AdjustBudget;
                            newDetailRow.TotalBudget      = detailRow.TotalBudget;
                            newDetailRow.TransferBudget   = detailRow.TransferBudget;
                            newDetailRow.AllocationType   = detailRow.AllocationType;
                            newDetailRow.BudgetSalesFeeId = detailRow.BudgetSalesFeeId;
                            totalAmount += newDetailRow.TransferBudget;
                            if (detailRow.AllocationType == (int)SystemEnums.AllocationType.In)
                            {
                                totalInAmount += detailRow.TransferBudget;
                            }
                            else
                            {
                                totalOutAmount += detailRow.TransferBudget;
                            }
                            newDetailTable.AddFormBudgetAllocationDetailRow(newDetailRow);
                        }
                    }
                    this.TAFormBudgetAllocationDetail.Update(newDetailTable);
                }
                else
                {
                    foreach (FormDS.FormBudgetAllocationDetailRow detailRow in this.FormDataSet.FormBudgetAllocationDetail)
                    {
                        // 与父表绑定
                        if (detailRow.RowState != DataRowState.Deleted)
                        {
                            detailRow.FormBudgetAllocationID = formBudgetAllocationRow.FormBudgetAllocationID;
                            if (detailRow.AllocationType == (int)SystemEnums.AllocationType.In)
                            {
                                totalInAmount += detailRow.TransferBudget;
                            }
                            else
                            {
                                totalOutAmount += detailRow.TransferBudget;
                            }
                            totalAmount += detailRow.TransferBudget;
                        }
                    }
                    this.TAFormBudgetAllocationDetail.Update(this.FormDataSet.FormBudgetAllocationDetail);
                }

                formBudgetAllocationRow.Amount = totalOutAmount;
                this.TAFormBudgetAllocation.Update(formBudgetAllocationRow);
                // 正式提交或草稿

                Dictionary <string, object> dic = new Dictionary <string, object>();
                dic["Apply_Amount"] = totalOutAmount;    //调拨金额

                APHelper AP = new APHelper();
                new APFlowBLL().ApplyForm(AP, TAForm, RejectedFormID, formRow, OrganizationUnitID, FlowTemplate, StatusID, dic);

                transaction.Commit();
            } catch (Exception ex) {
                transaction.Rollback();
                throw new ApplicationException(ex.Message);
            } finally {
                transaction.Dispose();
            }
        }
コード例 #27
0
ファイル: FormSaleBLL.cs プロジェクト: hijoy/CPL_ERS
        public void UpdateActivitySettlement(int FormID, SystemEnums.FormType FormTypeID, SystemEnums.FormStatus StatusID, string AttachedFileName, string RealAttachedFileName, string Remark, int PaymentTypeID)
        {
            SqlTransaction transaction = null;
            try {
                //事务开始
                transaction = TableAdapterHelper.BeginTransaction(this.TAForm);
                TableAdapterHelper.SetTransaction(this.TAFormSaleSettlement, transaction);
                TableAdapterHelper.SetTransaction(this.TAFormSettlementExpenseDetail, transaction);
                TableAdapterHelper.SetTransaction(this.TAFormSettlementSKUDetail, transaction);

                FormDS.FormRow formRow = this.TAForm.GetDataByID(FormID)[0];
                FormDS.FormSaleSettlementRow formSettleRow = this.TAFormSaleSettlement.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);

                //处理settlement的内容
                if (AttachedFileName != null && AttachedFileName != string.Empty) {
                    formSettleRow.AttachedFileName = AttachedFileName;
                } else {
                    formSettleRow.SetAttachedFileNameNull();
                }
                if (RealAttachedFileName != null && RealAttachedFileName != string.Empty) {
                    formSettleRow.RealAttachedFileName = RealAttachedFileName;
                } else {
                    formSettleRow.SetRealAttachedFileNameNull();
                }
                if (Remark != null && Remark != string.Empty) {
                    formSettleRow.Remark = Remark;
                }
                formSettleRow.PaymentTypeID = PaymentTypeID;
                this.TAFormSaleSettlement.Update(formSettleRow);

                //处理明细,先产品表
                decimal totalForecastOrderAmount = 0;
                decimal totalActualOrderAmount = 0;
                foreach (FormDS.FormSettlementSKUDetailRow skuRow in this.FormDataSet.FormSettlementSKUDetail) {
                    if (skuRow.RowState != DataRowState.Deleted) {
                        skuRow.FormSaleSettlementID = formSettleRow.FormSaleSettlementID;
                        totalForecastOrderAmount = totalForecastOrderAmount + skuRow.ForecastOrderAmount;
                        totalActualOrderAmount = totalActualOrderAmount + skuRow.ActualOrderAmount;
                    }
                }
                this.TAFormSettlementSKUDetail.Update(this.FormDataSet.FormSettlementSKUDetail);
                //费用项
                decimal totalAmountRMB = 0;
                decimal totalApplyAmountRMB = 0;
                foreach (FormDS.FormSettlementExpenseDetailRow expenseRow in this.FormDataSet.FormSettlementExpenseDetail) {
                    if (expenseRow.RowState != DataRowState.Deleted) {
                        expenseRow.FormSaleSettlementID = formSettleRow.FormSaleSettlementID;
                        totalAmountRMB = totalAmountRMB + expenseRow.AmountRMB;
                        totalApplyAmountRMB = totalApplyAmountRMB + expenseRow.ApplyAmountRMB;
                    }
                }
                this.TAFormSettlementExpenseDetail.Update(this.FormDataSet.FormSettlementExpenseDetail);

                formSettleRow.ForecastOrderAmount = totalForecastOrderAmount;
                formSettleRow.ApplyAmountRMB = totalApplyAmountRMB;
                if (totalForecastOrderAmount != 0) {
                    formSettleRow.CostBenefitRate = totalApplyAmountRMB / totalForecastOrderAmount * 100;
                } else {
                    formSettleRow.CostBenefitRate = 0;
                }
                formSettleRow.ActualOrderAmount = totalActualOrderAmount;
                formSettleRow.AmountRMB = totalAmountRMB;
                if (totalActualOrderAmount != 0) {
                    formSettleRow.ActualCostBenefitRate = totalAmountRMB / totalActualOrderAmount * 100;
                } else {
                    formSettleRow.ActualCostBenefitRate = 0;
                }

                this.TAFormSaleSettlement.Update(formSettleRow);

                // 正式提交
                if (StatusID == SystemEnums.FormStatus.Awaiting) {
                    Dictionary<string, object> dic = new Dictionary<string, object>();
                    dic["TotalAmount"] = totalAmountRMB;
                    MasterData.CustomerRow customer = new MasterDataBLL().GetCustomerById(formSettleRow.CustomerID)[0];
                    dic["CustomerChannel"] = new MasterDataBLL().GetCustomerChannelById(customer.CustomerChannelID)[0].CustomerChannelCode;
                    dic["KAType"] = customer.IsKaTypeNull() ? "" : customer.KaType;
                    dic["PaymentTypeID"] = PaymentTypeID;

                    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("Save Fail!" + ex.ToString());
            } finally {
                transaction.Dispose();
            }
        }
コード例 #28
0
ファイル: FormPurchaseBLL.cs プロジェクト: hijoy/CPL_ERS
        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();
            }
        }
コード例 #29
0
ファイル: FormSaleBLL.cs プロジェクト: hijoy/CPL_ERS
        public void UpdatePaymentFreeGoods(int FormID, SystemEnums.FormType FormTypeID, SystemEnums.FormStatus StatusID, int InvoiceStatusID, int PaymentTypeID,
                string Remark, string AttachedFileName, string RealAttachedFileName, int? VendorID)
        {
            SqlTransaction transaction = null;
            try {
                //事务开始
                transaction = TableAdapterHelper.BeginTransaction(this.TAForm);
                TableAdapterHelper.SetTransaction(this.TAFormSalePayment, transaction);
                TableAdapterHelper.SetTransaction(this.TAFormSalePaymentDetail, transaction);
                TableAdapterHelper.SetTransaction(this.TAFormSalePaymentFreeGoods, transaction);

                FormDS.FormRow formRow = this.TAForm.GetDataByID(FormID)[0];
                FormDS.FormSalePaymentRow formPaymentRow = this.TAFormSalePayment.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 (AttachedFileName != null && AttachedFileName != string.Empty) {
                    formPaymentRow.AttachedFileName = AttachedFileName;
                } else {
                    formPaymentRow.SetAttachedFileNameNull();
                }
                if (RealAttachedFileName != null && RealAttachedFileName != string.Empty) {
                    formPaymentRow.RealAttachedFileName = RealAttachedFileName;
                } else {
                    formPaymentRow.SetRealAttachedFileNameNull();
                }
                if (Remark != null && Remark != string.Empty) {
                    formPaymentRow.Remark = Remark;
                }
                formPaymentRow.InvoiceStatusID = InvoiceStatusID;
                formPaymentRow.PaymentTypeID = PaymentTypeID;
                if (VendorID != null) {
                    formPaymentRow.VendorID = VendorID.GetValueOrDefault();
                }
                this.TAFormSalePayment.Update(formPaymentRow);

                //处理明细
                decimal totalAmountRMB = 0;
                foreach (FormDS.FormSalePaymentDetailRow detailRow in this.FormDataSet.FormSalePaymentDetail) {
                    if (detailRow.RowState != DataRowState.Deleted) {
                        totalAmountRMB += detailRow.AmountRMB;
                        detailRow.FormSalePaymentID = formPaymentRow.FormSalePaymentID;
                    }
                }
                this.TAFormSalePaymentDetail.Update(this.FormDataSet.FormSalePaymentDetail);

                formPaymentRow.AmountRMB = totalAmountRMB;
                this.TAFormSalePayment.Update(formPaymentRow);

                foreach (FormDS.FormSalePaymentFreeGoodsRow detailFGRow in this.FormDataSet.FormSalePaymentFreeGoods) {
                    // 与父表绑定
                    if (detailFGRow.RowState != DataRowState.Deleted) {
                        detailFGRow.FormSalePaymentID = formPaymentRow.FormSalePaymentID;
                    }
                }
                this.TAFormSalePaymentFreeGoods.Update(this.FormDataSet.FormSalePaymentFreeGoods);

                // 正式提交
                if (StatusID == SystemEnums.FormStatus.Awaiting) {
                    Dictionary<string, object> dic = new Dictionary<string, object>();
                    dic["TotalAmount"] = totalAmountRMB;
                    MasterData.CustomerRow customer = new MasterDataBLL().GetCustomerById(this.TAFormSaleSettlement.GetDataByID(formPaymentRow.FormSaleSettlementID)[0].CustomerID)[0];
                    dic["CustomerChannel"] = new MasterDataBLL().GetCustomerChannelById(customer.CustomerChannelID)[0].CustomerChannelCode;
                    dic["KAType"] = customer.IsKaTypeNull() ? "" : customer.KaType;
                    dic["PaymentTypeID"] = PaymentTypeID;
                    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();
            }
        }
コード例 #30
0
ファイル: FormPurchaseBLL.cs プロジェクト: hijoy/CPL_ERS
        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();
            }
        }
コード例 #31
0
ファイル: FormSaleBLL.cs プロジェクト: hijoy/CPL_ERS
        public void UpdateSaleActivityApply(int FormID, SystemEnums.FormType FormTypeID, SystemEnums.FormStatus StatusID, decimal ExchangeRate, string ShopName, int? ShopCount, string ProjectName, string ProjectDesc,
                        string ApplyFileName, string ApplyRealFileName, int? DisplayTypeID, decimal? DisplayArea, bool IsDM, int? DiscountTypeID, DateTime? ActivityBeginDate, DateTime? ActivityEndDate,
                        DateTime? DeliveryBeginDate, DateTime? DeliveryEndDate, int? CostCenterID, decimal TotalBudget, decimal ApprovedAmount, decimal ApprovingAmount, decimal CompletedAmount, decimal ReimbursedAmount, decimal RemainBudget)
        {
            SqlTransaction transaction = null;

            try {
                //事务开始
                transaction = TableAdapterHelper.BeginTransaction(this.TAForm);
                TableAdapterHelper.SetTransaction(this.TAFormSaleApply, transaction);
                TableAdapterHelper.SetTransaction(this.TAFormSaleSKUDetail, transaction);
                TableAdapterHelper.SetTransaction(this.TAFormSaleExpenseDetail, transaction);

                FormDS.FormRow formRow = this.TAForm.GetDataByID(FormID)[0];
                FormDS.FormSaleApplyRow formApplyRow = this.TAFormSaleApply.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 (ShopName != null)
                    formApplyRow.ShopName = ShopName;
                if (ShopCount != null)
                    formApplyRow.ShopCount = ShopCount.GetValueOrDefault();
                if (ProjectName != null)
                    formApplyRow.ProjectName = ProjectName;
                if (ProjectDesc != null)
                    formApplyRow.ProjectDesc = ProjectDesc;
                if (ApplyFileName != null && ApplyFileName != string.Empty) {
                    formApplyRow.ApplyFileName = ApplyFileName;
                } else {
                    formApplyRow.SetApplyFileNameNull();
                }
                if (ApplyRealFileName != null && ApplyRealFileName != string.Empty) {
                    formApplyRow.ApplyRealFileName = ApplyRealFileName;
                } else {
                    formApplyRow.SetApplyRealFileNameNull();
                }
                if (DisplayTypeID != null)
                    formApplyRow.DisplayTypeID = DisplayTypeID.GetValueOrDefault();
                if (DisplayArea != null)
                    formApplyRow.DisplayArea = DisplayArea.GetValueOrDefault();
                formApplyRow.IsDM = IsDM;
                if (DiscountTypeID != null)
                    formApplyRow.DiscountTypeID = DiscountTypeID.GetValueOrDefault();
                if (ActivityBeginDate != null)
                    formApplyRow.ActivityBeginDate = ActivityBeginDate.GetValueOrDefault();
                if (ActivityEndDate != null)
                    formApplyRow.ActivityEndDate = ActivityEndDate.GetValueOrDefault();
                if (DeliveryBeginDate != null)
                    formApplyRow.DeliveryBeginDate = DeliveryBeginDate.GetValueOrDefault();
                if (DeliveryEndDate != null)
                    formApplyRow.DeliveryEndDate = DeliveryEndDate.GetValueOrDefault();

                formApplyRow.TotalBudget = TotalBudget;
                formApplyRow.ApprovedAmount = ApprovedAmount;
                formApplyRow.ApprovingAmount = ApprovingAmount;
                formApplyRow.CompletedAmount = CompletedAmount;
                formApplyRow.ReimbursedAmount = ReimbursedAmount;
                formApplyRow.RemainBudget = RemainBudget;

                this.TAFormSaleApply.Update(formApplyRow);

                //处理明细,先产品表
                decimal totalPriceDiscountAmountRMB = 0;//
                decimal totalForecastOrderAmount = 0;
                decimal maxDiscount = 0;
                foreach (FormDS.FormSaleSKUDetailRow skuRow in this.FormDataSet.FormSaleSKUDetail) {
                    if (skuRow.RowState != DataRowState.Deleted) {
                        skuRow.FormSaleApplyID = formApplyRow.FormSaleApplyID;
                        skuRow.PriceDiscountAmountRMB = decimal.Round(skuRow.PriceDiscountAmount * ExchangeRate, 2);
                        totalPriceDiscountAmountRMB = totalPriceDiscountAmountRMB + skuRow.PriceDiscountAmountRMB;
                        totalForecastOrderAmount = totalForecastOrderAmount + skuRow.ForecastOrderAmount;
                        if (skuRow.Discount > maxDiscount) {
                            maxDiscount = skuRow.Discount;
                        }
                        //如果有折扣的话,要生成费用项
                        if (!skuRow.IsPriceDiscountAmountRMBNull()) {
                            if (StatusID == SystemEnums.FormStatus.Awaiting && new ExpenseItemTableAdapter().GetPriceDiscountExpenseItem().Count != 0) {
                                FormDS.FormSaleExpenseDetailRow newExpenseDetail = this.FormDataSet.FormSaleExpenseDetail.NewFormSaleExpenseDetailRow();
                                newExpenseDetail.FormSaleApplyID = formApplyRow.FormSaleApplyID;
                                newExpenseDetail.ExpenseItemID = new ExpenseItemTableAdapter().GetPriceDiscountExpenseItem()[0].ExpenseItemID;
                                newExpenseDetail.SKUID = skuRow.SKUID;
                                newExpenseDetail.Amount = skuRow.PriceDiscountAmount;
                                newExpenseDetail.AmountRMB = decimal.Round(skuRow.PriceDiscountAmount * ExchangeRate, 2);
                                if (!skuRow.IsRemarkNull()) {
                                    newExpenseDetail.Remark = skuRow.Remark;
                                }
                                this.FormDataSet.FormSaleExpenseDetail.AddFormSaleExpenseDetailRow(newExpenseDetail);
                            }
                        }
                    }
                }
                this.TAFormSaleSKUDetail.Update(this.FormDataSet.FormSaleSKUDetail);
                //费用项
                decimal totalAmountRMB = 0;
                foreach (FormDS.FormSaleExpenseDetailRow expenseRow in this.FormDataSet.FormSaleExpenseDetail) {
                    if (expenseRow.RowState != DataRowState.Deleted) {
                        expenseRow.FormSaleApplyID = formApplyRow.FormSaleApplyID;
                        expenseRow.AmountRMB = decimal.Round(expenseRow.Amount * ExchangeRate, 2);
                        totalAmountRMB = totalAmountRMB + expenseRow.AmountRMB;
                    }
                }
                this.TAFormSaleExpenseDetail.Update(this.FormDataSet.FormSaleExpenseDetail);

                formApplyRow.PriceDiscountAmountRMB = totalPriceDiscountAmountRMB;
                formApplyRow.AmountRMB = totalAmountRMB;
                formApplyRow.OtherAmountRMB = totalAmountRMB - totalPriceDiscountAmountRMB;
                formApplyRow.ForecastOrderAmount = totalForecastOrderAmount;
                if (totalForecastOrderAmount != 0) {
                    formApplyRow.CostBenefitRate = totalAmountRMB / totalForecastOrderAmount * 100;
                } else {
                    formApplyRow.CostBenefitRate = 0;
                }
                TAFormSaleApply.Update(formApplyRow);

                // 正式提交
                if (StatusID == SystemEnums.FormStatus.Awaiting) {
                    Dictionary<string, object> dic = new Dictionary<string, object>();
                    dic["TotalAmount"] = totalAmountRMB;
                    MasterData.CustomerRow customer = new MasterDataBLL().GetCustomerById(formApplyRow.CustomerID)[0];
                    dic["CustomerChannel"] = new MasterDataBLL().GetCustomerChannelById(customer.CustomerChannelID)[0].CustomerChannelCode;
                    dic["KAType"] = customer.IsKaTypeNull() ? "" : customer.KaType;
                    dic["MaxDiscount"] = maxDiscount;
                    dic["DiscountType"] = DiscountTypeID;
                    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();
            }
        }
コード例 #32
0
ファイル: FormPurchaseBLL.cs プロジェクト: hijoy/CPL_ERS
        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();
            }
        }
コード例 #33
0
ファイル: FormSaleBLL.cs プロジェクト: hijoy/CPL_ERS
        public void AddNoActivitySettlement(int? RejectedFormID, int UserID, int? ProxyUserID, int? ProxyPositionID, int OrganizationUnitID, int PositionID, SystemEnums.FormType FormTypeID, SystemEnums.FormStatus StatusID,
                        int CustomerID, int BrandID, int ExpenseSubCategoryID, int CurrencyID, string AttachedFileName, string RealAttachedFileName, string Remark, string FormApplyIds, string FormApplyNos, int CostCenterID, int PaymentTypeID)
        {
            SqlTransaction transaction = null;
            try {
                //事务开始
                transaction = TableAdapterHelper.BeginTransaction(this.TAForm);
                TableAdapterHelper.SetTransaction(this.TAFormSaleSettlement, transaction);
                TableAdapterHelper.SetTransaction(this.TAFormSettlementExpenseDetail, 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)SystemEnums.PageType.NoActivitySettlementApply;
                formRow.CostCenterID = CostCenterID;
                this.FormDataSet.Form.AddFormRow(formRow);
                this.TAForm.Update(formRow);

                //处理settlement的内容
                FormDS.FormSaleSettlementRow formSettleRow = this.FormDataSet.FormSaleSettlement.NewFormSaleSettlementRow();
                formSettleRow.FormSaleSettlementID = formRow.FormID;
                formSettleRow.CustomerID = CustomerID;
                formSettleRow.BrandID = BrandID;
                formSettleRow.ExpenseSubCategoryID = ExpenseSubCategoryID;
                formSettleRow.CurrencyID = CurrencyID;
                if (AttachedFileName != null && AttachedFileName != string.Empty) {
                    formSettleRow.AttachedFileName = AttachedFileName;
                }
                if (RealAttachedFileName != null && RealAttachedFileName != string.Empty) {
                    formSettleRow.RealAttachedFileName = RealAttachedFileName;
                }
                if (Remark != null && Remark != string.Empty) {
                    formSettleRow.Remark = Remark;
                }
                formSettleRow.AmountRMB = 0;
                formSettleRow.FormApplyIds = FormApplyIds;
                formSettleRow.FormApplyNos = FormApplyNos;
                formSettleRow.IsClose = false;
                formSettleRow.PaymentTypeID = PaymentTypeID;
                this.FormDataSet.FormSaleSettlement.AddFormSaleSettlementRow(formSettleRow);
                this.TAFormSaleSettlement.Update(formSettleRow);

                //费用项
                decimal totalAmountRMB = 0;
                decimal totalApplyAmountRMB = 0;
                FormDS.FormSettlementExpenseDetailDataTable newExpenseDetailTable = new FormDS.FormSettlementExpenseDetailDataTable();
                foreach (FormDS.FormSettlementExpenseDetailRow expenseRow in this.FormDataSet.FormSettlementExpenseDetail) {
                    if (expenseRow.RowState != DataRowState.Deleted) {
                        FormDS.FormSettlementExpenseDetailRow newExpenseRow = newExpenseDetailTable.NewFormSettlementExpenseDetailRow();
                        newExpenseRow.FormSaleSettlementID = formSettleRow.FormSaleSettlementID;
                        newExpenseRow.FormSaleExpenseDetailID = expenseRow.FormSaleExpenseDetailID;
                        newExpenseRow.FormSaleApplyID = expenseRow.FormSaleApplyID;
                        newExpenseRow.ApplyFormNo = expenseRow.ApplyFormNo;
                        newExpenseRow.ApplyPeriod = expenseRow.ApplyPeriod;
                        newExpenseRow.ApplyProjectName = expenseRow.ApplyProjectName;
                        newExpenseRow.ExpenseItemID = expenseRow.ExpenseItemID;
                        if (!expenseRow.IsShopNameNull()) {
                            newExpenseRow.ShopName = expenseRow.ShopName;
                        }
                        if (!expenseRow.IsSKUIDNull()) {
                            newExpenseRow.SKUID = expenseRow.SKUID;
                        }
                        newExpenseRow.ApplyAmount = expenseRow.ApplyAmount;
                        newExpenseRow.ApplyAmountRMB = expenseRow.ApplyAmountRMB;
                        if (!expenseRow.IsApplyRemarkNull()) {
                            newExpenseRow.ApplyRemark = expenseRow.ApplyRemark;
                        }
                        if (!expenseRow.IsAdvancedAmountNull()) {
                            newExpenseRow.AdvancedAmount = expenseRow.AdvancedAmount;
                        }
                        newExpenseRow.AmountRMB = expenseRow.AmountRMB;
                        if (!expenseRow.IsRemarkNull()) {
                            newExpenseRow.Remark = expenseRow.Remark;
                        }

                        newExpenseDetailTable.AddFormSettlementExpenseDetailRow(newExpenseRow);
                        totalAmountRMB = totalAmountRMB + newExpenseRow.AmountRMB;
                        totalApplyAmountRMB = totalApplyAmountRMB + newExpenseRow.ApplyAmountRMB;
                    }
                }
                this.TAFormSettlementExpenseDetail.Update(newExpenseDetailTable);

                formSettleRow.ApplyAmountRMB = totalApplyAmountRMB;
                formSettleRow.AmountRMB = totalAmountRMB;

                this.TAFormSaleSettlement.Update(formSettleRow);

                //作废之前的单据
                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;
                    MasterData.CustomerRow customer = new MasterDataBLL().GetCustomerById(CustomerID)[0];
                    dic["CustomerChannel"] = new MasterDataBLL().GetCustomerChannelById(customer.CustomerChannelID)[0].CustomerChannelCode;
                    dic["KAType"] = customer.IsKaTypeNull() ? "" : customer.KaType;
                    dic["PaymentTypeID"] = PaymentTypeID;
                    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("Save Fail!" + ex.ToString());
            } finally {
                transaction.Dispose();
            }
        }
コード例 #34
0
ファイル: SalesReimburseBLL.cs プロジェクト: hijoy/VSL_ERS
        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();
            }
        }
コード例 #35
0
        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();
            }
        }
コード例 #36
0
    public string GenerateFormAndReturnError(int i, DataRow row, LogDS.ImportFormLogDetailRow logDetailRow)
    {
        SqlTransaction transaction = null;
        string errorInfor = string.Empty;
        try {
            FormTableAdapter TAForm = new FormTableAdapter();
            FormSaleSettlementTableAdapter TAFormSettlement = new FormSaleSettlementTableAdapter();
            FormSalePaymentTableAdapter TASalePayment = new FormSalePaymentTableAdapter();
            FormSalePaymentDetailTableAdapter TASalePaymentDetail = new FormSalePaymentDetailTableAdapter();
            FormSettlementExpenseDetailTableAdapter TAFormSettlementExpenseDetail = new FormSettlementExpenseDetailTableAdapter();

            transaction = TableAdapterHelper.BeginTransaction(TAForm);
            TableAdapterHelper.SetTransaction(TASalePayment, transaction);
            TableAdapterHelper.SetTransaction(TASalePaymentDetail, transaction);

            FormDS.FormDataTable tbForm = new FormDS.FormDataTable();
            FormDS.FormSalePaymentDataTable tbPayment = new FormDS.FormSalePaymentDataTable();
            FormDS.FormSalePaymentDetailDataTable tbPaymentDetail = new FormDS.FormSalePaymentDetailDataTable();
            FormDS.FormRow rowForm = null;
            FormDS.FormSalePaymentRow rowPayment = null;
            FormDS.FormSalePaymentDetailRow rowPaymentDetail = null;

            string settlementFormNo = string.Empty;
            DateTime SubmitDate = DateTime.Now;
            decimal PaymentAmount = 0;
            bool IsValid = true;
            if (CheckData(row) != null) {
                errorInfor = "第" + (i + 1) + "行有错:" + CheckData(row);
                IsValid = false;
            } else {
                settlementFormNo = row[0].ToString().Trim();
                SubmitDate = DateTime.Parse(row[1].ToString());
                PaymentAmount = decimal.Parse(row[2].ToString().Trim());

                logDetailRow.SettlementFormNo = settlementFormNo;
                logDetailRow.PaymentAmount = PaymentAmount;

                FormDS.FormDataTable tbSettlement = TAForm.GetDataByFormNo(settlementFormNo);
                if (tbSettlement.Rows.Count <= 0) {
                    errorInfor = "第" + (i + 1) + "行有错:系统中找不到结案单《" + settlementFormNo + "》";
                    IsValid = false;
                }
                FormDS.FormRow settlementForm = tbSettlement[0];
                FormDS.FormSaleSettlementRow rowSettlement = TAFormSettlement.GetDataByID(settlementForm.FormID)[0];

                if (rowSettlement.PaymentTypeID != 2 && rowSettlement.PaymentTypeID != 5) {
                    errorInfor = "第" + (i + 1) + "行有错:该单据支付方式,不是票扣或者调整因子《" + settlementFormNo + "》";
                    IsValid = false;
                }

                if (rowSettlement.IsClose) {
                    errorInfor = "第" + (i + 1) + "行有错:该单据已标记为支付完成《" + settlementFormNo + "》";
                    IsValid = false;
                }

                if (rowSettlement.PaymentTypeID == 2 && PaymentAmount > rowSettlement.AmountRMB) {
                    errorInfor = "第" + (i + 1) + "行有错:支付金额超过结案金额《" + settlementFormNo + "》";
                    IsValid = false;
                }
                if (IsValid) {
                    //生成单据
                    rowForm = tbForm.NewFormRow();
                    rowPayment = tbPayment.NewFormSalePaymentRow();

                    //生成Form
                    rowForm.SetRejectedFormIDNull();
                    //申请人取结案单申请人
                    rowForm.UserID = settlementForm.UserID;
                    UtilityBLL utility = new UtilityBLL();
                    rowForm.FormNo = utility.GetFormNo(utility.GetFormTypeString((int)SystemEnums.FormType.SalePayment));
                    rowForm.SetProxyUserIDNull();
                    rowForm.SetProxyPositionIDNull();
                    //申请人部门取结案单申请人所在部门
                    rowForm.OrganizationUnitID = settlementForm.OrganizationUnitID;
                    rowForm.PositionID = settlementForm.PositionID;
                    rowForm.FormTypeID = (int)SystemEnums.FormType.SalePayment;
                    rowForm.StatusID = (int)SystemEnums.FormStatus.ApproveCompleted;
                    rowForm.SubmitDate = SubmitDate;
                    rowForm.LastModified = SubmitDate;
                    rowForm.InTurnUserIds = "P";//待改动
                    rowForm.InTurnPositionIds = "P";//待改动
                    rowForm.PageType = (int)SystemEnums.PageType.PaymentCash;
                    rowForm.CostCenterID = settlementForm.CostCenterID;
                    rowForm.ApprovedDate = SubmitDate;
                    //是否创建凭证?
                    rowForm.IsCreateVoucher = false;
                    rowForm.IsExportLock = false;
                    rowForm.IsCompletePayment = false;
                    rowForm.IsInvoiceReturned = false;
                    tbForm.AddFormRow(rowForm);
                    TAForm.Update(rowForm);

                    //生成FormPayment
                    rowPayment.FormSalePaymentID = rowForm.FormID;
                    rowPayment.FormSaleSettlementID = settlementForm.FormID;
                    //生成时,不考虑预付款
                    rowPayment.SetFormSaleApplyIDNull();
                    rowPayment.InvoiceStatusID = (int)SystemEnums.InvoiceStatus.No;
                    rowPayment.PaymentTypeID = rowSettlement.PaymentTypeID;
                    //报销申请单备注
                    rowPayment.Remark = "此单据为自动生成单据。";
                    rowPayment.SetAttachedFileNameNull();
                    rowPayment.SetRealAttachedFileNameNull();
                    //报销金额
                    rowPayment.AmountRMB = PaymentAmount;
                    rowPayment.VatTypeID = 1;
                    rowPayment.AmountBeforeTax = rowPayment.AmountRMB;
                    rowPayment.TaxAmount = 0;
                    rowPayment.IsAdvanced = false;
                    //VendorID设置什么值
                    rowPayment.SetVendorIDNull();
                    tbPayment.AddFormSalePaymentRow(rowPayment);
                    TASalePayment.Update(rowPayment);

                    //生成FormPaymentDetail
                    decimal UsedAmount = 0;
                    FormDS.FormSettlementExpenseDetailDataTable tbSettlementExpenseDetail = TAFormSettlementExpenseDetail.GetDataByFormSaleSettlementID(rowSettlement.FormSaleSettlementID);
                    FormDS.FormSettlementExpenseDetailRow rowSettlementExpenseDetail = null;
                    for (int j = 0; j < tbSettlementExpenseDetail.Rows.Count; j++) {
                        rowSettlementExpenseDetail = (FormDS.FormSettlementExpenseDetailRow)tbSettlementExpenseDetail.Rows[j];
                        rowPaymentDetail = tbPaymentDetail.NewFormSalePaymentDetailRow();

                        rowPaymentDetail.FormSalePaymentID = rowPayment.FormSalePaymentID;
                        rowPaymentDetail.FormSaleApplyID = rowSettlementExpenseDetail.FormSaleApplyID;
                        rowPaymentDetail.FormSaleExpenseDetailID = rowSettlementExpenseDetail.FormSaleExpenseDetailID;
                        rowPaymentDetail.ApplyFormNo = rowSettlementExpenseDetail.ApplyFormNo;
                        rowPaymentDetail.ApplyPeriod = rowSettlementExpenseDetail.ApplyPeriod;
                        rowPaymentDetail.ApplyProjectName = rowSettlementExpenseDetail.ApplyProjectName;
                        rowPaymentDetail.ExpenseItemID = rowSettlementExpenseDetail.ExpenseItemID;
                        if (!rowSettlementExpenseDetail.IsShopNameNull()) {
                            rowPaymentDetail.ShopName = rowSettlementExpenseDetail.ShopName;
                        }
                        rowPaymentDetail.SKUID = rowSettlementExpenseDetail.SKUID;
                        rowPaymentDetail.ApplyAmount = rowSettlementExpenseDetail.ApplyAmount;
                        rowPaymentDetail.ApplyAmountRMB = rowSettlementExpenseDetail.ApplyAmountRMB;
                        rowPaymentDetail.SettlementAmount = rowSettlementExpenseDetail.AmountRMB;
                        rowPaymentDetail.TaxAmount = 0;

                        //待改动
                        if (j == tbSettlementExpenseDetail.Rows.Count - 1) {
                            rowPaymentDetail.AmountRMB = PaymentAmount - UsedAmount;
                            rowPaymentDetail.AmountBeforeTax = rowPaymentDetail.AmountRMB;
                            rowPaymentDetail.TaxAmount = rowPaymentDetail.TaxAmount;
                            rowPaymentDetail.PayedAmount = 0;
                            rowPaymentDetail.RemainAmount = 0;
                            UsedAmount += rowPaymentDetail.AmountRMB;
                        } else {
                            rowPaymentDetail.AmountRMB = decimal.Round((rowSettlementExpenseDetail.AmountRMB / rowSettlement.AmountRMB) * PaymentAmount, 2);
                            rowPaymentDetail.AmountBeforeTax = rowPaymentDetail.AmountRMB;
                            rowPaymentDetail.TaxAmount = 0;
                            rowPaymentDetail.PayedAmount = 0;
                            rowPaymentDetail.RemainAmount = 0;
                            UsedAmount += rowPaymentDetail.AmountRMB;
                        }
                        tbPaymentDetail.AddFormSalePaymentDetailRow(rowPaymentDetail);
                        TASalePaymentDetail.Update(tbPaymentDetail);
                    }
                    logDetailRow.PaymentFormNo = rowForm.FormNo;
                }
            }
            transaction.Commit();
        } catch (Exception e) {
            transaction.Rollback();
            errorInfor = e.Message.ToString();
        } finally {
            transaction.Dispose();
        }
        return errorInfor;
    }
コード例 #37
0
ファイル: FormTEBLL.cs プロジェクト: hijoy/CPL_ERS
        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();
            }
        }
コード例 #38
0
ファイル: FormTEBLL.cs プロジェクト: hijoy/CPL_ERS
        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();
            }
        }
コード例 #39
0
        public void AddFormReimburseGoods(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.TAFormReimburseSKUDetail, 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.ReimburseGoodsApply;
                this.FormDataSet.Form.AddFormRow(formRow);
                this.TAForm.Update(formRow);

                //处理申请表的内容
                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);


                //处理free goods明细
                if (RejectedFormID != null)
                {
                    FormDS.FormReimburseSKUDetailDataTable newFGTable = new FormDS.FormReimburseSKUDetailDataTable();
                    foreach (FormDS.FormReimburseSKUDetailRow detailFGRow in this.FormDataSet.FormReimburseSKUDetail)
                    {
                        // 与父表绑定
                        if (detailFGRow.RowState != DataRowState.Deleted)
                        {
                            FormDS.FormReimburseSKUDetailRow newDetailFGRow = newFGTable.NewFormReimburseSKUDetailRow();
                            newDetailFGRow.FormReimburseID = FormReimburseRow.FormReimburseID;
                            newDetailFGRow.SKUID           = detailFGRow.SKUID;
                            newDetailFGRow.PackageQuantity = detailFGRow.PackageQuantity;
                            newDetailFGRow.UnitPrice       = detailFGRow.UnitPrice;
                            newDetailFGRow.Quantity        = detailFGRow.Quantity;
                            newDetailFGRow.Amount          = detailFGRow.Amount;

                            if (!detailFGRow.IsRemarkNull())
                            {
                                newDetailFGRow.Remark = detailFGRow.Remark;
                            }
                            newFGTable.AddFormReimburseSKUDetailRow(newDetailFGRow);
                        }
                    }
                    this.TAFormReimburseSKUDetail.Update(newFGTable);
                }
                else
                {
                    foreach (FormDS.FormReimburseSKUDetailRow detailFGRow in this.FormDataSet.FormReimburseSKUDetail)
                    {
                        // 与父表绑定
                        if (detailFGRow.RowState != DataRowState.Deleted)
                        {
                            detailFGRow.FormReimburseID = FormReimburseRow.FormReimburseID;
                        }
                    }
                    this.TAFormReimburseSKUDetail.Update(this.FormDataSet.FormReimburseSKUDetail);
                }

                //明细表
                decimal totalAmount = 0;//计算总申请金额
                FormDS.FormReimburseDetailDataTable newDetailTable = new FormDS.FormReimburseDetailDataTable();
                foreach (FormDS.FormReimburseDetailRow detailRow in this.FormDataSet.FormReimburseDetail)
                {
                    // 与父表绑定
                    if (detailRow.RowState != DataRowState.Deleted)
                    {
                        totalAmount += detailRow.Amount;

                        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.ApplyPaymentTypeID = detailRow.ApplyPaymentTypeID;
                        newDetailRow.FormApplyID        = detailRow.FormApplyID;
                        newDetailRow.AccruedAmount      = detailRow.IsAccruedAmountNull() ? 0 : detailRow.AccruedAmount;
                        newDetailTable.AddFormReimburseDetailRow(newDetailRow);
                    }
                }
                this.TAFormReimburseDetail.Update(newDetailTable);
                FormReimburseRow.Amount = totalAmount;
                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;
                    //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, RejectedFormID, formRow, OrganizationUnitID, FlowTemplate, StatusID, dic);
                }

                transaction.Commit();
            } catch (Exception ex) {
                transaction.Rollback();
                throw new ApplicationException("Save Fail!" + ex.ToString());
            } finally {
                transaction.Dispose();
            }
        }