public static int updatemodel(usertable str) { Model1 mo = new Model1(); mo.Entry(str).State = System.Data.Entity.EntityState.Modified; return(mo.SaveChanges()); }
protected void updateLogin() { string sql = "SELECT RELATIONSHIPID FROM USERTABLE UT WHERE UT.USERID='" + ID + "' AND PASSWORD='******' AND STATUS=2"; Handler hdn = new Handler(); DataTable dt = hdn.GetTable(sql); if (dt.Rows.Count > 0) { usertable obj1 = new usertable(HttpContext.Current.Server.MapPath("~/XML/database.xml")); obj1.usertable_SRNO = -1; obj1.usertable_RELATIONSHIPID = -1; obj1.usertable_STATUS = 0; string condition = "USERID = '" + ID + "' AND PASSWORD = '******'"; if (obj1.Insert(false, "usertable", condition)) { } registrationtable obj = new registrationtable(HttpContext.Current.Server.MapPath("~/XML/database.xml")); obj.registrationtable_SRNO = -1; obj.registrationtable_SPONSORID = -1; obj.registrationtable_STATUS = 0; string condition1 = "SRNO =" + dt.Rows[0][0].ToString(); ; if (obj.Insert(false, "registrationtable", condition1)) { } } }
public static int insert(usertable str) { Model1 mo = new Model1(); mo.usertable.Add(str); return(mo.SaveChanges()); }
public ActionResult ShowUser() { ViewBag.ebulten = TempData["ebulten"]; ViewBag.login = TempData["login"]; usertable currentUser = (usertable)Session["MySessionUser"]; if (currentUser != null) { var user = db.usertables.Find(currentUser.id); var post = from x in db.posttables where x.isaktif == 1 && x.userid == currentUser.id select x; ViewBag.postlar = post.Count(); return(View("ShowUser", user)); } else { return(RedirectToAction("Index")); } }
public ActionResult register(FormCollection fc, usertable u) { //if (ModelState.IsValid) { string username1 = fc["username"]; var rs = from m in db.usertable where m.username.Equals(username1) select m; if (rs.ToList().Count > 0) { ViewBag.ErrorMessage = "用户已存在"; return(View("~/Views/Shared/_ErrorMessage.cshtml")); } else { SHA1 sha1 = new SHA1CryptoServiceProvider(); byte[] bytes_in = Encoding.UTF8.GetBytes((string)fc["password"]); byte[] bytes_out = sha1.ComputeHash(bytes_in); sha1.Dispose(); string result = BitConverter.ToString(bytes_out); result = result.Replace("-", ""); usertable user = new usertable { username = username1, password = result, qq = (string)fc["qq"], email = (string)fc["email"] }; Console.WriteLine(user.ToString()); db.usertable.Add(user); db.SaveChanges(); /*此处同鲜花网站,注册成功后直接返回首页,仍然是未登录状态*/ return(RedirectToAction("Index")); } } //return View(u); }
public static int delete(int id) { Model1 mo = new Model1(); usertable list = mo.usertable.FirstOrDefault(p => p.userId == id); mo.Entry(list).State = System.Data.Entity.EntityState.Deleted; return(mo.SaveChanges()); }
public static usertable loginIn(string name, string pwd) { Model1 mo = new Model1(); List <usertable> list = mo.usertable.ToList(); usertable li = list.FirstOrDefault(p => p.userName == name && p.userWord == pwd); return(li); }
public ActionResult updatemodel(usertable str) { if (Class3.updatemodel(str) != 0) { return(RedirectToAction("Index")); } else { return(RedirectToAction("update")); } }
protected void btnsubmit_Click(object sender, EventArgs e) { if (txtpassword.Text.Trim() != string.Empty) { registrationtable obj = new registrationtable(HttpContext.Current.Server.MapPath("~/XML/database.xml")); obj.registrationtable_SRNO = -1; obj.registrationtable_SPONSORID = -1; obj.registrationtable_STATUS = 2; string condition = "SRNO=" + ViewState["registrationid"].ToString(); if (obj.Insert(false, "registrationtable", condition)) { usertable obj1 = new usertable(HttpContext.Current.Server.MapPath("~/XML/database.xml")); obj1.usertable_SRNO = -1; obj1.usertable_STATUS = 2; obj1.usertable_NAME = txtmemname.Text; obj1.usertable_USERID = txtmememail.Text; obj1.usertable_PASSWORD = txtpassword.Text; obj1.usertable_ROLE = "USER"; obj1.usertable_RELATIONSHIPID = General.Parse<int>(ViewState["registrationid"].ToString()); if (obj1.Insert(true, "usertable")) { string encryptedid = EncryptionMethod(txtmememail.Text); string encryptedpassword = EncryptionMethod(txtpassword.Text); string x = HttpContext.Current.Request.Url.ToString(); string[] s = { "superadminmemberlist.aspx" }; string[] spath = x.Split(s, StringSplitOptions.None); string link = "http://crmproject.aishinfotech.net/activatelink.aspx?id=" + txtmememail.Text.Trim().ToLower() + "&psd=" + txtpassword.Text.Trim(); MessageBox("Mail Sent To User For Activation"); string body = "<html xmlns='http://www.w3.org/1999/xhtml'> <head runat='server'> <title>Registration</title> </head> " + " <body> <form id='form1' runat='server'> <div style=' border: 4px solid #537DA3; height:544px; width:600px; background-color:#fff; left:42%; top:0; margin-left:-200px; z-index:99999; border-radius:10px; position:fixed;'>" + " <img src='Images/logo.png' alt='' style='margin-left:3%; padding-top:5px;' /> <div style='font-size:18px; font-family:Arial Balck; font-weight:bold; margin-left:22px; color:#93c220;'>Welcome To Marketing Project</div><br />" + " <p style='margin-left:24px; line-height:22px;'>Hi " + txtmemname.Text + " <br /> Welcome to<a href=''>Marketing Project</a><strong>Get Started!</strong> </p>" + " <strong style='margin-left:24px;'>Your Login Details are :</strong> <p style='margin-left:24px;'><strong>UserName : </strong> " + txtmememail.Text.ToLower() + "<br />" + " <strong>Password :</strong> " + txtpassword.Text + " </p> <p style='color:#b9b7b7; font-size:13px;margin-left:24px;'> If you forget your username/password in future, you can use the <a href='http://crmproject.aishinfotech.net/register.aspx'>forgot your password</a> link on<br /> <a href='http://crmproject.aishinfotech.net'> Marketing Project </a></p>" + " <p style='margin-left:24px;'><strong>Activate Account</strong></p> <p style='color:#b9b7b7; font-size:13px;margin-left:24px; line-height:0px;'> Please visit below url </p><p style='margin-left:24px;line-height:17px;'><br/><a href='" + link + "'>" + link + "</a><br/></p>" + " </form></body> </html>"; try { General.SendMail("", "*****@*****.**", "9850386144k", "smtp.gmail.com", 587, "Registration", body, txtmememail.Text, "", ""); //General.SendMail("", "*****@*****.**", "aish@123", "smtp.gmail.com", 587, "registration", body, txtmememail.Text, "", ""); } catch (Exception ex) { } } } } else { MessageBox("Please Generate Password"); } }
public ActionResult insertmodel(usertable str) { if (Class3.insert(str) != 0) { return(RedirectToAction("Index")); } else { return(RedirectToAction("insert")); } }
public void Adduser() { if (Password == ConfirePassWord) { IQueryable <usertable> data = from v in _jsEntities.usertables where v.username == Username select v; var y = data.ToList(); usertable Newuser = new usertable { username = Username, password = Password, markid = MarkId, phonenum = PhoneNum, email = Emial, other = other }; if (data.ToList().Count <= 0) { _jsEntities.usertables.Add(Newuser); _jsEntities.SaveChanges(); MulTime(3); } else { if (NeedDo == 1) { Newuser.id = y[0].id; foreach (var c in data) { c.id = Newuser.id; c.markid = Newuser.markid; c.other = Newuser.other; c.password = Newuser.password; c.phonenum = Newuser.phonenum; c.username = Newuser.username; } _jsEntities.SaveChanges(); MulTime(3); } else { Username = string.Empty; hnit = "用户已存在"; } } } else { Password = ""; ConfirePassWord = "******"; } }
public ActionResult membermodified(usertable u) { var rs = db.usertable.Find(u.username); //rs.email = u.email; //rs.qq = u.qq; UpdateModel(rs); //db.Entry(u).State = System.Data.Entity.EntityState.Modified; //这个方法确实可以,但是首先传过来的信息要完整,其次内部的机理还不是很了解 db.SaveChanges(); return(RedirectToAction("memberMag")); }
public ActionResult NewUser(string username, string usersurname, string usermail, string password) { var kullanici = db.usertables.FirstOrDefault(x => x.usermail == usermail); if (kullanici != null) { // Mükerrer kullanıcı return(RedirectToAction("Index")); } var ekle = new usertable { username = username, usersurname = usersurname, password = password, usermail = usermail, authority = 2, isaktif = 1, }; if (Request.Files.Count > 0) { var image = Request.Files[0]; //kanka bu resmi aliyor. gelen request'in icinde gorunuyor su anda resim. if ((5 * 1024 * 1024) < image.ContentLength) //5MB { throw new Exception("hata mesaaji"); } //burada content type denetlenebilir. sadece resimlerin gelebilmesi icin //if (!ImageFormatHelper.GetRawImageFormat(fileBytes).IsIn(ImageFormat.Jpeg, ImageFormat.Png, ImageFormat.Gif)) //{ // throw new Exception("Admin_FileUploadDescriptionMessage"); //} var fileInfo = new FileInfo(image.FileName); var pic = "pic_" + DateTime.Now.Ticks + fileInfo.Extension; //new file name var filePath = "/Photos/users/" + pic; //sen bunu db'ye yaz.. var tempFilePath = Server.MapPath("~\\Photos\\users\\" + pic); image.SaveAs(tempFilePath); ekle.userphoto = filePath; } db.usertables.Add(ekle); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult NewUser(string username, string usersurname, string usermail, string password, int authority, int isaktif) { var usermailx = db.usertables.FirstOrDefault(x => x.usermail == usermail); if (usermailx != null) { TempData["user"] = string.Format("no"); return(Redirect(ControllerContext.HttpContext.Request.UrlReferrer.ToString())); } else { var ekle = new usertable { username = username, usersurname = usersurname, password = password, usermail = usermail, authority = authority, isaktif = isaktif, }; if (Request.Files.Count > 0) { var image = Request.Files[0]; if ((5 * 1024 * 1024) < image.ContentLength) { throw new Exception("hata mesaaji"); } var fileInfo = new FileInfo(image.FileName); var pic = "pic_" + DateTime.Now.Ticks + fileInfo.Extension; var filePath = "/Photos/users/" + pic; var tempFilePath = Server.MapPath("~\\Photos\\users\\" + pic); image.SaveAs(tempFilePath); ekle.userphoto = filePath; } db.usertables.Add(ekle); db.SaveChanges(); return(RedirectToAction("Index")); } }
public ActionResult Register(usertable u) { u.username = Request.Form["txtname"]; u.email = Request.Form["email"]; u.password = Request.Form["txtpass"]; u.city = Request.Form["city"]; u.mobile = Convert.ToInt32(Request.Form["mobile"]); db.usertables.Add(u); int res = db.SaveChanges(); if (res > 0) { ModelState.AddModelError("", "Registration Complete"); } return(RedirectToAction("Login")); }
public ActionResult UpdateUser(usertable p1) { var kullanici = db.usertables.Find(p1.id); //var ekle = new usertable //{ // id = id, // username = username, // usersurname = usersurname, // password = password, // usermail = usermail, // authority = authority, // isaktif = isaktif, //}; if (p1.userphoto != null) { var image = Request.Files[0]; if ((5 * 1024 * 1024) < image.ContentLength) { throw new Exception("hata mesaaji"); } var fileInfo = new FileInfo(image.FileName); var pic = "pic_" + DateTime.Now.Ticks + fileInfo.Extension; //new file name var filePath = "/Photos/users/" + pic; //sen bunu db'ye yaz.. var tempFilePath = Server.MapPath("~\\Photos\\users\\" + pic); image.SaveAs(tempFilePath); kullanici.userphoto = filePath; } kullanici.authority = p1.authority; kullanici.usermail = p1.usermail; kullanici.isaktif = p1.isaktif; kullanici.password = p1.password; kullanici.username = p1.username; kullanici.usersurname = p1.usersurname; db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Login(usertable model) { var CocukYaziniUser = db.usertables.FirstOrDefault(x => x.usermail == model.usermail && x.password == model.password); if (CocukYaziniUser != null) { Session["MySessionUser"] = CocukYaziniUser; ViewBag.successMessage = "Başarılı Giriş"; return(Redirect(ControllerContext.HttpContext.Request.UrlReferrer.ToString())); } //YALNIŞ GİRİŞ else { TempData["login"] = string.Format("no"); return(Redirect(ControllerContext.HttpContext.Request.UrlReferrer.ToString())); } }
public JsonResult loginIn(string name, string pwd) { usertable user = Class1.longin(name, pwd); JsonResult jsonResult = new JsonResult(); if (user != null) { string json = JsonConvert.SerializeObject(user); //HttpCookie cookie = new HttpCookie("login", Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(json))); //Response.Cookies.Add(cookie); jsonResult.Data = new { data = json, state = "200" }; jsonResult.JsonRequestBehavior = JsonRequestBehavior.AllowGet; return(jsonResult); } else { jsonResult.Data = new { data = "未找到该用户", state = "403" }; return(jsonResult); } }
public ActionResult ForgetPassword(usertable k) { var mailadresi = db.usertables.Where(x => x.usermail == k.usermail).FirstOrDefault(); if (mailadresi != null) { Guid rastgele = Guid.NewGuid(); mailadresi.password = rastgele.ToString().Substring(0, 8); db.SaveChanges(); SmtpClient client = new SmtpClient("mail.cocukyazini.com", 587); //client.EnableSsl = true; MailMessage mail = new MailMessage(); mail.From = new MailAddress("*****@*****.**", "Şifre Sıfırlama - Çocuk Yazını"); mail.To.Add(mailadresi.usermail); mail.IsBodyHtml = true; mail.Subject = "Şifre Değiştirme İsteği"; mail.Body += "Merhaba " + mailadresi.username + "<br/>" + "<b>Kullanıcı Mail Adresi :</b> " + mailadresi.usermail + "<br/>" + " <b>Şifreniz :</b> " + mailadresi.password + "<br /> <br />" + "Eğer şifrenin başkası tarafından değiştirildiğini düşünüyorsan bizimle iletişime geçebilirsin. </br> [email protected] <br/><br/><br/>" + "<a href='https://cocukyazini.com/'>Çocuk Yazını</a> <br /> <br /> <img src='https://cocukyazini.com/Photos/logo/cocuk.png' height='100px' />" ; NetworkCredential net = new NetworkCredential("*****@*****.**", "CocukYazinicom1234!"); client.Credentials = net; client.Send(mail); return(RedirectToAction("Index")); } else { var HataMesaji = " Girmiş olduğunuz E-posta sistemimizde kayıtlı değil."; ViewBag.mesaj = HataMesaji; return(View()); } }
public ActionResult ForgetPasswordEN(usertable k) { var mailadresi = db.usertables.Where(x => x.usermail == k.usermail).FirstOrDefault(); if (mailadresi != null) { Guid rastgele = Guid.NewGuid(); mailadresi.password = rastgele.ToString().Substring(0, 8); db.SaveChanges(); SmtpClient client = new SmtpClient("mail.cocukyazini.com", 587); //client.EnableSsl = true; MailMessage mail = new MailMessage(); mail.From = new MailAddress("*****@*****.**", "Şifre Sıfırlama - Çocuk Yazını"); mail.To.Add(mailadresi.usermail); mail.IsBodyHtml = true; mail.Subject = "Change Password - Children's Literature"; mail.Body += "Hello " + mailadresi.username + "<br/>" + "<b>User Mail :</b> " + mailadresi.usermail + "<br/>" + " <b>Your New Password :</b> " + mailadresi.password + "<br /> <br />" + "If you think your password has been changed by someone else, you can contact us.. </ br> [email protected] <br/><br/><br/>" + "<a href='https://cocukyazini.com/'>Çocuk Yazını</a> <br /> <br /> <img src='https://cocukyazini.com/Photos/logo/cocuk.png' height='100px' />" ; NetworkCredential net = new NetworkCredential("*****@*****.**", "CocukYazinicom1234!"); client.Credentials = net; client.Send(mail); return(RedirectToAction("Index")); } else { var HataMesaji = " The email you entered is not registered in system.."; ViewBag.mesaj = HataMesaji; return(View()); } }
public ActionResult UpdateUser(usertable p1) { var kullanici = db.usertables.Find(p1.id); if (p1.userphoto != null) { var image = Request.Files[0]; if ((5 * 1024 * 1024) < image.ContentLength) { throw new Exception("hata mesaaji"); } var fileInfo = new FileInfo(image.FileName); var pic = "pic_" + DateTime.Now.Ticks + fileInfo.Extension; //new file name var filePath = "/Photos/users/" + pic; //sen bunu db'ye yaz.. var tempFilePath = Server.MapPath("~\\Photos\\users\\" + pic); image.SaveAs(tempFilePath); kullanici.userphoto = filePath; } kullanici.usermail = p1.usermail; kullanici.password = p1.password; kullanici.username = p1.username; kullanici.usersurname = p1.usersurname; db.SaveChanges(); Session.Remove("MySessionUser"); Session.Abandon(); Session.Clear(); return(RedirectToAction("Index")); }
public ActionResult Index(usertable usr) { //get username and password from the user //check it against the database usertable sujitabooksEntities dbObject = new sujitabooksEntities(); var checkUser = dbObject.usertables.Where(l => l.u_name.Equals(usr.u_name) && l.u_password.Equals(usr.u_password)).FirstOrDefault(); if (checkUser != null) { var loggeduser = dbObject.usertables.Where(l => l.u_name.Equals(usr.u_name)).FirstOrDefault(); Session["u_name"] = loggeduser.u_name.ToString(); Session["u_id"] = loggeduser.u_id.ToString(); return(RedirectToAction("Dashboard")); } else { ViewBag.msg = "Invalid Username or Password"; } return(View()); }
protected void btnSave_Click(object sender, EventArgs e) { int cmpcount = 0; int branchcount = 0; foreach (ListItem aListItem in chkcmplist.Items) { if (aListItem.Selected) { cmpcount = 1; foreach (ListItem aListItem1 in chkbranchlist.Items) { if (aListItem1.Selected) { branchcount = 1; break; } } break; } } if (cmpcount > 0 && branchcount > 0) { usertable user = new usertable(HttpContext.Current.Server.MapPath("~/XML/database.xml")); user.usertable_SRNO = -1; user.usertable_NAME = txtname.Text; user.usertable_DESIGNATION = ddldesignation.SelectedItem.Text.Trim().ToString(); user.usertable_DEPARTMENT = ddldepartment.SelectedItem.Text.Trim().ToString(); if (rdfemale.Checked) { user.usertable_GENDER = "FEMALE"; } else { user.usertable_GENDER = "MALE"; } user.usertable_EMAIL = txtemail.Text; user.usertable_PHONE = txtphone.Text; user.usertable_USERID = txtuserid.Text; user.usertable_PASSWORD = GenerateRandomCode(); user.usertable_STATUS = 0; if (user.Insert(true, "usertable")) { int i = 0; foreach (ListItem aListItem in chkcmplist.Items) { if (aListItem.Selected) { permissionmaster permission = new permissionmaster(HttpContext.Current.Server.MapPath("~/XML/database.xml")); permission.permissionmaster_SRNO = -1; permission.permissionmaster_USERID = General.Parse<int>(Session["userid"].ToString().Trim()); permission.permissionmaster_CMPID = General.Parse<int>(aListItem.Value.ToString().Trim()); if (i == 0) { permission.permissionmaster_PREFFERED = 1; } else { permission.permissionmaster_PREFFERED = 0; } permission.permissionmaster_BRANCHID = -1; permission.permissionmaster_STATUS = 0; if (permission.Insert(true, "permissionmaster")) { } } } i = 0; foreach (ListItem aListItem in chkbranchlist.Items) { if (aListItem.Selected) { permissionmaster permission = new permissionmaster(HttpContext.Current.Server.MapPath("~/XML/database.xml")); permission.permissionmaster_SRNO = -1; permission.permissionmaster_USERID = General.Parse<int>(Session["userid"].ToString().Trim()); permission.permissionmaster_BRANCHID = General.Parse<int>(aListItem.Value.ToString().Trim()); if (i == 0) { permission.permissionmaster_PREFFERED = 1; } else { permission.permissionmaster_PREFFERED = 0; } permission.permissionmaster_CMPID = -1; permission.permissionmaster_STATUS = 0; if (permission.Insert(true, "permissionmaster")) { } } } } MessageBox("User Created Successfully"); FillUser(); } }
protected void btnedit_Click(object sender, EventArgs e) { usertable user = new usertable(HttpContext.Current.Server.MapPath("~/XML/database.xml")); user.usertable_SRNO = -1; user.usertable_NAME = txteditname.Text.Trim().ToString(); user.usertable_DESIGNATION = ddleditdesignation.SelectedItem.Text.Trim().ToString(); user.usertable_DEPARTMENT = ddleditdepartment.SelectedItem.Text.Trim().ToString(); if (rdeditfemale.Checked) { user.usertable_GENDER = "FEMALE"; } else { user.usertable_GENDER = "MALE"; } user.usertable_EMAIL = txteditemail.Text.Trim().ToString(); user.usertable_PHONE = txteditphone.Text.Trim().ToString(); user.usertable_USERID = txtedituserid.Text.Trim().ToString(); user.usertable_PASSWORD = txteditpassword.Text.Trim().ToString(); user.usertable_STATUS = General.Parse<int>(ddlstatus.SelectedValue.Trim().ToString()); string condition = "SRNO=" + ViewState["userid"].ToString(); if (user.Insert(false, "usertable", condition)) { MessageBox("User Updated Successfully"); FillUser(); } ScriptManager.RegisterStartupScript(this, this.GetType(), "viewuser", "ShowUser();", true); }