Ejemplo n.º 1
0
        private void buttonEfectuar_Click(object sender, EventArgs e)
        {
            try {
                if (Chofer == null)
                {
                    throw new CampoVacioException("Chofer");          // valido los datos ingresados
                }
                if (Turno == null)
                {
                    throw new CampoVacioException("Turno");
                }
                DataTable tabla = Rendicion.get(Chofer.id, Fecha, Turno.id);          // obtengo la rendicion

                if (tabla == null || tabla.Rows.Count == 0)                           // si no existe...
                {
                    new RendicionNoEfectuadaForm(this, Chofer, Fecha, Turno).abrir(); // abro la ventana de rendicion no efectuada
                }
                else                                                                  // caso contrario...
                {
                    var confirmResult = MessageBox.Show("La Rendicion indicada ya fue efectuada, desea consultar el resultado?",
                                                        "Rendicion",
                                                        MessageBoxButtons.YesNo);
                    if (confirmResult == DialogResult.Yes)
                    {
                        new RendicionEfectuadaForm(this, Chofer, new Rendicion(tabla.Rows[0])).abrir(); // abro la ventana de rendicion efectuada
                    }
                }
            }
            catch (SqlException) { }
            catch (CampoVacioException exception) {
                Error.show(exception.Message);
            }
        }
Ejemplo n.º 2
0
 private void buttonGuardar_Click(object sender, EventArgs e)
 {
     try
     {
         if (Convert.ToDecimal(textBoxImporteTotal.Text) == 0)
         {
             throw new Exception("El importe no puede ser cero");
         }
         Rendicion rendicion     = new Rendicion();
         Chofer    chofer_mapper = new Chofer();
         Turno     turno_mapper  = new Turno();
         Viaje     viaje_mapper  = new Viaje();
         Chofer    chofer        = chofer_mapper.Mapear((comboBoxChofer.SelectedItem as dynamic).Value);
         Turno     turno         = turno_mapper.Mapear((comboBoxTurno.SelectedItem as dynamic).Value);
         rendicion.fecha   = dateTimePickerFecha.Value;
         rendicion.chofer  = chofer;
         rendicion.turno   = turno;
         rendicion.importe = Convert.ToDecimal(textBoxImporteTotal.Text);
         rendicion.viajes  = new List <Viaje>();
         foreach (DataGridViewRow row in dataGridView1.Rows)
         {
             int   viaje_id = Convert.ToInt32(row.Cells[0].Value);
             Viaje viaje    = viaje_mapper.Mapear(viaje_id);
             rendicion.viajes.Add(viaje);
         }
         string respuesta = rendicion.Guardar();
         MessageBox.Show(respuesta, "Guardado de rendicion", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
         Hide();
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.Message, "Error en guardado de rendicion", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
 public RendicionEfectuadaForm(ReturningForm caller, Chofer chofer, Rendicion rendicion) : base(caller, chofer, rendicion.fecha)
 {
     InitializeComponent();
     DataGridViewRendicion.DataSource = Rendicion.getItems(rendicion.numero); // obtengo los viajes de la rendicion
     ImporteTotal            = rendicion.importeTotal;                        // cargo campos
     labelRendicionNro.Text += rendicion.numero.ToString();
     labelPorcentaje.Text   += (rendicion.porcentaje * 100).ToString() + "%";
     Turno = rendicion.turno;
 }
Ejemplo n.º 4
0
        private void busquedaDeValores()
        {
            Dictionary <String, String> parametrosDeBusqueda = new Dictionary <string, string>();

            if (TXTdni.Text != "")
            {
                parametrosDeBusqueda.Add("id_chofer", TXTdni.Text);
            }
            List <Rendicion> rendiciones = Rendicion.buscar(parametrosDeBusqueda);

            construccionDeGridView(rendiciones);
        }
Ejemplo n.º 5
0
        private void configurarGrilla(DataSet ds)
        {
            dgvRendiciones.Rows.Clear();
            List <Rendicion> rendiciones = new List <Rendicion>();

            foreach (DataRow row in ds.Tables[0].Rows)
            {
                Rendicion rend = new Rendicion();
                rend.DataRowToObject(row);
                rendiciones.Add(rend);

                dgvRendiciones.Rows.Add(rend.Chofer, rend.nro_Rendicion, rend.Turno, rend.Fecha, rend.Total);
            }
        }
Ejemplo n.º 6
0
        private void btnFacturar_Click(object sender, EventArgs e)
        {
            String Fecha = textBox_Fecha.Text;
            String Total = textBox_importe.Text;

            try
            {
                {
                    Rendicion rendicion = new Rendicion();
                    rendicion.SetFechaRendicion(Fecha);
                    String ChoferDNI = this.obtenerDNIaPartirDetextBox(comboBox_chofer.Text);
                    rendicion.SetIdChofer(ChoferDNI);
                    this.ideTurno = this.obtenerIdTurnoaPartirDeCombobox(comboBox_Turnos.Text);
                    rendicion.SetIdTurno(ideTurno);


                    if (!mapper.ExisteRendicion(Fecha, rendicion.GetIdChofer()))
                    {
                        rendicion.SetImporteTotalRendicion(Total);
                        int idRendicion = mapper.Crear(rendicion);
                        if (idRendicion > 0)
                        {
                            MessageBox.Show("Se creo correctamente la Rendición");

                            mapper.ActualizarRendicionIdenRegistrViaje(idRendicion, rendicion.GetFechaRendicion(), rendicion.GetIdChofer(), ideTurno);

                            this.Hide();
                            new MenuPrincipal().ShowDialog();
                            this.Close();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Ya se realizo la rendicion diaria para ese chofer o no posee registros en esa fecha ", "Rendicion existente", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            catch (CampoVacioException exception)
            {
                MessageBox.Show("Falta completar campo: " + exception.Message);
                return;
            }
            catch (NoHayViajesException exception)
            {
                MessageBox.Show(exception.Message, "Error al registrar", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
Ejemplo n.º 7
0
 private void CargarListado()
 {
     try
     {
         //obtengo en un dataset todos los roles de la bd
         DataSet ds = Rendicion.obtenerTodos();
         configurarGrilla(ds);
     }
     catch (ErrorConsultaException ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Ejemplo n.º 8
0
        private void BTNgenerar_Click(object sender, EventArgs e)
        {
            if (this.ValidarCamposMandatorios())
            {
                //validar que este todo bien seleccionado
                Dictionary <String, String> parametrosDeBusqueda = new Dictionary <string, string>();

                Int64    idChofer = getIdChoferSeleccionado();
                DateTime fecha    = Convert.ToDateTime(DTEfecha.Text);
                Int64    idTurno  = getIdTurno();

                parametrosDeBusqueda.Add("id_chofer", idChofer.ToString());
                parametrosDeBusqueda.Add("fecha_viaje_para_rendicion", fecha.ToString()); //hacer logica para comparar con las fechas de los viajes
                parametrosDeBusqueda.Add("id_turno", idTurno.ToString());

                rendicion = Rendicion.calcularRendicion(parametrosDeBusqueda);
                mostrarAtributos();
            }
            else
            {
                this.MensajeError();
            };
        }
Ejemplo n.º 9
0
 private void buttonGenerarRendicion_Click(object sender, EventArgs e)
 {
     Rendicion.generar(Chofer.id, Fecha, Turno.id, ImporteTotal, Porcentaje); // genero la rendicion
     this.Close();
 }