예제 #1
0
        //loaddata
        private void Form2_Load(object sender, EventArgs e)
        {
            QuanLyNguoiDungEntities enity = new QuanLyNguoiDungEntities();

            string tenLoaiNguoiDung = (from taikhoan in enity.TaiKhoans
                                       join nguoidung in enity.NguoiDungs
                                       on taikhoan.IdNguoiDung equals nguoidung.IdNguoiDung
                                       join loainguoidung in enity.LoaiNguoiDungs
                                       on nguoidung.IdLoaiNguoiDung equals loainguoidung.IdLoaiNguoiDung
                                       where taikhoan.Username == Form1.username
                                       select loainguoidung.TenLoai).FirstOrDefault();

            var loaiNguoiDung = (from taikhoan in enity.TaiKhoans
                                 join nguoidung in enity.NguoiDungs
                                 on taikhoan.IdNguoiDung equals nguoidung.IdNguoiDung
                                 join loainguoidung in enity.LoaiNguoiDungs
                                 on nguoidung.IdLoaiNguoiDung equals loainguoidung.IdLoaiNguoiDung
                                 where taikhoan.Username == Form1.username
                                 select loainguoidung).FirstOrDefault();

            // List<Quyen> quyens = loaiNguoiDung.Quyens.ToList();

            textBox1.Text = tenLoaiNguoiDung;
            if (tenLoaiNguoiDung.Trim() == "G1")
            {
                btn1.Enabled = true;
                btn2.Enabled = true;
                btn3.Enabled = true;
                btn4.Enabled = true;
                btn5.Enabled = true;
            }
            else if (tenLoaiNguoiDung.Trim() == "G2")
            {
                btn1.Enabled = true;
                btn2.Enabled = true;
                btn3.Enabled = true;
                btn4.Enabled = false;
                btn5.Enabled = false;
            }

            //MessageBox.Show(quyens.ToString());
        }
예제 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            QuanLyNguoiDungEntities enity = new QuanLyNguoiDungEntities();

            var user = enity.TaiKhoans.Where(u => u.Username == Form1.username && u.Password == textBox1.Text).FirstOrDefault();

            if (user != null)
            {
                user.Password = textBox2.Text;
                enity.SaveChanges();

                MessageBox.Show("Mật Khẩu thay đổi thành công");
                this.Close();
            }
            else
            {
                MessageBox.Show("Mật Khẩu hiện tại không đúng");
                textBox1.Clear();
                textBox2.Clear();
            }
        }