示例#1
0
        private void frmMain_Load(object sender, EventArgs e)
        {
            string query = "select Them, Sua, Xoa, CreateLogin from NGUOIDUNG where MaNV = '" + DAL.NguoiDung_Controller.MaNV + "' and MatKhau = '" + DAL.NguoiDung_Controller.matkhau + "'";

            DAL.Connect sqlConn = new DAL.Connect();
            sqlConn.openConnection();
            SqlDataReader dr = sqlConn.execCommand(query);

            while (dr.Read())
            {
                if (dr["CreateLogin"].ToString().Equals("True"))
                {
                    mnuHT_QLND.Enabled = true;
                }
                else
                {
                    mnuHT_QLND.Enabled = false;
                }

                if (dr["Them"].ToString().Equals("False") && dr["Sua"].ToString().Equals("False") && dr["Xoa"].ToString().Equals("False"))
                {
                    mnuDM.Enabled = false;
                }
                else
                {
                    mnuDM.Enabled = true;
                }
            }
            this.KeyPreview = true;
        }
示例#2
0
        private void showList()
        {
            //combobox.item.add();
            //combobox.selectedindex = 1
            string query = "select * from NGUOIDUNG";

            DAL.Connect conn = new DAL.Connect();
            conn.openConnection();
            SqlDataReader dr = conn.execCommand(query);

            while (dr.Read())
            {
                ListViewItem item = new ListViewItem();
                item.Text = dr["MaNV"].ToString().Trim();
                item.SubItems.Add(dr["MatKhau"].ToString().Trim());
                item.SubItems.Add(dr["Them"].ToString().Trim());
                item.SubItems.Add(dr["Sua"].ToString().Trim());
                item.SubItems.Add(dr["Xoa"].ToString().Trim());
                item.SubItems.Add(dr["CreateLogin"].ToString().Trim());
                lsvNguoiDung.Items.Add(item);
            }
        }