コード例 #1
0
    protected void B_Modificaridio_Click(object sender, EventArgs e)
    {
        ClientScriptManager  cm          = this.ClientScript;
        Logica_idiomaControl idioma      = new Logica_idiomaControl();
        Hashtable            componentes = new Hashtable();

        componentes = idioma.controlarIdioma((int)Session["idioma"], 24);
        String imagenX = "";
        String campo   = "";

        try
        {//si el componente de imagen esta visible
            idioma.validarFU_TB(T_mensajeditar.Visible);
            try
            {
                imagenX = idioma.fileUploadVacio(FU_imagen.PostedFile.FileName, (System.IO.Path.GetExtension(FU_imagen.PostedFile.FileName)).ToUpper(), T_mensajeditar.Text.ToString());
            }
            catch (Exception)
            {
                cm.RegisterClientScriptBlock(this.GetType(), "", "<script type='text/javascript'>alert('" + componentes["mensaje5"].ToString() + "');</script>");
                return;
            }

            try
            {
                idioma.validarImagenExistente((System.IO.File.Exists((Server.MapPath("~//Imagenes//ImagenesWeb") + "//" + (System.IO.Path.GetFileName(FU_imagen.PostedFile.FileName))))));

                //(System.IO.File.Exists((Server.MapPath("~\\Imagenes\\ImagenesWeb") + "\\" + (System.IO.Path.GetFileName(FU_imagen.PostedFile.FileName))))
            }
            catch (Exception)
            {
                cm.RegisterClientScriptBlock(this.GetType(), "", "<script type='text/javascript'>alert('" + componentes["mensaje6"].ToString() + "');</script>");
                return;
            }

            try
            {
                idioma.guardarImg((System.IO.Path.GetFileName(FU_imagen.PostedFile.FileName)), (System.IO.Path.GetExtension(FU_imagen.PostedFile.FileName)).ToUpper());
                FU_imagen.PostedFile.SaveAs(Server.MapPath(imagenX));
                campo = imagenX;
            }
            catch (Exception)
            {
                campo = imagenX;
            }
        }
        catch (Exception)
        {
            campo = T_mensajeditar.Text.ToString();
        }



        try
        {
            Logica_idiomaControl dato = new Logica_idiomaControl();
            dato.modificarIdioma(int.Parse(ddl_formularioeditar.SelectedValue.ToString()), ddl_mensajeeditar.SelectedValue.ToString(), campo, int.Parse(ddl_idiomaeditar.SelectedValue.ToString()));


            Response.Write("<script>window.alert('" + componentes["mensaje3"].ToString() + "');</script>" + "<script>window.setTimeout(location.href='nuevo_idioma.aspx', 2000);</script>");
        }
        catch (Exception)
        {
            Response.Write("<script>window.alert('" + componentes["mensaje4"].ToString() + "');</script>" + "<script>window.setTimeout(location.href='nuevo_idioma.aspx', 2000);</script>");
        }
    }