protected void btn_eliminar_Click(object sender, EventArgs e) { try { Int32 tel_id = ID_contacto[dpl_contacto.SelectedIndex - 1]; Telefono o_telefono = new Telefono(); foreach (Telefono telefono in telefonos_almacenados) { if (telefono.tel_id == tel_id) { o_telefono = telefono; break; } } if (TelefonosLN.getInstance().EliminarTelefono(o_telefono)) { Response.Write("<script>alert('Se elimino con exito el contacto.')</script>"); } else { Response.Write("<script>alert('Ha habido un error intente nuevamente.')</script>"); } } catch (Exception ex) { Response.Write("<script>alert('Ha habido un error intente nuevamente.')</script>"); } finally { limpiar(); } }
protected void btn_buscar_usuario_Click(object sender, EventArgs e) { if (txt_usuario_buscado.Text != "") { llenar_gridview(TelefonosLN.getInstance().ObtenerListaTelefonos(txt_usuario_buscado.Text)); } else { Response.Write("<script>alert('Ingrese un usuario para buscar.')</script>"); } }
protected void btn_registrar_Click(object sender, EventArgs e) { string txt_salida = ""; if (dpl_codigoarea.SelectedValue == "Seleccione") { txt_salida += txt_salida == "" ? "Codigo de Area" : ", Codigo de Area"; } if (dpl_prioridad.SelectedValue == "Seleccione la prioridad del contacto.") { txt_salida += txt_salida == "" ? "Prioridad" : ", Prioridad"; } if (dpl_tipo.SelectedValue == "Seleccione tipo de contacto.") { txt_salida += txt_salida == "" ? "Tipo de Contacto" : ", Tipo de Contacto"; } if (!(Regex.Match(txt_nro.Text, @"[0-9]*").Value == txt_nro.Text) | "" == txt_nro.Text) { txt_salida += txt_salida == "" ? "Número de Telefono" : ", Número de Telefono"; } try { if (!(Convert.ToInt32(txt_nro.Text) / 1000000 > 1 && Convert.ToInt32(txt_nro.Text) / 1000000 < 10)) { txt_salida += txt_salida == "" ? "Número de Telefono" : ", Número de Telefono"; } } catch (Exception ex) { txt_salida += txt_salida == "" ? "Número de Telefono" : ", Número de Telefono"; } if (txt_salida != "") { Response.Write("<script>alert('Campos erroneamente cargados: " + txt_salida + "')</script>"); } else { Telefono o_telefono = new Telefono(); o_telefono.tel_nro = dpl_codigoarea.SelectedValue + txt_nro.Text; o_telefono.tel_prioridad = Convert.ToInt32(dpl_prioridad.SelectedValue); o_telefono.tel_tipo = dpl_tipo.SelectedValue; Usuario o_usuario_temp = new Usuario(); if (btn_registrar.Text == "REGISTRAR") { o_usuario_temp.usuario = txt_usuario_buscado.Text; o_telefono.tel_usuario = o_usuario_temp; if (TelefonosLN.getInstance().RegistrarTelefono(o_telefono)) { Response.Write("<script>alert('Se registro con exito.')</script>"); limpiar(); } else { Response.Write("<script>alert('Ha habido un error intente nuevamente.')</script>"); } } else { try { Int32 tel_id = ID_contacto[dpl_contacto.SelectedIndex - 1]; o_telefono.tel_id = tel_id; Telefono o_telefono_temp = new Telefono(); foreach (Telefono telefono in telefonos_almacenados) { if (telefono.tel_id == tel_id) { o_telefono_temp = telefono; break; } } if (o_telefono != null) { o_usuario_temp = o_telefono_temp.tel_usuario; } else { o_usuario_temp.usuario = txt_usuario_buscado.Text; o_telefono_temp = null; } o_telefono.tel_usuario = o_usuario_temp; //EdiTAR if (TelefonosLN.getInstance().EditarTelefono(o_telefono)) { Response.Write("<script>alert('Se edito con exito el contacto.')</script>"); } else { Response.Write("<script>alert('Ha habido un error intente nuevamente.')</script>"); } } catch (Exception ex) { Response.Write("<script>alert('Ha habido un error intente nuevamente.')</script>"); } finally { llenar_gridview(TelefonosLN.getInstance().ObtenerListaTelefonos(txt_usuario_buscado.Text)); } } } }