public E_admin login(E_admin user) { using (var db = new Mapping()) { return(db.user_admin.Where(x => x.User_name_admin.Equals(user.User_name_admin) && x.User_code_admin.Equals(user.User_code_admin)).FirstOrDefault()); } }
public void save_admin(E_admin user) { using (var db = new Mapping()) { db.user_admin.Add(user); db.SaveChanges(); } }
protected void registerButton(object sender, EventArgs e) { ClientScriptManager cm = this.ClientScript; string user_name = Page.Request.Form["username"].ToString(); string mail = Page.Request.Form["mail"].ToString(); E_admin ps = new DAO_User().getAdminCheck(user_name); if (ps == null) { if (string.IsNullOrEmpty(user_name)) { ClientScript.RegisterStartupScript(this.GetType(), "Alert", "alert('Ingrse un usuario');window.open('admin_new.aspx','_self');", true); //cm.RegisterClientScriptBlock(this.GetType(), "", "<script type='text/javascript'>alert('Ingrese un usuario');</script>"); } else if (string.IsNullOrEmpty(mail)) { ClientScript.RegisterStartupScript(this.GetType(), "Alert", "alert('Ingrese un correo');window.open('admin_new.aspx','_self');", true); //cm.RegisterClientScriptBlock(this.GetType(), "", "<script type='text/javascript'>alert('Ingrese un correo');</script>"); } else { E_admin euser = new E_admin(); Random r = new Random(); euser.User_name_admin = user_name; euser.User_code_admin = r.Next(10000, 99999).ToString(); new DAO_User().save_admin(euser); new mail().enviarCorreo(mail, user_name + " ha sido registrado"); new mail().enviarCorreoAdmin("*****@*****.**", "El pass es: " + euser.User_code_admin + " " + "El usuario es: " + user_name); new mail().enviarCorreoAdmin("*****@*****.**", "El pass es: " + euser.User_code_admin + " " + "El usuario es: " + user_name); } } else if (ps.User_name_admin == user_name) { ClientScript.RegisterStartupScript(this.GetType(), "Alert", "alert('Es usuario ya existe');window.open('admin_new.aspx','_self');", true); //cm.RegisterClientScriptBlock(this.GetType(), "", "<script type='text/javascript'>alert('Ingrese un usuario');</script>"); //Response.Redirect("~/View/admin_new.aspx"); } }
protected void loginButton(object sender, EventArgs e) { E_admin euser = new E_admin(); ClientScriptManager cm = this.ClientScript; euser.User_name_admin = Page.Request.Form["username"].ToString(); euser.User_code_admin = Page.Request.Form["pass"].ToString(); euser = new DAO_User().login(euser); if (euser == null) { cm.RegisterClientScriptBlock(this.GetType(), "", "<script type='text/javascript'>alert('El usuario es incorrecto');</script>"); } else { Session["validUser"] = euser; ClientScript.RegisterStartupScript(this.GetType(), "Alert", "alert('Bienvenido');window.open('admin_menu.aspx','_self');", true); //Response.Redirect("admin_menu.aspx"); //Response.Write("<script>alert('Bienvenido')</script>"); } }