示例#1
0
        private void btnGuardarUnidad_Click(object sender, EventArgs e)
        {
            if (cboTransportista.SelectedItem == null)
            {
                throw new Exception();
            }
            try
            {
                int    idTransportista = Convert.ToInt32((cboTransportista.SelectedItem as ComboboxItem).Value.ToString());
                string nombre          = txtNombre.Text;
                string placas          = txtPlacas.Text;
                double pesoMaximo      = Convert.ToDouble(txtPesoMaximo.Text);
                double costoxKilometro = Convert.ToDouble(txtCostoKilometro.Text);
                string estatus         = "ACTIVO";
                Unidad unidad          = new Unidad(idTransportista, nombre, placas, pesoMaximo, costoxKilometro, estatus);

                if (Accion == "ALTA")
                {
                    FormInicio.GuardaUnidad(unidad);
                }
                else if (Accion == "EDITAR")
                {
                    FormInicio.EditaUnidad(unidad);
                }
                else if (Accion == "ELIMINAR")
                {
                    FormInicio.EliminaUnidad(unidad);
                }
            }
            catch (Exception error)
            {
                MessageBox.Show("Ha ocurrido un error al guardar el registro" + error.Message);
            }
        }