コード例 #1
0
ファイル: PolicyDI.cs プロジェクト: radtek/UGRS_Full
        //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);
        }
コード例 #2
0
        /// <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);
        }
コード例 #3
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);
            }
        }
コード例 #4
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);
        }
コード例 #5
0
        /// <summary>
        /// Obtener lista de vouchers por filtro.
        /// </summary>
        public IList <Vouchers> GetVouchersList(SearchVouchersDTO pObjSearchVouchersDTO)
        {
            List <Vouchers> lLstObjVouchers = new List <Vouchers>();

            SAPbobsCOM.Recordset lObjRecordset = null;
            try
            {
                string lStrQuery = this.GetSQL("GetVoucher");
                Dictionary <string, string> lLstStrParameters = new Dictionary <string, string>();
                foreach (string lStrFilter in GetFilterssVouchers(pObjSearchVouchersDTO, lLstStrParameters))
                {
                    lStrQuery += " " + lStrFilter;
                }

                lStrQuery += " order by Code desc";

                //this.UIAPIRawForm.DataSources.DataTables.Item("RESULT").ExecuteQuery(lStrQuery);

                lObjRecordset = (SAPbobsCOM.Recordset)DIApplication.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
                lStrQuery     = lStrQuery.Inject(lLstStrParameters);

                lObjRecordset.DoQuery(lStrQuery);

                if (lObjRecordset.RecordCount > 0)
                {
                    for (int i = 0; i < lObjRecordset.RecordCount; i++)
                    {
                        Vouchers lObjVoucher = new Vouchers();
                        lObjVoucher.RowCode  = lObjRecordset.Fields.Item("Code").Value.ToString();
                        lObjVoucher.Folio    = lObjRecordset.Fields.Item("U_Folio").Value.ToString();
                        lObjVoucher.Status   = Convert.ToInt32(lObjRecordset.Fields.Item("U_Status").Value.ToString());
                        lObjVoucher.Area     = lObjRecordset.Fields.Item("U_Area").Value.ToString();
                        lObjVoucher.Employee = lObjRecordset.Fields.Item("U_Employee").Value.ToString();

                        lObjVoucher.Date  = Convert.ToDateTime(lObjRecordset.Fields.Item("U_Date").Value.ToString());
                        lObjVoucher.Total = Convert.ToDouble(lObjRecordset.Fields.Item("U_Total").Value.ToString());
                        double lDblTotal = Convert.ToDouble((lObjRecordset.Fields.Item("DocTotal").Value.ToString()));
                        if (lObjVoucher.Total == lDblTotal && lObjVoucher.Status == (int)StatusEnum.Authorized_Ope_Admon)
                        {
                            //lObjVoucher.Status = 5;
                            if (mObjPurchaseServiceFactory.GetVouchersService().Update(lObjVoucher.RowCode, StatusEnum.Closed) != 0)
                            {
                                string lStrerror = DIApplication.Company.GetLastErrorDescription();
                                UIApplication.ShowMessageBox(lStrerror);
                            }
                            else
                            {
                                lObjVoucher.Status = (int)StatusEnum.Closed; // lObStatusEnum.GetDescription();
                            }
                        }

                        lLstObjVouchers.Add(lObjVoucher);
                        lObjRecordset.MoveNext();
                    }
                }
            }
            catch (Exception ex)
            {
                UIApplication.ShowMessageBox(string.Format("InitDataSourcesException: {0}", ex.Message));
                LogService.WriteError("PurchasesDAO (GetVouchersList): " + ex.Message);
                LogService.WriteError(ex);
            }
            finally
            {
                MemoryUtility.ReleaseComObject(lObjRecordset);
            }

            return(lLstObjVouchers);
        }