コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (!CurrentUser.IsSuperAdmin)
                {
                    pnlSuperadmin.Visible = false;
                    pnlAdmin.Visible      = false;
                }
                else
                {
                    pnlSuperadmin.Visible = true;
                    pnlAdmin.Visible      = true;
                }

                dropTrungTam.DataSource = BoPhanController.GetAll();
                dropTrungTam.DataBind();
                dropTrungTam.Items.Insert(0, new ListItem("----------Lựa chọn----------", "0"));

                dropChucVu.DataSource = CommonController.GetAllChucVu();
                dropChucVu.DataBind();
                dropChucVu.Items.Insert(0, new ListItem("----------Lựa chọn----------", "0"));

                int userId = ConvertUtility.ToInt32(Request.QueryString["uid"]);

                if (userId > 0)
                {
                    if (!CurrentUser.IsAdmin && !CurrentUser.IsSuperAdmin)
                    {
                        btnUpdate.Visible = false;
                    }

                    divMK.Visible = divXNMK.Visible = false;
                    UserInfo info = UserController.GetUser(userId);

                    txtUsername.Text    = info.Username;
                    txtDisplayName.Text = info.DisplayName;

                    txtMaSo.Text               = info.MaSo;
                    txtFullName.Text           = info.HoTen;
                    txtNgaySinh.Text           = info.NgaySinh.ToString("dd/MM/yyyy");
                    dropGioiTinh.Text          = info.GioiTinh.ToString();
                    dropChucVu.Text            = info.IDChucVu.ToString();
                    dropTrungTam.SelectedValue = info.IDTrungTam.ToString();

                    if (ConvertUtility.ToInt32(dropTrungTam.SelectedValue) > 0)
                    {
                        dropPhong.DataSource = DotDanhGiaController.GetAllPhongBan(ConvertUtility.ToInt32(dropTrungTam.SelectedValue));
                        dropPhong.DataBind();
                        dropPhong.Items.Insert(0, new ListItem("----------Lựa chọn----------", "0"));
                        dropPhong.SelectedValue = info.IDPhong.ToString();
                    }
                    else
                    {
                        dropPhong.Items.Insert(0, new ListItem("----------Lựa chọn----------", "0"));
                    }

                    txtNoiSinh.Text             = info.NoiSinh;
                    txtNguyenQuan.Text          = info.NguyenQuan;
                    txtQuocTich.Text            = info.QuocTich;
                    txtDanToc.Text              = info.DanToc;
                    txtTonGiao.Text             = info.TonGiao;
                    txtDiaChiThuongChu.Text     = info.DiaChiThuongChu;
                    txtDiaChiTamChu.Text        = info.DiaChiTamChu;
                    chkIsAdmin.Checked          = info.IsAdmin;
                    chkIsSuperAdmin.Checked     = info.IsSuperAdmin;
                    dropTrangThai.SelectedValue = info.TrangThai.ToString();
                }
            }
        }