protected void btnAdd_Click(object sender, EventArgs e) { string name = ""; string url = ""; SQLTrans.CrudServiceClient client = new SQLTrans.CrudServiceClient(); try { if (upload.HasFile) { name = clases.Tools.ImgName(upload.FileName, Server.MapPath("~/images/")); url = "/images/" + name; } client.sp_AgregarRestaurante((SQLTrans.LoginData)Session["userdata"], txtRname.Text, txtReferencia.Text, url); output.Text = "Transaccion completada!"; if (upload.HasFile) { upload.SaveAs(Server.MapPath(Path.Combine("~/images/", name))); } txtReferencia.Text = ""; txtRname.Text = ""; } catch (Exception ex) { output.Text = "Ocurrio un error y no se completo la transaccion!" + (char)13 + ex.Message; } }
protected void Page_Load(object sender, EventArgs e) { SQLTrans.CrudServiceClient client = new SQLTrans.CrudServiceClient(); SQLTrans.LoginData ldata = (SQLTrans.LoginData)Session["userdata"]; string text = Request["s"]; if (text != "") { string platillos = ""; string tipo = Request["tipo"]; foreach (SQLTrans.Platillos p in client.buscarPlatillo(text)) { if (tipo != null) { if (Convert.ToInt32(tipo) != p.ID_TIPO) { continue; } } platillos += string.Concat("<tr><td><img src='", (p.URL == null || p.URL == "") ? "/images/sin-imagen.gif" : p.URL, "' height='200px' width='200px' /></td><td>", p.NOMBRE, "</td><td>", p.TIPO, "</td><td>", p.RESTAURANTE, "</td><td>$", Math.Round(p.PRECIO, 2), "</td><td><a href=Platos.aspx?id=", p.ID_PLATILLOS, ">Ver</a> "); if (ldata != null) { if (ldata.isAdmin) { platillos += string.Concat("<a href=Platos.aspx?id=", p.ID_PLATILLOS, "&action=edit>Editar</a> <a href=Platos.aspx?id=", p.ID_PLATILLOS, "&action=delete OnClick=\"if ( ! UserDeleteConfirmation()) return false;\">Eliminar</a></td></tr>\n"); } } } tbody.InnerHtml = platillos; } }
protected void Button1_Click(object sender, EventArgs e) { SQLTrans.CrudServiceClient client = new SQLTrans.CrudServiceClient(); DataSet ds = client.sp_ValidarUsuario(txtUser.Text, txtPass.Text); string user = ""; if (ds.Tables[0].Rows.Count > 0) { try { user = ds.Tables[0].Rows[0][0].ToString(); } catch { } if (user != txtUser.Text) { Session.Remove("userdata"); output.Text = "Usuario o Password incorrectos!"; } else { SQLTrans.LoginData linfo = new SQLTrans.LoginData(); linfo.USER = txtUser.Text; linfo.PASS = txtPass.Text; linfo.isAdmin = client.isAdmin(linfo.USER); Session["userdata"] = linfo; Response.Redirect("Default.aspx"); } } }
protected void btnReg_Click(object sender, EventArgs e) { string url = ""; string name = ""; SQLTrans.CrudServiceClient client = new SQLTrans.CrudServiceClient(); try { if (upload.HasFile) { name = clases.Tools.ImgName(upload.FileName, Server.MapPath("~/images/")); url = "/images/" + name; } client.sp_AgregarUsuario(txtUsername.Text, txtNombre.Text, txtApellidos.Text, txtEmail.Text, txtBirth.Text, txtPassword.Text, url); output.Text = "Transaccion completada!"; if (upload.HasFile) { upload.SaveAs(Path.Combine(Server.MapPath("~/images"), name)); } Response.Redirect("LogIn.aspx"); } catch (Exception) { output.Text = "Ocurrio un error y no se completo la transaccion!"; } }
private void BtnEdit_Click(object sender, EventArgs e) { SQLTrans.LoginData ldata = ((SQLTrans.LoginData)Session["userdata"]); SQLTrans.CrudServiceClient client = new SQLTrans.CrudServiceClient(); try { int img = -1; string name = ""; string url = ""; if (upload.HasFile) { name = clases.Tools.ImgName(upload.FileName, Server.MapPath("~/images/")); url = "/images/" + name; img = client.sp_AgregarImagen(ldata, url); upload.SaveAs(Server.MapPath(Path.Combine("~/images/", name))); } string id = Request["id"].ToString(); if (ldata.isAdmin) { client.sp_AlterUsuario(ldata, id, img, txtNombre.Text, txtApellido.Text, txtCorreo.Text, txtBirth.Text, chkAdmin.Checked, null); } else { client.sp_AlterUsuario(ldata, id, img, txtNombre.Text, txtApellido.Text, txtCorreo.Text, txtBirth.Text, ldata.isAdmin, null); } output.Text = "Transaccion realizada!"; } catch (Exception ex) { Console.WriteLine(ex.Message); output.Text = "Ocurrio un error!"; } }
protected void Page_Load(object sender, EventArgs e) { string[] stipos = new SQLTrans.CrudServiceClient().GetTiposPlatillo(); LiteralControl tipos = new LiteralControl(); SQLTrans.Comentarios[] c = new SQLTrans.CrudServiceClient().GetLastsComentarios(); string lc = ""; foreach (SQLTrans.Comentarios i in c) { string url = i.URL; if (url == "" || url == null) { url = "/images/sin-imagen.gif"; } lc += $"<li><a href=#><img src={url} class='avatar avatar-40 photo' height='40' width='40'></a> <a href='Platos.aspx?id={i.ID_PLATILLOS}'>{i.ID_USUARIO}: </a>{i.COMENTARIOS}<div class=clear></div></li>"; } lastcomments.InnerHtml = lc; foreach (string t in stipos) { string[] sp = t.Split(','); tipos.Text += $"<li id=class='menu-item menu-item-type-taxonomy menu-item-object-category'><a href='Platos.aspx?tipo={sp[0]}'>{sp[1]}</a></li>"; } tipoplatillo.Controls.Add(tipos); if (Request["logout"] != null) { Session.Clear(); } if (Session["userdata"] != null) { SQLTrans.LoginData ldata = ((SQLTrans.LoginData)Session["userdata"]); try { new SQLTrans.CrudServiceClient().sp_AgregarEstadistica(ldata); } catch { } LiteralControl submenu = new LiteralControl(); user.InnerText = ldata.USER; user.HRef = "~/Users.aspx?id=" + ldata.USER; if (ldata.isAdmin) { signin.InnerText = "Crear Usuarios"; } else { signin.Attributes.Add("style", "display:none;"); } submenu.Text = string.Concat("<ul class='sub-menu' style='display: none; visibility: hidden;'>", "<li id = 'menu-item-47' class='menu-item menu-item-type-post_type menu-item-object-page'><a href = 'ARestaurantes.aspx' >Agregar Restaurante</a></li>", "<li id = 'menu-item-43' class='menu-item menu-item-type-post_type menu-item-object-page'><a href = 'APlatos.aspx' >Agregar Platillo</a></li>", "<li id = 'menu-item-142' class='menu-item menu-item-type-custom menu-item-object-custom'><a href = 'AlterPass.aspx' >Cambiar Password</a></li>" , (!ldata.isAdmin) ? $"<li id = 'menu-item-143' class='menu-item menu-item-type-custom menu-item-object-custom'><a href = 'Users.aspx?id={ldata.USER}&edit=true' >Cambiar perfil</a></li>" : "" , (ldata.isAdmin) ? "<li id = 'menu-item-144' class='menu-item menu-item-type-custom menu-item-object-custom'><a href = 'Users.aspx' >Ver usuarios</a></li>" : "" , (ldata.isAdmin) ? "<li id = 'menu-item-145' class='menu-item menu-item-type-custom menu-item-object-custom'><a href = 'History.aspx' >Ver historial</a></li>" : "" , "<li id = 'menu-item-143' class='menu-item menu-item-type-custom menu-item-object-custom'><a href = 'Default.aspx?Logout=true' >Cerrar sesion</a></li></ul>"); usermenu.Controls.Add(submenu); } }
protected void Page_Load(object sender, EventArgs e) { SQLTrans.CrudServiceClient client = new SQLTrans.CrudServiceClient(); int inicio = 1, fin = 10; if (Session["userdata"] != null) { SQLTrans.LoginData ldata = ((SQLTrans.LoginData)Session["userdata"]); if (Request["inicio"] != null && Request["fin"] != null) { try { inicio = Convert.ToInt32(Request["inicio"]); fin = Convert.ToInt32(Request["fin"]); } catch { inicio = 0; fin = 10; output.Text = "Valores no validos en parametros!"; } } string logs = ""; if (!ldata.isAdmin && Request["id"] == null) { output.Text = MSGNOGRANT; } else { foreach (SQLTrans.Logs l in client.GetLogs(ldata, inicio, fin)) { string t = ""; switch (l.TIPO) { case 'C': t = "Creacion"; break; case 'U': t = "Actualizacion"; break; case 'D': t = "Eliminacion"; break; default: t = "Desconocido"; break; } logs += $"<tr><td>{l.ID_USUARIO}</td><td>{t}</td><td>{l.TABLA}</td><td>{DateTime.Parse(l.CREACION).ToShortDateString()}</td></tr>"; } string h = ""; if (inicio - 10 < 0) { h = "display:none;"; } logs += $"<tr><td><a style='text-align:right;{h}' href=History.aspx?inicio={inicio-10}&fin={fin-10}>Anterior</a></td><td></td><td></td><td style='text-align:right;'><a href=History.aspx?inicio={inicio+10}&fin={fin+10}>Siguiente</a></td></tr>"; tbody.InnerHtml = logs; } } }
protected void Page_Load(object sender, EventArgs e) { SQLTrans.CrudServiceClient client = new SQLTrans.CrudServiceClient(); Dictionary <int, string> fotos = new Dictionary <int, string>(); fotos = client.getGallery(); string outstring = ""; foreach (int id in fotos.Keys) { outstring += "<dl class=\"gallery-item\">" + "<dt class=\"gallery-icon landscape\">" + $"<a href=\"Platos.aspx?={id}\"><img width=\"150\" height=\"150\" src=\"{fotos[id]}\" class=\"attachment-thumbnail size-thumbnail\" alt=\"\" srcset=\"\" sizes=\"(max-width: 150px) 100vw, 150px\"></a>" + "</dt></dl>"; } gallery.InnerHtml = outstring; }
protected void Page_Load(object sender, EventArgs e) { SQLTrans.CrudServiceClient client = new SQLTrans.CrudServiceClient(); if (Session["userdata"] != null) { SQLTrans.LoginData ldata = ((SQLTrans.LoginData)Session["userdata"]); if (!ldata.isAdmin && Request["id"] == null) { output.Text = MSGNOGRANT; } else if (Request["id"] != null) { portrait.Attributes.Remove("class"); string id = Request["id"]; if (Request["action"] == "edit" && ldata.isAdmin) { Button btnEdit = new Button(); btnEdit.Text = "Editar"; btnEdit.Click += BtnEdit_Click; editcontrols.Controls.Add(btnEdit); txtApellido.ReadOnly = false; txtBirth.ReadOnly = false; txtCorreo.ReadOnly = false; txtNombre.ReadOnly = false; chkAdmin.Enabled = true; } else if (Request["edit"] == "true" && ldata.USER == Request["id"]) { Button btnEdit = new Button(); btnEdit.Text = "Editar"; btnEdit.Click += BtnEdit_Click; editcontrols.Controls.Add(btnEdit); txtApellido.ReadOnly = false; txtBirth.ReadOnly = false; txtCorreo.ReadOnly = false; txtNombre.ReadOnly = false; } SQLTrans.Usuarios user; try { user = client.GetUsuario(id)[0]; } catch { output.Text = MSGNOUSER; return; } username.Text = id; if (!IsPostBack) { if (user.URL == null || user.URL == "") { img.ImageUrl = "/images/sin-imagen.gif"; } else { img.ImageUrl = user.URL; } chkAdmin.Checked = client.isAdmin(id); txtNombre.Text = user.NOMBRE; txtApellido.Text = user.APELLIDO; txtBirth.Text = Convert.ToDateTime(user.FECHA_CUMPLE).ToShortDateString(); txtCorreo.Text = user.CORREO_ELECTRONICO; lcount.Text = user.VISITAS.ToString(); } } else { userlist.Attributes.Remove("class"); string users = ""; foreach (SQLTrans.Usuarios u in client.GetUsuarios()) { users += string.Concat("<tr><td>", u.ID_USUARIO, "</td><td>", u.ADMIN ? "Admin" : "Usuario", "</td><td>", u.CORREO_ELECTRONICO, "</td><td><a href=Users.aspx?id=", u.ID_USUARIO, ">Ver</a> <a href=Users.aspx?id=", u.ID_USUARIO, "&action=edit>Editar</a></td></tr>\n"); } tbody.InnerHtml = users; } } else { output.Text = MSGNOGRANT; } }