public void Hienthi_MS()
        {
            var ms = new MuonSachController();

            l = ms.Detail().ToList();
            listView_MS.Items.Clear();
            int i = 1;

            var           dg     = new DocGiaController();
            List <docgia> listdg = dg.Detail().ToList();

            sothecbx.DataSource    = listdg;
            sothecbx.DisplayMember = "hoten";
            sothecbx.ValueMember   = "sothe";

            var         s        = new SachController();
            List <sach> Listsach = s.Detail().ToList();

            masachcbx.DataSource    = Listsach;
            masachcbx.DisplayMember = "tensach";
            masachcbx.ValueMember   = "masach";

            var             nv     = new NhanVienController();
            List <nhanvien> Listnv = nv.Detail().ToList();

            manvcbx.DataSource    = Listnv;
            manvcbx.DisplayMember = "tennv";
            manvcbx.ValueMember   = "manv";

            foreach (MuonSach m in l)
            {
                ListViewItem item = new ListViewItem();
                item.Text = "" + i++;
                item.SubItems.Add(m.Mamuon.ToString());
                item.SubItems.Add(m.sothe.ToString());
                item.SubItems.Add(m.masach.ToString());
                item.SubItems.Add(m.soluong.ToString());
                item.SubItems.Add(m.ngaymuon.ToString());
                item.SubItems.Add(m.hantra.ToString());
                item.SubItems.Add(m.manv.ToString());

                listView_MS.Items.Add(item);
            }
            if (PhanQuyen.quyen == 1)
            {
                btn_enable(false);
            }
            else
            {
                group_MS.Enabled = false;
                Them_MS.Enabled  = Sua_MS.Enabled = Xoa_MS.Enabled = Luu_MS.Enabled = Boqua_MS.Enabled = false;
                Thoat_MS.Enabled = true;
            }
        }
        private void Luu_DG_Click(object sender, EventArgs e)
        {
            if (Them_bool == true && Sua_bool == false)
            {
                var entity = new docgia();

                entity.sothe      = Convert.ToInt32(sothetxt.Text);
                entity.hoten      = tendgtxt.Text;
                entity.ngaysinh   = ngaysinhdg.Value;
                entity.gioitinh   = gioitinhdgtxt.Text;
                entity.diachi     = diachidgtxt.Text;
                entity.email      = emaildgtxt.Text;
                entity.socmtnd    = socmtnddgtxt.Text;
                entity.ngaylamthe = ngaythedg.Value;
                entity.handungthe = hanthedg.Value;

                var dg = new DocGiaController();
                if (dg.Add(entity) > 0)
                {
                    HienThi_DG();
                }
                else
                {
                    MessageBox.Show("Thêm độc giả không thành công");
                }
            }
            if (Them_bool == false && Sua_bool == true)
            {
                var entity = new docgia();
                entity.sothe      = Convert.ToInt32(sothetxt.Text);
                entity.hoten      = tendgtxt.Text;
                entity.ngaysinh   = ngaysinhdg.Value;
                entity.gioitinh   = gioitinhdgtxt.Text;
                entity.diachi     = diachidgtxt.Text;
                entity.email      = emaildgtxt.Text;
                entity.socmtnd    = socmtnddgtxt.Text;
                entity.ngaylamthe = ngaythedg.Value;
                entity.handungthe = hanthedg.Value;

                var dg = new DocGiaController();
                if (dg.Edit(entity))
                {
                    HienThi_DG();
                }
                else
                {
                    MessageBox.Show("Sửa độc giả không thành công");
                }
            }
            btn_enable(false);
        }
Exemple #3
0
 public frmSachMuon()
 {
     InitializeComponent();
     sachMuonControll = new SachMuonController();
     docGiaControll   = new DocGiaController();
     sachControll     = new SachController();
     LoadCBB();
     _txtmamuon.IsReadOnly      = true;
     _txtdiachidg.IsReadOnly    = true;
     _txtkhoadg.IsReadOnly      = true;
     _txtlopdg.IsReadOnly       = true;
     _txttendg.IsReadOnly       = true;
     _txttienkiguidg.IsReadOnly = true;
     LoadSachMuonTable();
     if (App.Role.AddAll == true)
     {
         _btnadd.IsEnabled        = true;
         _btnadd_cancel.IsEnabled = true;
     }
     else
     {
         if (App.Role.AddSachMuon != true)
         {
             _btnadd.IsEnabled        = false;
             _btnadd_cancel.IsEnabled = false;
         }
     }
     if (App.Role.EditAll == true)
     {
         _btnsave.IsEnabled = true;
     }
     else
     {
         if (App.Role.EditSachMuon != true)
         {
             _btnsave.IsEnabled = false;
         }
     }
     if (App.Role.DeleteAll == true)
     {
         _btndelete.IsEnabled = true;
     }
     else
     {
         if (App.Role.DeleteSachMuon != true)
         {
             _btndelete.IsEnabled = false;
         }
     }
 }
        public frmDocGia()
        {
            InitializeComponent();
            docGiaControll   = new DocGiaController();
            sachMuonControll = new SachMuonController();
            LoadCBB();
            LoadDocGiaTable();

            if (App.Role.AddAll == true)
            {
                _btnadd.IsEnabled        = true;
                _btnadd_cancel.IsEnabled = true;
            }
            else
            {
                if (App.Role.AddDocGia != true)
                {
                    _btnadd.IsEnabled        = false;
                    _btnadd_cancel.IsEnabled = false;
                }
            }
            if (App.Role.EditAll == true)
            {
                _btnsave.IsEnabled = true;
            }
            else
            {
                if (App.Role.EditDocGia != true)
                {
                    _btnsave.IsEnabled = false;
                }
            }

            if (App.Role.DeleteAll == true)
            {
                _btndelete.IsEnabled = true;
            }
            else
            {
                if (App.Role.DeleteDocGia != true)
                {
                    _btndelete.IsEnabled = false;
                }
            }
        }
        private void Xoa_DG_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Bạn có muốn xóa độc giả này?", "delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);

            if (result == DialogResult.Yes)
            {
                int id     = Convert.ToInt32(sothetxt.Text);
                var entity = new DocGiaController();
                if (entity.delete(id))
                {
                    HienThi_DG();
                }
                else
                {
                    MessageBox.Show("Xóa độc giả lỗi");
                }
            }
        }
        public void HienThi_DG()
        {
            var dg = new DocGiaController();

            l = dg.Detail();
            listView_DG.Items.Clear();
            int i = 1;

            sothetxt.Text   = l[0].sothe.ToString();
            tendgtxt.Text   = l[0].hoten.ToString();
            ngaysinhdg.Text = l[0].ngaysinh.ToString();
            if (l[0].gioitinh == null)
            {
                gioitinhdgtxt.Text = "";
            }
            else
            {
                gioitinhdgtxt.Text = l[0].gioitinh.ToString();
            }
            if (l[0].email == null)
            {
                emaildgtxt.Text = "";
            }
            else
            {
                emaildgtxt.Text = l[0].email.ToString();
            }
            if (l[0].diachi == null)
            {
                diachidgtxt.Text = "";
            }
            else
            {
                diachidgtxt.Text = l[0].diachi.ToString();
            }
            if (l[0].socmtnd == null)
            {
                socmtnddgtxt.Text = "";
            }
            else
            {
                socmtnddgtxt.Text = l[0].socmtnd.ToString();
            }
            if (l[0].ngaylamthe == null)
            {
                ngaythedg.Text = "";
            }
            else
            {
                ngaythedg.Text = l[0].ngaylamthe.ToString();
            }
            if (l[0].handungthe == null)
            {
                hanthedg.Text = "";
            }
            else
            {
                hanthedg.Text = l[0].handungthe.ToString();
            }
            foreach (var row in l)
            {
                ListViewItem item = new ListViewItem();
                item.Text = "" + i++;
                item.SubItems.Add(row.sothe.ToString());
                item.SubItems.Add(row.hoten.ToString());
                item.SubItems.Add(row.ngaysinh.ToString());
                item.SubItems.Add(row.ngaylamthe.ToString());

                listView_DG.Items.Add(item);
            }
            if (PhanQuyen.quyen == 1)
            {
                btn_enable(false);
            }
            else
            {
                groupDG.Enabled  = false;
                Them_DG.Enabled  = Sua_DG.Enabled = Xoa_DG.Enabled = Luu_DG.Enabled = Boqua_DG.Enabled = false;
                Thoat_DG.Enabled = true;
            }
        }