private void LoadData() { try { SqlConnection con = DataProvider.KetNoi(); DataTable dt = DataProvider.LayDataTable("users_list", con); List <User_DTO> dsUser = new List <User_DTO>(); if (dt.Rows.Count == 0) { return; } for (int i = 0; i < dt.Rows.Count; i++) { User_DTO us = new User_DTO(); us.ID = Convert.ToInt32(dt.Rows[i]["ID"].ToString()); us.UserName = dt.Rows[i]["UserName"].ToString(); us.ChucVu = dt.Rows[i]["ChucVu"].ToString(); us.DiaChi = dt.Rows[i]["DiaChi"].ToString(); us.SoDT = dt.Rows[i]["SoDT"].ToString(); dsUser.Add(us); } DataProvider.DongKetNoi(con); dtgvListUser.DataSource = dsUser; } catch (Exception ex) { XtraMessageBox.Show(ex.Message, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }
private void LoadData() { try { SqlConnection con = DataProvider.OpenConnection(); DataTable dt = DataProvider.GetDataTable("[JEWELRYSTOREMGMT].[dbo].[usp_getUserList]", con); List <User_DTO> dsUser = new List <User_DTO>(); if (dt.Rows.Count == 0) { return; } for (int i = 0; i < dt.Rows.Count; i++) { User_DTO us = new User_DTO(); us.UserID = Convert.ToInt32(dt.Rows[i]["UserID"].ToString()); us.UserName = dt.Rows[i]["UserName"].ToString(); us.Role = dt.Rows[i]["Role"].ToString(); us.PhoneNo = dt.Rows[i]["PhoneNo"].ToString(); us.Address = dt.Rows[i]["Address"].ToString(); dsUser.Add(us); } DataProvider.CloseConnection(con); dtgvListUser.DataSource = dsUser; } catch (Exception ex) { XtraMessageBox.Show(ex.Message, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }
public static List <DTO.User_DTO> GetAllUsers() { string stringquery = "select u.id_User, u.username, u.password, u.nameUser, u.id_Permission, p.name_Permission from USER_ACCOUNT AS u, PERMISSION as p where u.id_Permission = p.id_Permission"; con = DataProvider.OpenConnection(); DataTable dt = DataProvider.ExcuteQuery(stringquery, con); if (dt.Rows.Count == 0) { return(null); } List <User_DTO> listUsers = new List <User_DTO>(); for (int i = 0; i < dt.Rows.Count; i++) { User_DTO u = new User_DTO(); u.Id = int.Parse(dt.Rows[i]["id_User"].ToString()); u.Username = dt.Rows[i]["username"].ToString(); u.Password = dt.Rows[i]["password"].ToString(); u.NameUser = dt.Rows[i]["nameUser"].ToString(); u.Permission = int.Parse(dt.Rows[i]["id_Permission"].ToString()); u.NamePermission = dt.Rows[i]["name_Permission"].ToString(); listUsers.Add(u); } return(listUsers); }
public static List <DTO.User_DTO> GetUser(string userName, string passWord) { string stringquery = "SELECT * FROM USER_ACCOUNT WHERE username = '******' AND password = '******' "; con = DataProvider.OpenConnection(); DataTable dt = DataProvider.ExcuteQuery(stringquery, con); if (dt.Rows.Count == 0) { return(null); } List <User_DTO> User = new List <User_DTO>(); for (int i = 0; i < dt.Rows.Count; i++) { User_DTO u = new User_DTO(); u.Id = int.Parse(dt.Rows[i]["id_User"].ToString()); u.Username = dt.Rows[i]["username"].ToString(); u.Password = dt.Rows[i]["password"].ToString(); u.NameUser = dt.Rows[i]["nameUser"].ToString(); u.Permission = int.Parse(dt.Rows[i]["id_Permission"].ToString()); User.Add(u); } return(User); }
private void loadEntity() { Employee_BAL objImpl = new Employee_BAL(); Employee_DTO objInfo = objImpl.GetObject(EmployeeID); if (objInfo == null) { return; } txtFullName.Text = objInfo.FullName; txtDateOfBirth.Text = objInfo.DateOfBirth.ToString("dd/MM/yyyy"); if (objInfo.Gender == true) { rbtFeMale.Checked = true; } else { rbtMale.Checked = true; } ddlSubject.SelectedValue = objInfo.SubjectID.ToString(); ddlPosition.SelectedValue = objInfo.PositionID.ToString(); txtAcademicRank.Text = objInfo.AcademicRank; txtBachelorDegree.Text = objInfo.BachelorDegree; txtEmail.Text = objInfo.Email; txtPhone.Text = objInfo.Phone; txtAddress.Text = objInfo.Address; hddImagePath.Value = "/assets/global/employee/" + objInfo.ImagePath; hddFileImage.Value = objInfo.ImagePath; User_BAL objUser_BAL = new User_BAL(); User_DTO objUser_DTO = objUser_BAL.GetObject(EmployeeID); txtUsername.Text = objUser_DTO.UserName; ddlRole.SelectedValue = objUser_DTO.Role.ToString(); }
public static bool SuaUser(User_DTO userDTO) { string sChuoiTruyVan = "EXEC dbo.UpdateProfile @fullName , @address , @birthDay , @avatar , @nickname , @username , @sex"; bool ketQua = DataProvider.Instance.SelectExecuteNonQuery(sChuoiTruyVan, new object[] { userDTO.fullName, userDTO.address, userDTO.birthDay, userDTO.avatar, userDTO.nickName, userDTO.userName, userDTO.sex }); return(ketQua); }
//POST : /api/ApplicationUser/Register public async Task <IActionResult> Register([FromBody] User_DTO model) { if (!ModelState.IsValid) { return(BadRequest()); } try { var user = new IdentityUser { UserName = model.Email, Email = model.Email }; var result = await _userManager.CreateAsync(user, model.Password); if (result.Succeeded) { return(Created("User created", result)); } if (_userManager.FindByEmailAsync(model.Email) != null) { return(BadRequest("User already exists!")); } return(BadRequest()); } catch (Exception ex) { throw ex; } }
public bool editQuyen(User_DTO user) { string[] param = { "@manv", "@id", "@matkhau" }; object[] values = { user.Manv, user.Id, user.Mk }; string query = "Update quyennv Set manv=@manv, id=@id, matkhau=@matkhau where manv=@manv"; return(db.ExecuteNonQueryPara(query, param, values)); }
public bool deleteQuyen(User_DTO user) { string[] param = { "@manv", "@id", "@matkhau" }; object[] values = { user.Manv, user.Id, user.Mk }; string query = "Delete quyennv Where manv= @manv"; return(db.ExecuteNonQueryPara(query, param, values)); }
public void setUp() { user11 = new User_DTO("NV001", "123"); user12 = new User_DTO("NV001", "1234"); user21 = new User_DTO("NV002", "123"); user22 = new User_DTO("NV002", "1234"); user31 = new User_DTO("KH001", "5678"); user32 = new User_DTO("", ""); }
private User_DTO getDataQuyen() { User_DTO user = new User_DTO(); user.Manv = cbMaNV.SelectedValue.ToString(); user.Id = id; user.Mk = txtMatKhau.Text; return(user); }
public static bool DeleteUser(User_DTO u) { string query = string.Format(@"delete from USER_ACCOUNT where id_User= " + u.Id); con = DataProvider.OpenConnection(); bool kq = DataProvider.ExcuteNonQuery(query, con); //DataProvider.DongKetNoi(con); return(kq); }
public static bool AddUser(User_DTO u) { string query = string.Format(@"insert into USER_ACCOUNT values(N'{0}',N'{1}',N'{2}',N'{3}')", u.Username, "202cb962ac59075b964b07152d234b70", u.NameUser, u.Permission); con = DataProvider.OpenConnection(); bool kq = DataProvider.ExcuteNonQuery(query, con); //DataProvider.DongKetNoi(con); return(kq); }
public bool addQuyen(User_DTO user) { try { string[] param = { "@manv", "@id", "@matkhau" }; object[] values = { user.Manv, user.Id, user.Mk }; string query = "Insert Into quyennv Values(@manv,@id,@matkhau)"; return(db.ExecuteNonQueryPara(query, param, values)); } catch (Exception) { return(false); } }
public static User_DTO getUser_DTO(DAL.User user) { User_DTO newUserDTO = new User_DTO(); newUserDTO.id = user.id; newUserDTO.mail = user.mail; newUserDTO.password = user.password; newUserDTO.overide = user.overide; newUserDTO.attachment = user.attachment; List <string> newConcatList = new List <string>(); newConcatList.AddRange(db.Contacts.Where(i => i.userId == user.id).Select(i => i.mailContact)); newUserDTO.contact_list = newConcatList; return(newUserDTO); }
public List <User_DTO> GetAllUsers() { List <User> userDALList = DAL.GetAllUsers(); List <User_DTO> userApiList = new List <User_DTO>(); foreach (var item in userDALList) { User_DTO userapi = new User_DTO(); userapi.Id = item.Id; userapi.UserName = item.UserName; userapi.Password = item.Password; userApiList.Add(userapi); } return(userApiList); }
private void btnEdit_Click(object sender, EventArgs e) { string id = idUser.Text; string fname = fName.Text; string lname = lName.Text; string sexUser = sex.Text; string birth = birthday.Text; string pnumber = pNumber.Text; string inumber = iNumber.Text; string emailUser = email.Text; User_DTO user = new User_DTO(id, fname, lname, sexUser, birth, pnumber, inumber, emailUser); User_BUS.EditUser(user); this.Close(); }
//Add a user public static void AddUser(User_DTO user) { SqlConnection connecter = sqlConnectionData.Connecter(); SqlCommand commander = new SqlCommand("AddUser", connecter); commander.CommandType = CommandType.StoredProcedure; commander.Parameters.Add("@id", SqlDbType.Char, 10).Value = user.IdUser; commander.Parameters.Add("@firstName", SqlDbType.NVarChar, 100).Value = user.FirstName; commander.Parameters.Add("@lastName", SqlDbType.NVarChar, 100).Value = user.LastName; commander.Parameters.Add("@sex", SqlDbType.NVarChar, 6).Value = user.Sex; commander.Parameters.Add("@birthday", SqlDbType.Date).Value = user.Birthday; commander.Parameters.Add("@phoneNumber", SqlDbType.Char, 20).Value = user.PhoneNumber; commander.Parameters.Add("@identityNumber", SqlDbType.Char, 20).Value = user.IdentityNumber; commander.Parameters.Add("@email", SqlDbType.NVarChar, 100).Value = user.Email; connecter.Open(); commander.ExecuteNonQuery(); connecter.Close(); }
public string Render(User_DTO user) { var _output = new StringBuilder(); if (user != null) { var posts = user.Posts.ToList(); posts.Reverse(); foreach (var _item in posts) { _output.Append(_item.Detail + PresenterService.GetElapsedTime(_item.CreatedDateStamp)); _output.AppendLine(); } } // DEFAULT RETURN: return(_output.ToString()); }
public static DAL.User getUser_Dal(User_DTO user) { DAL.User newUserDAL = new DAL.User(); newUserDAL.id = user.id; newUserDAL.mail = user.mail; newUserDAL.password = user.password; newUserDAL.overide = user.overide; newUserDAL.attachment = user.attachment; if (user.contact_list != null) { foreach (var item in user.contact_list) { DAL.Contact c = new DAL.Contact(); c.userId = user.id; c.mailContact = item; db.Contacts.Add(c); } } return(newUserDAL); }
private void btnCapNhat_Click(object sender, EventArgs e) { //string sql = "Insert Into quyennv Values('"+cbMaNV.SelectedValue.ToString()+"','"+id+"','"+txtMatKhau.Text+"')"; //string sql2 = "Update quyennv set id='" + id + "',matkhau='" + txtMatKhau.Text + "' where manv = '" + cbMaNV.SelectedValue.ToString() + "'"; if (txtMatKhau.Text.Length == 3) { thongbao.Text = ""; if (!db.checkExist("quyennv", "manv", cbMaNV.SelectedValue.ToString())) { User_DTO user = getDataQuyen(); if (userBLL.addQuyen(user)) { rdbQuanTri.Checked = false; rdbNhanVien.Checked = false; rdbKhachHang.Checked = false; txtMatKhau.Text = ""; panelpq.Enabled = false; thongbao.Text = ""; MessageBox.Show("Cập nhật thành công!"); } } else { User_DTO user = getDataQuyen(); if (userBLL.editQuyen(user)) { rdbQuanTri.Checked = false; rdbNhanVien.Checked = false; rdbKhachHang.Checked = false; txtMatKhau.Text = ""; panelpq.Enabled = false; thongbao.Text = ""; MessageBox.Show("Cập nhật thành công!"); } } } else { thongbao.Text = "Mật khẩu gồm 3 ký tự!"; } }
private async void btn_block_Click(object sender, RoutedEventArgs e) { progress_bar.Visibility = Visibility.Visible; Button button = sender as Button; User_DTO user = button.DataContext as User_DTO; AccountBlock temp = new AccountBlock(); temp.account_id = user.account_id; bool result = false; if (user.is_block) { result = await RestAPI.PostBlock(temp, "unlock"); } else { result = await RestAPI.PostBlock(temp, "lock"); } if (send != null) { send.Invoke(); } progress_bar.Visibility = Visibility.Collapsed; if (result) { MessageBox.Show("Successful"); } else { MessageBox.Show("Fail"); } }
private void btnSave_Click(object sender, EventArgs e) { string sql = @"Exec TruyVanProfile @username"; DataTable dt = DataProvider.Instance.ExecuteQuery(sql, new object[] { userName }); User_DTO user = CheckControl(); //Bước 3: Insert vào bảng NHÂN VIÊN if (user != null) { if (user.avatar == null) { user.avatar = (byte[])dt.Rows[0]["Avatar"]; } if (User_BUL.UpdateUser(user) == true) //Nó đã thực thi làm thay đổi CSDL { MessageBox.Show("Cập nhật thành công!", "Thông báo"); LoadDetails(); } else { MessageBox.Show("Cập nhật không thành công!", "Thông báo"); } } //else //{ // if (User_BUL.ThemUser(user) == true) //Nó đã thực thi làm thay đổi CSDL // { // // LoadDataGridView(); // MessageBox.Show("Cập nhật thành công!", "Thông báo"); // //Reset(); // } // else // { // MessageBox.Show("Cập nhật không thành công!", "Thông báo"); // } //} }
private async void btn_delete_Click(object sender, RoutedEventArgs e) { progress_bar.Visibility = Visibility.Visible; Button button = sender as Button; User_DTO user = button.DataContext as User_DTO; bool result = await RestAPI.PostDeleteAccount(user.account_id.ToString()); if (send != null) { send.Invoke(); } progress_bar.Visibility = Visibility.Collapsed; if (result) { MessageBox.Show("Delete Successful"); } else { MessageBox.Show("Delete Fail"); } }
protected void btnSave_Click(object sender, EventArgs e) { Employee_DTO objInfo = new Employee_DTO(); objInfo.FullName = txtFullName.Text; if (String.IsNullOrEmpty(txtDateOfBirth.Text) == false) { objInfo.DateOfBirth = DateTime.ParseExact(txtDateOfBirth.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture); } objInfo.Gender = rbtFeMale.Checked == true ? true : false; objInfo.SubjectID = int.Parse(ddlSubject.SelectedValue.ToString()); objInfo.PositionID = int.Parse(ddlPosition.SelectedValue.ToString()); objInfo.AcademicRank = txtAcademicRank.Text; objInfo.BachelorDegree = txtBachelorDegree.Text; objInfo.Email = txtEmail.Text; objInfo.Address = txtAddress.Text; objInfo.Phone = txtPhone.Text; objInfo.EmployeeID = EmployeeID; //user User_DTO objUserInfo = new User_DTO(); objUserInfo.UserID = EmployeeID; objUserInfo.UserName = txtUsername.Text; objUserInfo.Role = int.Parse(ddlRole.SelectedValue); Employee_BAL objImpl = new Employee_BAL(); User_BAL objUserImpl = new User_BAL(); var data_path = "/assets/global/employee/"; if (objUserImpl.IsExists(objUserInfo.UserID, objUserInfo.UserName) == true) { litError.Text = "<div class='alert alert-danger'><button class='close' data-close='alert'></button><span>Tài khoản này đã tồn tại!</span></div>"; return; } else { litError.Text = ""; } if (objInfo.EmployeeID > 0) { if (fuImagePath.PostedFile != null && fuImagePath.FileName.Length > 0) { if (!Directory.Exists(Server.MapPath(data_path))) { Directory.CreateDirectory(Server.MapPath(data_path)); } string fileNameImage = Guid.NewGuid().ToString() + Path.GetExtension(fuImagePath.PostedFile.FileName.ToLower()); this.fuImagePath.PostedFile.SaveAs(Server.MapPath(data_path + fileNameImage)); objInfo.ImagePath = fileNameImage; if (!string.IsNullOrEmpty(this.hddFileImage.Value)) { string PathFile = Server.MapPath(data_path + hddFileImage.Value); if (File.Exists(PathFile)) { File.Delete(PathFile); } } } else { if (!string.IsNullOrEmpty(this.hddFileImage.Value)) { if (this.hddRemoveImage.Value == "1") { string PathFile = Server.MapPath(data_path + this.hddFileImage.Value); if (File.Exists(PathFile)) { File.Delete(PathFile); } objInfo.ImagePath = ""; } else { objInfo.ImagePath = hddFileImage.Value; } } } objImpl.Update(objInfo); objUserImpl.Update(objUserInfo); } else { if (fuImagePath.PostedFile != null && fuImagePath.FileName.Length > 0) { if (!Directory.Exists(Server.MapPath(data_path))) { Directory.CreateDirectory(Server.MapPath(data_path)); } string fileNameImage = Guid.NewGuid().ToString() + Path.GetExtension(fuImagePath.PostedFile.FileName.ToLower()); fuImagePath.PostedFile.SaveAs(Server.MapPath(data_path + fileNameImage)); objInfo.ImagePath = fileNameImage; } EmployeeID = objImpl.Insert(objInfo); objUserInfo.UserID = EmployeeID; objUserInfo.Password = StringHelper.MD5("123456"); objUserInfo.IsLock = false; objUserImpl.Insert(objUserInfo); } Response.Redirect("~/employee/listemployee"); }
//Add a user public static void AddUser(User_DTO user) { User_DAO.AddUser(user); }
//Edit info user public static void EditUser(User_DTO user) { User_DAO.EditUser(user); }
public int Insert(User_DTO obj) { return(objUser_DAL.Insert(obj)); }
public int Update(User_DTO obj) { return(objUser_DAL.Update(obj)); }
// PUBLIC METHODS: public void Add(User_DTO user) { _context.Users.Add(_mapper.Map <User>(user)); }