protected void Page_Load(object sender, EventArgs e) { ScriptManager.GetCurrent(this).RegisterPostBackControl(btnCerrar); ScriptManager.GetCurrent(this).RegisterPostBackControl(imgPopup); this.Form.DefaultButton = this.btnBuscar.UniqueID; //Session["IDE_USUARIO"] = BL_Session.Usuario.ToString(); if (!Page.IsPostBack) { BL_Seguridad obj = new BL_Seguridad(); DataTable dt = new DataTable(); dt = obj.uspSEL_TBOPCIONES_MENU(); if (dt.Rows.Count > 0) { ListView1.DataSource = dt; ListView1.DataBind(); } else { ListView1.DataSource = dt; ListView1.DataBind(); } ///////////////////////////// DataTable dtPersonal = new DataTable(); dtPersonal = obj.SP_LISTAR_FELIZ_CUMPLE(); if (dtPersonal.Rows.Count > 0) { GridCumple.DataSource = dtPersonal; GridCumple.DataBind(); } else { GridCumple.DataSource = dtPersonal; GridCumple.DataBind(); } SelecionarPerfil(); AnuncioHSEC("Tool Box HSEC"); if (BL_Session.FLG_COMUNICADO.ToString() == "1") { DataTable dtResultado = new DataTable(); BL_HSEC_ANUNCIOS objPopup = new BL_HSEC_ANUNCIOS(); dtResultado = objPopup.uspCONSULTAR_POPUP_ANUNCIOS(); if (dtResultado.Rows.Count > 0) { imgPopup.ImageUrl = dtResultado.Rows[0]["URL"].ToString(); string URL_WEB = dtResultado.Rows[0]["URL_WEB"].ToString(); hdUrl.Value = dtResultado.Rows[0]["URL_WEB"].ToString(); //if (URL_WEB !=string.Empty ) //{ // ScriptManager.RegisterStartupScript(this, typeof(Page), "invocarfuncion", "OpenPopup_url('" + URL_WEB + "');", true); //} } ScriptManager.RegisterStartupScript(this, typeof(Page), "invocarfuncion", "OpenPopup();", true); } } }
protected void btnCerrar_Click(object sender, ImageClickEventArgs e) { DataTable dtResultado = new DataTable(); BL_HSEC_ANUNCIOS obj = new BL_HSEC_ANUNCIOS(); dtResultado = obj.uspUPDATE_POPUP_LECTURA(Session["IDE_USUARIO"].ToString()); BL_Session.FLG_COMUNICADO = 0; //if (dtResultado.Rows.Count > 0) //{ // hdcodigo.Value = dtResultado.Rows[0]["IDE_ANUNCIO"].ToString(); //} }
protected void VerUrl(object sender, ImageClickEventArgs e) { ImageButton imgPopup = ((ImageButton)sender); if (hdUrl.Value != string.Empty) { string URL_WEB = hdUrl.Value; ScriptManager.RegisterStartupScript(this, typeof(Page), "invocarfuncion", "OpenPopup_url('" + URL_WEB + "');", true); } DataTable dtResultado = new DataTable(); BL_HSEC_ANUNCIOS obj = new BL_HSEC_ANUNCIOS(); dtResultado = obj.uspUPDATE_POPUP_LECTURA(Session["IDE_USUARIO"].ToString()); BL_Session.FLG_COMUNICADO = 0; }
protected void listar() { DataTable dtResultado = new DataTable(); BL_HSEC_ANUNCIOS obj = new BL_HSEC_ANUNCIOS(); dtResultado = obj.uspSEL_HSEC_ANUNCIOS_POR_TIPO(ddlTipo2.SelectedValue, ""); if (dtResultado.Rows.Count > 0) { GridView1.DataSource = dtResultado; GridView1.DataBind(); } else { GridView1.DataSource = dtResultado; GridView1.DataBind(); } }
protected void AnuncioHSEC(string TIPO) { BL_HSEC_ANUNCIOS obj = new BL_HSEC_ANUNCIOS(); DataTable dt = new DataTable(); dt = obj.uspSEL_HSEC_ANUNCIOS_BUSCAR(TIPO, "1"); if (dt.Rows.Count > 0) { DataList1.DataSource = dt; DataList1.DataBind(); } else { DataList1.DataSource = dt; DataList1.DataBind(); } }
protected void ver_datos(object sender, ImageClickEventArgs e) { ImageButton btnEditar = ((ImageButton)sender); GridViewRow row = btnEditar.NamingContainer as GridViewRow; string pk = GridView1.DataKeys[row.RowIndex].Values[0].ToString(); DataTable dtResultado = new DataTable(); BL_HSEC_ANUNCIOS obj = new BL_HSEC_ANUNCIOS(); dtResultado = obj.uspSEL_HSEC_ANUNCIOS_POR_ID(pk); if (dtResultado.Rows.Count > 0) { hdcodigo.Value = dtResultado.Rows[0]["IDE_ANUNCIO"].ToString(); txtinicio.Text = dtResultado.Rows[0]["FECHA_INICIO"].ToString(); txtfin.Text = dtResultado.Rows[0]["FECHA_FIN"].ToString(); txttitulo.Text = dtResultado.Rows[0]["ARCHIVO_NOMBRE"].ToString(); ddlTipo.SelectedValue = dtResultado.Rows[0]["TIPO_ANUNCIO"].ToString(); txturl.Text = dtResultado.Rows[0]["URL"].ToString(); ddlVisible.SelectedValue = dtResultado.Rows[0]["VISIBLE"].ToString(); } }
protected void Guardar() { string cleanMessage = string.Empty; string RUTA = Server.MapPath(FolderHSEC + ddlTipo.SelectedItem.ToString()); string ARCHIVO = string.Empty; string ARCHIVO_RUTA = string.Empty; string ARCHIVO_EXTESION = string.Empty; Boolean fileOK = false; if (FileUpload1.HasFile) { int length = FileUpload1.PostedFile.ContentLength; ARCHIVO_EXTESION = Path.GetExtension(FileUpload1.FileName).ToUpper(); String[] allowedExtensions = { ".gif", ".png", ".jpeg", ".jpg", ".pdf", ".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".txt" }; for (int i = 0; i < allowedExtensions.Length; i++) { if (ARCHIVO_EXTESION.ToUpper() == allowedExtensions[i].ToUpper()) { fileOK = true; } } if (fileOK) { try { // Se carga la ruta física de la carpeta temp del sitio //string rutaBackups = FolderAlquilerBackups; // Si el directorio no existe, crearlo if (!Directory.Exists(RUTA)) { Directory.CreateDirectory(RUTA); } ARCHIVO = EliminarCaracteres.ReemplazarCaracteresEspeciales(FileUpload1.PostedFile.FileName); ARCHIVO_RUTA = String.Format("{0}\\{1}", RUTA, ARCHIVO); ImageFormat formatFoto; if (ValidaExtension(ARCHIVO_EXTESION.ToUpper())) { System.Drawing.Image imgFoto = RedimensionarImagen(FileUpload1.PostedFile.InputStream, "700"); switch (ARCHIVO_EXTESION.ToUpper()) { case "GF": formatFoto = ImageFormat.Gif; break; case "BMP": formatFoto = ImageFormat.Bmp; break; case "PNG": formatFoto = ImageFormat.Png; break; default: formatFoto = ImageFormat.Jpeg; break; } } // Verificar que el archivo no exista if (File.Exists(ARCHIVO_RUTA)) { //File.Delete(ARCHIVO_RUTA); ARCHIVO = EliminarCaracteres.ReemplazarCaracteresEspeciales(Path.GetFileName(FileUpload1.FileName)); ARCHIVO_RUTA = RUTA + "\\" + ARCHIVO; FileUpload1.SaveAs(ARCHIVO_RUTA); //FileUpload1.SaveAs(rutaBackups + fileArchivo); } else { ARCHIVO = EliminarCaracteres.ReemplazarCaracteresEspeciales(DateTime.UtcNow.ToFileTimeUtc() + Path.GetExtension(FileUpload1.PostedFile.FileName)); //FileUpload1.SaveAs(archivo); ARCHIVO_RUTA = RUTA + "\\" + ARCHIVO; FileUpload1.SaveAs(ARCHIVO_RUTA); //FileUpload1.SaveAs(rutaBackups + fileArchivo); } } catch (Exception ex) { cleanMessage = "Archivo no puedo ser cargado"; ScriptManager.RegisterStartupScript(this, typeof(Page), "invocarfuncion", "doAlert('" + cleanMessage + "');", true); } } } BE_HSEC_ANUNCIOS oBESol = new BE_HSEC_ANUNCIOS(); oBESol.IDE_ANUNCIO = Convert.ToInt32(string.IsNullOrEmpty(hdcodigo.Value) ? "0" : hdcodigo.Value); oBESol.ARCHIVO = ARCHIVO; oBESol.ARCHIVO_NOMBRE = txttitulo.Text.Trim(); oBESol.ARCHIVO_URL = FolderHSEC + ddlTipo.SelectedItem.ToString(); oBESol.ARCHIVO_EXTESION = ARCHIVO_EXTESION; oBESol.TIPO_ANUNCIO = Convert.ToInt32(ddlTipo.SelectedValue); oBESol.COMENTARIOS = txtcomentarios.Text.Trim(); oBESol.URL = txturl.Text.Trim(); oBESol.ORDEN = 1; oBESol.FECHA_INICIO = txtinicio.Text; oBESol.FECHA_FIN = txtfin.Text; oBESol.FLG_VISIBLE = Convert.ToInt32(ddlVisible.SelectedValue); oBESol.USER_REGISTRO = Session["IDE_USUARIO"].ToString(); int dtrpta = 0; dtrpta = new BL_HSEC_ANUNCIOS().uspINS_HSEC_ANUNCIOS(oBESol); if (dtrpta > 0) { hdcodigo.Value = string.Empty; txtinicio.Text = string.Empty; txttitulo.Text = string.Empty; txturl.Text = string.Empty; txtcomentarios.Text = string.Empty; txtfin.Text = string.Empty; listar(); cleanMessage = "Registro exitoso."; ScriptManager.RegisterStartupScript(this, typeof(Page), "invocarfuncion", "doAlert('" + cleanMessage + "');", true); } }