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; } }
protected void btnBuscar_Click(object sender, EventArgs e) { try { if (String.IsNullOrEmpty(txtNum.Text)) { throw new Exception("Debe completar el campo de busqueda"); } Session["ViajeNacBuscado"] = FabricaLogica.GetLogicaViajes().BuscarViaje(Convert.ToInt32(txtNum.Text.Trim())); if ((ViajesNacionales)Session["ViajeNacBuscado"] != null) { btnAgregar.Enabled = false; txtCompania.Text = ((ViajesNacionales)Session["ViajeNacBuscado"])._Com._Nombre; txtTerminal.Text = ((ViajesNacionales)Session["ViajeNacBuscado"])._Ter._Codigo; txtFechaPartida.Text = ((ViajesNacionales)Session["ViajeNacBuscado"])._FechaPartida.ToString(); txtFechaArribo.Text = ((ViajesNacionales)Session["ViajeNacBuscado"])._FechaArribo.ToString(); txtCantidadAsientos.Text = ((ViajesNacionales)Session["ViajeNacBuscado"])._CantidadAsientos.ToString(); ddParadas.Text = Convert.ToString(((ViajesNacionales)Session["ViajeNacBuscado"])._ParadasIntermedias); btnEliminar.Enabled = true; btnModificar.Enabled = true; } else { Limpiar(); btnAgregar.Enabled = true; lblMensaje.Text = "No existe el viaje internacional, si desea puede agregarlo."; } } catch (Exception ex) { lblMensaje.Text = ex.Message; } }
protected void btnEliminar_Click(object sender, EventArgs e) { try { LimpiarTodo(); FabricaLogica.GetLogicaViajes().Eliminar((ViajesNacionales)Session["ViajeNacBuscado"]); } catch (Exception ex) { lblMensaje.Text = ex.Message; } }
public string Estadisticas() { try { IlogicaViajes FLogica = FabricaLogica.GetLogicaViajes(); List <Viajes> lista = FLogica.ListarViajesTodos(); XmlDocument xmldoc = new XmlDocument(); xmldoc.LoadXml("<lista></lista>"); foreach (Viajes v in lista) { XmlNode nodoViaje = xmldoc.CreateNode(XmlNodeType.Element, "Viaje", ""); XmlNode nodoNumero = xmldoc.CreateNode(XmlNodeType.Element, "Número", ""); nodoNumero.InnerXml = v.numero.ToString(); nodoViaje.AppendChild(nodoNumero); XmlNode nodoCiudadDestino = xmldoc.CreateNode(XmlNodeType.Element, "CiudadDestino", ""); nodoCiudadDestino.InnerXml = v.t.ciudad; nodoViaje.AppendChild(nodoCiudadDestino); XmlNode nodoPaisDestino = xmldoc.CreateNode(XmlNodeType.Element, "PaisDestino", ""); nodoPaisDestino.InnerXml = v.t.pais; nodoViaje.AppendChild(nodoPaisDestino); XmlNode nodoCompania = xmldoc.CreateNode(XmlNodeType.Element, "Compania", ""); nodoCompania.InnerXml = v.c.nombre; nodoViaje.AppendChild(nodoCompania); XmlNode nodoFechaPartida = xmldoc.CreateNode(XmlNodeType.Element, "FechaPartida", ""); nodoFechaPartida.InnerXml = v.partida.ToString(); nodoViaje.AppendChild(nodoFechaPartida); xmldoc.DocumentElement.AppendChild(nodoViaje); } return(xmldoc.OuterXml); } catch (Exception ex) { XmlDocument unDoc = new System.Xml.XmlDocument(); XmlNode noddoError = unDoc.CreateNode(XmlNodeType.Element, SoapException.DetailElementName.Name, SoapException.DetailElementName.Namespace); XmlNode nodeDetalle = unDoc.CreateNode(XmlNodeType.Element, "Error", ""); nodeDetalle.InnerText = ex.Message; noddoError.AppendChild(nodeDetalle); SoapException miEx = new SoapException(ex.Message, SoapException.ClientFaultCode, Context.Request.Url.AbsolutePath, noddoError); throw miEx; } }
public string ViajesXML() { ILogicaViaje LViaje = FabricaLogica.GetLogicaViajes(); List <Viaje> ListarViajes = LViaje.Listar(); XmlDocument DocumentoXML = new XmlDocument(); XmlNode NodoV = DocumentoXML.CreateNode(XmlNodeType.Element, "Viaje", ""); try { foreach (Viaje V in ListarViajes) { XmlNode NodoViaje = DocumentoXML.CreateNode(XmlNodeType.Element, "Viaje", ""); XmlNode NodoNum = DocumentoXML.CreateNode(XmlNodeType.Element, "Numero", ""); NodoNum.InnerText = V._NumViaje.ToString(); NodoViaje.AppendChild(NodoNum); XmlNode NodoCiudad = DocumentoXML.CreateNode(XmlNodeType.Element, "CiudadDestino", ""); NodoCiudad.InnerText = V._Ter._Ciudad; NodoViaje.AppendChild(NodoCiudad); XmlNode NodoPais = DocumentoXML.CreateNode(XmlNodeType.Element, "PaisDestino", ""); NodoPais.InnerText = V._Ter._Pais; NodoViaje.AppendChild(NodoPais); XmlNode NodoCompañia = DocumentoXML.CreateNode(XmlNodeType.Element, "Compañia", ""); NodoCompañia.InnerText = V._Com._Nombre; NodoViaje.AppendChild(NodoCompañia); XmlNode NodoFecha = DocumentoXML.CreateNode(XmlNodeType.Element, "FechaPartida", ""); NodoFecha.InnerText = V._FechaPartida.ToString();; NodoViaje.AppendChild(NodoFecha); NodoV.AppendChild(NodoViaje); } } catch (Exception ex) { XmlDocument _undoc = new System.Xml.XmlDocument(); XmlNode _NodoError = _undoc.CreateNode(XmlNodeType.Element, SoapException.DetailElementName.Name, SoapException.DetailElementName.Namespace); XmlNode _NodoDetalle = _undoc.CreateNode(XmlNodeType.Element, "Error", ex.Message); _NodoDetalle.InnerText = ex.Message; _NodoError.AppendChild(_NodoDetalle); SoapException _MiEx = new SoapException("Error WS", SoapException.ClientFaultCode, Context.Request.Url.AbsoluteUri, _NodoError); throw _MiEx; } DocumentoXML.AppendChild(NodoV); return(DocumentoXML.OuterXml); }
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; } }
protected void btnBuscar_Click(object sender, EventArgs e) { try { Viajes v = FabricaLogica.GetLogicaViajes().BuscarViaje(Convert.ToInt32(txtBusqueda.Text)); txtBusqueda.Enabled = false; txtEmpleado.Enabled = false; Panel2.Enabled = true; lblError.Text = ""; if (v is Nacionales) { Nacionales n = (Nacionales)v; Panel2.Visible = true; Session["ViajeNacional"] = n; FechaYHora3.Fecha = n.partida; FechaYHora4.Fecha = n.arribo; txtAsiento.Text = n.cantAsientos.ToString(); txtParadas.Text = n.paradas.ToString(); txtEmpleado.Text = n.e.ci.ToString(); txtDestino.Text = n.t.codigo.ToString(); txtCompania.Text = n.c.nombre; BtnEliminar.Enabled = true; btnAgregar.Enabled = false; btnModificar.Enabled = true; } else if (v is Internacionales) { txtBusqueda.Enabled = true; Panel2.Enabled = false; throw new Exception("El numero ingresado corresponde a un viaje Internacional."); } else { Empleado E = (Empleado)Session["Empleado"]; txtEmpleado.Text = E.ci.ToString(); txtAsiento.Text = ""; txtParadas.Text = ""; txtDestino.Text = ""; txtCompania.Text = ""; btnModificar.Enabled = false; btnAgregar.Enabled = true; } } catch (Exception ex) { lblError.Text = ex.Message; } }
protected void BtnEliminar_Click(object sender, EventArgs e) { try { Nacionales n = (Nacionales)Session["ViajeNacional"]; FabricaLogica.GetLogicaViajes().BajaViaje(n); Panel2.Visible = false; BtnEliminar.Visible = false; lblError.Text = "Viaje eliminado con éxito."; } catch (Exception ex) { lblError.Text = ex.Message; } }
protected void btnQuitar_Click(object sender, EventArgs e) { try { List <Viaje> viajes = new List <Viaje>(); viajes.AddRange(FabricaLogica.GetLogicaViajes().Listar()); viajes.AddRange(FabricaLogica.GetLogicaViajes().ListarViaje()); Session["ListaDeViajes"] = viajes; rptrViajes.DataSource = viajes; rptrViajes.DataBind(); ddlCompania.SelectedValue = "Todas"; chkPorFecha.Checked = false; } catch (Exception ex) { lblMsj.Text = ex.Message; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { try { Session["viajeElegido"] = null; List <Viajes> v = FabricaLogica.GetLogicaViajes().ListarViajes(); RepeaterCViajes.DataSource = v; RepeaterCViajes.DataBind(); Session["TodosLosViajes"] = v; List <Terminal> terminales = new List <Terminal>(); List <Compania> companias = new List <Compania>(); foreach (Viajes viajes in v) { terminales.Add(viajes.t); companias.Add(viajes.c); } var resultadoT = ((from t in terminales group t by t.codigo into b select b.Key)).ToList <object>(); foreach (var j in resultadoT) { DDLDestino.Items.Add(j.ToString()); } var resultadoC = ((from c in companias group c by c.nombre into a select a.Key)).ToList <object>(); foreach (var q in resultadoC) { DDLCompania.Items.Add(q.ToString()); } DDLDestino.SelectedIndex = -1; DDLCompania.SelectedIndex = -1; } catch (Exception ex) { lblError.Text = ex.Message; } } }
public List <Viaje> ListarViajes() { try { ILogicaViaje LViaje = FabricaLogica.GetLogicaViajes(); return(LViaje.Listar()); } catch (Exception ex) { XmlDocument _undoc = new System.Xml.XmlDocument(); XmlNode _NodoError = _undoc.CreateNode(XmlNodeType.Element, SoapException.DetailElementName.Name, SoapException.DetailElementName.Namespace); XmlNode _NodoDetalle = _undoc.CreateNode(XmlNodeType.Element, "Error", ex.Message); _NodoDetalle.InnerText = ex.Message; _NodoError.AppendChild(_NodoDetalle); SoapException _MiEx = new SoapException("Error WS", SoapException.ClientFaultCode, Context.Request.Url.AbsoluteUri, _NodoError); throw _MiEx; } }
protected void rptrViajes_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName == "VerViaje") { try { int codViaje = Convert.ToInt32(((TextBox)e.Item.Controls[1]).Text); Viaje v = FabricaLogica.GetLogicaViajes().Buscar(codViaje); if (v == null) { v = FabricaLogica.GetLogicaViajes().BuscarViaje(codViaje); } Session["ConsultaViaje"] = v; Response.Redirect("~/DetalleDeViaje.aspx"); } catch (Exception ex) { lblMsj.Text = ex.Message; } } }
protected void Page_Load(object sender, EventArgs e) { lblMsj.Text = ""; if (!IsPostBack) { try { List <Viaje> viajes = new List <Viaje>(); viajes.AddRange(FabricaLogica.GetLogicaViajes().Listar()); viajes.AddRange(FabricaLogica.GetLogicaViajes().ListarViaje()); Session["ListaDeViajes"] = viajes; rptrViajes.DataSource = viajes; rptrViajes.DataBind(); LlenarDDL(); } catch (Exception ex) { lblMsj.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; } }
public Viajes BuscarViaje(int numero) { try { IlogicaViajes viaje = FabricaLogica.GetLogicaViajes(); return(viaje.BuscarViaje(numero)); } catch (Exception ex) { XmlDocument _undoc = new XmlDocument(); XmlNode _NodoError = _undoc.CreateNode(XmlNodeType.Element, SoapException.DetailElementName.Name, SoapException.DetailElementName.Namespace); XmlNode _nodoDetalle = _undoc.CreateNode(XmlNodeType.Element, "Error", ""); _nodoDetalle.InnerText = ex.Message; _NodoError.AppendChild(_nodoDetalle); SoapException _MiEx = new SoapException(ex.Message, SoapException.ClientFaultCode, Context.Request.Url.AbsoluteUri, _NodoError); throw _MiEx; } }
protected void btnModificar_Click(object sender, EventArgs e) { try { Nacionales n = (Nacionales)Session["ViajeNacional"]; if (n.c.nombre != txtCompania.Text) { n.c = FabricaLogica.GetLogicaCompania().BuscarCompaniaActivas(txtCompania.Text); } if (n.t.codigo != txtDestino.Text) { n.t = FabricaLogica.GetLogicaTerminal().BuscarTerminalActiva(txtDestino.Text); } n.e = (Empleado)Session["Empleado"]; n.cantAsientos = Convert.ToInt32(txtAsiento.Text); n.paradas = Convert.ToInt32(txtParadas.Text); n.partida = FechaYHora3.Fecha; n.arribo = FechaYHora4.Fecha; Panel2.Enabled = false; txtBusqueda.Enabled = true; txtBusqueda.Text = ""; txtAsiento.Text = ""; txtParadas.Text = ""; txtDestino.Text = ""; txtCompania.Text = ""; BtnEliminar.Enabled = false; FabricaLogica.GetLogicaViajes().ModificarViaje(n); lblError.Text = "Viaje modificado con éxito"; } catch (Exception ex) { lblError.Text = ex.Message; } }
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); Nacionales N = new Nacionales(Convert.ToInt32(txtBusqueda.Text), Convert.ToInt32(txtAsiento.Text), FechaYHora3.Fecha, FechaYHora4.Fecha, E, T, C, Convert.ToInt32(txtParadas.Text)); FabricaLogica.GetLogicaViajes().AltaViaje(N); Panel2.Enabled = false; txtBusqueda.Enabled = true; txtBusqueda.Text = ""; txtAsiento.Text = ""; txtParadas.Text = ""; txtDestino.Text = ""; txtCompania.Text = ""; lblError.Text = "Viaje registrado con éxito."; } catch (Exception ex) { lblError.Text = ex.Message; } }
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; } }