Beispiel #1
0
 public AuthorizationDS.OrganizationUnitRow GetNearestCostCenter(int OUID)
 {
     OUTreeBLL otBLL = new OUTreeBLL();
     AuthorizationDS.OrganizationUnitRow rowOU = otBLL.GetOrganizationUnitById(OUID);
     if (rowOU.IsCostCenterIDNull()) {
         return GetNearestCostCenter(rowOU.ParentOrganizationUnitId);
     } else {
         return rowOU;
     }
 }
Beispiel #2
0
        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;
        }