protected void BtnGuardar_Click(object sender, EventArgs e) { if (TxtTitulo.Value == "") { string msj3 = @"<script type='text/javascript'> swal({ title: ""Ingrese Titulo"", icon: ""warning"", dangerMode: true, }) </script>"; ScriptManager.RegisterStartupScript(this, typeof(System.Web.UI.Page), "mensaje", msj3, false); return; } if (TxtDescripcion.Text == "") { string msj3 = @"<script type='text/javascript'> swal({ title: ""Ingrese Descripcion"", icon: ""warning"", dangerMode: true, }) </script>"; ScriptManager.RegisterStartupScript(this, typeof(System.Web.UI.Page), "mensaje", msj3, false); return; } if (UploasIMg.HasFile == false) { string msj3 = @"<script type='text/javascript'> swal({ title: ""Seleccione Imagen"", icon: ""warning"", dangerMode: true, }) </script>"; ScriptManager.RegisterStartupScript(this, typeof(System.Web.UI.Page), "mensaje", msj3, false); return; } System.Drawing.Bitmap LaImagen = new System.Drawing.Bitmap(UploasIMg.PostedFile.InputStream); if (((LaImagen.Width != 350) || (LaImagen.Height != 625))) { string msj3 = @"<script type='text/javascript'> swal({ title: ""El tamaño del imagen debe ser: horizontal: 350 pixeles - Vertical: 625 pixeles"", icon: ""warning"", dangerMode: true, }) </script>"; ScriptManager.RegisterStartupScript(this, typeof(System.Web.UI.Page), "mensaje", msj3, false); return; } Int32 IdNotificacion = 0; int alto; int ancho; DateTime thisDay = DateTime.Now; String str, str2, str3, str4; str = thisDay.ToString(); //.ToString("dd/MM/yyyy hh:mm:ss"); str2 = str.Replace("/", "_"); str3 = str2.Replace(" ", "_"); str4 = str3.Replace(":", "_"); //Response.Write("<script>alert('" + str4.ToString() + "')</script>"); try { UploasIMg.PostedFile.SaveAs(Server.MapPath("~/NotificacionImagen/") + str4.ToString() + UploasIMg.PostedFile.FileName); System.Drawing.Image img; Bitmap imagen = new Bitmap(Server.MapPath("~/NotificacionImagen/") + str4.ToString() + UploasIMg.PostedFile.FileName); ancho = imagen.Width; alto = imagen.Height; img = ResizeImage(imagen, 350, 625); img.Save(Server.MapPath("~/NotificacionImagen/Z-") + str4.ToString() + UploasIMg.PostedFile.FileName); } catch (Exception ex) { StackTrace st = new StackTrace(ex, true); string Mensaje = ex.Message; String Mess = "Imagen demasiado pesado"; string menssajeScript = "<script type='text/javascript'>" + " swal({" + "title: '" + Mess.ToString() + "'," + " icon: 'warning'," + " dangerMode: true," + " }) </script>"; ScriptManager.RegisterStartupScript(this, typeof(Page), "mensaje", menssajeScript, false); return; } //TxtTitulo.Value.ToString()+ IdNotificacion = obj.InsertarNotificaciones(TxtTitulo.Value.ToString().Trim().ToUpper(), TxtDescripcion.Text.ToString().ToUpper().Trim(), "Z-" + str4.ToString() + Path.GetFileName(UploasIMg.FileName), Convert.ToInt32(Request.Cookies["WebNestle"]["DLIdUsuario"])); Promociones obj_promocion = new Promociones(); Int32 IdUsuario = Convert.ToInt32(Request.Cookies["WebNestle"]["DLIdUsuario"]); if (IdNotificacion != 0) { foreach (GridViewRow row in gv_insert.Rows) { obj_promocion.InsertarNotificacionTipoUser(IdNotificacion, Convert.ToInt32(row.Cells[2].Text.ToString())); } } string mensaje = @"<script type='text/javascript'> swal({ title: ""Insertado Correctamente"", icon: ""success"", dangerMode: false, }) </script>"; ScriptManager.RegisterStartupScript(this, typeof(Page), "mensaje", mensaje, false); PanelAgregar.Visible = false; panelListar.Visible = true; TxtBuscarG.Value = ""; ListarNotficaciones(TxtBuscarG.Value.ToString().Trim()); }