/// <summary> /// Khởi tạo dữ liệu /// </summary> private void InitData() { BGroup ctl = new BGroup(); OGroup obj = new OGroup(); try { //-- kiểm tra và lấy về nhóm người dùng cần sửa if (GroupId > 0) { obj = ctl.Get(GroupId)[0]; } else { return; } txtDescription.Text = obj.Description; txtName.Text = obj.Name; txtName.Visible = false; lblName.Text = obj.Name; lblName.Visible = true; } catch (Exception ex) { } }
/// <summary> /// Khởi tạo dữ liệu /// </summary> private void InitData() { BUser ctlUP = new BUser(); if (!Global.IsAdmin()) { Response.Redirect("/permission-fail.aspx"); } BGroup ctl = new BGroup(); OGroup obj = new OGroup(); try { //-- kiểm tra và lấy về nhóm người dùng cần sửa if (GroupId > 0) { obj = ctl.Get(GroupId)[0]; } else { return; } txtDescription.Text = obj.Description; txtName.Text = obj.Name; txtName.Visible = true; lblName.Text = obj.Name; lblName.Visible = false; } catch (Exception ex) { } }
public bool Add(OGroup obj) { SqlParameter[] sqlPara = new SqlParameter[2]; sqlPara[0] = new SqlParameter("@Name", SqlDbType.NVarChar); sqlPara[0].Value = obj.Name; sqlPara[1] = new SqlParameter("@Description", SqlDbType.NVarChar); sqlPara[1].Value = obj.Description; return(RunProcudure("sp_tblGroup_add", sqlPara)); }
/// <summary> /// Bind danh sách người dùng theo nhóm /// </summary> private void BindData() { BUser ctlUP = new BUser(); if (!Global.IsAdmin()) { Response.Redirect("/permission-fail.aspx"); } BGroup ctl = new BGroup(); OGroup obj = new OGroup(); grvListUserGroups.DataSource = ctl.Get("", "Desc", "GroupId"); grvListUserGroups.DataBind(); }
/// <summary> /// Cập nhật thông tin nhóm người dùng /// </summary> private void UpdateGroup() { if (!IsNameValid()) { return; } BGroup ctl = new BGroup(); OGroup obj; try { if (GroupId > 0) { obj = ctl.Get(GroupId)[0]; } else { obj = new OGroup(); } }catch (Exception ex) { obj = new OGroup(); } //-- gán thông tin cho đối tượng nhóm người dùng obj.Description = txtDescription.Text; obj.Name = txtName.Text; //-- Cập nhật User if (obj.GroupID > 0) { ctl.Update(obj.GroupID, obj.Name, obj.Description); } //--Thêm mới User else { obj.Name = txtName.Text; ctl.Add(obj); } //--Về trang quản lý nhóm người dùng Response.Redirect("Group.aspx"); }