Ejemplo n.º 1
0
        private void ucGe_Menu_Mantenimiento_x_usuario_event_btnNuevoChq_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            try
            {
                if (cartera_I.vt_NunDocumento != null)
                {
                    frmCxc_CobrosRetenciones frm = new frmCxc_CobrosRetenciones();
                    if (cartera_I.vt_tipoDoc == "FACT")
                    {
                        fa_factura_Info Infofac = new fa_factura_Info();
                        fa_factura_Bus  busFac  = new fa_factura_Bus();
                        Infofac = busFac.Get_Info_factura(cartera_I.IdEmpresa, cartera_I.IdSucursal, cartera_I.IdBodega, cartera_I.IdComprobante);
                        frm.setInfo(Infofac, null, cartera_I.pe_nombreCompleto, Convert.ToInt32(Infofac.IdCaja), cartera_I.vt_tipoDoc);
                    }
                    else
                    {
                        fa_notaCreDeb_Info InfoND = new fa_notaCreDeb_Info();
                        fa_notaCredDeb_Bus busND  = new fa_notaCredDeb_Bus();
                        InfoND = busND.Get_Info_notaCreDeb_x_ND(cartera_I.IdEmpresa, cartera_I.IdSucursal, cartera_I.IdBodega, cartera_I.IdComprobante);
                        frm.setInfo(null, InfoND, cartera_I.pe_nombreCompleto, Convert.ToInt32(InfoND.IdCaja), cartera_I.vt_tipoDoc);
                    }

                    frm.Accion = Cl_Enumeradores.eTipo_action.grabar;


                    if (cartera_I.Saldo > 0)
                    {
                        frm.ShowDialog();
                        cargar();
                    }
                    else
                    {
                        MessageBox.Show("El Documento seleccionado Debe Tener Saldo a Cobrar", "SISTEMA", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    MessageBox.Show("Antes de continuar seleccione un Documento a Cobrar", "SISTEMA", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                Log_Error_bus.Log_Error(ex.ToString());
                MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public Boolean GuardarDB(fa_devol_venta_Info Info, ref string msg)
        {
            try
            {
                // nota de credito
                fa_notaCredDeb_Bus         BusBNotaDB = new fa_notaCredDeb_Bus();
                in_movi_inve_Info          invCabInfo = new in_movi_inve_Info();
                in_movi_inve_Bus           inBus      = new in_movi_inve_Bus();
                cxc_cobro_Info             Cobro      = new cxc_cobro_Info();
                cl_parametrosGenerales_Bus param      = cl_parametrosGenerales_Bus.Instance;
                string  mensaje_cbte_cble             = "";
                decimal idNota                = 0;
                string  codigoNota            = "";
                string  mensajeDocumentoDupli = "";
                string  mensajeError          = "";
                string  numDocumento          = "";


                if (BusBNotaDB.GuardarDB(Info.InfoNotaCreDeb, ref idNota, ref mensajeDocumentoDupli, ref mensajeError))
                {
                    Info.IdNota = idNota;
                    data.GuardarDB(Info, ref msg);
                    invCabInfo = setInventarioMovi(Info);
                    inBus.GrabarDB(invCabInfo, ref idNota, ref mensaje_cbte_cble, ref msg);
                }


                return(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("", "GuardarDB", ex.Message), ex)
                      {
                          EntityType = typeof(fa_devol_venta_Bus)
                      };
            }
        }
        public Boolean AnularDevolucion(int idEmpresa, int idSucursal, int idBodega, decimal idDevolucion, DateTime Fecha_Anulacion, string motivo, ref string mensageError)
        {
            try
            {
                in_movi_inve_Bus    MoviInve_Bus = new in_movi_inve_Bus();
                in_movi_inve_Info   InfoMoviAnu  = new in_movi_inve_Info();
                fa_devol_venta_Bus  DevVtaBus    = new fa_devol_venta_Bus();
                fa_devol_venta_Info DevVta_info  = new fa_devol_venta_Info();
                fa_notaCredDeb_Bus  BusBNotaDB   = new fa_notaCredDeb_Bus();
                fa_notaCreDeb_Info  InfoNotaCre  = new fa_notaCreDeb_Info();
                Boolean             resAnuMoviInv;
                Boolean             resAnuDevVta;
                string MensajeError = "";



                Fecha_Anulacion = Convert.ToDateTime(Fecha_Anulacion.ToShortDateString());

                #region "validaciones"
                ct_Periodo_Bus Perbus = new ct_Periodo_Bus();


                if (Perbus.Get_Periodo_Esta_Cerrado(idEmpresa, Fecha_Anulacion, ref MensajeError))
                {
                    mensageError = "no se puede anular por q el periodo esta cerrardo para esta fecha de anulacion";
                    return(false);
                }

                #endregion


                DevVta_info = DevVtaBus.Get_Info_devol_vent(idEmpresa, idSucursal, idBodega, idDevolucion, ref mensageError);

                ///////// optengo el movimiento de inventario q se genero por la devolcuion en vta
                InfoMoviAnu = MoviInve_Bus.Get_Info_Movi_inven
                                  (DevVta_info.mvInv_IdEmpresa, DevVta_info.mvInv_IdSucursal, DevVta_info.mvInv_IdBodega, DevVta_info.mvInv_IdMovi_inven_tipo, DevVta_info.mvInv_IdNumMovi);
                ///////////////

                InfoMoviAnu.MotivoAnulacion = motivo;
                InfoMoviAnu.IdusuarioUltAnu = param.IdUsuario;

                //////////// anula el movimiento de inventario /////////////////////////
                resAnuMoviInv = MoviInve_Bus.AnularDB(InfoMoviAnu, Fecha_Anulacion, ref mensageError);
                //////////// anula el movimiento de inventario /////////////////////////

                //////////// anula el la cabecera de dev vat
                resAnuDevVta = data.AnularDB(idEmpresa, idSucursal, idBodega, idDevolucion, motivo);
                //////////// anula el la cabecera de dev vat

                //////////// anula la nota de credito
                InfoNotaCre                 = BusBNotaDB.Get_Info_notaCreDeb_x_ND(idEmpresa, idSucursal, idBodega, DevVta_info.IdNota);
                InfoNotaCre.MotiAnula       = motivo;
                InfoNotaCre.IdUsuarioUltAnu = param.IdUsuario;
                InfoNotaCre.Fecha_UltAnu    = Fecha_Anulacion;
                BusBNotaDB.AnularDB(InfoNotaCre, ref mensageError);
                //////////// anula la nota de credito

                ///modifica la devolucion

                ///

                return(resAnuMoviInv && resAnuDevVta);
            }
            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("", "AnularDevolucion", ex.Message), ex)
                      {
                          EntityType = typeof(fa_devol_venta_Bus)
                      };
            }
        }