Пример #1
0
        public bool XoaNhomQuyen(Entities.NhomQuyen nq)
        {
            try
            {
                cl = new Server_Client.Client();
                // gán TCPclient
                this.client1 = cl.Connect(Luu.IP, Luu.Ports);
                // khởi tạo biến truyền vào với hàm khởi tạo nếu muốn truyền giá trị

                // khởi tạo mảng đối tượng để hứng giá trị
                bool nq1;
                clientstrem = cl.SerializeObj(this.client1, "XoaNhomQuyen", nq);
                // đổ mảng đối tượng vào datagripview
                nq1 = (bool)cl.DeserializeHepper(clientstrem, null);
                return(nq1);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Пример #2
0
 public bool ThemNhomQuyen(string tnq)
 {
     try
     {
         cl = new Server_Client.Client();
         // gán TCPclient
         this.client1 = cl.Connect(Luu.IP, Luu.Ports);
         // khởi tạo biến truyền vào với hàm khởi tạo nếu muốn truyền giá trị
         Entities.NhomQuyen nq = new Entities.NhomQuyen(tnq);
         nq.MaNhanVien  = Common.Utilities.User.NhanVienID;
         nq.TenDangNhap = Common.Utilities.User.TenDangNhap;
         // khởi tạo mảng đối tượng để hứng giá trị
         //Entities.NhomQuyen[] nq1;
         clientstrem = cl.SerializeObj(this.client1, "ThemNhomQuyen", nq);
         // đổ mảng đối tượng vào datagripview
         bool trave = (bool)cl.DeserializeHepper(clientstrem, null);
         return(trave);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Пример #3
0
        public bool ThemNhomQuyen(string tnq)
        {
            try
            {
                cl = new Server_Client.Client();
                // gán TCPclient
                this.client1 = cl.Connect(Luu.IP, Luu.Ports);
                // khởi tạo biến truyền vào với hàm khởi tạo nếu muốn truyền giá trị
                Entities.NhomQuyen nq = new Entities.NhomQuyen(tnq);
                nq.MaNhanVien =Common.Utilities.User.NhanVienID;
                nq.TenDangNhap = Common.Utilities.User.TenDangNhap;
                // khởi tạo mảng đối tượng để hứng giá trị
                //Entities.NhomQuyen[] nq1;
                clientstrem = cl.SerializeObj(this.client1, "ThemNhomQuyen", nq);
                // đổ mảng đối tượng vào datagripview
                bool trave = (bool)cl.DeserializeHepper(clientstrem, null);
                return trave;
            }
            catch (Exception)
            {

                return false;
            }
        }
Пример #4
0
 private void btnXoa_Click(object sender, EventArgs e)
 {
     System.Windows.Forms.DialogResult giatri = System.Windows.Forms.MessageBox.Show("Bạn chắc chắn Muốn Xóa không ?", "Thông Báo", System.Windows.Forms.MessageBoxButtons.YesNo);
     {
         if (giatri == System.Windows.Forms.DialogResult.Yes)
         {
             TreeNode temp = tvNhomQuyen.SelectedNode;
             if (temp != null)
             {
                 if (temp.Parent != null)
                 {
                     bool kt = true;
                     foreach (Entities.NhomQuyen item in NhomQuyen)
                     {
                         if (temp.Parent.Name.Equals(item.TenNhomQuyen))
                         {
                             kt = item.isDeleted;
                             break;
                         }
                     }
                     if (kt)
                     {
                         Entities.NhomQuyen nq1 = new Entities.NhomQuyen(temp.Parent.Name);
                         nq1.MaNhanVien = Common.Utilities.User.NhanVienID;
                         nq1.TenDangNhap = Common.Utilities.User.TenDangNhap;
                         if (!XoaNhomQuyen(nq1))
                             MessageBox.Show("Xóa Thất Bại");
                     }
                     else
                         MessageBox.Show("Không Được Phép Xóa");
                 }
                 else
                 {
                     bool kt = true;
                     foreach (Entities.NhomQuyen item in NhomQuyen)
                     {
                         if (temp.Name.Equals(item.TenNhomQuyen))
                         {
                             kt = item.isDeleted;
                             break;
                         }
                     }
                     if (kt)
                     {
                         Entities.NhomQuyen nq1 = new Entities.NhomQuyen(temp.Name);
                         nq1.MaNhanVien = Common.Utilities.User.NhanVienID;
                         nq1.TenDangNhap = Common.Utilities.User.TenDangNhap;
                         if (!XoaNhomQuyen(nq1))
                             MessageBox.Show("Xóa Thất Bại");
                     }
                     else
                         MessageBox.Show("Không Được Phép Xóa");
                 }
                 NQ = "Admin";
                 Tree();
                 Entities.ChiTietQuyen[] ctqt = LayChiTietQuyen(NQ);
                 if (ctqt != null)
                 {
                     dataGridView1.DataSource = ctqt;
                     fixdgv();
                 }
                 else
                 {
                     dataGridView1.DataSource = new Entities.ChiTietQuyen[0];
                     fixdgv();
                 }
                 dataGridView1.Refresh();
             }
             else
                 MessageBox.Show("Chưa Chọn Nhóm Quyền");
         }
     }
 }
Пример #5
0
 private void btnXoa_Click(object sender, EventArgs e)
 {
     System.Windows.Forms.DialogResult giatri = System.Windows.Forms.MessageBox.Show("Bạn chắc chắn Muốn Xóa không ?", "Thông Báo", System.Windows.Forms.MessageBoxButtons.YesNo);
     {
         if (giatri == System.Windows.Forms.DialogResult.Yes)
         {
             TreeNode temp = tvNhomQuyen.SelectedNode;
             if (temp != null)
             {
                 if (temp.Parent != null)
                 {
                     bool kt = true;
                     foreach (Entities.NhomQuyen item in NhomQuyen)
                     {
                         if (temp.Parent.Name.Equals(item.TenNhomQuyen))
                         {
                             kt = item.isDeleted;
                             break;
                         }
                     }
                     if (kt)
                     {
                         Entities.NhomQuyen nq1 = new Entities.NhomQuyen(temp.Parent.Name);
                         nq1.MaNhanVien  = Common.Utilities.User.NhanVienID;
                         nq1.TenDangNhap = Common.Utilities.User.TenDangNhap;
                         if (!XoaNhomQuyen(nq1))
                         {
                             MessageBox.Show("Xóa Thất Bại");
                         }
                     }
                     else
                     {
                         MessageBox.Show("Không Được Phép Xóa");
                     }
                 }
                 else
                 {
                     bool kt = true;
                     foreach (Entities.NhomQuyen item in NhomQuyen)
                     {
                         if (temp.Name.Equals(item.TenNhomQuyen))
                         {
                             kt = item.isDeleted;
                             break;
                         }
                     }
                     if (kt)
                     {
                         Entities.NhomQuyen nq1 = new Entities.NhomQuyen(temp.Name);
                         nq1.MaNhanVien  = Common.Utilities.User.NhanVienID;
                         nq1.TenDangNhap = Common.Utilities.User.TenDangNhap;
                         if (!XoaNhomQuyen(nq1))
                         {
                             MessageBox.Show("Xóa Thất Bại");
                         }
                     }
                     else
                     {
                         MessageBox.Show("Không Được Phép Xóa");
                     }
                 }
                 NQ = "Admin";
                 Tree();
                 Entities.ChiTietQuyen[] ctqt = LayChiTietQuyen(NQ);
                 if (ctqt != null)
                 {
                     dataGridView1.DataSource = ctqt;
                     fixdgv();
                 }
                 else
                 {
                     dataGridView1.DataSource = new Entities.ChiTietQuyen[0];
                     fixdgv();
                 }
                 dataGridView1.Refresh();
             }
             else
             {
                 MessageBox.Show("Chưa Chọn Nhóm Quyền");
             }
         }
     }
 }