protected void btnGuardar_Click(object sender, EventArgs e) { EstadoNegocio estadoNegocio = new EstadoNegocio(); Estado objNegocio = new Estado(); Estado obj = new Estado(); try { objNegocio.Nombre = txtcNombre.Text.ToUpper(); if (txtcNombre.Text == "") { throw new Exception("Error nombre del estado no puede estar en blanco"); } obj = estadoNegocio.obtenerEstado().Find(x => x.Nombre == objNegocio.Nombre); if (obj == null) { estadoNegocio.insertarEstado(objNegocio); Response.Redirect("WebEstado.aspx"); } else { throw new Exception("Error ya existe ese nombre del estado"); } } catch (Exception ex) { lblModalTitle.Text = "Validación"; lblModalBody.Text = ex.Message; ScriptManager.RegisterStartupScript(Page, Page.GetType(), "myModal", "openModal();", true); } }
protected void Page_Load(object sender, EventArgs e) { MunicipioNegocio negocioMunicipio = new MunicipioNegocio(); EstadoNegocio negocioEstado = new EstadoNegocio(); Estado objEstado = new Estado(); if (Session["ID"] == null) { GridViewRow datos = (GridViewRow)Session["gvr"]; lblID.Text = datos.Cells[0].Text; } else { lblID.Text = Session["ID"] as string; } try { int idEstado = Convert.ToInt32(lblID.Text.ToString()); objEstado = negocioEstado.obtenerEstado().Find(x => x.idEstado == idEstado); lblNombreEstado.Text = objEstado.Nombre; GridViewMunicipio.DataSource = negocioMunicipio.obtenerMunicipio(idEstado); GridViewMunicipio.DataBind(); } catch (Exception ex) { throw new Exception("Error en la consulta" + ex.Message); } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { dropListEstado.DataSource = estadoNegocio.obtenerEstado(); dropListEstado.DataValueField = "idEstado"; dropListEstado.DataTextField = "Nombre"; dropListEstado.DataBind(); GridViewRow datos = (GridViewRow)Session["gvr"]; lblID.Text = datos.Cells[0].Text; txtcNombre.Text = datos.Cells[2].Text; dropListEstado.Items.FindByValue(datos.Cells[1].Text.ToString()).Selected = true; txtcNombre.Attributes.Add("placeHolder", "Nombre del Municipio"); txtcNombre.Focus(); } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { EstadoNegocio estadoNegocio = new EstadoNegocio(); try { GridViewEstado.DataSource = estadoNegocio.obtenerEstado(); GridViewEstado.DataBind(); } catch (Exception ex) { throw new Exception("error de la consulta" + ex.Message); } } }
protected void CargaEstado() { try { if (!Page.IsPostBack) { EstadoNegocio objEdoBE = new EstadoNegocio(); DropListEstado.DataSource = objEdoBE.obtenerEstado(); DropListEstado.DataValueField = "idEstado"; DropListEstado.DataTextField = "Nombre"; DropListEstado.DataBind(); MunicipioNegocio objMunBE = new MunicipioNegocio(); dropListMunicipio.DataSource = objMunBE.obtenerMunicipio(1); dropListMunicipio.DataValueField = "idMunicipio"; dropListMunicipio.DataTextField = "Nombre"; dropListMunicipio.DataBind(); InstitucionNegocio objInsBE = new InstitucionNegocio(); DropListInst.DataSource = objInsBE.obtenerInstitucion(); DropListInst.DataValueField = "idInstitucion"; DropListInst.DataTextField = "NombreInstitucion"; DropListInst.DataBind(); // catalogo pendiente de carrera /* CarreraNegocio objCarBE = new CarreraNegocio(); * DropListCarrera.DataSource = objCarBE.ConsultaInsenCarrera(Convert.ToInt32(DropListInst.SelectedValue.ToString())); * DropListCarrera.DataValueField = "idCarrera"; * DropListCarrera.DataTextField = "Nombre"; * DropListCarrera.DataBind(); */ } } catch (Exception ex) { Mensajes.Msjs(this, "Error", "Ocurrió el siguiente detalle: " + ex.Message); } }