public int them1taikhoan(eTaiKhoan tk) { try { var tmp = db.Tbl_Users.Where(x => x.ID == tk.ID1).FirstOrDefault(); if (tmp != null) { return(0); } Tbl_User user = new Tbl_User(); user.ID = tk.ID1; user.MaNV = tk.Manv1; user.Nhom = tk.Nhom1; user.Password = tk.Password1; user.Phanquyen = tk.PhanQuyen1; db.Tbl_Users.InsertOnSubmit(user); db.SubmitChanges(); return(1); } catch { return(0); } }
private void AddUser_Click(object sender, RoutedEventArgs e) { string temp = ""; ServicesXml sx = new ServicesXml(); Tbl_User tuser = new Tbl_User(); tuser.UserId = rand.Next(); tuser.UserName = string.Format("{0}{1}", tbFName.Text, tbLName.Text.Substring(0, 1)); tuser.Password = rand.Next().ToString(); tuser.DateOfBirthday = (DateTime)dpDoB.SelectedDate; tuser.Gender = (Gender)(lbGender.SelectedIndex); if (!sx.AddUser(tuser, out temp)) { errorMesage.Foreground = new SolidColorBrush(Colors.Red); errorMesage.Content = temp; } else { errorMesage.Foreground = new SolidColorBrush(Colors.Green); errorMesage.Content = temp; Thread.Sleep(3000); AdminWindow.mf.Source = new Uri("Pages/ListUsersPage.xaml", UriKind.RelativeOrAbsolute); } }
public ActionResult Create(Tbl_Task task) { if (ModelState.IsValid) { using (var databaseContext = new TODOListDBEntities()) { try { if (Session["UserInfo"] != null) { loginUser = (Tbl_User)Session["UserInfo"]; } task.UserId = loginUser.Id; task.CreatedDate = DateTime.Now; task.ModifiedDate = DateTime.Now; databaseContext.Tbl_Task.Add(task); databaseContext.SaveChanges(); } catch (DbEntityValidationException e) { ViewBag.Message = "All fields are compulsory"; return(View("Create")); } } ViewBag.Message = "Task Added"; return(View("Create")); } else { return(View()); } }
public async Task <IActionResult> Register(ViewModel_Register model, string returnUrl = null) { try { ViewData["ReturnUrl"] = returnUrl; if (ModelState.IsValid) { var user = new Tbl_User { Email = model.Email, UserName = model.Email }; var result = await userManager.CreateAsync(user, model.Password); if (result.Succeeded) { // await CreateRole("Admin"); // for checking user role is Exict or not var result1 = await userManager.AddToRoleAsync(user, "Admin"); var code = await userManager.GenerateEmailConfirmationTokenAsync(user); var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: HttpContext.Request.Scheme); //await emailSender.SendEmailAsync(model.Email, "Confirm Account", // $"Pleas Enter the link: <a href='{callbackUrl}'>Link</a>"); TempData["Message"] = "Registration was Successfull"; return(View("Login", model)); } AddErrors(result); } return(View("Login", model)); } catch (Exception) { throw; } }
public ActionResult login(Tbl_User user) { using (ctx) { var usr = ctx.Tbl_User.Single(u => u.UserName.Equals(user.UserName) && u.Password.Equals(user.Password)); //String nomAdmin = usr.UserName.ToString(); //String passAdmin = usr.Password.ToString(); //if (nomAdmin.Equals("Admin") && passAdmin.Equals("123")) //{ // return RedirectToAction("/Admin/Dashboard"); //} if (usr != null) { String nomAdmin = usr.UserName.ToString(); String passAdmin = usr.Password.ToString(); Session["UserID"] = nomAdmin; Session["Username"] = passAdmin; if (nomAdmin.Equals("Mohamed Ali") && passAdmin.Equals("1234")) { return(RedirectToAction("Dashboard", "Admin")); } return(RedirectToAction("Checkout")); } else { return(RedirectToAction("Erreur")); ModelState.AddModelError("", "Username or password is wrong"); } } return(View()); }
public ActionResult IsValidUser(Tbl_User loginUser) { using (var dataContext = new TODOListDBEntities()) { //String password = Decrypt(loginUser.Password); //Retireving the user details from DB based on username and password enetered by user. Tbl_User addedUser = dataContext.Tbl_User.Where(query => query.Username.Equals(loginUser.Username)).SingleOrDefault(); //If user is not present, then false is returned. if (addedUser == null) { ViewBag.Message = "Incorrect username"; return(View("Login")); } //If user is present true is returned. else { String testpassword = loginUser.Password; String password = Decrypt(addedUser.Password); if (password.Equals(testpassword)) { Session["UserInfo"] = addedUser; return(RedirectToAction("ToDo", "Task")); } ViewBag.Message = "Incorrect password"; return(View("Login")); } } }
public Tbl_User Get_User(int User_ID) { Tbl_User user = new Tbl_User(); user = db.Tbl_User.Find(User_ID); return(user); }
public Tbl_User Get_User(string username) { Tbl_User user = new Tbl_User(); user = db.Tbl_User.Where(a => a.User_Username == username).SingleOrDefault(); return(user); }
public ActionResult User_Edit(Model_UserEdit model) { Tbl_Login _Login = db.Tbl_Login.Where(a => a.Login_ID == model.ID).SingleOrDefault(); Tbl_User _User = _Login.Tbl_User; _Login.Login_Email = model.Email; _Login.Login_Mobile = model.Mobile; _User.User_GenderCodeID = Rep_CodeGroup.Get_CodeIDWithGUID(Guid.Parse(model.Gender)); _User.User_Name = model.Name; _User.User_Family = model.Family; db.Entry(_Login).State = EntityState.Modified; db.Entry(_User).State = EntityState.Modified; if (Convert.ToBoolean(db.SaveChanges() > 0)) { TempData["TosterState"] = "success"; TempData["TosterType"] = TosterType.Maseage; TempData["TosterMassage"] = "عملیات با موفقیت انجام شد"; return(RedirectToAction("index")); } else { TempData["TosterState"] = "error"; TempData["TosterType"] = TosterType.Maseage; TempData["TosterMassage"] = "عملیات با موفقیت انجام نشد"; return(RedirectToAction("index")); } }
public ActionResult AddUser(Tbl_User registerUser) { if (ModelState.IsValid) { using (var databaseContext = new TODOListDBEntities()) { try { registerUser.Password = Encrypt(registerUser.Password); databaseContext.Tbl_User.Add(registerUser); databaseContext.SaveChanges(); }catch (DbUpdateException e) { ViewBag.Message = "Username ALready Exists"; return(View("Register")); } } ViewBag.Message = "User Details Saved"; return(View("Register")); } else { //If the validation fails, we are returning the model object with errors to the view, which will display the error messages. return(View("Register", registerUser)); } }
public ActionResult adopt(int id) { try { Tbl_Pets p = db.Tbl_Pets.Find(id); int cost = Convert.ToInt32(p.Pet_Price); int userid = Convert.ToInt32(Session["id"]); Tbl_User u = db.Tbl_User.Find(userid); int h = u.Wallet - cost; if ((h) > 0) { db.taken(p.PetID); db.amount(u.UserID, h); Session["amount"] = h; ViewBag.SuccessMessage = "Thank You for Your Adoption!The amount has been debited from your Wallet"; Session["SuccessMessage"] = "Thank You for Your Adoption!The amount has been debited from your Wallet"; TempData["SuccessMessage"] = "Thank You for Your Adoption!The amount has been debited from your Wallet"; return(RedirectToAction("Index", "USER")); } ViewBag.FailureMessage = "Sorry You dont have sufficient balance. Please recharge and try again"; Session["FailureMessage"] = "Sorry You dont have sufficient balance. Please recharge and try again"; TempData["FailureMessage"] = "Sorry You dont have sufficient balance. Please recharge and try again"; return(RedirectToAction("Recharge")); } catch (Exception e) { return(View(e.Message)); } }
protected void Page_Load(object sender, EventArgs e) { string username = this.Request["username"]; string psd = this.Request["psd"]; string imei = this.Request["imei"]; Msg msg = UserLoginModel.Login(username, psd, imei); JavaScriptSerializer jss = new JavaScriptSerializer(); if (msg.Status) { Tbl_User oUser = msg.UserData as Tbl_User; LoginRet loginRet = new LoginRet(); loginRet.Identify = oUser.Access; loginRet.UserName = oUser.Name; loginRet.Status = 1; this.Response.Write(jss.Serialize(loginRet)); } else { LoginRet loginRet = new LoginRet(); loginRet.Message = msg.Message; loginRet.Status = 0; this.Response.Write(jss.Serialize(loginRet)); } }
public static int UpdateTbl_User(Tbl_User tbl_user) { WebCommon.Public.WriteLog("修改会员:" + tbl_user.UserName); tbl_user.DealUser = WebCommon.Public.GetUserName(); tbl_user.DealTime = DateTime.Now; return(new Tbl_UserService().UpdateTbl_UserById(tbl_user)); }
public ActionResult CheckUser(Tbl_User User) { var DbUser = _context.Tbl_User.SingleOrDefault(u => u.Username == User.Username); if (DbUser == null || DbUser.Password != User.Password) { ViewBag.Error = "نام کاربری و یا رمز عبور اشتباه است"; return(View("Login")); } else if (DbUser.Password == User.Password) { ViewBag.Error = ""; Session["UserId"] = DbUser.Id; if (DbUser.AccessLevelID == 1) { return(RedirectToAction("Dashbord", "Admin")); } else if (DbUser.AccessLevelID == 2) { return(RedirectToAction("Home", "SellerPanel")); } else { return(RedirectToAction("Login", "Home")); } } else { return(HttpNotFound()); } }
//[ValidateAntiForgeryToken] public ActionResult Register1(Tbl_User tbl_User) { if (IsExist(tbl_User.Email)) { try { if (ModelState.IsValid) { tbl_User.ConfirmPassword = Security.HashSHA1(tbl_User.ConfirmPassword); tbl_User.UserPassword = Security.HashSHA1(tbl_User.UserPassword); tbl_User.Wallet = 1000; db.Tbl_User.Add(tbl_User); db.SaveChanges(); return(View("Login")); } } catch (Exception e) { return(View(e.Message)); } } else { ModelState.AddModelError("Email", "The email already exist"); } return(View(tbl_User)); }
public bool RemoveUser(Tbl_User User) { //try //{ // //check if user exists // var res = from t in db.Tbl_User // where t.User_ID == User.User_ID // select t; // if (res.Count() > 0) // { // // user exists // db.Tbl_User.Remove(User); // db.SaveChanges(); // return true; // } // else // { // // no such user // return false; // } //} //catch (Exception ex) //{ // return false; //} return(true); }
public ActionResult Register(Tbl_User u, string State) { if (Session["User"] == null) { Tbl_User ur = new Tbl_User(); ur.User_Active = false; ur.User_Address = u.User_Address; ur.User_City = u.User_City; ur.User_Date = DateTime.Now; ur.User_Email = u.User_Email; ur.User_Mobile = u.User_Mobile; ur.User_NameFamily = u.User_NameFamily; ur.User_NationalCode = u.User_NationalCode; ur.User_Password = u.User_Password; ur.User_PostalCode = u.User_PostalCode; ur.User_Rating = "0"; ur.User_Roleid = 1; ur.User_Stateid = Convert.ToInt32(State); ur.User_Tel = u.User_Tel; ur.User_Username = u.User_Username; db.Tbl_User.Add(ur); if (Convert.ToBoolean(db.SaveChanges() > 0)) { TempData["Message"] = " .ثبت نام شما با موفقیت انجام شد. لطفا به ایمیل خود مراجعه و روی لینک تایید کلیک نمایید"; //ایمیل فعالسازی را ارسال کنم Tbl_ConfirmEmail ce = new Tbl_ConfirmEmail(); ce.ConfirmEamil_Date = DateTime.Today; ce.ConfirmEamil_Status = false; ce.ConfirmEamil_Userid = db.Tbl_User.OrderByDescending(a => a.User_ID).FirstOrDefault().User_ID; db.Tbl_ConfirmEmail.Add(ce); db.SaveChanges(); Email email = new Email(); string email_User = db.Tbl_User.OrderByDescending(a => a.User_ID).FirstOrDefault().User_Email; email.SendEmail(db.Tbl_Setting.FirstOrDefault().Smtp, db.Tbl_Setting.FirstOrDefault().Email, db.Tbl_Setting.FirstOrDefault().Passsword, email_User, " فعالسازی اکانت کاربری در سایت " + db.Tbl_Setting.FirstOrDefault().Tilte + "", "کاربر گرامی : " + u.User_NameFamily + " <br /> برای فعالسازی اکانت کاربری خود درسایت " + db.Tbl_Setting.FirstOrDefault().Tilte + " روی لینک زیر کلیک نمایید. <br /> <a href='http://localhost:59195/Register/ConfirmEmails?Code=" + db.Tbl_ConfirmEmail.OrderByDescending(a => a.ConfirmEamil_ID).FirstOrDefault().ConfirmEamil_ID + "'> لینک فعالسازی شما </a>"); return(RedirectToAction("Massage")); } else { TempData["Message"] = "NotAdded"; return(RedirectToAction("Massage")); } } else { return(RedirectToAction("Profile", "Profile")); } }
public ActionResult ChangeSoftware_req() { HttpSessionStateBase session = HttpContext.Session; Tbl_User user = _userService.GetUserById(Convert.ToInt32(session["UserID"])); session.Add("Section_ID", user.Section_ID); return(View()); }
public ActionResult DeleteConfirmed(int id) { Tbl_User tbl_User = db.Tbl_User.Find(id); db.Tbl_User.Remove(tbl_User); db.SaveChanges(); return(RedirectToAction("Index")); }
public void Get() { this.Context.Response.ContentType = "text/plain"; if (string.IsNullOrEmpty(this.Context.Request.QueryString["username"])) { string imei = this.Context.Request.QueryString["imei"]; Msg msg = UserLoginModel.Login(imei); JavaScriptSerializer jss = new JavaScriptSerializer(); if (msg.Status) { Tbl_User oUser = msg.UserData as Tbl_User; LoginRet oLogin = new LoginRet(); oLogin.UserName = oUser.Name; oLogin.Indetify = oUser.Access; oLogin.Status = 1; this.Context.Response.Write(jss.Serialize(oLogin)); this.Context.Response.Write("#"); } else { Tbl_User oUser = msg.UserData as Tbl_User; LoginRet oLogin = new LoginRet(); oLogin.Status = 0; this.Context.Response.Write(jss.Serialize(oLogin)); this.Context.Response.Write("#"); } } else { string username = this.Context.Request.QueryString["username"]; string psd = this.Context.Request.QueryString["psd"]; string imei = this.Context.Request.QueryString["imei"]; Msg msg = UserLoginModel.Login(username, psd, imei); JavaScriptSerializer jss = new JavaScriptSerializer(); if (msg.Status) { Tbl_User oUser = msg.UserData as Tbl_User; LoginRet loginRet = new LoginRet(); loginRet.Indetify = oUser.Access; loginRet.UserName = oUser.Name; loginRet.Status = 1; this.Context.Response.Write(jss.Serialize(loginRet)); this.Context.Response.Write("#"); } else { LoginRet loginRet = new LoginRet(); loginRet.Message = msg.Message; loginRet.Status = 0; this.Context.Response.Write(jss.Serialize(loginRet)); this.Context.Response.Write("#"); } } }
public ActionResult Edit([Bind(Include = "UserID,Username,Password,Email,Type")] Tbl_User tbl_User) { if (ModelState.IsValid) { db.Entry(tbl_User).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tbl_User)); }
public ActionResult Register(RegisterModel model) { //if (Password != MatchPassword) //{ // return View(); //} if (!ModelState.IsValid) { ViewBag.State = "Error"; return(View("Register", model)); } Tbl_User ur = new Tbl_User(); ur.User_Name = model.Name; ur.User_Family = model.Family; ur.User_Email = model.Email; ur.User_Mobile = model.Mobile; ur.User_Date = DateTime.Now; ur.User_BranchID = model.Branch; ur.User_SABAlloow = false; db.Tbl_User.Add(ur); Tbl_Login login = new Tbl_Login(); string s = Session["User"].ToString(); login = db.Tbl_Login.Where(a => a.Login_UserName == s).SingleOrDefault(); login.Login_UserID = ur.User_ID; var Salt = Guid.NewGuid().ToString("N"); var SaltPassword = model.Password + Salt; var SaltPasswordBytes = Encoding.UTF8.GetBytes(SaltPassword); var SaltPasswordHush = Convert.ToBase64String(SHA512.Create().ComputeHash(SaltPasswordBytes)); login.Login_PasswordHush = SaltPasswordHush; login.Login_PasswordSalt = Salt; login.Login_RegisterActive = false; db.Entry(login).State = System.Data.Entity.EntityState.Modified; if (Convert.ToBoolean(db.SaveChanges() > 0)) { Session["Register"] = "Deactive"; return(RedirectToAction("Login", "Account")); } else { } return(View()); }
public ActionResult Create([Bind(Include = "UserID,Username,Password,Email,Type")] Tbl_User tbl_User) { if (ModelState.IsValid) { db.Tbl_User.Add(tbl_User); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tbl_User)); }
public virtual ActionResult SoftwareChangeList(DataSourceRequest command, ChangeSoftwareListModel model) { HttpSessionStateBase session = HttpContext.Session; Tbl_User user = _userService.GetUserById(Convert.ToInt32(session["UserID"])); if (model.Amount == 0 && string.IsNullOrEmpty(model.CustomerConnector) && model.Customer_ID == 0 && string.IsNullOrEmpty(model.RequestDate) && string.IsNullOrEmpty(model.DeliveryDate) && string.IsNullOrEmpty(model.Description) && string.IsNullOrEmpty(model.RequiredChanges)) { var SoftwareItems = _softwareService.GetAllSoftwareChange(); var gridModel = new DataSourceResult { Data = SoftwareItems.Select(x => new ChangeSoftwareModel { Amount = x.Amount, CustomerName = _customerService.GetCustomerById(x.Customer_ID).CustomerName, CustomerConnector = x.CustomerConnector, RequestDate = x.RequestDate, Description = x.Description, DeliveryDate = x.DeliveryDate, Customer_ID = x.Customer_ID, RowColor = user.Section_ID == 1 && string.IsNullOrEmpty(x.DeliveryDate) ? 1 : user.Section_ID == 3 && !string.IsNullOrEmpty(x.DeliveryDate) && x.Amount == 0 ? 1 : 0, Request_ID = x.Request_ID, RequiredChanges = x.RequiredChanges }), Total = SoftwareItems.Count() }; return(Json(gridModel)); } else { var SoftwareItems = _softwareService.SearchSoftwareChange(model.Amount, model.CustomerConnector, model.Customer_ID, model.RequestDate, model.DeliveryDate, model.Description, model.RequiredChanges); var gridModel = new DataSourceResult { Data = SoftwareItems.Select(x => new ChangeSoftwareModel { Amount = x.Amount, CustomerName = _customerService.GetCustomerById(x.Customer_ID).CustomerName, CustomerConnector = x.CustomerConnector, RequestDate = x.RequestDate, Description = x.Description, DeliveryDate = x.DeliveryDate, Customer_ID = x.Customer_ID, RowColor = user.Section_ID == 1 && string.IsNullOrEmpty(x.DeliveryDate) ? 1 : user.Section_ID == 3 && !string.IsNullOrEmpty(x.DeliveryDate) && x.Amount == 0 ? 1 : 0, Request_ID = x.Request_ID, RequiredChanges = x.RequiredChanges }), Total = SoftwareItems.Count() }; return(Json(gridModel)); } }
public bool AddNewUser(Tbl_User User, int departmentId, int activeId) { try { if (_context.Tbl_User.Any(x => x.User_ID == User.User_ID)) { // user already exists Tbl_User ToBeUpdatedUser = _context.Tbl_User.First(x => x.User_ID == User.User_ID); ToBeUpdatedUser.Name = User.Name; ToBeUpdatedUser.LastName = User.LastName; ToBeUpdatedUser.UserName = User.UserName; ToBeUpdatedUser.Password = User.Password; ToBeUpdatedUser.Section_ID = _context.Tbl_Section.First(u => u.Section_ID == departmentId).Section_ID; ToBeUpdatedUser.Active = activeId; ToBeUpdatedUser.PersonnelID = User.PersonnelID; ToBeUpdatedUser.LastUpdateUser_ID = User.LastUpdateUser_ID; ToBeUpdatedUser.LastUpdateTime = User.LastUpdateTime; ToBeUpdatedUser.LastUpdateDate = User.LastUpdateDate; } else { if (_context.Tbl_User.Any(x => x.UserName == User.UserName)) { return(false); } Tbl_User ToBeInsertedUser = new Tbl_User(); ToBeInsertedUser.Name = User.Name; ToBeInsertedUser.LastName = User.LastName; ToBeInsertedUser.UserName = User.UserName; ToBeInsertedUser.Password = User.Password; ToBeInsertedUser.Section_ID = _context.Tbl_Section.First(u => u.Section_ID == departmentId).Section_ID; ToBeInsertedUser.Active = activeId; ToBeInsertedUser.PersonnelID = User.PersonnelID; ToBeInsertedUser.LastUpdateUser_ID = User.LastUpdateUser_ID; ToBeInsertedUser.LastUpdateTime = User.LastUpdateTime; ToBeInsertedUser.LastUpdateDate = User.LastUpdateDate; _context.Tbl_User.Add(ToBeInsertedUser); } if (_context.SaveChanges() > 0) { return(true); } else { return(false); } } catch (Exception ex) { return(false); } }
// GET: User/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Tbl_User tbl_User = db.Tbl_User.Find(id); if (tbl_User == null) { return(HttpNotFound()); } return(View(tbl_User)); }
public ActionResult Home() { if (Session["UserId"] != null) { int UserId = Convert.ToInt32(Session["UserId"]); var DbUser = _context.Tbl_User.SingleOrDefault(u => u.Id == UserId); Tbl_User User = DbUser; return(View(User)); } else { return(RedirectToAction("Login", "Home")); } }
protected void addRows_Click(object sender, EventArgs e) { string sUserName = txbUsername.Text; string sPsd = txbPsd.Text; string sIdentify = txbIdentify.Text; Tbl_User oUser = new Tbl_User(); oUser.Name = sUserName; oUser.LoginPwd = sPsd; oUser.Access = int.Parse(sIdentify); lUsers.Add(oUser); GridView1.DataSource = BuildGridViewDataSource(lUsers); GridView1.DataBind(); }
public ActionResult Register(Tbl_User account) { if (ModelState.IsValid) { using (ctx) { ctx.Tbl_User.Add(account); ctx.SaveChanges(); } ModelState.Clear(); ViewBag.Message = account.UserName + " " + account.Email + " sucessfully registred"; return(RedirectToAction("login")); } return(View()); }
public static Boolean CheckUser(string username) { Boolean haveUser = false; Tbl_User userInfo = null; using (var en = new LingYunEntities()) { userInfo = en.Tbl_User.Where(a => a.Name == username).FirstOrDefault(); } if (userInfo != null) { haveUser = true; } return(haveUser); }