public List <DTO_Transaction> GetTransactions(DTO_User user) { List <DTO_Transaction> transactions = new List <DTO_Transaction>(); using (DB_111206_scrapEntities db = new DB_111206_scrapEntities()) { var match = db.Users.Where(u => u.email == user.Email && u.pwd == user.Password).FirstOrDefault(); if (match != null) { var all_trans = match.Transactions.ToList(); { foreach (var t in all_trans) { DTO_Transaction tran = new DTO_Transaction(); tran.Id = t.tranId; tran.Price = (double)t.salePrice; tran.DT = t.tranDate; transactions.Add(tran); } } } } return(transactions); }
public List <DTO_User> RegisterUser(DTO_User u) { //DB Connection DB_111206_scrapEntities db = new DB_111206_scrapEntities(); List <DTO_User> tempList = new List <DTO_User>(); tempList.Add(u); var temp = new Scrap_DAL.User { //no userid because system creates it email = u.Email, fName = u.FirstName, lName = u.LastName, phone = u.Phone, pwd = u.Password, }; db.Users.Add(temp); var loginItem = new Scrap_DAL.UserLogin { userID = temp.userID, lat = Convert.ToSingle(temp.lat), lon = Convert.ToSingle(temp.lon), logInDateTime = DateTime.Now }; db.UserLogins.Add(loginItem); db.SaveChanges(); return(tempList); }
public async Task <IActionResult> EditUserAsync([FromBody] DTO_User userDto) { try { var userByUserName = await _userService.GetUserByUserNameAsync(userDto.UserName); if (userByUserName != null) { if (userByUserName.UserId != userDto.UserID) { return(Conflict("The entered user name already exist.")); } } var userToUpdate = _mapper.Map <DTO_User, User>(userDto); var userUpdated = await _userService.Update(userToUpdate); var response = _mapper.Map <User, DTO_User>(userUpdated); return(Ok(response)); } catch (Exception exception) { throw exception; } }
public List <DTO_User> LoginUser(DTO_Login login) { DTO_User user = new DTO_User(); List <DTO_User> users = new List <DTO_User>(); using (DB_111206_scrapEntities db = new DB_111206_scrapEntities()) { var match = db.Users.Where(u => u.email == login.Email && u.pwd == login.Password).FirstOrDefault(); if (match != null) { user.id = match.userID; user.LastName = match.lName; user.FirstName = match.fName; user.Email = match.email; user.Password = match.pwd; user.Phone = match.phone; users.Add(user); UserLogin userlogin = new UserLogin(); userlogin.userID = user.id; userlogin.lat = login.Latutude; userlogin.lon = login.Longitude; userlogin.logInDateTime = DateTime.Now; db.UserLogins.Add(userlogin); db.SaveChanges(); // email("New user login", "Hello, World!"); } } return(users); }
private void button1_Click(object sender, EventArgs e) { if (txtInputID.Text.Trim() == "" || txtInputPwd.Text.Trim() == "") { MessageBox.Show("Thêm không thành công", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); txtInputID.Text = ""; txtInputPwd.Text = ""; return; } string inputID = txtInputID.Text.Trim().ToUpper(); string inputPwd = txtInputPwd.Text.Trim().ToUpper(); user = BUS_User.getUser(inputID, inputPwd); if (user == null) { MessageBox.Show("Đăng nhập không thành công, sai thông tin", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); txtInputID.Text = ""; txtInputPwd.Text = ""; } else { this.DialogResult = DialogResult.OK; this.Close(); } }
public bool Kiemtrauser(DTO_User user) // nhan DTO user tu BUS va tra ket qua dung sai ve lai BUS { try { OpenConection(); // open connection SqlCommand command = new SqlCommand(); command.Parameters.Add(new SqlParameter("@User", user.User)); //them parameter vao command.parameter command.Parameters.Add(new SqlParameter("@Password", user.Password)); command.Parameters.Add(new SqlParameter("@ChucVu", "0")); SqlDataReader dta = DataReaderStoredProcedure(command, "SelectTaiKhoan"); //su dung command.parameter va ExecuteReader de tra ve gia tri DateReader if (dta.Read()) // neu co gia tri tra ve { return(true); } else { return(false); } } catch { return(false); } finally { CloseConnection(); // close connection } }
public static DTO_User SearchUser(string userName) { CreateXML(); XmlDocument xd = new XmlDocument(); FileStream rfile = new FileStream(userXmlFilePath, FileMode.Open); xd.Load(rfile); DTO_User user = new DTO_User(); XmlNodeList list = xd.GetElementsByTagName("User"); for (int i = 0; i < list.Count; i++) { XmlElement userNode = (XmlElement)xd.GetElementsByTagName("User")[i]; XmlElement passwordNode = (XmlElement)xd.GetElementsByTagName("Password")[i]; XmlElement emailNode = (XmlElement)xd.GetElementsByTagName("Email")[i]; if (userNode.GetAttribute("Username") == userName) { user.Username = userName; user.Password = passwordNode.InnerText; user.Email = emailNode.InnerText; rfile.Close(); return(user); } } rfile.Close(); return(null); }
public static void InsertUser(DTO_User user) { CreateXML(); XmlDocument xd = new XmlDocument(); FileStream lfile = new FileStream(userXmlFilePath, FileMode.Open); xd.Load(lfile); XmlElement userNode = xd.CreateElement("User"); userNode.SetAttribute("Username", user.Username); XmlElement passwordNode = xd.CreateElement("Password"); XmlText pwText = xd.CreateTextNode(user.Password); XmlElement emailNode = xd.CreateElement("Email"); XmlText eText = xd.CreateTextNode(user.Email); passwordNode.AppendChild(pwText); emailNode.AppendChild(eText); userNode.AppendChild(passwordNode); userNode.AppendChild(emailNode); xd.DocumentElement.AppendChild(userNode); lfile.Close(); xd.Save(userXmlFilePath); }
public bool Insert(DTO_User usr) { try { conn.Open(); SqlCommand cmd = new SqlCommand("INSERT INTO [USER] VALUES(@Id, @Name, @Type, @Username, @Password, @DateStart, @Address)", conn); cmd.Parameters.AddWithValue("@Id", usr.Id); cmd.Parameters.AddWithValue("@Name", usr.Name); cmd.Parameters.AddWithValue("@Type", usr.Type); cmd.Parameters.AddWithValue("@Username", usr.Username); cmd.Parameters.AddWithValue("@Password", usr.Password); cmd.Parameters.AddWithValue("@DateStart", usr.DateStart); cmd.Parameters.AddWithValue("@Address", usr.Address); if (cmd.ExecuteNonQuery() > 0) { return(true); } } catch (Exception e) { } finally { conn.Close(); } return(false); }
public async Task <DTO_User> WS_RegisterUser(DTO_User user) { DTO_User temp = new DTO_User(); try { HttpResponseMessage response = await client.PostAsJsonAsync(string.Format(@"{0}{1}", URL, "AddUser"), user); response.EnsureSuccessStatusCode(); var json = await response.Content.ReadAsStringAsync(); var des = (Wrapper <DTO_User>)Newtonsoft.Json.JsonConvert.DeserializeObject(json, typeof(Wrapper <DTO_User>)); var userList = des.Data.ToList(); if (userList.Count == 1) { temp = userList.FirstOrDefault(); } else { temp = null; } } catch (Newtonsoft.Json.JsonSerializationException hre) { Debug.WriteLine(hre.Message); } return(temp); }
public DTO_User VerifyUserLogin(DTO_Login uL) { //DB Connection DB_111206_scrapEntities db = new DB_111206_scrapEntities(); //get table contents var listUsers = db.Users.ToList(); var tempUser = listUsers.Where(x => x.email == uL.Email && x.pwd == uL.Password).FirstOrDefault(); //create list to return with sql objects DTO_User user = new DTO_User(); if (tempUser != null) { DTO_User verifiedUser = new DTO_User { id = tempUser.userID, FirstName = tempUser.fName, LastName = tempUser.lName, Phone = tempUser.phone, Password = tempUser.pwd }; //Add user to list for returning user = verifiedUser; //create odbject for UserLogins var loginItem = new Scrap_DAL.UserLogin { userID = tempUser.userID, lat = Convert.ToDouble(tempUser.lat), lon = Convert.ToDouble(tempUser.lon), logInDateTime = DateTime.Now }; db.UserLogins.Add(loginItem); db.SaveChanges(); } return(user); }
public List <DTO_User> AddUser(DTO_User user) { List <DTO_User> users = new List <DTO_User>(); using (DB_122744_doodleEntities db = new DB_122744_doodleEntities()) { var sqllist = db.users.Where(c => c.Email == user.EmailAddress).ToList(); if (sqllist.Count == 0) { user sqlobj = new user(); sqlobj.UserID = user.ID; sqlobj.DisplayName = user.DisplayName; sqlobj.Email = user.EmailAddress; sqlobj.Password = user.Password; sqlobj.Picture = user.Picture; sqlobj.Active = true; db.users.Add(sqlobj); users.Add(user); db.SaveChanges(); } else { users.Clear(); } return(users); } }
public bool CreateTaiKhoan(DTO_User dtoUser) { try { OpenConection(); SqlCommand command = new SqlCommand(); command.Parameters.Add(new SqlParameter("@ID", generateID())); command.Parameters.Add(new SqlParameter("@User", dtoUser.User)); command.Parameters.Add(new SqlParameter("@Password", dtoUser.Password)); command.Parameters.Add(new SqlParameter("@HoTen", dtoUser.HoTen)); command.Parameters.Add(new SqlParameter("@CMND", dtoUser.CMND)); command.Parameters.Add(new SqlParameter("@NgaySinh", dtoUser.NgaySinh)); command.Parameters.Add(new SqlParameter("@DiaChi", dtoUser.DiaChi)); ExecuteQueriesStoredProcedure(command, "CreateTaiKhoan"); return(true); } catch { return(false); } finally { CloseConnection(); } }
public void Them() { if (cbnhanvien.SelectedIndex < 0) { ToastNotification.Show(this, "Chưa chọn giáo viên", null, 2000, (eToastGlowColor)eToastGlowColor.Blue, (eToastPosition)eToastPosition.BottomCenter); return; } if (txttendn.Text == "" && txtmk.Text == "") { ToastNotification.Show(this, "Vui lòng điền đủ thông tin!", null, 2000, (eToastGlowColor)eToastGlowColor.Blue, (eToastPosition)eToastPosition.BottomCenter); return; } DataTable numberr; dtuer = new DTO_User() { Pass = txtmk.Text, User = txttendn.Text }; numberr = _db.Them(ref err, dtuer, Convert.ToInt32(cbnhanvien.SelectedValue)); if (numberr.Rows.Count > 0) { ToastNotification.Show(this, numberr.Rows[0]["ErrMsg"].ToString(), null, 2000, (eToastGlowColor)eToastGlowColor.Blue, (eToastPosition)eToastPosition.BottomCenter); } }
public bool addUser(DTO_User user) { if (user.UserType != "ADMIN" && user.UserType != "OP") { return(false); } try { conn.Open(); string sqlStr = string.Format(@"INSERT INTO [dbo].[OPERATOR_ID] ([ID],[PWD],[USER_TYPE]) VALUES('{0}','{1}','{2}')", user.ID, user.Password, user.UserType); SqlCommand cmd = new SqlCommand(sqlStr, conn); if (cmd.ExecuteNonQuery() > 0) { return(true); } else { return(false); } } catch { } finally { conn.Close(); } return(false); }
public string LoadTaiKhoan([FromBody] DTO_User dtoUser) { string JSONresult; DataTable dt = busTaiKhoan.LoadTaiKhoan(dtoUser); JSONresult = JsonConvert.SerializeObject(dt); return(JSONresult); }
public User(DTO_User user) { UserID = user.UserID; EmployeeID = user.EmployeeID; Username = user.Username; Pass = user.Pass; PermissionID = user.PermissionID; Active = user.Active; }
public async Task <string> CreateAsync(DTO_User user) { user.Password = PasswordService.Hash(user.Password); await Database.Users.Add(Mapper.Map <DTO_User, DAL.DataBase.Models.User>(user)); Database.Save(); return("Success"); }
public DTO_User GetUser(int id) { User u = uc.GetUserById(id); TimeStamp t = dbTools.GetTimeStamp(u.Timestamp); DTO_User user = new DTO_User() { user = u, timestamp = t }; return(user); }
public void ShowInfo(int cmnd) { panelInfo.Visible = true; panelChangePass.Visible = false; DTO_User u = BUS_User.GetUser(cmnd); lbCMND.Text = u.CMND.ToString(); lbHoTen.Text = u.HoTen; lbdiachi.Text = u.DiaChi; lbPhone.Text = u.SDT; }
/// <summary> /// 登录 /// </summary> private async void Login() { Loading.Visibility = Visibility.Visible; DTO_User du = new DTO_User(); //获取帐号 du._Number = username.Text; //获取登录密码 du._Pass = password.Password; if (!string.IsNullOrEmpty(du._Number) && !string.IsNullOrEmpty(du._Pass)) { //获取本机ip du._IP = Dns.GetHostAddresses(Dns.GetHostName()).GetValue(1).ToString(); //尝试登陆 try { //传递客户端实现服务器接口消息 InstanceContext ic = new InstanceContext(new ISC_Implement(this)); //建立通讯 AL_ServiceClient alsc = new AL_ServiceClient(ic); //请求服务器,验证登录信息 DTO_Login dl = await alsc.LoginAsync(du); //判断是否登录成功 if (dl.IsLogin) { //创建登录成功窗体对象 m = new Main(this, dl, alsc); //显示 m.Show(); } else { //new MyMessageBox("系统提示", dl.LoginMess).Show(); MessageBox.Show(dl.LoginMess); } } catch (Exception) { } } else { //new MyMessageBox("系统提示", "用户名和密码不能为空").Show(); MessageBox.Show("用户名和密码不能为空"); } Loading.Visibility = System.Windows.Visibility.Collapsed; }
public static void InsertUpdate(DTO_User a) { User u = new User(); u.CMND = a.CMND; u.DiaChi = a.DiaChi; u.SDT = a.SDT; u.NgaySinh = a.NgaySinh; u.HoTen = a.HoTen; u.GioiTinh = a.Sex; u.InsertUpdate(); }
private void btnAccept_Click(object sender, EventArgs e) { bool check = true; try { if (txtCMND.Text.Length != 9) { check = false; Alert("Chứng minh không hợp lệ", frmAlert.Type.Info); } if ((cmnd == 0) && (BUS_User.GetAllUser().Find(p => p.CMND == Int32.Parse(txtCMND.Text)) != null)) { check = false; Alert("Đã tồn tại người này trong CSDL", frmAlert.Type.Info); } if (txtPhone.Text.Length != 10) { check = false; Alert("Số di dộng không hợp lệ! ", frmAlert.Type.Info); } if (checkNam.Checked == false && checkNu.Checked == false) { check = false; Alert("Chưa chọn giới tính", frmAlert.Type.Info); } if (check) { DTO_User u = new DTO_User( Int32.Parse(txtCMND.Text), txtHoTen.Text, ngaysinhpicker.Value, checkNam.Checked ? true : false, txtPhone.Text, txtDiaChi.Text); if (cmnd == 0) { BUS_User.InsertUpdate(u); Alert("Đã thêm thành công", frmAlert.Type.Success); } else { BUS_User.InsertUpdate(u); Alert("Đã sửa thành công ^^", frmAlert.Type.Success); } } } catch (Exception) { Alert("Đã xảy ra lỗi", frmAlert.Type.Error); } }
public static DTO_User GetUser(int cmnd) { User a = User.GetUser(cmnd); DTO_User b = new DTO_User(); b.SDT = a.SDT; b.NgaySinh = a.NgaySinh; b.DiaChi = a.DiaChi; b.HoTen = a.HoTen; b.Sex = a.GioiTinh; b.CMND = a.CMND; return(b); }
// POST: api/Login public bool Post([FromBody] DTO_User dtoUser) { bool checkuser = busLogin.KiemTraUser(dtoUser); // truyen DTO user qua BUS de xu ly thong tin if (checkuser == true) // neu Bus login tra ve dung { return(true); // true. neu co user } else { return(false); // false. neu k co user } }
public IHttpActionResult GetUser(int id) { User user = db.Users.Find(id); if (user == null) { return(NotFound()); } DTO_User duser = new DTO_User(); user.ConvertToDTO(duser); return(Ok(duser)); }
public bool LuuTaiKhoan([FromBody] DTO_User dtoUser) { bool luu; luu = busTaiKhoan.LuuTaiKhoan(dtoUser); if (luu) { return(true); } else { return(false); } }
public bool createTaiKhoan([FromBody] DTO_User dtoUser) { bool create; create = busTaoTaiKhoan.TaoTaiKhoan(dtoUser); if (create) { return(true); } else { return(false); } }
private async void BTN_LoginLogin_Click(object sender, RoutedEventArgs e) { if (TBox_LoginEmail.Text != "" && TBox_LoginPassword.Text != "") { //Validate that it's actually an email address DTO_Login login = new DTO_Login(); login.Email = TBox_LoginEmail.Text; login.Password = TBox_LoginPassword.Text; //Figure out how to pull real location login.Latitude = 200; login.Longitude = 200; DTO_User user = new DTO_User(); var temp = await WS_Login(login); user = temp; if (user != null) { S_User.Instance.userID = user.ID; S_User.Instance.displayName = user.DisplayName; S_User.Instance.emailAddress = user.EmailAddress; S_User.Instance.picture = user.Picture; await WS_GetGameStatuses(); await WS_GetDrawCategories(); DrawPage_Home(); } else { DrawPage_Login(); output.Text = "Invalid Login"; } } else { DrawPage_Login(); if (TBox_LoginEmail.Text == "") { TBox_LoginEmail.Text = "Required"; } if (TBox_LoginPassword.Text == "") { TBox_LoginPassword.Text = "Required"; } output.Text = "Invalid Login"; } }
async private void AuthorizeLogin(DTO_User user) { DrawMe dm = new DrawMe(); dm.Show(); bool b = false; while (!b) { Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait; b = await BuildLookupLists(); Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait; await s1.Login(user); getCurrentLogInUser(); Mouse.OverrideCursor = Cursors.Arrow; } int j = 3; NexusHome Page = new NexusHome(); StringBuilder s = new StringBuilder(); s.Append("The username and password combination is not what is on file. / n / r You have failed to login "); s.Append(i.ToString() + " of " + j.ToString() + " times. /r/n If you fail " + (j - i).ToString() + " more time"); if (j - i > 1) { s.Append("'s"); } s.Append(" your account will be locked until administration restores your credentials."); if (s1.LoggedInEmployee != null) { this.NavigationService.Navigate(Page); } else { MessageBox.Show(s.ToString(), "Login Failure", MessageBoxButton.OK, MessageBoxImage.Error); } LoginBtn.IsEnabled = true; }