コード例 #1
0
        public static string GenerateRepeatFormStr(FormDS.FormDataTable tbForm)
        {
            string systemInfo = "";

            if (tbForm != null && tbForm.Count > 0)
            {
                foreach (FormDS.FormRow formRow in tbForm)
                {
                    systemInfo += "P" + formRow.FormID + ":" + formRow.FormNo + ":" + formRow.PageType + "P";
                }
            }
            return(systemInfo);
        }
コード例 #2
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;
    }
コード例 #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);
                }
            }
        }
コード例 #4
0
ファイル: FormTEBLL.cs プロジェクト: hijoy/CPL_ERS
        public void AddFormInvitationReimburseApply(int? FormInvitationApplyID, 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, int ManageExpenseItemID)
        {
            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.FormInvitationReimburse;
                formRow.CostCenterID = new StuffUserBLL().GetCostCenterIDByPositionID(PositionID);
                tbForm.AddFormRow(formRow);
                this.TAForm.Update(tbForm);

                //处理申请表的内容
                FormDS.FormInvitationReimburseDataTable tbFormInvitationReimburse = new FormDS.FormInvitationReimburseDataTable();
                FormDS.FormInvitationReimburseRow FormInvitationReimburseRow = tbFormInvitationReimburse.NewFormInvitationReimburseRow();
                FormInvitationReimburseRow.FormInvitationReimburseID = formRow.FormID;
                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;

                if (FormInvitationApplyID != null) {
                    FormInvitationReimburseRow.FormInvitationApplyID = FormInvitationApplyID.GetValueOrDefault();
                }

                FormInvitationReimburseRow.TotalBudget = TotalBudget.GetValueOrDefault();
                FormInvitationReimburseRow.ApprovingAmount = ApprovingAmount.GetValueOrDefault();
                FormInvitationReimburseRow.ApprovedAmount = ApprovedAmount.GetValueOrDefault();
                FormInvitationReimburseRow.RemainBudget = RemainBudget.GetValueOrDefault();

                tbFormInvitationReimburse.AddFormInvitationReimburseRow(FormInvitationReimburseRow);
                this.TAFormInvitationReimburse.Update(tbFormInvitationReimburse);

                //作废之前的单据
                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"] = 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();
            }
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: hijoy/CPL_ERS
        private void ImportTxtData(int importType, FileSystemInfo[] fsis)
        {
            foreach (FileSystemInfo fsi in fsis) {
                FormSampleRequestBLL formsamplerequestbll = new FormSampleRequestBLL();
                MasterDataBLL masterdatabll = new MasterDataBLL();
                LogBLL logbll = new LogBLL();
                FormSaleBLL formbll = new FormSaleBLL();
                int SuccessCount = 0;
                int FailCount = 0;
                string[] Content = File.ReadAllLines(fsi.FullName, Encoding.Default);
                //插入LOG主数据
                int logId = logbll.InsertImportLog(importType, fsi.Name, 27, Content.Length, SuccessCount, FailCount);
                for (int i = 0; i < Content.Length; i++) {
                    try {
                        //导入数据
                        #region 类型为SKU
                        if (importType == 0) {
                            string[] SKU = Content[i].Split('\t');
                            if (SKU.Length != 13) {
                                logbll.InsertImportLogDetail(logId, i + 1, "SKU数据COUNT错误!");
                                FailCount += 1;
                                continue;
                            }
                            //SKU = Content[i].Replace("\"", "").Split('\t');
                            Boolean active = false;
                            if (SKU[12].ToUpper().IndexOf("IM") >= 0) {
                                active = true;
                            } else if (SKU[12].ToUpper().IndexOf("IZ") >= 0) {
                                active = false;
                            } else {
                                logbll.InsertImportLogDetail(logId, i + 1, "active数据错误!");
                                FailCount += 1;
                                continue;
                            }

                            int BrandId = 0;
                            int SKUCategoryId = 0;
                            int SKUTypeID = 0;

                            MasterData.BrandDataTable Brand = masterdatabll.GetBrandByName(SKU[2]);
                            if (Brand.Rows.Count > 0) {
                                BrandId = Brand[0].BrandID;
                            } else {
                                logbll.InsertImportLogDetail(logId, i + 1, string.Format("编号为{0}的产品未找到Brand({1})!", SKU[0], SKU[2]));
                                FailCount += 1;
                                continue;
                            }
                            MasterData.SKUCategoryDataTable SKUCategory = masterdatabll.GetSKUCategoryByName(SKU[3]);
                            if (SKUCategory.Rows.Count > 0) {
                                SKUCategoryId = SKUCategory[0].SKUCategoryID;
                            } else {
                                logbll.InsertImportLogDetail(logId, i + 1, string.Format("编号为{0}的产品未找到SKU Category({1})!", SKU[0], SKU[3]));
                                FailCount += 1;
                                continue;
                            }
                            MasterData.SKUTypeDataTable SKUType = masterdatabll.GetSKUTypeByName(SKU[4]);
                            if (SKUType.Rows.Count > 0) {
                                SKUTypeID = SKUType[0].SKUTypeID;
                            }
                            MasterData.SKUDataTable dtSKU = masterdatabll.GetSKUBySKUNo(SKU[0]);
                            if (dtSKU.Rows.Count > 0) {
                                //Update
                                masterdatabll.UpdateSKU(dtSKU[0].SKUID, SKU[0], SKU[1], BrandId, SKUTypeID, SKUCategoryId, SKU[5], SKU[6], SKU[7], SKU[8], SKU[9], Decimal.Parse(SKU[10]), SKU[11], active);
                            } else if (active)//未找到数据  并且active 是ture的才做插入
                            {
                                //导入数据
                                masterdatabll.InsertSKU(SKU[0], SKU[1], BrandId, SKUTypeID, SKUCategoryId, SKU[5], SKU[6], SKU[7], SKU[8], SKU[9], Decimal.Parse(SKU[10]), SKU[11], active);
                            }
                        }
                        #endregion

                        #region 类型为Item
                        if (importType == 1) {
                            string[] Item = Content[i].Split('\t');
                            if (Item.Length != 6) {
                                logbll.InsertImportLogDetail(logId, i + 1, "Item数据COUNT错误!");
                                FailCount += 1;
                                continue;
                            }
                            //Item = Content[i].Replace("\"", "").Split('\t');

                            int ItemCategoryID = 0;
                            Boolean active = false;
                            if (Item[5].ToUpper().IndexOf("PC") >= 0) {
                                active = true;
                            } else if (Item[5].ToUpper().IndexOf("PZ") >= 0) {
                                active = false;
                            } else {
                                logbll.InsertImportLogDetail(logId, i + 1, "active数据错误!");
                                FailCount += 1;
                                continue;
                            }
                            MasterData.ItemCategoryDataTable ItemCategory = masterdatabll.GetItemCategoryByCode(Item[2]);
                            if (ItemCategory.Rows.Count > 0) {
                                ItemCategoryID = ItemCategory[0].ItemCategoryID;
                            } else {
                                logbll.InsertImportLogDetail(logId, i + 1, "未找到Item Category!");
                                FailCount += 1;
                                continue;
                            }
                            MasterData.ItemDataTable dtItem = masterdatabll.GetItemByCode(Item[0]);
                            if (dtItem.Rows.Count > 0) {
                                //Update
                                masterdatabll.UpdateItem(dtItem[0].ItemID, Item[0], Item[1], ItemCategoryID, Item[3], Item[4], active);
                            } else if (active)//未找到数据  并且active 是ture的才做插入
                            {
                                //导入数据
                                masterdatabll.InsertItem(Item[0], Item[1], ItemCategoryID, Item[3], Item[4], active);
                            }
                        }
                        #endregion

                        #region 类型为Customer
                        if (importType == 2) {
                            string[] Customer = Content[i].Split('\t');
                            if (Customer.Length != 14) {
                                logbll.InsertImportLogDetail(logId, i + 1, "Customer数据COUNT错误!");
                                FailCount += 1;
                                continue;
                            }
                            //Customer = Content[i].Replace("\"", "").Split('\t');
                            Boolean active = false;
                            if (Customer[12].ToUpper().IndexOf("CM") >= 0) {
                                active = true;
                            } else if (Customer[12].ToUpper().IndexOf("CZ") >= 0) {
                                active = false;
                            } else {
                                logbll.InsertImportLogDetail(logId, i + 1, "active数据错误!");
                                FailCount += 1;
                                continue;
                            }
                            int CustomerTypeID = 0;
                            int CustomerChannelID = 0;
                            int ProvinceID = 0;
                            int CustomerRegionID = 0;
                            //查询ID

                            MasterData.CustomerTypeDataTable CustomerType = masterdatabll.GetCustomerTypeByName(Customer[5]);
                            if (CustomerType.Rows.Count > 0) {
                                CustomerTypeID = CustomerType[0].CustomerTypeID;
                            } else {

                                logbll.InsertImportLogDetail(logId, i + 1, "未找到Customer Type!");
                                FailCount += 1;
                                continue;
                            }

                            MasterData.CustomerChannelDataTable CustomerChannel = masterdatabll.GetCustomerChanneByCode(Customer[6]);
                            if (CustomerChannel.Rows.Count > 0) {
                                CustomerChannelID = CustomerChannel[0].CustomerChannelID;
                            } else {
                                logbll.InsertImportLogDetail(logId, i + 1, "未找到Customer Channel!");
                                FailCount += 1;
                                continue;
                            }

                            MasterData.ProvinceDataTable Province = masterdatabll.GetProvinceByName(Customer[8]);
                            if (Province.Rows.Count > 0) {
                                ProvinceID = Province[0].ProvinceID;
                            } else {
                                logbll.InsertImportLogDetail(logId, i + 1, "未找到Province!");
                                FailCount += 1;
                                continue;
                            }

                            MasterData.CustomerRegionDataTable CustomerRegion = masterdatabll.GetCustomerRegionByName(Customer[9]);
                            if (CustomerRegion.Rows.Count > 0)
                                CustomerRegionID = CustomerRegion[0].CustomerRegionID;
                            else {
                                logbll.InsertImportLogDetail(logId, i + 1, "未找到Customer Region!");
                                FailCount += 1;
                                continue;
                            }
                            MasterData.CustomerDataTable dtCustomer = masterdatabll.GetCustomerByNo(Customer[0]);
                            if (dtCustomer.Rows.Count > 0) {
                                //Update
                                masterdatabll.UpdateCustomer(dtCustomer[0].CustomerID, Customer[0], Customer[1], Customer[2], Customer[3], Customer[4], Customer[4],
                                    CustomerTypeID, CustomerChannelID, Customer[7], ProvinceID, CustomerRegionID, Customer[10], Customer[11],
                                    "", "", "", "", active, Customer[13]);
                            } else if (active)//未找到数据  并且active 是ture的才做插入
                            {
                                //导入数据
                                masterdatabll.InsertCustomer(Customer[0], Customer[1], Customer[2], Customer[3], Customer[4], Customer[5],
                                    CustomerTypeID, CustomerChannelID, Customer[7], ProvinceID, CustomerRegionID, Customer[10], Customer[11],
                                    "", "", "", "", active, Customer[13]);
                            } else {
                                logbll.InsertImportLogDetail(logId, i + 1, "未激活的数据不导入!");
                                FailCount += 1;
                                continue;
                            }
                        }
                        #endregion

                        #region 类型为货补
                        if (importType == 3) {
                            string[] Delivery = Content[i].Split('\t');
                            if (Delivery.Length != 7) {
                                logbll.InsertImportLogDetail(logId, i + 1, "Delivery数据COUNT错误!");
                                FailCount += 1;
                                continue;
                            }
                            string l_strMaaNumber = Delivery[0].ToString();
                            string l_strSKUNo = Delivery[1].ToString();
                            string l_strPrice = Delivery[2].ToString();
                            string l_strDeliveryNo = Delivery[3].ToString();
                            string l_strQuantity = Delivery[4].ToString();
                            string l_strAmountRMB = Delivery[5].ToString();
                            string l_strDeliveryDate = Delivery[6].ToString();
                            int SkuID = 0;
                            int FormID = 0;
                            decimal Price = 0;
                            decimal AmountRMB = 0;
                            decimal Quantity = 0;
                            DateTime DeliveryDate = DateTime.Now;
                            if (string.IsNullOrEmpty(l_strMaaNumber) || string.IsNullOrEmpty(l_strSKUNo) || string.IsNullOrEmpty(l_strPrice) ||
                                string.IsNullOrEmpty(l_strDeliveryNo) || string.IsNullOrEmpty(l_strQuantity) || string.IsNullOrEmpty(l_strAmountRMB) ||
                                string.IsNullOrEmpty(l_strDeliveryDate)) {
                                logbll.InsertImportLogDetail(logId, i, "数据有空列,导入失败!");
                                FailCount++;
                                continue;
                            }
                            FormDS.FormDataTable l_dtForm = formbll.GetDataByFormNo(l_strMaaNumber);
                            if (l_dtForm.Rows.Count == 0) {
                                logbll.InsertImportLogDetail(logId, i, "未找到MAA号:" + l_strMaaNumber + "的单据,导入失败!");
                                FailCount++;
                                continue;
                            } else {
                                FormID = l_dtForm[0].FormID;
                            }
                            MasterData.SKUDataTable l_dtSKU = new MasterDataBLL().GetSKUBySKUNo(l_strSKUNo);
                            if (l_dtSKU.Rows.Count == 0) {
                                logbll.InsertImportLogDetail(logId, i, "未找到此SKU:" + l_strSKUNo + " NUMBER 下的SKU,导入失败!");
                                FailCount++;
                                continue;
                            } else {
                                SkuID = l_dtSKU[0].SKUID;
                            }
                            //价格是成本价,进入系统应该是
                            try {
                                Price = decimal.Round(decimal.Parse(l_strPrice) * (decimal)1.1 * (decimal)1.17, 2);
                            } catch {
                                logbll.InsertImportLogDetail(logId, i, "单价错误,导入失败!");
                                FailCount++;
                                continue;
                            }
                            try {
                                Quantity = decimal.Parse(l_strQuantity);
                            } catch {
                                logbll.InsertImportLogDetail(logId, i, "数量错误,导入失败!");
                                FailCount++;
                                continue;
                            }
                            try {
                                AmountRMB = Price * Quantity;
                            } catch {
                                logbll.InsertImportLogDetail(logId, i, "发货金额,导入失败!");
                                FailCount++;
                                continue;
                            }
                            try {
                                DeliveryDate = DateTime.Parse(l_strDeliveryDate);
                            } catch {
                                logbll.InsertImportLogDetail(logId, i, "日期错误,导入失败!");
                                FailCount++;
                                continue;
                            }
                            if (string.IsNullOrEmpty(l_strDeliveryNo)) {
                                logbll.InsertImportLogDetail(logId, i, "订单号为空,导入失败!");
                                FailCount++;
                                continue;
                            }
                            int result = 0;
                            FormDS.FormDeliveryGoodsDataTable l_dtFormDeliveryGoods = formbll.GetDataByDeliveryNoAndSkuID(l_strDeliveryNo, SkuID, l_strMaaNumber);
                            if (l_dtFormDeliveryGoods.Rows.Count > 0) {
                                result = formbll.UpdateFormDeliveryGoods(int.Parse(l_dtFormDeliveryGoods.Rows[0][0].ToString()), l_strDeliveryNo, DeliveryDate, Price, Quantity, AmountRMB);
                                if (result == 0) {
                                    logbll.InsertImportLogDetail(logId, i, "数据更新失败!");
                                    FailCount++;
                                    continue;
                                }
                            } else {
                                result = formbll.InsertFormDeliveryGoods(FormID, SkuID, l_strDeliveryNo, DeliveryDate, Price, Quantity, AmountRMB);
                                if (result == 0) {
                                    logbll.InsertImportLogDetail(logId, i, "数据插入失败!");
                                    FailCount++;
                                    continue;
                                }
                            }
                            formsamplerequestbll.UpdateFormAfterDeliveryComplete(FormID, 27);
                        }
                        #endregion

                        #region 类型为APH
                        if (importType == 4) {
                            string[] PaymentInfo = Content[i].Split('\t');
                            if (PaymentInfo.Length != 3) {
                                logbll.InsertImportLogDetail(logId, i + 1, "APH数据COUNT错误!");
                                FailCount += 1;
                                continue;
                            }
                            FormDS.FormDataTable l_dtform = new FormDS.FormDataTable();
                            l_dtform = formbll.GetDataByFormNo(PaymentInfo[0]);
                            if (l_dtform.Rows.Count == 0) {
                                logbll.InsertImportLogDetail(logId, i + 1, "未找到此Form单号:" + PaymentInfo[0] + "的单据");
                                FailCount += 1;
                                continue;
                            }
                            FormDS.FormRow l_drform = l_dtform[0];
                            if (l_drform.FormTypeID == (int)SystemEnums.FormType.FormMarketingPayment ||
                                l_drform.FormTypeID == (int)SystemEnums.FormType.PVApply ||
                                l_drform.FormTypeID == (int)SystemEnums.FormType.RDPayment ||
                                l_drform.FormTypeID == (int)SystemEnums.FormType.SalePayment ||
                                l_drform.FormTypeID == (int)SystemEnums.FormType.TravelReimburseApply ||
                                l_drform.FormTypeID == (int)SystemEnums.FormType.PersonalReimburseApply) {

                                try {
                                    if (!string.IsNullOrEmpty(PaymentInfo[1]))
                                        l_drform.PaymentDate = DateTime.Parse(PaymentInfo[1].Substring(0, 4) + "-" + PaymentInfo[1].Substring(4, 2) + "-" + PaymentInfo[1].Substring(6, 2));
                                    else {
                                        logbll.InsertImportLogDetail(logId, i + 1, "付款时间不能为空!");
                                        FailCount += 1;
                                        continue;
                                    }
                                } catch {
                                    logbll.InsertImportLogDetail(logId, i + 1, "时间格式不正确");
                                    FailCount += 1;
                                    continue;
                                }
                            } else {
                                logbll.InsertImportLogDetail(logId, i + 1, "单号:" + PaymentInfo[0] + " 不是正确的付款单号");
                                FailCount += 1;
                                continue;
                            }
                            try {
                                if (!string.IsNullOrEmpty(PaymentInfo[2])) {
                                    decimal PaymentAmount = decimal.Parse(PaymentInfo[2]);
                                    l_drform.PaymentAmount = PaymentAmount;
                                } else {
                                    logbll.InsertImportLogDetail(logId, i + 1, "付款金额不能为空!");
                                    FailCount += 1;
                                    continue;
                                }
                            } catch {
                                logbll.InsertImportLogDetail(logId, i + 1, "付款金额错误!");
                                FailCount += 1;
                                continue;
                            }
                            formbll.TAForm.Update(l_drform);
                        }
                        #endregion

                        SuccessCount += 1;
                    } catch (Exception ee) {
                        logbll.InsertImportLogDetail(logId, i + 1, ee.Message);
                        FailCount += 1;
                        continue;
                    }
                }
                //Update SuccessCount FailCount
                logbll.UpdateImportLog(logId, importType, fsi.Name, 1, Content.Length, SuccessCount, FailCount);
            }
        }
コード例 #6
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();
            }
        }
コード例 #7
0
ファイル: PersonalReimburseBLL.cs プロジェクト: hijoy/VSL_ERS
        public void AddFormTravelApply(int? RejectedFormID, int UserID, int? ProxyUserID, int? ProxyPositionID, int OrganizationUnitID,
            int PositionID, SystemEnums.FormType FormTypeID, SystemEnums.FormStatus StatusID, decimal? TransportFee, decimal? HotelFee,
            decimal? MealFee, decimal? OtherFee, string Remark, string AttachmentFileName, string RealAttachmentFileName)
        {
            SqlTransaction transaction = null;
            try {
                transaction = TableAdapterHelper.BeginTransaction(this.TAForm);
                TableAdapterHelper.SetTransaction(this.TAFormTravelApply, transaction);
                TableAdapterHelper.SetTransaction(this.TAFormTravelApplyDetail, 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.TravelApply;
                tbForm.AddFormRow(formRow);
                this.TAForm.Update(tbForm);

                //处理申请表的内容
                FormDS.FormTravelApplyDataTable tbFormTravelApply = new FormDS.FormTravelApplyDataTable();
                FormDS.FormTravelApplyRow rowFormTravelApply = tbFormTravelApply.NewFormTravelApplyRow();
                decimal TotalFee = 0;

                rowFormTravelApply.FormTravelApplyID = formRow.FormID;
                if (TransportFee != null) {
                    rowFormTravelApply.TransportFee = TransportFee.GetValueOrDefault();
                    TotalFee += rowFormTravelApply.TransportFee;
                }
                if (HotelFee != null) {
                    rowFormTravelApply.HotelFee = HotelFee.GetValueOrDefault();
                    TotalFee += rowFormTravelApply.HotelFee;
                }
                if (MealFee != null) {
                    rowFormTravelApply.MealFee = MealFee.GetValueOrDefault();
                    TotalFee += rowFormTravelApply.MealFee;
                }
                if (OtherFee != null) {
                    rowFormTravelApply.OtherFee = OtherFee.GetValueOrDefault();
                    TotalFee += rowFormTravelApply.OtherFee;
                }
                rowFormTravelApply.TotalFee = TotalFee;
                if (Remark != null) {
                    rowFormTravelApply.Remark = Remark;
                }
                rowFormTravelApply.AttachedFileName = AttachmentFileName;
                rowFormTravelApply.RealAttachedFileName = RealAttachmentFileName;
                tbFormTravelApply.AddFormTravelApplyRow(rowFormTravelApply);
                this.TAFormTravelApply.Update(tbFormTravelApply);

                int TotalDays = 0;
                //处理明细数据
                if (RejectedFormID != null) {
                    FormDS.FormTravelApplyDetailDataTable newDetailTable = new FormDS.FormTravelApplyDetailDataTable();
                    foreach (FormDS.FormTravelApplyDetailRow detailRow in this.FormDataSet.FormTravelApplyDetail) {
                        if (detailRow.RowState != System.Data.DataRowState.Deleted) {
                            FormDS.FormTravelApplyDetailRow newDetailRow = newDetailTable.NewFormTravelApplyDetailRow();
                            newDetailRow.FormTravelApplyID = rowFormTravelApply.FormTravelApplyID;
                            newDetailRow.BeginDate = detailRow.BeginDate;
                            newDetailRow.EndDate = detailRow.EndDate;
                            newDetailRow.Departure = detailRow.Departure;
                            newDetailRow.Destination = detailRow.Destination;
                            newDetailRow.Vehicle = detailRow.Vehicle;
                            newDetailRow.Remark = detailRow.Remark;
                            newDetailRow.Days = (detailRow.EndDate - detailRow.BeginDate).Days + 1;
                            TotalDays += newDetailRow.Days;
                            newDetailTable.AddFormTravelApplyDetailRow(newDetailRow);
                        }
                    }
                    this.TAFormTravelApplyDetail.Update(newDetailTable);
                } else {
                    foreach (FormDS.FormTravelApplyDetailRow detailRow in this.FormDataSet.FormTravelApplyDetail) {
                        // 与父表绑定
                        if (detailRow.RowState != DataRowState.Deleted) {
                            detailRow.FormTravelApplyID = rowFormTravelApply.FormTravelApplyID;
                            TotalDays += detailRow.Days;
                        }
                    }
                    this.TAFormTravelApplyDetail.Update(this.FormDataSet.FormTravelApplyDetail);
                }

                this.TAFormTravelApply.Update(rowFormTravelApply);

                //作废之前的单据
                if (RejectedFormID != null) {
                    FormDS.FormRow oldRow = TAForm.GetDataByID(RejectedFormID.GetValueOrDefault())[0];
                    if (oldRow.StatusID == (int)SystemEnums.FormStatus.Rejected) {
                        new APFlowBLL().ScrapForm(oldRow.FormID);
                    }
                }

                // 正式提交或草稿 流程模板带修改
                Dictionary<string, object> dic = new Dictionary<string, object>();
                dic["Apply_Amount"] = rowFormTravelApply.TotalFee;//金额
                AuthorizationDS.OrganizationUnitDataTable OUTable = new AuthorizationDSTableAdapters.OrganizationUnitTableAdapter().GetOrganizationUnitCodeByOrganizationUnitID(formRow.OrganizationUnitID);
                if (OUTable.Count == 0) {
                    throw new ApplicationException("没有找到您所在部门的流程,请联系管理员");
                }
                dic["Days"] = TotalDays;
                dic["Department"] = OUTable[0].OrganizationUnitCode;
                APHelper AP = new APHelper();
                new APFlowBLL().ApplyForm(AP, TAForm, RejectedFormID, formRow, OrganizationUnitID, new AuthorizationBLL().GetFlowTemplate((int)SystemEnums.BusinessUseCase.FormTravelApply, formRow.UserID), StatusID, dic);
                transaction.Commit();
            } catch (Exception ex) {
                transaction.Rollback();
                throw new ApplicationException(ex.Message);
            } finally {
                transaction.Dispose();
            }
        }