/// <summary>
        /// Se agrega una carga a la lista de cargas.
        /// </summary>
        private void dgvCargas_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
        {
            for (int contador = 0; contador < e.RowCount; contador++)
            {
                DataGridViewRow   fila  = dgvCargas.Rows[e.RowIndex + contador];
                RegistroPenalidad carga = (RegistroPenalidad)fila.DataBoundItem;

                //fila.Cells[ATMCarga.Index].Value = carga.ToString();

                //if (carga.Colaborador_verificador != null)
                //{

                //    if (carga.Modificada)
                //        fila.DefaultCellStyle.BackColor = Color.Green;
                //    else
                //        fila.DefaultCellStyle.BackColor = Color.LightGreen;

                //}
                //else if (carga.Cierre != null)
                //{
                //    fila.DefaultCellStyle.BackColor = Color.Yellow;
                //}
                //else if (carga.Cajero != null)
                //{
                //    fila.DefaultCellStyle.BackColor = Color.LightCoral;
                //}
            }
        }
        /// <summary>
        /// Mostrar la ventana de revisión de la carga.
        /// </summary>
        private void mostrarVentanaRevision()
        {
            RegistroPenalidad             carga      = (RegistroPenalidad)dgvCargas.SelectedRows[0].DataBoundItem;
            frmIngresoRegistroPenalidades formulario = new frmIngresoRegistroPenalidades(carga, _colaborador);

            formulario.ShowDialog(this);
        }
        /// <summary>
        /// Clic en el botón de eliminar carga.
        /// </summary>
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            try
            {
                if (Mensaje.mostrarMensajeConfirmacion("MensajeCargaATMEliminacion") == DialogResult.Yes)
                {
                    foreach (DataGridViewRow fila in dgvCargas.SelectedRows)
                    {
                        RegistroPenalidad carga = (RegistroPenalidad)fila.DataBoundItem;

                        _coordinacion.eliminarRegistroPenalidad(carga);



                        dgvCargas.Rows.Remove(fila);
                    }

                    Mensaje.mostrarMensaje("MensajeCargaATMConfirmacionEliminacion");
                }
            }
            catch (Excepcion ex)
            {
                ex.mostrarMensaje();
            }
        }
        /// <summary>
        /// Doble clic en la lista de cargas.
        /// </summary>
        private void dgvCargas_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex != -1)
            {
                DataGridViewRow   fila  = dgvCargas.SelectedRows[0];
                RegistroPenalidad carga = (RegistroPenalidad)fila.DataBoundItem;

                this.mostrarVentanaModificacion();
            }
        }
        /// <summary>
        /// Agregar un registro a la lista.
        /// </summary>
        public void agregarRegistroPenalidad(RegistroPenalidad registro)
        {
            try
            {
                BindingList <RegistroPenalidad> registros = (BindingList <RegistroPenalidad>)dgvCargas.DataSource;

                registros.Add(registro);
            }
            catch (Excepcion ex)
            {
                ex.mostrarMensaje();
            }
        }
Beispiel #6
0
        /// <summary>
        /// Eliminar los datos de una cámara.
        /// </summary>
        /// <param name="c">Objeto RegistroPenalidad con los datos de la cámara a eliminar</param>
        public void eliminarRegistroPenalidad(RegistroPenalidad c)
        {
            SqlCommand comando = _manejador.obtenerProcedimiento("DeleteRegistroPenalidad");

            _manejador.agregarParametro(comando, "@registro", c.Id, SqlDbType.Int);

            try
            {
                _manejador.ejecutarConsultaActualizacion(comando);
                comando.Connection.Close();
            }
            catch (Exception)
            {
                comando.Connection.Close();
                throw new Excepcion("ErrorRegistroPenalidadEliminacion");
            }
        }
        /// <summary>
        /// Se selecciona otra carga de la lista de cargas.
        /// </summary>
        private void dgvCargas_SelectionChanged(object sender, EventArgs e)
        {
            if (dgvCargas.SelectedRows.Count > 0)
            {
                DataGridViewRow   fila  = dgvCargas.SelectedRows[0];
                RegistroPenalidad carga = (RegistroPenalidad)fila.DataBoundItem;


                btnEliminar.Enabled  = true;
                btnModificar.Enabled = true;
            }
            else
            {
                btnEliminar.Enabled  = false;
                btnModificar.Enabled = false;
            }
        }
        public frmIngresoRegistroPenalidades(RegistroPenalidad reg, Colaborador c)
        {
            InitializeComponent();

            cboEmpresaTransporte.ListaMostrada = _mantenimiento.listarEmpresasTransporte();
            cboCliente.ListaMostrada           = _mantenimiento.listarClientes(string.Empty);
            cboTipoPenalidad.ListaMostrada     = _mantenimiento.listarPenalidades();
            dtpFecha.Value            = reg.Fecha_Registro;
            cboCliente.Text           = reg.Cliente.ToString();
            cboPuntoVenta.Text        = reg.Punto_Venta.ToString();
            cboEmpresaTransporte.Text = reg.Transportadora.ToString();
            cboTipoPenalidad.Text     = reg.Penalidad.ToString();

            chkProntoAviso.Checked = reg.Pronto_Aviso;

            _registro_penalidad = reg;
        }
Beispiel #9
0
        /// <summary>
        /// Registrar una nueva cámara.
        /// </summary>
        /// <param name="c">Objeto RegistroPenalidad con los datos de la nueva cámara</param>
        public void agregarRegistroPenalidad(ref RegistroPenalidad c)
        {
            SqlCommand comando = _manejador.obtenerProcedimiento("InsertRegistroPenalidad");

            _manejador.agregarParametro(comando, "@colaborador", c.Colaborador, SqlDbType.Int);
            _manejador.agregarParametro(comando, "@punto_venta", c.Punto_Venta.Id, SqlDbType.SmallInt);
            _manejador.agregarParametro(comando, "@penalidad", c.Penalidad.ID, SqlDbType.Int);
            _manejador.agregarParametro(comando, "@transportadora", c.Transportadora, SqlDbType.TinyInt);
            _manejador.agregarParametro(comando, "@prontoaviso", c.Pronto_Aviso, SqlDbType.Bit);
            _manejador.agregarParametro(comando, "@fecha", c.Fecha_Registro, SqlDbType.DateTime);

            try
            {
                c.Id = (int)_manejador.ejecutarEscalar(comando);
                comando.Connection.Close();
            }
            catch (Exception)
            {
                comando.Connection.Close();
                throw new Excepcion("ErrorRegistroPenalidadRegistro");
            }
        }
Beispiel #10
0
        /// <summary>
        /// Listar todas las registros registradas.
        /// </summary>
        /// <returns>Lista de registros registradas en el sistema</returns>
        public BindingList <RegistroPenalidad> listarRegistroPenalidades(DateTime fecha, DateTime fechafin, PuntoVenta p, EmpresaTransporte emp)
        {
            BindingList <RegistroPenalidad> camaras = new BindingList <RegistroPenalidad>();

            SqlCommand    comando    = _manejador.obtenerProcedimiento("SelectRegistroPenalidades");
            SqlDataReader datareader = null;

            _manejador.agregarParametro(comando, "@transportadora", emp, SqlDbType.TinyInt);
            _manejador.agregarParametro(comando, "@fecha", fecha, SqlDbType.DateTime);
            _manejador.agregarParametro(comando, "@fechafin", fechafin, SqlDbType.DateTime);
            if (p != null)
            {
                _manejador.agregarParametro(comando, "@punto", p.Id, SqlDbType.SmallInt);
            }
            else
            {
                _manejador.agregarParametro(comando, "@punto", p, SqlDbType.SmallInt);
            }

            try
            {
                datareader = _manejador.ejecutarConsultaDatos(comando);

                while (datareader.Read())
                {
                    int id = (int)datareader["ID_Registro"];

                    DateTime fecha_registro = (DateTime)datareader["Fecha"];


                    int    id_penalidad          = (int)datareader["ID_Penalidad"];
                    string descripcion_penalidad = (string)datareader["Descripcion_Penalidad"];

                    int    id_tipo_penalidad          = (int)datareader["ID_TipoPenalidad"];
                    string descripcion_tipo_penalidad = (string)datareader["Descripcion_TipoPenalidad"];

                    TipoPenalidad tipo = new TipoPenalidad(id: (short)id_tipo_penalidad, nombre: descripcion_tipo_penalidad);

                    Penalidad penalidad = new Penalidad(id: id_penalidad, descripcion: descripcion_penalidad, tipopenalidad: tipo);


                    short  id_punto     = (short)datareader["ID_Punto"];
                    string nombre_punto = (string)datareader["Nombre_Punto"];


                    short  id_cliente     = (short)datareader["ID_Cliente"];
                    string nombre_cliente = (string)datareader["Nombre_Cliente"];
                    string centrocostos   = "";

                    if (datareader["CentroCostos"] != DBNull.Value)
                    {
                        centrocostos = (string)datareader["CentroCostos"];
                    }

                    decimal entrega_niquel = 0;

                    if (datareader["Tarifa_Niquel"] != DBNull.Value)
                    {
                        entrega_niquel = (decimal)datareader["Tarifa_Niquel"];
                    }

                    //Monedas moneda_niquel = (Monedas)datareader["MonedaEntregaNiquel"];

                    Monedas moneda_feriado = Monedas.Colones;

                    if (datareader["Moneda_Tarifa_Feriado"] != DBNull.Value)
                    {
                        moneda_feriado = (Monedas)datareader["Moneda_Tarifa_Feriado"];
                    }



                    Monedas moneda_tarifa = Monedas.Colones;

                    if (datareader["Moneda_Tarifa_Regular"] != DBNull.Value)
                    {
                        moneda_tarifa = (Monedas)datareader["Moneda_Tarifa_Regular"];
                    }



                    decimal recargo = 0;
                    if (datareader["Recargo"] != DBNull.Value)
                    {
                        recargo = (decimal)datareader["Recargo"];
                    }

                    decimal tarifa_feriado = 0;

                    if (datareader["Tarifa_Feriados"] != DBNull.Value)
                    {
                        tarifa_feriado = (decimal)datareader["Tarifa_Feriados"];
                    }


                    decimal tarifa_regular = 0;

                    if (datareader["Tarifa_Regular"] != DBNull.Value)
                    {
                        tarifa_regular = (decimal)datareader["Tarifa_Regular"];
                    }


                    decimal tope = 0;

                    if (datareader["Tope"] != DBNull.Value)
                    {
                        tope = (decimal)datareader["Tope"];
                    }


                    double tarifa = 0;

                    if (datareader["Tarifa"] != DBNull.Value)
                    {
                        tarifa = (double)datareader["Tarifa"];
                    }

                    double nivel_servicio = 0;

                    if (datareader["Nivel Servicio"] != DBNull.Value)
                    {
                        nivel_servicio = (double)datareader["Nivel Servicio"];
                    }

                    Cliente cliente = new Cliente(id: (short)id_cliente, nombre: nombre_cliente);

                    PuntoVenta punto = new PuntoVenta(id: (short)id_punto, nombre: nombre_punto, cliente: cliente);
                    punto.CentroCostos         = centrocostos;
                    punto.EntregaNiquel        = entrega_niquel;
                    punto.MonedaTarifaFeriados = moneda_feriado;
                    punto.MonedaTarifaRegular  = moneda_tarifa;
                    punto.TarifaFeriado        = tarifa_feriado;
                    punto.TarifaRegular        = tarifa_regular;
                    punto.Tope    = tope;
                    punto.Recargo = recargo;



                    byte   id_transportadora     = (byte)datareader["ID_Transportadora"];
                    string nombre_transportadora = (string)datareader["Nombre_Transportadora"];


                    bool pronto_aviso = (bool)datareader["Pronto_Aviso"];

                    EmpresaTransporte empresa = new EmpresaTransporte(id: id_transportadora, nombre: nombre_transportadora);


                    RegistroPenalidad camara = new RegistroPenalidad(id: id, transportadora: empresa, penalidad: penalidad, punto: punto, pronto_aviso: pronto_aviso, fecha_registro: fecha_registro, nivel_s: nivel_servicio);
                    camara.Tarifa = Convert.ToDecimal(tarifa);

                    camaras.Add(camara);
                }

                comando.Connection.Close();
            }
            catch (Exception)
            {
                comando.Connection.Close();
                throw new Excepcion("ErrorDatosConexion");
            }

            return(camaras);
        }
        /// <summary>
        /// Clic en el botón de guardar.
        /// </summary>
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            // Verificar que se hayan seleccionado los datos

            if (cboPuntoVenta.SelectedIndex == 0 || cboEmpresaTransporte.SelectedIndex == 0 || cboTipoPenalidad.SelectedIndex == 0)
            {
                Excepcion.mostrarMensaje("ErrorubicacionDatosRegistro");
                return;
            }

            try
            {
                frmAdministracionRegistroPenalidades padre = (frmAdministracionRegistroPenalidades)this.Owner;

                Penalidad         penalidad      = (Penalidad)cboTipoPenalidad.SelectedItem;
                EmpresaTransporte transportadora = (EmpresaTransporte)cboEmpresaTransporte.SelectedItem;
                PuntoVenta        punto_venta    = (PuntoVenta)cboPuntoVenta.SelectedItem;
                bool     pronto_aviso            = chkProntoAviso.Checked;
                DateTime fecha = dtpFecha.Value;



                // Verificar si la ubicación ya está registrada

                if (_registro_penalidad == null)
                {
                    // Agregar los datos de la ubicación

                    if (Mensaje.mostrarMensajeConfirmacion("MensajeRegistroPenalidadRegistro") == DialogResult.Yes)
                    {
                        RegistroPenalidad nueva = new RegistroPenalidad(penalidad: penalidad, transportadora: transportadora, punto: punto_venta, colaborador: _usuario, pronto_aviso: pronto_aviso, fecha_registro: fecha);

                        _coordinacion.agregarRegistroPenalidad(ref nueva);

                        padre.agregarRegistroPenalidad(nueva);
                        Mensaje.mostrarMensaje("MensajeRegistroPenalidadConfirmacionRegistro");
                        this.Close();
                    }
                }
                else
                {
                    // Actualizar los datos de la ubicación

                    RegistroPenalidad copia = new RegistroPenalidad(penalidad: penalidad, id: _registro_penalidad.Id, transportadora: transportadora,
                                                                    punto: punto_venta, pronto_aviso: pronto_aviso);

                    _coordinacion.actualizarRegistroPenalidad(copia);

                    _registro_penalidad.Transportadora = transportadora;
                    _registro_penalidad.Penalidad      = penalidad;
                    _registro_penalidad.Punto_Venta    = punto_venta;
                    _registro_penalidad.Pronto_Aviso   = pronto_aviso;

                    padre.actualizarLista();
                    Mensaje.mostrarMensaje("MensajeRegistroPenalidadConfirmacionActualizacion");
                    this.Close();
                }
            }
            catch (Excepcion ex)
            {
                ex.mostrarMensaje();
            }
        }