private void btnAnular_Click(object sender, EventArgs e)
        {
            try
            {
                imp_ordencompra_ext_x_ct_cbtecble_Bus BusOrdxCbt = new imp_ordencompra_ext_x_ct_cbtecble_Bus();
                Get();
                ct_Cbtecble_Bus CbteCble_B = new ct_Cbtecble_Bus();
                if (lbl_Estado.Visible)
                {
                    MessageBox.Show("No se puede anular el gasto debido a que ya se encuentra anulado.", "Mensaje Erp");
                    return;
                }
                FrmGe_MotivoAnulacion oFrm = new FrmGe_MotivoAnulacion();
                if (MessageBox.Show("¿Está seguro que desea anular el Gasto #" + txtIdRegistroGasto.Text + " ?", "Anulación de Gastos", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    oFrm.ShowDialog();
                    String MovitoAnulacion = oFrm.motivoAnulacion;
                    _Info.IdTipoCbte_Anul = tipocbte.IdTipoCbte_Anul;
                    string mensej = "";
                    if (Bus.AnularDB(_Info))
                    {
                        MessageBox.Show("Anulado con exito el Gasto # " + _Info.IdRegistroGasto);
                        lbl_Estado.Visible       = true;
                        btnOk.Enabled            = false;
                        BtnGuardarYsalir.Enabled = false;
                        decimal IdCbteCbleRev = 0;
                        string  msg2          = "";
                        if (generarDiarioTipoImp == true)
                        {
                            CbteCble_B.ReversoCbteCble(param.IdEmpresa, _SetInfo.IdCbteCble, tipocbte.IdTipoCbte, tipocbte.IdTipoCbte_Anul, ref IdCbteCbleRev, ref msg2, param.IdUsuario, MovitoAnulacion);

                            Bus.ACtualizarAnulado(_Info, IdCbteCbleRev);
                            imp_ordencompra_ext_x_ct_cbtecble_Info ordCompraxCbte_info = new imp_ordencompra_ext_x_ct_cbtecble_Info();
                            ordCompraxCbte_info.ct_IdEmpresa         = ordCompraxCbte_info.imp_IdEmpresa = param.IdEmpresa;
                            ordCompraxCbte_info.imp_IdOrdenCompraExt = Convert.ToDecimal(searchLookUpEditImportacion.EditValue);
                            var idSucursa = Importaciones.Find(var => var.IdOrdenCompraExt == ordCompraxCbte_info.imp_IdOrdenCompraExt).IdSucusal;
                            ordCompraxCbte_info.imp_IdSucusal = Convert.ToInt32(idSucursa);
                            ordCompraxCbte_info.ct_IdTipoCbte = tipocbte.IdTipoCbte_Anul;
                            ordCompraxCbte_info.ct_IdCbteCble = IdCbteCbleRev;
                            ordCompraxCbte_info.TipoReg       = "AGAST";
                            BusOrdxCbt.GuardarDB(ordCompraxCbte_info, ref msg2);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log_Error_bus.Log_Error(ex.ToString());
            }
        }
Ejemplo n.º 2
0
        public Boolean GrabarDB(cp_orden_giro_Info Info_OrdenGiro, ref decimal idCbteCble, ref string mensaje)
        {
            Boolean res = false;

            try
            {
                //validar serie y #Documento Factura



                if (Validar_y_corregir_objeto(Info_OrdenGiro, ref mensaje))
                {
                    if (data.ExisteFacturaPorProveedor(Info_OrdenGiro.IdEmpresa, Info_OrdenGiro.IdProveedor, Info_OrdenGiro.co_serie, Info_OrdenGiro.co_factura))
                    {
                        mensaje = "La Factura#: " + Info_OrdenGiro.co_serie + "-" + Info_OrdenGiro.co_factura + ". Ya se encuentra ingresada";
                        res     = false;
                        return(false);
                    }


                    if (!CbteCble_B.GrabarDB(Info_OrdenGiro.Info_CbteCble_x_OG, ref idCbteCble, ref mensaje))
                    {
                        mensaje = "No se pudo Ingresar el Cbte Cble de la Factura Proveedor \n Comuníquese con sistema por favor" + mensaje; return(false);
                    }
                    else
                    {
                        Info_OrdenGiro.IdCbteCble_Ogiro = idCbteCble;
                        if (!data.GrabarDB(Info_OrdenGiro, ref mensaje))
                        {
                            mensaje = "No se pudo Ingresar la Factura Proveedor \n Comuníquese con sistema por favor" + mensaje; return(false);
                        }

                        if (Info_OrdenGiro.lst_reembolso != null)
                        {
                            if (Info_OrdenGiro.lst_reembolso.Count != 0)
                            {
                                if (!Reem_B.GuardarDBLst(Info_OrdenGiro.lst_reembolso, Info_OrdenGiro.IdEmpresa, Info_OrdenGiro.IdTipoCbte_Ogiro, Info_OrdenGiro.IdCbteCble_Ogiro, ref mensaje))
                                {
                                    mensaje = "No se pudo Ingresar lo(s) reembolso(s) \n Comuníquese con sistema por favor" + mensaje; return(false);
                                }
                            }
                        }


                        if (Info_OrdenGiro.lst_formasPagoSRI != null)
                        {
                            if (Info_OrdenGiro.lst_formasPagoSRI.Count != 0)
                            {
                                if (!pagoSRI_B.GuardarDB(Info_OrdenGiro.lst_formasPagoSRI, Info_OrdenGiro.IdEmpresa, Info_OrdenGiro.IdTipoCbte_Ogiro, Info_OrdenGiro.IdCbteCble_Ogiro, ref mensaje))
                                {
                                    mensaje = "No se pudo Ingresar la(s) Forma(s) de Pago \n Comuníquese con sistema por favor" + mensaje; return(false);
                                }
                            }
                        }

                        if (Info_OrdenGiro.Info_cuotas_x_doc.lst_cuotas_det.Count != 0)
                        {
                            Info_OrdenGiro.Info_cuotas_x_doc.IdEmpresa_ct = Info_OrdenGiro.IdEmpresa;
                            Info_OrdenGiro.Info_cuotas_x_doc.IdTipoCbte   = Info_OrdenGiro.IdTipoCbte_Ogiro;
                            Info_OrdenGiro.Info_cuotas_x_doc.IdCbteCble   = Info_OrdenGiro.IdCbteCble_Ogiro;
                            bus_cuotas_x_doc.GuardarDB(Info_OrdenGiro.Info_cuotas_x_doc);
                        }

                        if (Info_OrdenGiro.Info_Retencion != null && Info_OrdenGiro.Info_Retencion.Info_CbteCble_x_RT != null)
                        {
                            if (Info_OrdenGiro.Info_Retencion.IdEmpresa != 0)
                            {
                                Info_OrdenGiro.Info_Retencion.IdCbteCble_Ogiro = Info_OrdenGiro.IdCbteCble_Ogiro = idCbteCble;


                                //grabando la retencion

                                if (Bus_Retencion.Graba_CbteCble_Ret_FactProveedor(Info_OrdenGiro.Info_Retencion, Info_OrdenGiro.Info_Retencion.Info_CbteCble_x_RT, ref mensaje))
                                {
                                    //actualizando el suencial de la retencion serie y #retencion
                                    Bus_Retencion.Modificar_Num_Retencion(Info_OrdenGiro.Info_Retencion, ref mensaje);
                                }
                                else
                                {
                                    mensaje = "Hubo un inconveniente al ingresar la retención comuniquese con sistemas.." + mensaje; res = false;
                                }
                            }
                        }

                        decimal IdCbteCble = 0; IdCbteCble = idCbteCble;

                        if (Info_OrdenGiro.LstImportacionGrid != null)
                        {
                            if (Info_OrdenGiro.LstImportacionGrid.Count() > 0)
                            {
                                Info_OrdenGiro.LstImportacionGrid.ForEach(p => p.IdCbteCble = IdCbteCble);

                                if (ocXgastosxImp_B.GuardarDB(Info_OrdenGiro.LstImportacionGrid, ref mensaje))
                                {
                                    Info_OrdenGiro.LstocXcbt_I.ForEach(p => p.ct_IdCbteCble = IdCbteCble);
                                    if (ocXcbt_B.GuardarDB(Info_OrdenGiro.LstocXcbt_I, ref mensaje))
                                    {
                                        Info_OrdenGiro.LisImportacion.ForEach(p => p.og_IdCbteCble = IdCbteCble);
                                        if (Importacion_B.GrabarDB(Info_OrdenGiro.LisImportacion, ref mensaje))
                                        {
                                            Info_OrdenGiro.LstImportacionOC.ForEach(p => p.og_IdCbteCble = IdCbteCble);

                                            if (!OC_B.GrabarDB(Info_OrdenGiro.LstImportacionOC, ref mensaje))
                                            {
                                                mensaje = "Hubo un inconveniente al ingresar la importación comuniquese con sistemas.." + mensaje; res = false;
                                            }
                                        }
                                        else
                                        {
                                            mensaje = "Hubo un inconveniente al ingresar la importación comuniquese con sistemas.." + mensaje; res = false;
                                        }
                                    }
                                    else
                                    {
                                        mensaje = "Hubo un inconveniente al ingresar la importación comuniquese con sistemas.." + mensaje; res = false;
                                    }
                                }
                                else
                                {
                                    mensaje = "Hubo un inconveniente al ingresar la importación comuniquese con sistemas.." + mensaje; res = false;
                                }
                            }
                        }
                    }
                }
                else
                {
                    res = false;
                    return(false);
                }


                res = true;
            }
            catch (Exception ex)
            {
                Core.Erp.Info.Log_Exception.LoggingManager.Logger.Log(Core.Erp.Info.Log_Exception.LoggingCategory.Error, ex.Message);
                throw new Core.Erp.Info.Log_Exception.DalException(string.Format("", "GrabarFactProveedor", ex.Message), ex)
                      {
                          EntityType = typeof(cp_orden_giro_Bus)
                      };
            }
            return(res);
        }