예제 #1
0
    protected void BtnCreateModel_Click(object sender, EventArgs e)
    {
        string folio     = DateTime.Now.ToLongTimeString().Replace(":", "");
        string path      = Path.Combine(Server.MapPath("~/Images/COT_PMODEL/"));
        string fileName  = folio + FileUpFoto.FileName.ToString();
        string path_foto = "http://" + HttpContext.Current.Request.Url.Authority + "/Images/COT_PMODEL/" + fileName;

        path = path + fileName;
        FileUpFoto.SaveAs(path);
        Random  random   = new Random();
        int     _TokenId = random.Next(10000, 9999999);
        Modelos modelos  = new Modelos();

        Modelos._Modelo modelo = new Modelos._Modelo {
            NOMBRE         = TxtModelName.Text,
            DESCRIPCION    = TxtDescripcion.Text,
            ESTADO         = true,
            HASPIECES      = false,
            IMAGE          = path_foto,
            TokenId        = _TokenId.ToString(),
            ID_PASIGFAMCAT = 0,
        };
        bool Isinsert = modelos.InsertModel(modelo);

        if (Isinsert)
        {
            Encriptacion encriptacion = new Encriptacion(_TokenId.ToString());
            Response.Redirect("~/View/Comercial/AdmVentas/Productos/EdicionModelos.aspx?ID=" + modelos.IdBeforeInsert + "&TOKEN=" + encriptacion.TokenEncriptado);
        }
        else
        {
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "none", "<script> $(document).ready(alert('Error al intentar crear el modelo, intentelo nuevamente.'));</script>", false);
        }
    }
예제 #2
0
    protected void BtnEditImage_Click(object sender, EventArgs e)
    {
        string folio = DateTime.Now.ToLongTimeString().Replace(":", "");
        string path  = Path.Combine(Server.MapPath("~/Images/COT_COMPONENTES/"));

        if (!string.IsNullOrEmpty(FileUpFoto.FileName.ToString()))
        {
            string fileName  = folio + FileUpFoto.FileName.ToString();
            string path_foto = "http://" + HttpContext.Current.Request.Url.Authority + "/Images/COT_COMPONENTES/" + fileName;
            path = path + fileName;
            FileUpFoto.SaveAs(path);

            //hacer un update a la tabla con la foto
            ComponentesClass cOMPO      = new ComponentesClass();
            bool             Isinserted = cOMPO.UpdateComponente(HdnIdComp.Value, COT_MCOMPONENTES.Campos.IMG_PATH(), path_foto);
            if (!Isinserted)
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "none", "<script> $(document).ready(alert('Error al intentar Actualizar la información, intentelo nuevamente.'));</script>", false);
            }
            else
            {
                Response.Redirect("~/View/Comercial/AdmVentas/Productos/EdicionComponente.aspx?ID=" + HdnIdComp.Value + "&TOKEN=" + TOKEN);
            }
        }
        else
        {
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "none", "<script> $(document).ready(alert('No se seleccionó ningún archivo.'));</script>", false);
        }
    }
예제 #3
0
    protected void BtnCrearComp_Click(object sender, EventArgs e)
    {
        string folio     = DateTime.Now.ToLongTimeString().Replace(":", "");
        string path      = Path.Combine(Server.MapPath("~/Images/COT_COMPONENTES/"));
        string fileName  = folio + FileUpFoto.FileName.ToString();
        string path_foto = "http://" + HttpContext.Current.Request.Url.Authority + "/Images/COT_COMPONENTES/" + fileName;

        path = path + fileName;
        FileUpFoto.SaveAs(path);
        Random           random     = new Random();
        int              TokenId    = random.Next(10000, 9999999);
        ComponentesClass Componente = new ComponentesClass();
        bool             Isinsert   = Componente.InsertinTabla(TxtNombreComp.Text, TxtDescripcion.Text, path_foto, TokenId);

        if (Isinsert)
        {
            Encriptacion encriptacion = new Encriptacion(TokenId.ToString());
            Response.Redirect("~/View/Comercial/AdmVentas/Productos/EdicionComponente.aspx?ID=" + Componente.IdReturnedInsert + "&TOKEN=" + encriptacion.TokenEncriptado);
        }
        else
        {
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "none", "<script> $(document).ready(alert('Error al intentar crear el componente, intentelo nuevamente.'));</script>", false);
        }
    }