示例#1
0
        private void button1_Click(object sender, EventArgs e)
        {
            var actualizarChofer = new NuevoChofer();

            actualizarChofer.nombre   = txtNombreChofer.Text;
            actualizarChofer.apellido = txtApellidoChofer.Text;
            if (!Utils.IsDigitsOnly(txtDniChofer.Text) || txtDniChofer.Text.Length != 8)
            {
                MessageBox.Show("El DNI debe tener 8 digitos numericos", "Alta Chofer", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            actualizarChofer.num_dni          = Convert.ToInt32(txtDniChofer.Text);
            actualizarChofer.email            = txtMailChofer.Text;
            actualizarChofer.telefono         = Convert.ToInt32(txtTelefonoChofer.Text);
            actualizarChofer.direccion        = txtDireccionChofer.Text;
            actualizarChofer.fecha_nacimiento = dateFechaNacimiento.Value.ToString("yyyy-MM-dd hh:mm:ss");


            try
            {
                Repositorio.modificarChofer(this.dni, actualizarChofer);
                MessageBox.Show("El chofer se modifico correctamente:", "Modificar Chofer", MessageBoxButtons.OK, MessageBoxIcon.Information);
                new Principal(Tabs.chofer()).Show();
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error al modificar chofer - Exception :" + ex.ToString(), "Modificar Chofer", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
示例#2
0
        private void btnCrearChofer_Click(object sender, EventArgs e)
        {
            if (lstUsuarios.SelectedItem == null)
            {
                MessageBox.Show("Debe seleccionar un usuario", "Alta Chofer", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            var nuevoChofer = new NuevoChofer();

            nuevoChofer.usuario  = lstUsuarios.SelectedItem.ToString();
            nuevoChofer.nombre   = txtNombreChofer.Text;
            nuevoChofer.apellido = txtApellidoChofer.Text;
            if (!Utils.IsDigitsOnly(txtDniChofer.Text) || txtDniChofer.Text.Length != 8)
            {
                MessageBox.Show("El DNI debe tener 8 digitos numericos", "Alta Chofer", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            nuevoChofer.num_dni = Convert.ToInt32(txtDniChofer.Text);
            nuevoChofer.email   = txtMailChofer.Text;
            Convert.ToInt32(99999999);
            nuevoChofer.telefono         = Convert.ToInt32(txtTelefonoChofer.Text);
            nuevoChofer.direccion        = txtDireccionChofer.Text;
            nuevoChofer.fecha_nacimiento = dateFechaNacimiento.Value.ToString("yyyy-MM-dd hh:mm:ss");


            try
            {
                Repositorio.crearChofer(nuevoChofer);
                MessageBox.Show("El chofer se creo correctamente:", "Alta chofer", MessageBoxButtons.OK, MessageBoxIcon.Information);
                new Principal(Tabs.chofer()).Show();
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error al crear chofer - Exception :" + ex.ToString(), "Alta Chofer", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }