Exemple #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);
     }
 }
Exemple #2
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);
     }
 }
 private void buttonGuardar_Click(object sender, EventArgs e)
 {
     try
     {
         if ((comboBoxMarca.SelectedItem as dynamic).Value == 0)
         {
             throw new Exception("Debe seleccionar una marca");
         }
         if ((comboBoxTurno.SelectedItem as dynamic).Value == 0)
         {
             throw new Exception("Debe seleccionar un turno");
         }
         if ((comboBoxChofer.SelectedItem as dynamic).Value == 0)
         {
             throw new Exception("Debe seleccionar un chofer");
         }
         if (textBoxModelo.Text == "")
         {
             throw new Exception("Debe ingresar un modelo de automovil");
         }
         if (textBoxPatente.Text == "")
         {
             throw new Exception("Debe ingresar una patente");
         }
         Marca  marca_mapper  = new Marca();
         Turno  turno_mapper  = new Turno();
         Chofer chofer_mapper = new Chofer();
         int    marca_id      = (int)(comboBoxMarca.SelectedItem as dynamic).Value;
         int    turno_id      = (int)(comboBoxTurno.SelectedItem as dynamic).Value;
         int    chofer_id     = (int)(comboBoxChofer.SelectedItem as dynamic).Value;
         automovil.marca      = marca_mapper.Mapear(marca_id);
         automovil.modelo     = textBoxModelo.Text;
         automovil.patente    = textBoxPatente.Text;
         automovil.turno      = turno_mapper.Mapear(turno_id);
         automovil.chofer     = chofer_mapper.Mapear(chofer_id);
         automovil.habilitado = checkBoxHabilitado.Checked;
         string respuesta = automovil.Guardar();
         MessageBox.Show(respuesta, "Guardado de automovil", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
         Hide();
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.Message, "Guardado de automovil error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemple #4
0
 private void comboBoxChofer_SelectionChangeCommitted(object sender, EventArgs e)
 {
     if ((comboBoxChofer.SelectedItem as dynamic).Value > 0)
     {
         try
         {
             ComboBoxManager cbm                    = new ComboBoxManager();
             Chofer          chofer_mapper          = new Chofer();
             Chofer          chofer                 = chofer_mapper.Mapear((comboBoxChofer.SelectedItem as dynamic).Value);
             string          automovil_seleccionado = cargaAutomovilSeleccionado(chofer.usuario.id);
             comboBoxAutomovil = cbm.Automovil(comboBoxAutomovil, automovil_seleccionado);
         }
         catch (Exception exception)
         {
             comboBoxAutomovil.SelectedIndex = 0;
             MessageBox.Show(exception.Message, "Seleccion de chofer error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Exemple #5
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);
            }
        }