Пример #1
0
        private void btn_ok_update_Click(object sender, EventArgs e)
        {
            Vehycle empl = new Vehycle();

            updateData(empl, index);
            btn_ok_update.Visible = false;
            btn_ok.Visible        = true;
            MessageBox.Show("Actualizado");
            Refresh();
        }
Пример #2
0
        private void updateData(Vehycle veh, int index)
        {
            if (string.IsNullOrEmpty(txtDescription.Text) || string.IsNullOrEmpty(txtNoChasis.Text) || string.IsNullOrEmpty(txtNoMotor.Text) ||
                string.IsNullOrEmpty(txtNoMotor.Text) || string.IsNullOrEmpty(txtNoPlaca.Text) || string.IsNullOrEmpty(cbx_Marca.Text) ||
                string.IsNullOrEmpty(cbx_Modelo.Text) || string.IsNullOrEmpty(cbx_TipoCombustible.Text) || string.IsNullOrEmpty(cbx_TipoVehiculo.Text) ||
                string.IsNullOrEmpty(comboEstado.Text))
            {
                MessageBox.Show("Completar Información");
                return;
            }
            else
            {
                int Item          = Int32.Parse(dataGridView1[0, index].Value.ToString());
                var updateVehycle = (from a in bd.Vehiculos
                                     select a).Where(m => m.Id_Vehiculo.Equals(Item)).SingleOrDefault();

                updateVehycle.Descripcion = txtDescription.Text;
                updateVehycle.No_Chasis   = txtNoChasis.Text;
                updateVehycle.No_Motor    = Int32.Parse(txtNoMotor.Text);
                updateVehycle.No_Placa    = txtNoPlaca.Text;
                updateVehycle.Estado      = comboEstado.Text.ToString() == "Activo" ? 1 : 0;
                //updateEmployee2.Usuario1 = txtUser.Text;
                //updateEmployee2.Contrasenia = txtUser.Text;
                //updateEmployee2.Estado = comboEstado.Text.ToString() == "Activo" ? 1 : 0;
                bd.SaveChanges();
                txtDescription.Clear();
                txtNoChasis.Clear();
                txtNoMotor.Clear();
                txtNoPlaca.Clear();
                comboEstado.SelectedIndex         = -1;
                cbx_Marca.SelectedIndex           = -1;
                cbx_Modelo.SelectedIndex          = -1;
                cbx_TipoCombustible.SelectedIndex = -1;
                cbx_TipoVehiculo.SelectedIndex    = -1;

                this.loadDataGrid();
            }
        }