Example #1
0
        //Actualiza status de comprobante
        private bool UpdateCancel(string pStrDocEntry, string pStrCodeVoucher)
        {
            bool lBolResult = false;

            try
            {
                List <VouchersDetail> lLstVouchersDetail = mObjPurchaseServiceFactory.GetPurchaseVouchersService().GetVoucherDetailByTrans(pStrDocEntry);
                if (lLstVouchersDetail.Count > 0)
                {
                    VouchersDetail lObjVoucherDetail = lLstVouchersDetail.Where(x => x.DocEntry == pStrDocEntry).FirstOrDefault();
                    lObjVoucherDetail.Status = "Cancelado";

                    if (mObjPurchaseServiceFactory.GetVouchersDetailService().Update(lObjVoucherDetail) == 0)
                    {
                        mObjPurchaseServiceFactory.GetVouchersService().UpdateTotal(pStrCodeVoucher);
                        lBolResult = true;
                        LogService.WriteSuccess("PolicyDI (UpdateCancel) Cancelacion realizada correctamente, TransId: " + pStrDocEntry);
                    }
                    else
                    {
                        lBolResult = false;
                        LogService.WriteError("PolicyDI (UpdateCancel)  TransId:" + pStrDocEntry + " Mensaje:" + DIApplication.Company.GetLastErrorDescription());
                    }
                }
            }
            catch (Exception ex)
            {
                LogService.WriteError("PolicyDI (UpdateCancel) TransId:" + pStrDocEntry + " Mensaje:" + ex.Message);
                LogService.WriteError(ex);
            }
            return(lBolResult);
        }
Example #2
0
        /// <summary>
        /// Actualiza  estatus
        /// </summary>
        public void UpdateStatus(string pStrCode, string pStrDocEntry, string pStrCodeVoucher)
        {
            try
            {
                VouchersDetail lObjVoucher = mObjPurchaseServiceFactory.GetPurchaseVouchersService().GetVouchesDetail(pStrCode).Where(x => x.DocEntry == pStrDocEntry).First();
                if (!string.IsNullOrEmpty(lObjVoucher.DocEntry))
                {
                    string lStrDocStatus = mObjPurchaseServiceFactory.GetPurchaseInvoiceService().GetDocCanceled(pStrDocEntry, lObjVoucher.Type);
                    if (!lStrDocStatus.Equals("Cancelado"))
                    {
                        lStrDocStatus = mObjPurchaseServiceFactory.GetPurchaseInvoiceService().GetDocStatus(pStrDocEntry);
                    }


                    lObjVoucher.Status = lStrDocStatus;
                    if (mObjPurchaseServiceFactory.GetVouchersDetailService().Update(lObjVoucher) != 0)
                    {
                        UIApplication.ShowMessageBox(string.Format("Exception: {0}", DIApplication.Company.GetLastErrorDescription()));
                        LogService.WriteError("InvoiceDI (AddVoucherDetail) " + DIApplication.Company.GetLastErrorDescription());
                    }
                    else
                    {
                        mObjPurchaseServiceFactory.GetVouchersService().UpdateTotal(pStrCodeVoucher);
                    }
                }
            }
            catch (Exception ex)
            {
                LogService.WriteError("InvoiceDI (UpdateStatus) " + ex.Message);
                LogService.WriteError(ex);
            }
        }
Example #3
0
        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);
        }