Beispiel #1
0
 public void UpdateFormReimburseInvoice(int FormReimburseInvoiceID, string InvoiceNo, decimal InvoiceAmount, string Remark)
 {
     FormDS.FormReimburseInvoiceDataTable table     = this.FormDataSet.FormReimburseInvoice;
     FormDS.FormReimburseInvoiceRow       rowDetail = table.FindByFormReimburseInvoiceID(FormReimburseInvoiceID);
     if (rowDetail == null)
     {
         return;
     }
     rowDetail.InvoiceNo     = InvoiceNo;
     rowDetail.InvoiceAmount = InvoiceAmount;
     rowDetail.Remark        = Remark;
 }
Beispiel #2
0
        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();
            }
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            //FormReimburseInvoiceTableAdapter taInvoice = new FormReimburseInvoiceTableAdapter();
            //FormTableAdapter taForm = new FormTableAdapter();
            //FormDS.FormReimburseInvoiceDataTable tbInvoice = taInvoice.GetData();
            //foreach (FormDS.FormReimburseInvoiceRow item in tbInvoice) {
            //    if (!item.IsSystemInfoNull()) {
            //        string SystemInfo = item.SystemInfo;
            //        string[] FormNos = SystemInfo.Split(',');
            //        string RepeatFormStr = "";
            //        if (FormNos.Length > 0) {
            //            foreach (string FormNo in FormNos) {
            //                if (!string.IsNullOrEmpty(FormNo)) {
            //                    FormDS.FormDataTable tbForm = taForm.GetDataByFormNo(FormNo);
            //                    if (tbForm != null && tbForm.Count > 0) {
            //                        RepeatFormStr += "P" + tbForm[0].FormID + ":" + tbForm[0].FormNo + "P";
            //                    }
            //                }
            //            }
            //        }
            //        item.SystemInfo = RepeatFormStr;
            //        taInvoice.Update(item);
            //    }
            //}

            //FormReimburseInvoiceTableAdapter taInvoice = new FormReimburseInvoiceTableAdapter();
            //FormTableAdapter taForm = new FormTableAdapter();
            //FormDS.FormReimburseInvoiceDataTable tbInvoice = taInvoice.GetData();
            //foreach (FormDS.FormReimburseInvoiceRow item in tbInvoice) {
            //    if (!item.IsSystemInfoNull()) {
            //        string SystemInfo = item.SystemInfo;
            //        SystemInfo = SystemInfo.Replace("PP", "P");
            //        string[] FormNos = SystemInfo.Split('P');
            //        string RepeatFormStr = "";
            //        if (FormNos.Length > 0) {
            //            foreach (string FormNo in FormNos) {
            //                if (!string.IsNullOrEmpty(FormNo)) {
            //                    FormDS.FormDataTable tbForm = taForm.GetDataByID(int.Parse(FormNo.Split(':')[0]));
            //                    if (tbForm != null && tbForm.Count > 0) {
            //                        RepeatFormStr += "P" + tbForm[0].FormID + ":" + tbForm[0].FormNo + "P";
            //                    }
            //                }
            //            }
            //        }
            //        item.SystemInfo = RepeatFormStr;
            //        taInvoice.Update(item);
            //    }
            //}

            FormReimburseInvoiceTableAdapter taInvoice = new FormReimburseInvoiceTableAdapter();
            FormTableAdapter taForm = new FormTableAdapter();

            FormDS.FormReimburseInvoiceDataTable tbInvoice = taInvoice.GetData();
            foreach (FormDS.FormReimburseInvoiceRow item in tbInvoice)
            {
                if (!item.IsSystemInfoNull())
                {
                    string SystemInfo = item.SystemInfo;
                    SystemInfo = SystemInfo.Replace("PP", "P");
                    string[] FormNos       = SystemInfo.Split('P');
                    string   RepeatFormStr = "";
                    if (FormNos.Length > 0)
                    {
                        foreach (string FormNo in FormNos)
                        {
                            if (!string.IsNullOrEmpty(FormNo))
                            {
                                FormDS.FormDataTable tbForm = taForm.GetDataByID(int.Parse(FormNo.Split(':')[0]));
                                if (tbForm != null && tbForm.Count > 0)
                                {
                                    RepeatFormStr += "P" + tbForm[0].FormID + ":" + tbForm[0].FormNo + ":" + tbForm[0].PageType + "P";
                                }
                            }
                        }
                    }
                    item.SystemInfo = RepeatFormStr;
                    taInvoice.Update(item);
                }
            }
        }
Beispiel #4
0
        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();
            }
        }