public void BajaViajeInternacionales(Viajes v) { SqlConnection DBCS = Conexion.CrearCnn(); Internacionales I = (Internacionales)v; SqlCommand comando = new SqlCommand("BajaViajeInternacional", DBCS); comando.CommandType = CommandType.StoredProcedure; comando.Parameters.Add(new SqlParameter("@Numero", I.numero)); SqlParameter retorno = new SqlParameter("@Retorno", SqlDbType.Int); retorno.Direction = ParameterDirection.ReturnValue; comando.Parameters.Add(retorno); try { DBCS.Open(); comando.ExecuteNonQuery(); int r = Convert.ToInt32(retorno.Value); if (r == -1) { throw new Exception("Error al eliminar viaje."); } } catch (Exception ex) { throw ex; } finally { DBCS.Close(); } }
protected void btnAgregar_Click(object sender, EventArgs e) { try { Compania C = FabricaLogica.GetLogicaCompania().BuscarCompaniaActivas(txtCompania.Text); Empleado E = (Empleado)Session["Empleado"]; Terminal T = FabricaLogica.GetLogicaTerminal().BuscarTerminalActiva(txtDestino.Text); Internacionales I = new Internacionales(Convert.ToInt32(txtBusqueda.Text), Convert.ToInt32(txtAsiento.Text), FechaYHora1.Fecha, FechaYHora2.Fecha, E, T, C, Convert.ToBoolean(rblSAbordo.SelectedValue), txtDocumentacion.Text); FabricaLogica.GetLogicaViajes().AltaViaje(I); Panel2.Enabled = false; BtnEliminar.Enabled = false; txtBusqueda.Enabled = true; txtBusqueda.Text = ""; txtAsiento.Text = ""; txtCompania.Text = ""; txtDestino.Text = ""; txtDocumentacion.Text = ""; txtEmpleado.Text = ""; rblSAbordo.ClearSelection(); lblError.Text = "Viaje registrado con éxito."; } catch (Exception ex) { lblError.Text = ex.Message; } }
private void btnModificar_Click(object sender, EventArgs e) { try { bool bandera = true; int salida = 0; WebService WS = new WebService(); objViajeInter = new Internacionales(); objViajeInter.numero = Convert.ToInt32(txtNumero.Text); if (Int32.TryParse(txtCantAsientos.Text, out salida)) { objViajeInter.cantAsientos = salida; bandera = true; } else { lblError.Text = "Ingrese una cantidad de asientos válida."; bandera = false; } objViajeInter.partida = dtpPartida.Value; objViajeInter.arribo = dtpArribo.Value; objViajeInter.e = empLogueado; foreach (Terminal t in listaT) { if (t.codigo == cbTerminal.SelectedItem.ToString()) { objViajeInter.t = t; } } foreach (Compania c in listaC) { if (c.nombre == cbCompañia.SelectedItem.ToString()) { objViajeInter.c = c; } } objViajeInter.servAbordo = cbServAbordo.Checked; objViajeInter.documentacion = txtDocumentacion.Text; if (bandera == true) { WS.ModificarViaje(objViajeInter); this.ActivoPorDefecto(); lblError.Text = "Modificación con éxito."; errorProvider1.Clear(); } } catch (System.Web.Services.Protocols.SoapException ex) { manejoErrorWS(ex.Message); } catch (Exception ex) { lblError.Text = ex.Message; } }
protected void BtnModificar_Click(object sender, EventArgs e) { try { int _Numero = Convert.ToInt16(TBNumero.Text); Terminales _Terminal = (from unaTerminal in (List <Terminales>)Session["Terminales"] where unaTerminal.Codigo == DDLTerminal.SelectedValue select unaTerminal).First(); Companias _Compania = (from unaCompania in (List <Companias>)Session["Companias"] where unaCompania.Nombre == DDLCompania.SelectedValue select unaCompania).First(); int diapartida = Convert.ToDateTime(TBFechaPartida.Text).Day; int mespartida = Convert.ToDateTime(TBFechaPartida.Text).Month; int aniopartida = Convert.ToDateTime(TBFechaPartida.Text).Year; int horapartida = Convert.ToInt16(DDLHoraPartida.Text); int minutospartida = Convert.ToInt16(DDLMinutosPartida.Text); int diaarribo = Convert.ToDateTime(TBFechaArribo.Text).Day; int mesarribo = Convert.ToDateTime(TBFechaArribo.Text).Month; int anioarribo = Convert.ToDateTime(TBFechaArribo.Text).Year; int horaarribo = Convert.ToInt16(DDLHoraArribo.Text); int minutosarribo = Convert.ToInt16(DDLMinutosArribo.Text); DateTime _Fechapartida = new DateTime(aniopartida, mespartida, diapartida, horapartida, minutospartida, 0); DateTime _Fechaarribo = new DateTime(anioarribo, mesarribo, diaarribo, horaarribo, minutosarribo, 0); int _CantAsientos = Convert.ToInt16(TBCantAsientos.Text); Empleados _Empleado = (Empleados)Session["Empleado"]; bool _Servicio = false; if (DDLServicio.SelectedIndex == 1) { _Servicio = true; } string _Documentacion = TBDocumentacion.Text; Internacionales unInter = new Internacionales(_Numero, _Compania, _Terminal, _Fechapartida, _Fechaarribo, _CantAsientos, _Empleado, _Servicio, _Documentacion); ILogicaViajes FViaje = FabricaLogica.getLogicaViaje(); FViaje.Modificar_Viaje(unInter); LblError.ForeColor = System.Drawing.Color.Blue; LblError.Text = "El Viaje " + Convert.ToString(unInter.Numero) + " ha sido modificado correctamente."; LimpioFormulario(); } catch (Exception ex) { LblError.ForeColor = System.Drawing.Color.Red; LblError.Text = ex.Message; } }
//Operaciones public Internacionales Buscar_Viaje(int pCodViaje) { SqlConnection oConexion = new SqlConnection(Conexion.STR); SqlCommand oComando = new SqlCommand("Buscar_ViajeInternacional", oConexion); oComando.CommandType = CommandType.StoredProcedure; oComando.Parameters.AddWithValue("@numero", pCodViaje); Internacionales unInter = null; try { oConexion.Open(); SqlDataReader _Reader = oComando.ExecuteReader(); if (_Reader.HasRows) { _Reader.Read(); int _numero = (int)_Reader["numero"]; Companias _compania = PersistenciaCompania.GetInstancia().BuscarTodos_Compania((string)_Reader["compania"]); Terminales _terminal = PersistenciaTerminales.GetInstancia().BuscarTodos_Terminal((string)_Reader["destino"]); DateTime _fechapartida = (DateTime)_Reader["fecha_partida"]; DateTime _fechaarribo = (DateTime)_Reader["fecha_arribo"]; int _asientos = (int)_Reader["asientos"]; Empleados _empleado = PersistenciaEmpleado.GetInstancia().BuscarTodos_Empleado((string)_Reader["empleado"]); bool _servicio = (bool)_Reader["servicio"]; string _documentacion = (string)_Reader["documentacion"]; unInter = new Internacionales(_numero, _compania, _terminal, _fechapartida, _fechaarribo, _asientos, _empleado, _servicio, _documentacion); _Reader.Close(); } } catch (SqlException) { throw new Exception("La base de datos no se encuentra disponible. Contacte al administrador."); } catch (Exception ex) { throw new Exception(ex.Message); } finally { oConexion.Close(); } return(unInter); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { try { Viajes v = (Viajes)Session["viajeElegido"]; lblNumero.Text = v.numero.ToString(); lblPartida.Text = v.partida.ToString(); lblArribo.Text = v.arribo.ToString(); lblCantAsientos.Text = v.cantAsientos.ToString(); lblEmpleado.Text = v.e.nombreCompleto; if (v is Internacionales) { Internacionales i = (Internacionales)v; lblDocumentacion.Text = i.documentacion; if (i.servAbordo == true) { lblServAbordo.Text = "Si"; } else { lblServAbordo.Text = "No"; } lblParadas.Text = "Valór no admitido."; } else { Nacionales n = (Nacionales)v; lblParadas.Text = n.paradas.ToString(); lblServAbordo.Text = "Valór no admitido."; lblDocumentacion.Text = "Valór no admitido."; } lblNombre.Text = v.c.nombre; lblDireccion.Text = v.c.direccion; lblTelefono.Text = v.c.telefono.ToString(); lblCodigo.Text = v.t.codigo; lblCiudad.Text = v.t.ciudad; lblPais.Text = v.t.pais; GDVFacilidades.DataSource = v.t.facilidades; GDVFacilidades.ShowHeader = false; GDVFacilidades.DataBind(); } catch (Exception ex) { lblError.Text = ex.Message; } } }
protected void BtnBuscar_Click(object sender, EventArgs e) { try { Viajes v = FabricaLogica.GetLogicaViajes().BuscarViaje(Convert.ToInt32(txtBusqueda.Text)); Panel2.Enabled = true; txtBusqueda.Enabled = false; txtEmpleado.Enabled = false; lblError.Text = ""; if (v is Internacionales) { Internacionales I = (Internacionales)v; Session["ViajeInternacional"] = I; FechaYHora1.Fecha = I.partida; FechaYHora2.Fecha = I.arribo; BtnEliminar.Enabled = true; btnAgregar.Enabled = false; btnModificar.Enabled = true; txtAsiento.Text = I.cantAsientos.ToString(); txtDocumentacion.Text = I.documentacion; txtEmpleado.Text = I.e.ci.ToString(); txtDestino.Text = I.t.codigo.ToString(); txtCompania.Text = I.c.nombre; rblSAbordo.SelectedValue = I.servAbordo.ToString(); } else if (v is Nacionales) { throw new Exception("El numero ingresado corresponde a un viaje Nacional."); } else { Empleado E = (Empleado)Session["Empleado"]; txtEmpleado.Text = E.ci.ToString(); txtAsiento.Text = ""; txtDestino.Text = ""; txtCompania.Text = ""; BtnEliminar.Enabled = false; btnModificar.Enabled = false; btnAgregar.Enabled = true; txtDocumentacion.Text = ""; rblSAbordo.SelectedIndex = 1; } } catch (Exception ex) { lblError.Text = ex.Message; } }
public void Eliminar_Internacional(Internacionales unInter) { SqlConnection oConexion = new SqlConnection(Conexion.STR); SqlCommand oComando = new SqlCommand("Eliminar_ViajeInternacional", oConexion); oComando.CommandType = CommandType.StoredProcedure; oComando.Parameters.AddWithValue("@numero", unInter.Numero); SqlParameter oRetorno = new SqlParameter("@Retorno", SqlDbType.Int); oRetorno.Direction = ParameterDirection.ReturnValue; oComando.Parameters.Add(oRetorno); int oAfectados = -1; try { oConexion.Open(); oComando.ExecuteNonQuery(); oAfectados = (int)oComando.Parameters["@Retorno"].Value; if (oAfectados == -1) { throw new Exception("El viaje ingresado no existe en la base de datos"); } if (oAfectados == -2 || oAfectados == -3) { throw new Exception("Error al eliminar el viaje en la base de datos. Inténtelo nuevamente "); } } catch (SqlException) { throw new Exception("La base de datos no se encuentra disponible. Contacte al administrador."); } catch (Exception ex) { throw new Exception("Problemas con la base de datos: " + ex.Message); } finally { oConexion.Close(); } }
public List <Internacionales> Listar_Todos_Viajes_Int() { SqlConnection oConexion = new SqlConnection(Conexion.STR); SqlCommand oComando = new SqlCommand("Listar_Todos_Viajes_Internacionales", oConexion); oComando.CommandType = CommandType.StoredProcedure; List <Internacionales> _Lista = new List <Internacionales>(); try { oConexion.Open(); SqlDataReader _Reader = oComando.ExecuteReader(); while (_Reader.Read()) { int _numero = (int)_Reader["numero"]; Companias _compania = PersistenciaCompania.GetInstancia().BuscarTodos_Compania((string)_Reader["compania"]); Terminales _terminal = PersistenciaTerminales.GetInstancia().BuscarTodos_Terminal((string)_Reader["destino"]); DateTime _fechapartida = (DateTime)_Reader["fecha_partida"]; DateTime _fechaarribo = (DateTime)_Reader["fecha_arribo"]; int _asientos = (int)_Reader["asientos"]; Empleados _empleado = PersistenciaEmpleado.GetInstancia().BuscarTodos_Empleado((string)_Reader["empleado"]); bool _servicio = (bool)_Reader["servicio"]; string _documentacion = (string)_Reader["documentacion"]; Internacionales viaje = new Internacionales(_numero, _compania, _terminal, _fechapartida, _fechaarribo, _asientos, _empleado, _servicio, _documentacion); _Lista.Add(viaje); } _Reader.Close(); } catch (SqlException) { throw new Exception("La base de datos no se encuentra disponible. Contacte al administrador."); } catch (Exception ex) { throw new Exception(ex.Message); } finally { oConexion.Close(); } return(_Lista); }
private void BtnAlta_Click(object sender, EventArgs e) { try { Internacionales _unInternacional = new Internacionales(); _unInternacional.Numero = Convert.ToInt32(TBNumero.Text); _unInternacional.Compania = (Companias)CBCompania.SelectedItem; _unInternacional.Terminal = (Terminales)CBTerminal.SelectedItem; _unInternacional.Asientos = Convert.ToInt32(TBAsientos.Text); _unInternacional.Servicio = CBServicio.Checked; DateTime _Fechapartida = new DateTime(DTPFechaPartida.Value.Year, DTPFechaPartida.Value.Month, DTPFechaPartida.Value.Day, CBHoraPartida.SelectedIndex, CBMinutosPartida.SelectedIndex, 0); DateTime _Fechaarribo = new DateTime(DTPFechaArribo.Value.Year, DTPFechaArribo.Value.Month, DTPFechaArribo.Value.Day, CBHoraArribo.SelectedIndex, CBMinutosArribo.SelectedIndex, 0); _unInternacional.Fecha_partida = _Fechapartida; _unInternacional.Fecha_arribo = _Fechaarribo; _unInternacional.Documentacion = TBDocumentacion.Text; _unInternacional.Empleado = _EmpLogueado; new AppWinAdministracion.WSTerminalRef.WSTerminal().Alta_Viaje(_unInternacional); LblError.Text = "Viaje Internacional dado de alta con éxito"; this.ActivoPorDefecto(); } catch (System.Web.Services.Protocols.SoapException ex) { int aux = ex.Message.IndexOf("ERROR: "); LblError.Text = ex.Message.Substring(aux, 80); } catch (Exception ex) { if (ex.Message.Length > 80) { LblError.Text = ex.Message.Substring(0, 80); } else { LblError.Text = ex.Message; } } }
private void txtNumero_Validating(object sender, CancelEventArgs e) { try { WebService WS = new WebService(); if (txtNumero.Text.Length != 0) { errorProvider1.Clear(); Viajes viaje = WS.BuscarViaje(Convert.ToInt32(txtNumero.Text)); if (viaje is Nacionales) { errorProvider1.SetError(txtNumero, "Este viaje es de tipo Nacional."); } else { objViajeInter = (Internacionales)viaje; if (objViajeInter == null) { this.ActivoAgregar(); } else { this.ActivoActualizacion(); txtEmpleado.Text = objViajeInter.e.nombreCompleto; } } } else { errorProvider1.SetError(txtNumero, "Debe rellenar este campo."); } } catch (System.Web.Services.Protocols.SoapException ex) { manejoErrorWS(ex.Message); } catch (Exception ex) { lblError.Text = ex.Message; } }
public List <Viajes> ListarInternacionalesTodos() { List <Viajes> lista = new List <Viajes>(); SqlConnection DBCS = Conexion.CrearCnn(); Internacionales I = null; SqlCommand comando = new SqlCommand("ListarInternacionalesTodos", DBCS); comando.CommandType = CommandType.StoredProcedure; try { DBCS.Open(); SqlDataReader r; r = comando.ExecuteReader(); if (r.HasRows) { while (r.Read()) { I = new Internacionales(Convert.ToInt32(r.GetValue(0)), Convert.ToInt32(r.GetValue(1)), Convert.ToDateTime(r.GetValue(2)), Convert.ToDateTime(r.GetValue(3)), PersistenciaEmpleado.GetInstancia().BuscarEmpleadosTodos(Convert.ToInt32(r.GetValue(4))), PersistenciaTerminal.GetInstancia().BuscarTerminalTodos(r.GetValue(5).ToString()), PersistenciaCompania.GetInstancia().BuscarCompaniaTodas(r.GetValue(6).ToString()), Convert.ToBoolean(r.GetValue(7)), r.GetValue(8).ToString()); lista.Add(I); } } r.Close(); } catch (Exception ex) { throw ex; } finally { DBCS.Close(); } return(lista); }
private void TBNumero_Validating(object sender, CancelEventArgs e) { try { Viajes _unInternacional = null; _unInternacional = new AppWinAdministracion.WSTerminalRef.WSTerminal().Buscar_Viaje(Convert.ToInt32(TBNumero.Text)); if (_unInternacional == null) { this.ActivoAgregar(); } else if (_unInternacional is Nacionales) { LblError.Text = "El viaje ingresado corresponde a un viaje nacional"; } else { _objInternacional = (Internacionales)_unInternacional; this.ActivoActualizacion(); } } catch (System.Web.Services.Protocols.SoapException ex) { int aux = ex.Message.IndexOf("ERROR: "); LblError.Text = ex.Message.Substring(aux, 80); } catch (Exception ex) { if (ex.Message.Length > 80) { LblError.Text = ex.Message.Substring(0, 80); } else { LblError.Text = ex.Message; } } }
public Internacionales BuscarViajeInternacionales(int numero) { SqlConnection DBCS = Conexion.CrearCnn(); Internacionales i = null; SqlCommand comando = new SqlCommand("BuscarViajeInternacional", DBCS); comando.CommandType = CommandType.StoredProcedure; comando.Parameters.Add(new SqlParameter("@Numero", numero)); try { DBCS.Open(); SqlDataReader r; r = comando.ExecuteReader(); if (r.HasRows) { r.Read(); i = new Internacionales(Convert.ToInt32(r.GetValue(0)), Convert.ToInt32(r.GetValue(1)), Convert.ToDateTime(r.GetValue(2)), Convert.ToDateTime(r.GetValue(3)), PersistenciaEmpleado.GetInstancia().BuscarEmpleadosTodos(Convert.ToInt32(r.GetValue(4))), PersistenciaTerminal.GetInstancia().BuscarTerminalTodos(r.GetValue(5).ToString()), PersistenciaCompania.GetInstancia().BuscarCompaniaTodas(r.GetValue(6).ToString()), Convert.ToBoolean(r.GetValue(7)), r.GetValue(8).ToString() ); } r.Close(); return(i); } catch (Exception ex) { throw ex; } finally { DBCS.Close(); } }
protected void BtnEliminar_Click(object sender, EventArgs e) { try { Internacionales unInter = (Internacionales)Session["Internacional"]; ILogicaViajes FViaje = FabricaLogica.getLogicaViaje(); FViaje.Eliminar_Viaje(unInter); LblError.ForeColor = System.Drawing.Color.Blue; LblError.Text = "El Viaje " + Convert.ToString(unInter.Numero) + " ha sido eliminado correctamente."; LimpioFormulario(); } catch (Exception ex) { LblError.ForeColor = System.Drawing.Color.Red; LblError.Text = ex.Message; } }
protected void btnModificar_Click(object sender, EventArgs e) { try { Internacionales I = (Internacionales)Session["ViajeInternacional"]; if (I.c.nombre != txtCompania.Text) { I.c = FabricaLogica.GetLogicaCompania().BuscarCompaniaActivas(txtCompania.Text); } if (I.t.codigo != txtDestino.Text) { I.t = FabricaLogica.GetLogicaTerminal().BuscarTerminalActiva(txtDestino.Text); } I.e = (Empleado)Session["Empleado"]; I.cantAsientos = Convert.ToInt32(txtAsiento.Text); I.documentacion = txtDocumentacion.Text; I.servAbordo = Convert.ToBoolean(rblSAbordo.SelectedValue); I.partida = FechaYHora1.Fecha; I.arribo = FechaYHora2.Fecha; FabricaLogica.GetLogicaViajes().ModificarViaje(I); Panel2.Enabled = false; BtnEliminar.Enabled = false; txtBusqueda.Enabled = true; txtBusqueda.Text = ""; txtAsiento.Text = ""; txtCompania.Text = ""; txtDestino.Text = ""; txtDocumentacion.Text = ""; txtEmpleado.Text = ""; rblSAbordo.ClearSelection(); lblError.Text = "Viaje modificado con éxito"; } catch (Exception ex) { lblError.Text = ex.Message; } }
private void ActivoPorDefecto() { BtnAlta.Enabled = false; BtnBaja.Enabled = false; BtnModificar.Enabled = false; TBNumero.Text = ""; CBCompania.SelectedIndex = -1; CBTerminal.SelectedIndex = -1; TBAsientos.Text = ""; CBServicio.Checked = false; DTPFechaPartida.Value = DateTime.Today; CBHoraPartida.SelectedIndex = -1; CBMinutosPartida.SelectedIndex = -1; DTPFechaArribo.Value = DateTime.Today; CBHoraArribo.SelectedIndex = -1; CBMinutosArribo.SelectedIndex = -1; TBDocumentacion.Text = ""; TBNumero.Focus(); TBNumero.Enabled = true; CBCompania.Enabled = false; CBTerminal.Enabled = false; TBAsientos.Enabled = false; CBServicio.Enabled = false; DTPFechaPartida.Enabled = false; CBHoraPartida.Enabled = false; CBMinutosPartida.Enabled = false; DTPFechaArribo.Enabled = false; CBHoraArribo.Enabled = false; //CBMinutosArribo.Enabled = false; TBDocumentacion.Enabled = false; TBNumero.Focus(); _objInternacional = null; }
protected void BtnEliminar_Click(object sender, EventArgs e) { try { Internacionales I = (Internacionales)Session["ViajeInternacional"]; FabricaLogica.GetLogicaViajes().BajaViaje(I); Panel2.Enabled = false; BtnEliminar.Enabled = false; txtBusqueda.Enabled = true; txtBusqueda.Text = ""; txtAsiento.Text = ""; txtCompania.Text = ""; txtDestino.Text = ""; txtDocumentacion.Text = ""; txtEmpleado.Text = ""; rblSAbordo.ClearSelection(); lblError.Text = "Viaje eliminado con éxito."; } catch (Exception ex) { lblError.Text = ex.Message; } }
public void Alta_Internacional(Internacionales unInter) { SqlConnection oConexion = new SqlConnection(Conexion.STR); SqlCommand oComando = new SqlCommand("Alta_ViajeInternacional", oConexion); oComando.CommandType = CommandType.StoredProcedure; oComando.Parameters.AddWithValue("@numero", unInter.Numero); oComando.Parameters.AddWithValue("@compania", unInter.Compania.Nombre); oComando.Parameters.AddWithValue("@destino", unInter.Terminal.Codigo); oComando.Parameters.AddWithValue("@fecha_partida", unInter.Fecha_partida); oComando.Parameters.AddWithValue("@fecha_arribo", unInter.Fecha_arribo); oComando.Parameters.AddWithValue("@asientos", unInter.Asientos); oComando.Parameters.AddWithValue("@empleado", unInter.Empleado.Cedula); oComando.Parameters.AddWithValue("@servicio", unInter.Servicio); oComando.Parameters.AddWithValue("@documentacion", unInter.Documentacion); SqlParameter oRetorno = new SqlParameter("@Retorno", SqlDbType.Int); oRetorno.Direction = ParameterDirection.ReturnValue; oComando.Parameters.Add(oRetorno); try { oConexion.Open(); oComando.ExecuteNonQuery(); if (Convert.ToInt32(oRetorno.Value) == -1) { throw new Exception("El número de viaje ingresado ya existe en la base de datos"); } if (Convert.ToInt32(oRetorno.Value) == -2) { throw new Exception("Ya existe un viaje al destino indicado en ese horario. Los viajes al mismo destino deben tener un mínimo de 2 horas de diferencia entre ellos."); } if (Convert.ToInt32(oRetorno.Value) == -3) { throw new Exception("La compañía ingresada no existe en la base de datos o está dada de baja."); } if (Convert.ToInt32(oRetorno.Value) == -4) { throw new Exception("La terminal ingresada no existe en la base de datos o está dada de baja."); } if (Convert.ToInt32(oRetorno.Value) == -5) { throw new Exception("El empleado logueado no existe en la base de datos o está dado de baja."); } if (Convert.ToInt32(oRetorno.Value) == -6 || Convert.ToInt32(oRetorno.Value) == -7) { throw new Exception("Se produjo un error al intentar dar de alta el viaje. Inténtelo nuevamente."); } } catch (SqlException) { throw new Exception("La base de datos no se encuentra disponible. Contacte al administrador."); } catch (Exception ex) { throw new Exception("Problemas con la base de datos: " + ex.Message); } finally { oConexion.Close(); } }
public void ParaPoderSerializar(Nacionales unNac, Internacionales unInter) { }
public Internacionales DeclaroVInternacional(Internacionales I) { return(I); }
private void BtnDeshacer_Click(object sender, EventArgs e) { _objInternacional = null; this.ActivoPorDefecto(); }
public void AltaViajeInternacionales(Viajes v) { SqlConnection DBCS = Conexion.CrearCnn(); Internacionales I = (Internacionales)v; SqlCommand comando = new SqlCommand("AltaViajeInternacional", DBCS); comando.CommandType = CommandType.StoredProcedure; comando.Parameters.Add(new SqlParameter("@Numero", I.numero)); comando.Parameters.Add(new SqlParameter("@CantAsientos", I.cantAsientos)); comando.Parameters.Add(new SqlParameter("@Partida", I.partida)); comando.Parameters.Add(new SqlParameter("@Arribo", I.arribo)); comando.Parameters.Add(new SqlParameter("@CIEmpleado", I.e.ci)); comando.Parameters.Add(new SqlParameter("@NomCompania", I.c.nombre)); comando.Parameters.Add(new SqlParameter("@CodTerminal", I.t.codigo)); comando.Parameters.Add(new SqlParameter("@ServAbordo", I.servAbordo)); comando.Parameters.Add(new SqlParameter("@Documentacion", I.documentacion)); SqlParameter retorno = new SqlParameter("@Retorno", SqlDbType.Int); retorno.Direction = ParameterDirection.ReturnValue; comando.Parameters.Add(retorno); try { DBCS.Open(); comando.ExecuteNonQuery(); int r = Convert.ToInt32(retorno.Value); if (r == -1) { throw new Exception("Ya existe un viaje con ese número."); } if (r == -2) { throw new Exception("El empleado ingresado no es correcto"); } if (r == -3) { throw new Exception("La terminal ingresada no es correcta."); } if (r == -4) { throw new Exception("La compañía ingresada no es correcta"); } if (r == -5) { throw new Exception("No pueden existir viajes con menos de dos horas de diferencia al mismo destino"); } if (r == -6) { throw new Exception("Error al dar de alta el viaje."); } } catch (Exception ex) { throw ex; } finally { DBCS.Close(); } }