protected void Page_Load(object sender, EventArgs e) { trang = Request.QueryString["trang"] != null ? Request.QueryString["trang"].ToString() : "1"; lblNameError.Visible = false; lblMessage.Visible = false; itemFormat = lblDeparmentRowFormat.Text; id = Request.QueryString["id"] ?? "0"; if (!IsPostBack) { List <string> userNames = staffRepository.GetAvailableUserName(); if (id != "0") { staff = staffRepository.GetById(int.Parse(id)); ckKichHoat.Checked = staff.KichHoat; txtName.Text = staff.TenCanBo; txtEmail.Text = staff.Email; txtSoDienThoai.Text = staff.SoDienThoai; StaffName = staff.TenCanBo; if (!string.IsNullOrEmpty(staff.UserName)) { userNames.Add(staff.UserName); } mappings = staffRepository.GetMappingByStaff(int.Parse(id)); } ddlAccount.DataSource = userNames; ddlAccount.Items.Add(new ListItem { Text = "[Bạn hãy chọn]", Value = "0" }); ddlAccount.DataBind(); if (id != "0") { ddlAccount.SelectedValue = staff.UserName; } Sys_DanhMucChucVuRepository positionRepository = new Sys_DanhMucChucVuRepository(); positions = positionRepository.GetAll().ToList(); ///Phong ban, don vi Sys_DanhMucDonViRepository repository = new Sys_DanhMucDonViRepository(); List <DepartmentTreeNode> nodes = new List <DepartmentTreeNode>(); List <Sys_DanhMucDonVi> departments = repository.GetDepartmentStructure(); int level = 0; departments.ForEach(x => nodes = BuildTreeNode(x, level, nodes)); rptDepartment.DataSource = nodes; rptDepartment.DataBind(); } }
private void BuildTree() { List <string> nodes = new List <string>(); Sys_DanhMucDonViRepository repository = new Sys_DanhMucDonViRepository(); List <Sys_DanhMucDonVi> departments = repository.GetDepartmentStructure(); int level = 0; departments.ForEach(x => nodes = BuildTreeNode(x, level, itemFormat, nodes)); nodes.ForEach(x => DeparmentTree = string.Concat(DeparmentTree, x)); }