Ejemplo n.º 1
0
        private void btnGuardarTarifa_Click(object sender, EventArgs e)
        {
            if (cboRuta.SelectedItem == null || cboUnidad.SelectedItem == null || cboClienteF.SelectedItem == null)
            {
                throw new Exception();
            }
            try
            {
                int    idruta          = Convert.ToInt32((cboRuta.SelectedItem as ComboboxItem).Value.ToString());
                int    idunidad        = Convert.ToInt32((cboUnidad.SelectedItem as ComboboxItem).Value.ToString());
                int    idclientefiscal = Convert.ToInt32((cboClienteF.SelectedItem as ComboboxItem).Value.ToString());
                string estatus         = "ACTIVO";
                Tarifa tarifa          = new Tarifa(idruta, idunidad, idclientefiscal, estatus);

                if (Accion == "ALTA")
                {
                    FormInicio.GuardaTarifa(tarifa);
                }
                else if (Accion == "EDITAR")
                {
                    FormInicio.EditaTarifa(tarifa);
                }
                else if (Accion == "ELIMINAR")
                {
                    FormInicio.EliminaTarifa(tarifa);
                }
            }
            catch (Exception error)
            {
                MessageBox.Show("Ha ocurrido un error al guardar el registro" + error.Message);
            }
        }