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); } }