protected void GvUser_RowCommand(object sender, GridViewCommandEventArgs e) { int index = Convert.ToInt32(e.CommandArgument); GridViewRow gvrow = GvUser.Rows[index]; if (e.CommandName.Equals("editRecord")) { hfPopupUpdate.Value = GvUser.DataKeys[index].Value.ToString(); DataTable dt = new DataTable(); dt = Users.GetUserID(int.Parse(hfPopupUpdate.Value)).Tables[0]; DataTable dtNhomquyen = Roles_User.GetComboxGroup(int.Parse(hfPopupUpdate.Value)).Tables[0]; txtTendangnhap.Text = dt.Rows[0]["TenDangNhap"].ToString(); txtMatKhau.Text = dt.Rows[0]["MatKhau"].ToString(); cboNhomquyen.SelectedIndex = cboNhomquyen.Items.IndexOf(cboNhomquyen.Items.FindByValue(dtNhomquyen.Rows[0]["NhomID"].ToString())); cboDoanhNghiep.SelectedIndex = cboDoanhNghiep.Items.IndexOf(cboDoanhNghiep.Items.FindByValue(dt.Rows[0]["DoanhNghiepID"].ToString())); mpeUpdate.Show(); } else if (e.CommandName.Equals("deleteRecord")) { hfPopupDelete.Value = GvUser.DataKeys[index].Value.ToString(); lbxacnhanxoa.Text = "Đồng ý xóa <b>" + HttpUtility.HtmlDecode(gvrow.Cells[1].Text).ToString() + "</b>"; mpeDelete.Show(); } }
protected void GvUser_RowCommand(object sender, GridViewCommandEventArgs e) { int ID = Convert.ToInt32(e.CommandArgument.ToString()); if (e.CommandName.Equals("editRecord")) { hfPopupUpdate.Value = ID.ToString(); DataTable dt = new DataTable(); dt = Users.GetUserID(int.Parse(hfPopupUpdate.Value)).Tables[0]; DataTable dtNhomquyen = Roles_User.GetComboxGroup(int.Parse(hfPopupUpdate.Value)).Tables[0]; txtTendangnhap.Text = dt.Rows[0]["TenDangNhap"].ToString(); txtMatKhau.Text = dt.Rows[0]["MatKhau"].ToString(); cboNhomquyen.SelectedIndex = cboNhomquyen.Items.IndexOf(cboNhomquyen.Items.FindByValue(dtNhomquyen.Rows[0]["NhomID"].ToString())); cboDoanhNghiep.SelectedIndex = cboDoanhNghiep.Items.IndexOf(cboDoanhNghiep.Items.FindByValue(dt.Rows[0]["DoanhNghiepID"].ToString())); mpeUpdate.Show(); } else if (e.CommandName.Equals("deleteRecord")) { hfPopupDelete.Value = ID.ToString(); lbxacnhanxoa.Text = "Đồng ý xóa bản ghi?"; mpeDelete.Show(); } else if (e.CommandName.Equals("PhanQuyenRecord")) { hfPopupRole.Value = ID.ToString(); nguoidungid = ID.ToString(); doanhnghiepid = AppSessionInfo.CurrentUser.DoanhNghiepID.ToString(); DataTable dt = new DataTable(); dt = Users.GetUserID(int.Parse(hfPopupRole.Value)).Tables[0]; lblXacNhanQuyen.Text = "Cấp quyền nhắn tin cho TK: <b>" + dt.Rows[0]["TenDangNhap"].ToString() + "</b>"; mpeRole.Show(); } }
protected void btnSave_Click(object sender, EventArgs e) { if (hfPopupUpdate.Value == "0") { if (Roles_User.InsertUserGroup(txtTenQuyen.Text, txtGhiChu.Text, cbxNhomQL.Checked) != "0") { ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "alertMessage('Thành công!','success','Thêm mới thành công!!');", true); LoadUserGroup(0); clearText(); } else { ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "alertMessage('Cảnh báo!','warning','Lỗi khi thêm mới. vui lòng kiểm tra lại dữ liệu..!!');", true); } } else { if (Roles_User.UpdateUserGroup(int.Parse(hfPopupUpdate.Value), txtTenQuyen.Text, txtGhiChu.Text, cbxNhomQL.Checked) != "0") { ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "alertMessage('Thành công!','success','Cập nhật nhóm thành công!!');", true); LoadUserGroup(0); } else { ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "alertMessage('Cảnh báo!','warning','Có lỗi khi cập nhật!');", true); } } }
public static string SendMessage(string idQuyens) { RoleDelete(); try { string[] quyen = idQuyens.Split(','); for (int i = 0; i < quyen.Length; i++) { if (quyen[i] != "root") { Roles_User.InsertGroupRole(int.Parse(nhomquyenid), int.Parse(quyen[i])); int parentid = GetParentIdByQuyenId(int.Parse(quyen[i])); if (parentid != 1) { if (!CheckExistParentNode(int.Parse(nhomquyenid), parentid)) { Roles_User.InsertGroupRole(int.Parse(nhomquyenid), parentid); } } } } return("Cập nhật quyền thành công!!"); } catch (Exception ex) { throw ex; } }
private void BindComBox() { DataSet ds = Roles_User.GetGroupRoles(); cboNhomquyen.DataSource = ds; cboNhomquyen.DataValueField = "NhomID"; cboNhomquyen.DataTextField = "TenNhom"; cboNhomquyen.DataBind(); cboNhomquyen.Items.Insert(0, new ListItem("-- Chọn nhom quyen --", "")); }
private static void RoleDelete() { List <NguoiDung_NhomKH> lsnd_nkh = objbn.GetNhomKHByNguoiDungID(int.Parse(nguoidungid.ToString())); if (lsnd_nkh.Count > 0) { for (int i = 0; i < lsnd_nkh.Count; i++) { Roles_User.NhomKHDelete(int.Parse(nguoidungid.ToString()), lsnd_nkh[i].IdNhomKH); } } }
private static void RoleDelete() { DataSet dsRolechidl1 = Roles_User.GetRoleChidl1(int.Parse(nhomquyenid)); if (dsRolechidl1.Tables[0].Rows.Count > 0) { for (int i = 0; i < dsRolechidl1.Tables[0].Rows.Count; i++) { Roles_User.RoleDelete(int.Parse(dsRolechidl1.Tables[0].Rows[i]["QuyenID"].ToString()), int.Parse(nhomquyenid)); } } }
private void ShowData(int index) { if (index > -1) { int id = Convert.ToInt32(GvgroupUser.DataKeys[index].Value); DataTable dt = new DataTable(); dt = Roles_User.GetGroup(id).Tables[0]; txtTenQuyen.Text = dt.Rows[0]["TenNhom"].ToString(); txtGhiChu.Text = dt.Rows[0]["MoTa"].ToString(); cbxNhomQL.Checked = bool.Parse(dt.Rows[0]["IsGroupAdmin"].ToString()); } else { txtTenQuyen.Text = ""; txtGhiChu.Text = ""; } }
protected void LoadUserGroup(int index) { DataSet ds = new DataSet(); ds = Roles_User.GetUserGroup(); GvgroupUser.DataSource = ds.Tables[0];; GvgroupUser.DataBind(); //if (ds.Tables[0].Rows.Count > 0) //{ // GvgroupUser.SelectedIndex = index; // ShowData(index); //} //else //{ // ShowData(-1); //} }
protected void btnSave_Click(object sender, EventArgs e) { if (!Roles_User.CheckOldPass(int.Parse(AppSessionInfo.CurrentUser.NguoiDungID.ToString()), txtOldPass.Text)) { ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "alertMessage('Cảnh báo!','warning','Mật khẩu cũ không đúng!');", true); } else { if (Roles_User.UpdatePass(int.Parse(AppSessionInfo.CurrentUser.NguoiDungID.ToString()), txtNewPass.Text) == "1") { ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "alertMessage('Thành công!','success','Cập nhật thành công!');", true); } else { ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "alertMessage('Cảnh báo!','warning','Có lỗi khi cập nhật!');", true); } } }
protected void btnXoadongy_Click(object sender, EventArgs e) { if (Roles_User.CheckExistUserInGroup(int.Parse(hfPopupDelete.Value)) || Roles_User.CheckExistRoleInGroup(int.Parse(hfPopupDelete.Value))) { ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "alertMessage('Cảnh báo!','warning','Còn tồn tại người dùng hoặc quyền thuộc nhóm!');", true); } else { if (Roles_User.DeleteUserGroup(int.Parse(hfPopupDelete.Value)) != "0") { ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "alertMessage('Thành công!','success','Xóa nhóm thành công!!');", true); LoadUserGroup(0); } else { ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "alertMessage('Cảnh báo!','warning','Có lỗi khi xóa!');", true); } } }
public static string PhanQuyenNT(string idnhoms) { RoleDelete(); if (idnhoms == "") { return("Chọn nhóm để phân quyền nhắn tin!"); } else { string[] idnhom = idnhoms.Split(','); for (int i = 0; i < idnhom.Length; i++) { if (idnhom[i] != "root") { Roles_User.InsertNguoiDungNhomKH(int.Parse(nguoidungid.ToString()), int.Parse(idnhom[i])); } } return("Phân nhóm nhắn tin thành công!"); } }
protected DataTable LoadUserGroup() { return(Roles_User.GetUserGroup().Tables[0]); }