Example #1
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);
     }
 }
Example #2
0
 private void cargaTurno(int turno_id = Entidad.NUEVO)
 {
     try
     {
         if (turno_id == Entidad.NUEVO)
         {
             turno = new Turno();
         }
         else
         {
             Turno turno_mapper = new Turno();
             this.turno = turno_mapper.Mapear(turno_id);
             checkBoxHabilitado.Checked = turno.habilitado;
             textBoxHoraInicio.Text     = turno.hora_inicio.ToString();
             textBoxHoraFin.Text        = turno.hora_fin.ToString();
             textBoxDescripcion.Text    = turno.descripcion;
             textBoxValorKM.Text        = turno.valor_kilometro.ToString();
             textBoxPrecioBase.Text     = turno.precio_base.ToString();
         }
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.Message, "Turno error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Example #3
0
 private void buttonGuardar_Click(object sender, EventArgs e)
 {
     try
     {
         int valueParsed;
         if (!Int32.TryParse(textBoxKilometrosRecorridos.Text.Trim(), out valueParsed))
         {
             throw new Exception("Debe ingresar una cantidad de kilometros del tipo numerico");
         }
         Viaje     viaje            = new Viaje();
         Chofer    chofer_mapper    = new Chofer();
         Turno     turno_mapper     = new Turno();
         Cliente   cliente_mapper   = new Cliente();
         Automovil automovil_mapper = new Automovil();
         Chofer    chofer           = chofer_mapper.Mapear((comboBoxChofer.SelectedItem as dynamic).Value);
         Turno     turno            = turno_mapper.Mapear((comboBoxTurno.SelectedItem as dynamic).Value);
         Cliente   cliente          = cliente_mapper.Mapear((comboBoxCliente.SelectedItem as dynamic).Value);
         Automovil automovil        = automovil_mapper.Mapear((comboBoxAutomovil.SelectedItem as dynamic).Value);
         viaje.chofer              = chofer;
         viaje.automovil           = automovil;
         viaje.turno               = turno;
         viaje.cantidad_kilometros = Convert.ToInt32(textBoxKilometrosRecorridos.Text);
         viaje.fecha_inicio        = dateTimePickerFechaInicio.Value;
         viaje.fecha_fin           = dateTimePickerFechaFin.Value;
         viaje.cliente             = cliente;
         string respuesta = viaje.Guardar();
         MessageBox.Show(respuesta, "Guardado de viaje", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
         Hide();
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.Message, "Error en guardado de Registro de viaje", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Example #4
0
        private void buttonFiltrado_Click(object sender, EventArgs e)
        {
            try
            {
                Chofer chofer_mapper = new Chofer();
                Turno  turno_mapper  = new Turno();
                Chofer chofer        = chofer_mapper.Mapear((comboBoxChofer.SelectedItem as dynamic).Value);
                Turno  turno         = turno_mapper.Mapear((comboBoxTurno.SelectedItem as dynamic).Value);

                this.vw_rendicionTableAdapter.Fill(this.gD1C2017DataSet.vw_rendicion);
                DataView dv           = new DataView(this.gD1C2017DataSet.vw_rendicion);
                DateTime fecha_inicio = new DateTime(dateTimePickerFecha.Value.Year, dateTimePickerFecha.Value.Month, dateTimePickerFecha.Value.Day, 0, 0, 0);
                DateTime fecha_fin    = fecha_inicio.AddDays(1);
                string   rowFilter    = String.Format("[{0}] >= '{1}' AND [{0}] <= '{2}'", "viaj_fecha_inicio", fecha_inicio, fecha_fin);
                rowFilter += String.Format(" AND [{0}] = '{1}'", "viaj_chofer", chofer.id);
                rowFilter += String.Format(" AND [{0}] = '{1}'", "viaj_turno", turno.id);

                if (!String.IsNullOrWhiteSpace(rowFilter))
                {
                    dv.RowFilter = rowFilter;
                }
                dataGridView1.DataSource = dv;
                dataGridView1.Refresh();
                decimal rendicion_total = 0;
                foreach (DataRowView row_view in dv)
                {
                    DataRow row = row_view.Row;
                    rendicion_total += Convert.ToDecimal(row[11]);
                }
                rendicion_total          = rendicion_total * Convert.ToDecimal(textBoxPorcentaje.Text);
                textBoxImporteTotal.Text = rendicion_total.ToString("0.##");
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message, "Error en filtrado de rendicion", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }