protected void Page_Load(object sender, EventArgs e) { base.Page_Load(sender, e); if (!this.IsPostBack) { String title = this.GetLocalResourceObject("titleLabel.Text").ToString(); PageUtility.SetContentTitle(this.Page, title); MasterDataBLL mdBLL = new MasterDataBLL(); int formID = int.Parse(Request["ObjectId"]); this.ViewState["ObjectId"] = formID; FormDS.FormSalePaymentRow rowFormPayment = this.FormSaleBLL.GetFormSalePaymentByID(int.Parse(this.ViewState["ObjectId"].ToString())); FormDS.FormRow rowForm = this.FormSaleBLL.GetFormByID(formID)[0]; if (rowForm.IsProcIDNull()) { ViewState["ProcID"] = ""; } else { ViewState["ProcID"] = rowForm.ProcID; } this.FormNoCtl.Text = rowForm.FormNo; AuthorizationDS.StuffUserRow applicant = new AuthorizationBLL().GetStuffUserById(rowForm.UserID); this.StuffNameCtl.Text = CommonUtility.GetStaffFullName(applicant); this.PositionNameCtl.Text = new OUTreeBLL().GetPositionById(rowForm.PositionID).PositionName; if (new OUTreeBLL().GetOrganizationUnitById(rowForm.OrganizationUnitID) != null) { this.DepartmentNameCtl.Text = new OUTreeBLL().GetOrganizationUnitById(rowForm.OrganizationUnitID).OrganizationUnitName; } this.StuffNoCtl.Text = applicant.IsStuffNoNull() ? "" : applicant.StuffNo; this.AttendDateCtl.Text = applicant.AttendDate.ToShortDateString(); this.ApplyFormNoCtl.Text = this.FormSaleBLL.GetFormByID(rowFormPayment.FormSaleApplyID)[0].FormNo; FormDS.FormSaleApplyRow rowFormApply = this.FormSaleBLL.GetFormSaleApplyByID(rowFormPayment.FormSaleApplyID)[0]; this.PeriodCtl.Text = rowFormApply.FPeriod.ToString("yyyy-MM"); MasterData.CustomerRow customer = mdBLL.GetCustomerById(rowFormApply.CustomerID)[0]; this.CustomerNameCtl.Text = customer.CustomerName; this.CustomerChannelCtl.Text = mdBLL.GetCustomerChannelById(customer.CustomerChannelID)[0].CustomerChannelName; this.KATypeCtl.Text = customer.IsKaTypeNull() ? "" : customer.KaType; this.CustomerRegionCtl.Text = mdBLL.GetCustomerRegionById(customer.CustomerRegionID).CustomerRegionName; this.CityCtl.Text = customer.City; this.BrandCtl.Text = mdBLL.GetBrandById(rowFormApply.BrandID)[0].BrandName; MasterData.ExpenseSubCategoryRow rowExpenseSubCategory = mdBLL.GetExpenseSubCategoryById(rowFormApply.ExpenseSubCategoryID); this.ExpenseCategoryCtl.Text = mdBLL.GetExpenseCategoryById(rowExpenseSubCategory.ExpenseCategoryID).ExpenseCategoryName; this.ExpenseSubCategoryCtl.Text = rowExpenseSubCategory.ExpenseSubCategoryName; this.CurrencyCtl.Text = mdBLL.GetCurrencyByID(rowFormApply.CurrencyID).CurrencyShortName; this.ExchangeRateCtl.Text = rowFormApply.ExchangeRate.ToString(); this.ShopNameCtl.Text = rowFormApply.IsShopNameNull() ? "" : rowFormApply.ShopName; this.ShopCountCtl.Text = rowFormApply.IsShopCountNull() ? "" : rowFormApply.ShopCount.ToString(); this.ProjectNameCtl.Text = rowFormApply.IsProjectNameNull() ? "" : rowFormApply.ProjectName; this.CostCenterCtl.Text = CommonUtility.GetMAACostCenterFullName(rowForm.CostCenterID); if (!rowFormApply.IsActivityBeginDateNull()) { this.ActivityBeginCtl.Text = rowFormApply.ActivityBeginDate.ToString("yyyy-MM-dd"); } if (!rowFormApply.IsActivityEndDateNull()) { this.ActivityEndCtl.Text = rowFormApply.ActivityEndDate.ToString("yyyy-MM-dd"); } this.ProjectDescCtl.Text = rowFormApply.IsProjectDescNull() ? "" : rowFormApply.ProjectDesc; if (!rowFormApply.IsApplyFileNameNull()) this.UCFileUpload.AttachmentFileName = rowFormApply.ApplyFileName; if (!rowFormApply.IsApplyRealFileNameNull()) this.UCFileUpload.RealAttachmentFileName = rowFormApply.ApplyRealFileName; if (!rowFormPayment.IsRemarkNull()) { this.RemarkCtl.Text = rowFormPayment.Remark; } if (!rowFormPayment.IsAttachedFileNameNull()) { this.UCPaymentFile.AttachmentFileName = rowFormPayment.AttachedFileName; } if (!rowFormPayment.IsRealAttachedFileNameNull()) { this.UCPaymentFile.RealAttachmentFileName = rowFormPayment.RealAttachedFileName; } this.InvoiceStatusCtl.Text = new InvoiceStatusTableAdapter().GetDataByID(rowFormPayment.InvoiceStatusID)[0].Name; if (!rowFormPayment.IsVendorIDNull()) { MasterData.VendorRow vendor = mdBLL.GetVendorByID(rowFormPayment.VendorID); this.VendorCtl.Text = vendor.VendorName + "-" + vendor.VendorCode; } this.txtVatType.Text = mdBLL.GetVatTypeById(rowFormPayment.VatTypeID)[0].VatTypeName; //PO if (!rowFormPayment.IsFormPOIDNull()) { FormDS.FormRow rowFormPO = this.FormSaleBLL.GetFormByID(rowFormPayment.FormPOID)[0]; this.hlPO.Text = rowFormPO.FormNo; this.hlPO.NavigateUrl = CommonUtility.GetPOPostBackUrl(rowFormPO.FormID); } else { this.hlPO.Text = "无"; } //历史单据 if (rowForm.IsRejectedFormIDNull()) { lblRejectFormNo.Text = "无"; } else { FormDS.FormRow rejectedForm = this.FormSaleBLL.GetFormByID(rowForm.RejectedFormID)[0]; this.lblRejectFormNo.Text = rejectedForm.FormNo; this.lblRejectFormNo.NavigateUrl = "javascript:window.showModalDialog('" + System.Configuration.ConfigurationManager.AppSettings["WebSiteUrl"] + "/FormSale/NoActivityAdvancedPaymentApproval.aspx?ShowDialog=1&ObjectId=" + rejectedForm.FormID + "','', 'dialogWidth:1000px;dialogHeight:750px;resizable:yes;')"; } //明细 this.odsInvoice.SelectParameters["FormID"].DefaultValue = rowFormPayment.FormSalePaymentID.ToString(); this.odsPaymentDetails.SelectParameters["FormSalePaymentID"].DefaultValue = rowFormPayment.FormSalePaymentID.ToString(); //审批页面处理&按钮处理 AuthorizationDS.StuffUserRow stuffUser = (AuthorizationDS.StuffUserRow)Session["StuffUser"]; this.ViewState["StuffUserID"] = stuffUser.StuffUserId; if (rowForm.InTurnUserIds.Contains("P" + stuffUser.StuffUserId + "P")) { this.SubmitBtn.Visible = true; this.cwfAppCheck.IsView = false; this.ViewState["IsView"] = false; } else { this.SubmitBtn.Visible = false; this.cwfAppCheck.IsView = true; this.ViewState["IsView"] = true; } if (rowForm.StatusID == (int)SystemEnums.FormStatus.Rejected && stuffUser.StuffUserId == rowForm.UserID) { this.EditBtn.Visible = true; this.ScrapBtn.Visible = true; } else { this.EditBtn.Visible = false; this.ScrapBtn.Visible = false; } //如果是弹出,取消按钮不可见 if (this.Request["ShowDialog"] != null) { if (this.Request["ShowDialog"].ToString() == "1") { this.upButton.Visible = false; this.Master.FindControl("divMenu").Visible = false; this.Master.FindControl("tbCurrentPage").Visible = false; } } //判断财务摘要的显示问题 if (!rowForm.IsFinanceRemarkNull()) { this.FinanceRemarkCtl.Text = rowForm.FinanceRemark; } int opViewId = BusinessUtility.GetBusinessOperateId(SystemEnums.BusinessUseCase.FinanceRemark, SystemEnums.OperateEnum.View); int opManageId = BusinessUtility.GetBusinessOperateId(SystemEnums.BusinessUseCase.FinanceRemark, SystemEnums.OperateEnum.Manage); AuthorizationDS.PositionRow ViewerPosition = (AuthorizationDS.PositionRow)this.Session["Position"]; PositionRightBLL positionRightBLL = new PositionRightBLL(); bool HasViewRight = positionRightBLL.CheckPositionRight(ViewerPosition.PositionId, opViewId); bool HasManageRight = positionRightBLL.CheckPositionRight(ViewerPosition.PositionId, opManageId); //如果没有权限则隐藏 if (!HasViewRight && !HasManageRight) { this.FinanceRemarkTitleDIV.Visible = false; this.FinanceRemarkDIV.Visible = false; this.SaveBtn.Visible = false; } //如果没有填写的权限或者已经填写了,则隐藏保存按钮 if (HasViewRight && (!HasManageRight || !rowForm.IsFinanceRemarkNull())) { this.FinanceRemarkCtl.ReadOnly = true; this.SaveBtn.Visible = false; } //如果不是审批中或者审批完成不能修改 if (rowForm.StatusID != 1 && rowForm.StatusID != 2) { this.FinanceRemarkCtl.ReadOnly = true; this.SaveBtn.Visible = false; } } this.cwfAppCheck.FormID = (int)this.ViewState["ObjectId"]; this.cwfAppCheck.ProcID = this.ViewState["ProcID"].ToString(); this.cwfAppCheck.IsView = (bool)this.ViewState["IsView"]; }
/// <summary> /// 销售 /// </summary> /// <param name="FormID"></param> /// <returns></returns> private bool ExportSaleDataByFormID(int FormID, int logId) { ExportDataDS.ExportDataDataTable l_dtExportData = new ExportDataDS.ExportDataDataTable(); FormDS.FormSalePaymentRow l_drFormSalePayment = new FormDS.FormSalePaymentDataTable().NewFormSalePaymentRow(); FormMarketingBLL formmarkbll = new FormMarketingBLL(); FormTEBLL formtebll = new FormTEBLL(); FormSaleBLL formsalebll = new FormSaleBLL(); MasterDataBLL masterdatabll = new MasterDataBLL(); FormPurchaseBLL formPurchaseBLL = new FormPurchaseBLL(); int Count = 0; FormDS.FormDataTable l_dtform = formmarkbll.GetFormByID(FormID); FormDS.FormRow l_drform = l_dtform.NewFormRow(); try { if (l_dtform.Rows.Count > 0) { l_drform = l_dtform[0]; if (l_drform.IsFinanceRemarkNull()) { logbll.InsertExportLogDetail(logId, "单据编号:" + l_drform.FormNo + ",提交人:" + new StuffUserBLL().GetStuffUserById(l_drform.UserID)[0].StuffName + ",错误信息:财务摘要为空,导出失败!"); return false; } l_drFormSalePayment = formsalebll.GetFormSalePaymentByID(l_drform.FormID); //if (l_drFormSalePayment.PaymentTypeID == (int)SystemEnums.PaymentType.FreeGoods) //{ // logbll.InsertExportLogDetail(logId, "单据编号:" + l_drform.FormNo + ",提交人:" + new StuffUserBLL().GetStuffUserById(l_drform.UserID)[0].StuffName + ",错误信息:货补的数据不导出!"); // return false; //} //if (l_drFormSalePayment.PaymentTypeID == (int)SystemEnums.PaymentType.Transfer) //{ // logbll.InsertExportLogDetail(logId, "单据编号:" + l_drform.FormNo + ",提交人:" + new StuffUserBLL().GetStuffUserById(l_drform.UserID)[0].StuffName + ",错误信息:帐扣的数据不导入!"); // return false; //} //if (l_drFormSalePayment.PaymentTypeID == (int)SystemEnums.PaymentType.PiaoKou) //{ // logbll.InsertExportLogDetail(logId, "单据编号:" + l_drform.FormNo + ",提交人:" + new StuffUserBLL().GetStuffUserById(l_drform.UserID)[0].StuffName + ",错误信息:票扣的数据不导入!"); // return false; //} //if (l_drFormSalePayment.PaymentTypeID == 5) //{ // logbll.InsertExportLogDetail(logId, "单据编号:" + l_drform.FormNo + ",提交人:" + new StuffUserBLL().GetStuffUserById(l_drform.UserID)[0].StuffName + ",错误信息:调整因子的数据不导入!"); // return false; //} FormDS.FormSalePaymentDetailDataTable l_dtFormSalePaymentDetail = formsalebll.GetFormSalePaymentDetailByPaymentID(FormID); for (int i = 0; i < l_dtFormSalePaymentDetail.Rows.Count; i++) { if (l_dtFormSalePaymentDetail[i].AmountRMB == Decimal.Zero) { Count++; continue; } //PurchaseDS.FormInvoiceDataTable l_dtFormInvoice = formPurchaseBLL.GetFormInvoiceByFormID(FormID); ExportDataDS.ExportDataRow l_drExportData = l_dtExportData.NewExportDataRow(); l_drExportData.FormID = FormID; l_drExportData.CompanyCode = l_drExportData.CompanyCode = masterdatabll.GetCompanyById(masterdatabll.GetVendorTypeById(masterdatabll.GetVendorByID(l_drFormSalePayment.VendorID).VendorTypeID).CompanyID).CompanyCode; l_drExportData.VendorCode = masterdatabll.GetVendorByID(l_drFormSalePayment.VendorID).VendorCode; if (l_drExportData.IsVendorCodeNull() || string.IsNullOrEmpty(l_drExportData.VendorCode)) { logbll.InsertExportLogDetail(logId, "单据编号:" + l_drform.FormNo + ",提交人:" + new StuffUserBLL().GetStuffUserById(l_drform.UserID)[0].StuffName + ",错误信息:Vendor Code为空,无法导出!"); return false; } //发票号码改为单据编号,单据编号变为10位 l_drExportData.Invoice = l_drform.FormNo; l_drExportData.Invoicedate = l_drform.SubmitDate.ToString("yyyyMMdd"); //if (l_dtFormInvoice.Rows.Count > 1) // l_drExportData.Reference = l_dtFormInvoice[1].InvoiceNo; //if (l_dtFormInvoice.Rows.Count > 0) { // l_drExportData.Invoice = l_dtFormInvoice[0].InvoiceNo; // l_drExportData.Invoicedate = l_dtFormInvoice[0].InvoiceDate.ToString("yyyyMMdd"); //} else { // l_drExportData.Invoice = l_drform.FormNo; // l_drExportData.Invoicedate = l_drform.SubmitDate.ToString("yyyyMMdd"); //} l_drExportData.TotalMoney = l_drFormSalePayment.AmountBeforeTax; //l_drExportData.Currency = masterdatabll.GetCurrencyByID(formsalebll.GetFormSaleApplyByID(l_dtFormSalePaymentDetail[i].FormSaleApplyID)[0].CurrencyID).CurrencyShortName; //l_drExportData.ExchangeRate = formsalebll.GetFormSaleApplyByID(l_dtFormSalePaymentDetail[i].FormSaleApplyID)[0].ExchangeRate; l_drExportData.ManageExpenseItem = masterdatabll.GetExpenseItemById(l_dtFormSalePaymentDetail[i].ExpenseItemID).ExpenseItemName; //profit center取AccrualCode,如果没有报错 if (masterdatabll.GetCostCenterById(l_drform.CostCenterID).IsAccrualCodeNull()) { logbll.InsertExportLogDetail(logId, "单据编号:" + l_drform.FormNo + ",提交人:" + new StuffUserBLL().GetStuffUserById(l_drform.UserID)[0].StuffName + ",错误信息:Profit Center Accrual Code为空,无法导出!"); return false; } else { l_drExportData.CostCenter = masterdatabll.GetCostCenterById(l_drform.CostCenterID).AccrualCode; } if (l_dtFormSalePaymentDetail[i].ApplyPeriod.AddMonths(5).Year == l_drform.SubmitDate.AddMonths(5).Year) l_drExportData.AccountCode = masterdatabll.GetExpenseItemById(l_dtFormSalePaymentDetail[i].ExpenseItemID).AccrualAccountingCode; else l_drExportData.AccountCode = masterdatabll.GetExpenseItemById(l_dtFormSalePaymentDetail[i].ExpenseItemID).LastAccountingCode; l_drExportData.DetailMoney = l_dtFormSalePaymentDetail[i].AmountBeforeTax; //PO No 变为取报销单的PO的No if (l_drFormSalePayment.IsFormPOIDNull()) { //PurchaseDS.FormPODataTable formPO = formPurchaseBLL.GetFormPOByParentFormID(l_dtFormSalePaymentDetail[i].FormSaleApplyID); //if (formPO.Rows.Count > 0) { // l_drExportData.PONumber = formPO[0].BPCSPONo; // PurchaseDS.FormPODetailDataTable formPODetail = formPurchaseBLL.GetPODetailByFormPOID(formPO[0].FormPOID); // l_drExportData.POLineNumber = formPODetail.Rows.Count.ToString(); //} else { l_drExportData.PONumber = 0; l_drExportData.POLineNumber = "0"; //} } else { //若已选PO,取所选PO信息 PurchaseDS.FormPORow formPO = formPurchaseBLL.GetFormPOByID(l_drFormSalePayment.FormPOID); PurchaseDS.FormPODetailDataTable formPODetail = formPurchaseBLL.GetPODetailByFormPOID(l_drFormSalePayment.FormPOID); l_drExportData.PONumber = formPO.BPCSPONo; l_drExportData.POLineNumber = formPODetail.Count.ToString(); } l_drExportData.FormNo = l_drform.FormNo; l_drExportData.FinanceRemark = l_drform.FinanceRemark; l_drExportData.TaxRateCode = masterdatabll.GetVatTypeById(l_drFormSalePayment.VatTypeID)[0].VatTypeName; l_drExportData.TaxAmt = l_dtFormSalePaymentDetail[i].TaxAmount; l_dtExportData.AddExportDataRow(l_drExportData); Count++; } if (l_dtExportData.Rows.Count == 0) { logbll.InsertExportLogDetail(logId, "单据编号:" + l_drform.FormNo + ",提交人:" + new StuffUserBLL().GetStuffUserById(l_drform.UserID)[0].StuffName + ",错误信息:无明细数据,无法导出!"); return false; } if (l_dtFormSalePaymentDetail.Rows.Count == Count) ExportByFormView(l_dtExportData); else { logbll.InsertExportLogDetail(logId, "单据编号:" + l_drform.FormNo + ",提交人:" + new StuffUserBLL().GetStuffUserById(l_drform.UserID)[0].StuffName + ",错误信息:明细数据数量不一致,无法导出!"); return false; } } } catch (Exception e) { logbll.InsertExportLogDetail(logId, "单据编号:" + l_drform.FormNo + ",提交人:" + new StuffUserBLL().GetStuffUserById(l_drform.UserID)[0].StuffName + ",错误信息:" + e.Message); return false; } return true; }
/// <summary> /// PV /// </summary> /// <param name="FormID"></param> /// <returns></returns> private bool ExportPVDataByFormID(int FormID, int logId) { ExportDataDS.ExportDataDataTable l_dtExportData = new ExportDataDS.ExportDataDataTable(); PurchaseDS.FormPVDetailDataTable l_dtFormPVDetail = new PurchaseDS.FormPVDetailDataTable(); PurchaseDS.FormPVRow l_drFormPV = new PurchaseDS.FormPVDataTable().NewFormPVRow(); FormMarketingBLL formmarkbll = new FormMarketingBLL(); FormPurchaseBLL formPurchaseBLL = new FormPurchaseBLL(); MasterDataBLL masterdatabll = new MasterDataBLL(); FormDS.FormDataTable l_dtform = formmarkbll.GetFormByID(FormID); FormDS.FormRow l_drform = l_dtform.NewFormRow(); try { if (l_dtform.Rows.Count > 0) { l_drform = l_dtform[0]; if (l_drform.IsFinanceRemarkNull()) { logbll.InsertExportLogDetail(logId, "单据编号:" + l_drform.FormNo + ",提交人:" + new StuffUserBLL().GetStuffUserById(l_drform.UserID)[0].StuffName + ",错误信息:财务摘要为空,导出失败!"); return false; } l_drFormPV = formPurchaseBLL.GetFormPVByID(FormID); //PurchaseDS.FormInvoiceDataTable l_dtFormInvoice = formPurchaseBLL.GetFormInvoiceByFormID(FormID); ExportDataDS.ExportDataRow l_drExportData = l_dtExportData.NewExportDataRow(); l_drExportData.FormID = FormID; l_drExportData.CompanyCode = masterdatabll.GetCompanyById(masterdatabll.GetVendorTypeById(masterdatabll.GetVendorByID(l_drFormPV.VendorID).VendorTypeID).CompanyID).CompanyCode; //验证公司是否和成本中心对应的一致 string CCCompanyCode = masterdatabll.GetCompanyById(masterdatabll.GetCostCenterById(l_drform.CostCenterID).CompanyID).CompanyCode; if (l_drExportData.CompanyCode != CCCompanyCode) { logbll.InsertExportLogDetail(logId, "单据编号:" + l_drform.FormNo + ",提交人:" + new StuffUserBLL().GetStuffUserById(l_drform.UserID)[0].StuffName + ",错误信息:Company Code不一致,无法导出!"); return false; } l_drExportData.VendorCode = masterdatabll.GetVendorByID(l_drFormPV.VendorID).VendorCode; if (l_drExportData.IsVendorCodeNull() || string.IsNullOrEmpty(l_drExportData.VendorCode)) { logbll.InsertExportLogDetail(logId, "单据编号:" + l_drform.FormNo + ",提交人:" + new StuffUserBLL().GetStuffUserById(l_drform.UserID)[0].StuffName + ",错误信息:Vendor Code为空,无法导出!"); return false; } //发票号码改为单据编号,单据编号变为10位 l_drExportData.Invoice = l_drform.FormNo; //l_drExportData.Invoicedate = l_drform.SubmitDate.ToString("yyyyMMdd"); l_drExportData.Invoicedate = getInvoiceDate(l_drform.FormID, l_drform.SubmitDate); //if (l_dtFormInvoice.Rows.Count > 1) // l_drExportData.Reference = l_dtFormInvoice[1].InvoiceNo; //if (l_dtFormInvoice.Rows.Count > 0) { // l_drExportData.Invoice = l_dtFormInvoice[0].InvoiceNo; // l_drExportData.Invoicedate = l_dtFormInvoice[0].InvoiceDate.ToString("yyyyMMdd"); //} else { // l_drExportData.Invoice = l_drform.FormNo; // l_drExportData.Invoicedate = l_drform.SubmitDate.ToString("yyyyMMdd"); //} l_drExportData.TotalMoney = l_drFormPV.AMTBeforeTax; //l_drExportData.Currency = masterdatabll.GetCurrencyByID(l_drFormPV.CurrencyID).CurrencyShortName; //l_drExportData.ExchangeRate = l_drFormPV.ExchangeRate; l_drExportData.ManageExpenseItem = masterdatabll.GetItemCategoryById(l_drFormPV.FinalItemCategoryID).AccountingName; l_drExportData.CostCenter = masterdatabll.GetCostCenterById(l_drform.CostCenterID).CostCenterCode; l_drExportData.AccountCode = masterdatabll.GetItemCategoryById(l_drFormPV.FinalItemCategoryID).AccountingCode; l_drExportData.DetailMoney = l_drFormPV.AMTBeforeTax; if (!l_drFormPV.IsFormPOIDNull()) { PurchaseDS.FormPORow formPO = formPurchaseBLL.GetFormPOByID(l_drFormPV.FormPOID); l_drExportData.PONumber = formPO.BPCSPONo; PurchaseDS.FormPODetailDataTable formPODetail = formPurchaseBLL.GetPODetailByFormPOID(l_drFormPV.FormPOID); l_drExportData.POLineNumber = formPODetail.Rows.Count.ToString(); } else { l_drExportData.PONumber = 0; l_drExportData.POLineNumber = "0"; } l_drExportData.FinanceRemark = l_drform.FinanceRemark; l_drExportData.FormNo = l_drform.FormNo; l_drExportData.TaxAmt = l_drFormPV.AMTTax; l_drExportData.TaxRateCode = masterdatabll.GetVatTypeById(l_drFormPV.VatRateID)[0].VatTypeName; l_dtExportData.AddExportDataRow(l_drExportData); if (l_dtExportData.Rows.Count == 0) { logbll.InsertExportLogDetail(logId, "单据编号:" + l_drform.FormNo + ",提交人:" + new StuffUserBLL().GetStuffUserById(l_drform.UserID)[0].StuffName + ",错误信息:无明细数据,无法导出!"); return false; } ExportByFormView(l_dtExportData); } } catch (Exception e) { logbll.InsertExportLogDetail(logId, "单据编号:" + l_drform.FormNo + ",提交人:" + new StuffUserBLL().GetStuffUserById(l_drform.UserID)[0].StuffName + ",错误信息:" + e.Message); return false; } return true; }
private bool ExportPO(int formid, int logId) { string BakPath = ConfigurationManager.AppSettings["ExportService.BakPath"]; AuthorizationBLL authorizationbll = new AuthorizationBLL(); MasterDataBLL masterdatabll = new MasterDataBLL(); FormQueryBLL formQueryBLL = new FormQueryBLL(); FormPurchaseBLL formPurchaseBLL = new FormPurchaseBLL(); OUTreeBLL outreebll = new OUTreeBLL(); PurchaseDS.FormDataTable l_dtform = new PurchaseDS.FormDataTable(); PurchaseDS.FormRow form = l_dtform.NewFormRow(); try { PurchaseDS.FormPORow formPO = formPurchaseBLL.GetFormPOByID(formid); PurchaseDS.FormPODetailDataTable formPODetail = formPurchaseBLL.GetPODetailByFormPOID(formPO.FormPOID); form = formPurchaseBLL.GetFormByID(formPO.FormPOID)[0]; string POFileName = ConfigurationManager.AppSettings["ExportService.POFileName"]; string POLineFileName = ConfigurationManager.AppSettings["ExportService.POLineFileName"]; string spit = "\t"; string CompanyCode = masterdatabll.GetCompanyById(masterdatabll.GetVendorTypeById(masterdatabll.GetVendorByID(formPO.VendorID).VendorTypeID).CompanyID).CompanyCode; string VendorCode = masterdatabll.GetVendorByID(formPO.VendorID).VendorCode; string POcontent = ( "PH" + spit + "" + spit + formPO.BPCSPONo + spit + "0" + spit + "" + spit + "0" + spit + CompanyCode + spit + "" + spit + CompanyCode + spit + VendorCode + spit + "0" + spit + "4" + spit + "" + spit + masterdatabll.GetCompanyById(formPO.CompanyID).CompanyName + spit + authorizationbll.GetStuffUserById(form.UserID).UserName.ToUpper() + spit + bSubstring(formPO.DeliveryAddress, 30) + spit + SpitAddress(formPO.DeliveryAddress, 60) + spit + SpitAddress(formPO.DeliveryAddress, 90) + spit + "" + spit + "" + spit + "" + spit + form.SubmitDate.ToString("yyyyMMdd") + spit + "0" + spit + "0" + spit + "0" + spit + formPODetail[0].DeliveryDate.ToString("yyyyMMdd") + spit + "0" + spit + "0" + spit + bSubstring(formPO.Remark, 30) + spit + masterdatabll.GetPaymentTermById(masterdatabll.GetVendorByID(formPO.VendorID).PaymentTermID)[0].PaymentTermName + spit + "1" + spit + "" + spit + outreebll.GetOrganizationUnitById(form.OrganizationUnitID).OrganizationUnitCode + spit + masterdatabll.GetShippingTermById(formPO.ShippingTermID).ShippingTermCode + spit + "" + spit + masterdatabll.GetCurrencyByID(formPO.CurrencyID).CurrencyShortName + spit + formPO.ExchangeRate + spit + formPO.ExchangeRate + spit + formPODetail.Rows.Count + spit + formPO.ExchangeRate + spit + authorizationbll.GetStuffUserById(form.UserID).UserName.ToUpper() + spit + "" + spit + authorizationbll.GetStuffUserById(form.UserID).UserName.ToUpper() + spit + form.ApprovedDate.ToString("yyyyMMdd") + spit + "" + spit + "0" + spit + "" + spit + "0" + spit + "" + spit + "" + spit + "" + spit + "" + spit + "").Replace("\r", "").Replace("\n", ""); int order = 0; string[] PODetailcontent = new string[formPODetail.Rows.Count]; foreach (PurchaseDS.FormPODetailRow l_drformPODetail in formPODetail) { order++; PODetailcontent[order - 1] = ( "PO" + spit + formPO.BPCSPONo + spit + order + spit + l_drformPODetail.ItemCode.ToUpper() + spit + VendorCode + spit + l_drformPODetail.Quantity + spit + l_drformPODetail.Quantity + spit + l_drformPODetail.DeliveryDate.ToString("yyyyMMdd") + spit + "" + spit + "0" + spit + l_drformPODetail.AmountRMB.ToString() + spit + "0" + spit + "0" + spit + "EA" + spit + "0" + spit + "" + spit + "0" + spit + "0" + spit + "" + spit + "" + spit + "" + spit + DateTime.Now.ToString("yyyyMMdd") + spit + masterdatabll.GetPaymentTermById(masterdatabll.GetVendorByID(formPO.VendorID).PaymentTermID)[0].PaymentTermName + spit + "" + spit + "0" + spit + "1" + spit + "1" + spit + "" + spit + CompanyCode + spit + "0" + spit + "0" + spit + "0" + spit + "0" + spit + l_drformPODetail.DeliveryDate.ToString("yyyyMMdd") + spit + "" + spit + "0" + spit + "0" + spit + "" + spit + masterdatabll.GetCurrencyByID(formPO.CurrencyID).CurrencyShortName + spit + formPO.ExchangeRate + spit + formPO.ExchangeRate + spit + "0" + spit + l_drformPODetail.AmountRMB.ToString() + spit + "0" + spit + "1" + spit + "" + spit + "0" + spit + "0" + spit + "0" + spit + "" + spit + "" + spit + "" + spit + "01" + spit + "4" + spit + masterdatabll.GetCompanyById(formPO.CompanyID).CompanyName + spit +//Ship To Company authorizationbll.GetStuffUserById(form.UserID).UserName.ToUpper() + spit + bSubstring(formPO.DeliveryAddress, 30) + spit + SpitAddress(formPO.DeliveryAddress, 60) + spit + SpitAddress(formPO.DeliveryAddress, 90) + spit + "" + spit + "" + spit + "" + spit + "0" + spit + "0" + spit + l_drformPODetail.DeliveryDate.ToString("yyyyMMdd") + spit + "0" + spit + l_drformPODetail.DeliveryDate.ToString("yyyyMMdd") + spit + l_drformPODetail.DeliveryDate.ToString("yyyyMMdd") + spit + "" + spit + outreebll.GetOrganizationUnitById(form.OrganizationUnitID).OrganizationUnitCode + spit + "" + spit + "" + spit + masterdatabll.GetCostCenterById(form.CostCenterID).CostCenterCode + spit + l_drformPODetail.ItemCode.ToUpper() + spit + l_drformPODetail.ItemDescription + spit + "1" + spit + "0" + spit + "0" + spit + "3" + spit + "0" + spit + "0" + spit + "" + spit + "" + spit + "" + spit + "" + spit + "" + spit + "" + spit + "" + spit + l_drformPODetail.Quantity).Replace("\r", "").Replace("\n", ""); ; } File.AppendAllLines(path + POLineFileName, PODetailcontent, Encoding.Default); File.AppendAllLines(BakPath + DateTime.Now.ToString("yyyyMMddhhmmss") + POLineFileName, PODetailcontent, Encoding.Default); File.AppendAllText(path + POFileName, POcontent + "\r\n", Encoding.Default); File.AppendAllText(BakPath + DateTime.Now.ToString("yyyyMMddhhmmss") + POFileName, POcontent, Encoding.Default); } catch (Exception e) { logbll.InsertExportLogDetail(logId, "单据编号:" + form.FormNo + ",提交人:" + new StuffUserBLL().GetStuffUserById(form.UserID)[0].StuffName + ",错误信息:" + e.Message); return false; } return true; }
private void UpdateVendorbyID(int VendorId) { MasterDataBLL masterdatabll = new MasterDataBLL(); MasterData.VendorRow l_drVendor = masterdatabll.GetVendorByID(VendorId); l_drVendor.IsExport = true; masterdatabll.TAVendor.Update(l_drVendor); }
public string GetVendorNameByID(object VendorID) { if (VendorID.ToString() != string.Empty) { MasterDataBLL mdBLL = new MasterDataBLL(); int id = Convert.ToInt32(VendorID); MasterData.VendorRow rowVendor = mdBLL.GetVendorByID(id); MasterData.CompanyRow rowCompany = mdBLL.GetCompanyById(rowVendor.CompanyID); return rowCompany.CompanyCode + "-" + rowVendor.VendorName; } else { return null; } }