/// <summary> /// Actualiza el total /// </summary> public int UpdateTotal(string pStrCode) { int lIntResult = -1; try { PurchasesServiceFactory mObjPurchaseServiceFactory = new PurchasesServiceFactory(); var lObjVoucher = mObjPurchaseServiceFactory.GetPurchaseVouchersService().GetVouches(pStrCode); if (lObjVoucher.Count > 0) { List <VouchersDetailDTO> lLstVouchersDetail = mObjPurchaseServiceFactory.GetPurchaseVouchersService().GetInvoiceVouchesDetail(lObjVoucher[0].Area, lObjVoucher[0].Folio); lObjVoucher[0].Total = lLstVouchersDetail.Where(x => x.Status != "Cancelado").Sum(x => x.Total); // lObjVoucher[0].Total = pDblTotal; // lObjVoucher[0].Total = mObjPurchaseServiceFactory.GetPurchaseVouchersService().GetVouchesDetail(pStrCode).Where(x => x.Status != "Cancelado").Sum(x => x.Total); lIntResult = mObjPurchaseServiceFactory.GetVouchersService().Update(lObjVoucher[0]); if (lIntResult != 0) { UIApplication.ShowMessageBox(string.Format("Exception: {0}", DIApplication.Company.GetLastErrorDescription())); LogService.WriteError("InvoiceDI (AddVoucherDetail) " + DIApplication.Company.GetLastErrorDescription()); } } else { LogService.WriteError("VouchersService: Comprobante no encontrado: " + pStrCode); } } catch (System.Exception ex) { LogService.WriteError("VouchersService (UpdateTotal) " + ex.Message); LogService.WriteError(ex); } return(lIntResult); }
public int Update(string pStrCode, StatusEnum pEnumStatus) { PurchasesServiceFactory mObjPurchaseServiceFactory = new PurchasesServiceFactory(); var lObjVoucher = mObjPurchaseServiceFactory.GetPurchaseVouchersService().GetVouches(pStrCode); if (lObjVoucher.Count > 0) { lObjVoucher[0].Status = (int)pEnumStatus; return(mObjVouchersDAO.Update(lObjVoucher[0])); } return(-1); }
static void Main(string[] args) { try { Application oApp = null; if (args.Length < 1) { oApp = new Application(); } else { oApp = new Application(args[0]); } LogService.Filename("AddOnCompras"); Menu MyMenu = new Menu(); MyMenu.AddMenuItems(); oApp.RegisterMenuEventHandler(MyMenu.SBO_Application_MenuEvent); DIApplication.DIConnect((SAPbobsCOM.Company)Application.SBO_Application.Company.GetDICompany()); Application.SBO_Application.AppEvent += new SAPbouiCOM._IApplicationEvents_AppEventEventHandler(SBO_Application_AppEvent); //TestXML(); //Initialize Tables UIApplication.ShowSuccess(string.Format("Inicializar las tablas")); PurchasesServiceFactory lObjFoodProductionFactory = new PurchasesServiceFactory(); lObjFoodProductionFactory.GetSetupService().InitializeTables(); UIApplication.ShowSuccess(string.Format("AddonCompras 1.2.69 iniciado correctamente")); LogService.WriteSuccess(string.Format("AddonCompras 1.2.69 iniciado correctamente")); oApp.Run(); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); System.Windows.Forms.Application.Exit(); } }
public bool UpdateStatus(VouchersDetail pObjVoucherDetail) { bool lBolTranSuccess = false; try { string lStrDocStatus = GetDocCanceled(pObjVoucherDetail.DocEntry.ToString(), pObjVoucherDetail.Type); if (!lStrDocStatus.Equals("Cancelado")) { lStrDocStatus = GetDocStatus(pObjVoucherDetail.DocEntry.ToString()); } if (lStrDocStatus != pObjVoucherDetail.Status && pObjVoucherDetail.Type != "Nota") { pObjVoucherDetail.Status = lStrDocStatus; DIApplication.Company.StartTransaction(); PurchasesServiceFactory lObjPurchasesServiceFactory = new PurchasesServiceFactory(); //if (pObjVoucherDetail.Type == "Nota") //{ // var lObjVoucher = lObjPurchasesServiceFactory.GetPurchaseVouchersService().GetVoucherDetailByTrans(pObjVoucherDetail.DocEntry); // pObjVoucherDetail.Total = lObjVoucher.Sum(x => x.Total); // pObjVoucherDetail.Subtotal = lObjVoucher.Sum(x => x.Subtotal); //} if (lObjPurchasesServiceFactory.GetVouchersDetailService().Update(pObjVoucherDetail) == 0) { if (lObjPurchasesServiceFactory.GetVouchersService().UpdateTotal(pObjVoucherDetail.CodeVoucher) != 0) { LogService.WriteError("InvoiceDI (UpdateTotal) " + DIApplication.Company.GetLastErrorDescription()); } else { lBolTranSuccess = true; } } } } catch (Exception ex) { lBolTranSuccess = false; LogService.WriteError("PurchasesDAO (UpdateStatus): " + ex.Message); LogService.WriteError(ex); } finally { try { if (lBolTranSuccess) { DIApplication.Company.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_Commit); lBolTranSuccess = true; } else { if (DIApplication.Company.InTransaction) { DIApplication.Company.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack); lBolTranSuccess = false; } } } catch (Exception ex) { lBolTranSuccess = false; LogService.WriteError("PurchasesDAO (UpdateStatus): " + ex.Message); LogService.WriteError(ex); } } return(lBolTranSuccess); }