Пример #1
0
 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);
     }
 }
Пример #2
0
        private void cargarListadoTurnosDelSistema()
        {
            //cargo el listado de funcionalidades no pertenecientes al rol cargadas en el sistema
            //exijo que se muestre solo el nombre de las funcionalidades
            lstTurnosTot.Items.Clear();
            DataSet ds = Turno.obtenerTurnosHabilitados();

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                Turno unTurno = new Turno();
                unTurno.DataRowToObject(dr);
                if (!(contieneLaListaDeTurnosDeAutomovil(unTurno)))
                {
                    lstTurnosTot.Items.Add(unTurno);
                }
            }
            lstTurnosTot.DisplayMember = "Descripcion";
        }
Пример #3
0
        private void cargarTurnosHabilitados(DataTable table, int estado)
        {
            int cont = 0;

            Turno.DataSource = table;
            try
            {
                DataRow row = table.Rows[cont];
                while (row != null)
                {
                    Turno.ValueMember = "TURNO_DESCRIPCION";
                    Turno.SetItemChecked(cont, Convert.ToBoolean(estado));
                    cont++;
                    try { row = table.Rows[cont]; }
                    catch { row = null; }
                }
            }
            catch
            { Mensaje_OK("No existen turnos asignados"); }
        }
 private void createNewTurn()
 {
     try
     {
         if (comboTurno.SelectedIndex.Equals(-1))
         {
             throw new Exception("Debe seleccionar un turno");
         }
         Turno turno = this.comboTurno.SelectedItem as Turno;
         if (turno.getId() != (int)unAuto.Cells["IdTurno"].Value)
         {
             dao.createTurno(unAuto, turno);
             MessageBox.Show("El turno fue agregado con exito");
         }
         else
         {
             MessageBox.Show("El turno no cambio");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message.ToString());
     }
 }