Пример #1
0
        private void cbbNamGiaHan_TextChanged(object sender, EventArgs e)
        {
            DataRow row      = ((DataRowView)cbbMaDocGia.SelectedItem).Row;
            string  madocgia = row[0].ToString();

            using (QUANLYTHUVIENEntities db = new QUANLYTHUVIENEntities())
            {
                var lephigiahanQuery = from thongtindocgia in db.THONGTINDOCGIAs join nhomdocgia in db.NHOMDOCGIAs
                                       on thongtindocgia.MANHOM equals nhomdocgia.MANHOM
                                       join quydinh in db.QUYDINHs on nhomdocgia.MAQUYDINH equals quydinh.MAQUYDINH
                                       where thongtindocgia.MADOCGIA == madocgia
                                       select quydinh.LEPHIGIAHAN;


                string b   = lephigiahanQuery.Single().ToString();
                int    phi = Convert.ToInt32(b) * Convert.ToInt32(cbbNamGiaHan.Text);
                tbxPhi.Text = "" + phi.ToString();
                string str = tbxNgayHetHan.Text.ToString().Trim();
                str = str.Substring(6, 4);
                string day = tbxNgayHetHan.Text.ToString().Trim();
                day = day.Substring(3, 2);
                string month = tbxNgayHetHan.Text.ToString().Trim();
                month = month.Substring(0, 2);
                int    year   = Convert.ToInt32(str) + Convert.ToInt32(cbbNamGiaHan.Text);
                string hanmoi = month + "-" + day + "-" + year.ToString();
                MessageBox.Show("Thẻ được sử dụng tới : " + hanmoi + " Nhấn gia hạn để tiếp tục ");
            }
        }
Пример #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            DialogResult dr = MessageBox.Show("Bạn có muốn hủy cuốn sách này không ?", "Thông báo", MessageBoxButtons.YesNo);

            if (dr != DialogResult.Yes)
            {
                return;
            }

            using (QUANLYTHUVIENEntities db = new QUANLYTHUVIENEntities())
            {
                var trangthaihuyQuery = from thongtincuonsach in db.THONGTINCUONSACHes
                                        where thongtincuonsach.MACUONSACH == tbxMaCS.Text
                                        select thongtincuonsach;
                if (trangthaihuyQuery.Any())
                {
                    THONGTINCUONSACH thongtincuonsach = trangthaihuyQuery.Single();
                    if (thongtincuonsach.TRANGTHAIHUY == 0)
                    {
                        thongtincuonsach.TRANGTHAIHUY = 1;
                        db.SaveChanges();
                        MessageBox.Show("Đã hủy cuốn sách thành công !!!");
                    }
                    else
                    {
                        MessageBox.Show("Cuốn sách này đã được hủy !!!");
                    }
                }
            }
        }
Пример #3
0
        private void btnMoKhoa_Click(object sender, EventArgs e)
        {
            if (cbbMaDocGia.Text == "")
            {
                MessageBox.Show("Chưa chọn mã đọc giả để mở khóa !!!");
            }
            else
            {
                using (QUANLYTHUVIENEntities db = new QUANLYTHUVIENEntities())
                {
                    DataRow row      = ((DataRowView)cbbMaDocGia.SelectedItem).Row;
                    string  madocgia = row[0].ToString();

                    var thongtindocgiaQuery = from thongtindocgia in db.THONGTINDOCGIAs
                                              where thongtindocgia.MADOCGIA == madocgia
                                              select thongtindocgia;
                    if (thongtindocgiaQuery.Any())
                    {
                        THONGTINDOCGIA ttdg = thongtindocgiaQuery.Single();
                        ttdg.TRANGTHAIDOCGIA = 1;
                        db.SaveChanges();
                    }
                    MessageBox.Show("Đã mở khóa thành công.");
                }
            }
            cbbMaDocGia.DataSource  = LayDuLieuMaDG();
            cbbMaDocGia.ValueMember = "MaDocGia";
        }
Пример #4
0
 public int QuyenTruyCap()
 {
     using (QUANLYTHUVIENEntities db = new QUANLYTHUVIENEntities())
     {
         var quyentruycapQuery = from dangnhap in db.DANGNHAPs
                                 where dangnhap.TENDANGNHAP == frmMain.bientoancuc.bienxy
                                 select dangnhap.QUYENTRUYCAP;
         string quyen = quyentruycapQuery.Single().ToString();
         return(Convert.ToInt32(quyen));
     }
 }
Пример #5
0
        private void cbbMaDocGia_TextChanged(object sender, EventArgs e)
        {
            DataRow row      = ((DataRowView)cbbMaDocGia.SelectedItem).Row;
            string  madocgia = row[0].ToString();

            using (QUANLYTHUVIENEntities db = new QUANLYTHUVIENEntities())
            {
                var ngayhethanQuery = from thongtindocgia in db.THONGTINDOCGIAs
                                      where thongtindocgia.MADOCGIA == madocgia
                                      select thongtindocgia.NGAYHETHAN;

                tbxNgayHetHan.Text = ngayhethanQuery.Single().ToString();
            }
        }
Пример #6
0
        private void frmGopYDocGia_Load(object sender, EventArgs e)
        {
            lblUser.Text = frmMain.bientoancuc.bienxy;

            using (QUANLYTHUVIENEntities db = new QUANLYTHUVIENEntities())
            {
                var thongtindocgiaQuery = from thongtindocgia in db.THONGTINDOCGIAs
                                          join dangnhap in db.DANGNHAPs on thongtindocgia.MATAIKHOAN equals dangnhap.MATAIKHOAN
                                          where dangnhap.TENDANGNHAP == lblUser.Text
                                          select new { thongtindocgia.TENDOCGIA, thongtindocgia.MADOCGIA };
                var obj = thongtindocgiaQuery.Single();

                lblMaDocGia.Text  = obj.MADOCGIA;
                lblTenDocGia.Text = obj.TENDOCGIA;
            }
        }
Пример #7
0
 private void cbbChonNhom_SelectedIndexChanged(object sender, EventArgs e)
 {
     using (QUANLYTHUVIENEntities db = new QUANLYTHUVIENEntities())
     {
         var lephicaptheQuery = from quydinh in db.QUYDINHs
                                join nhomdocgia in db.NHOMDOCGIAs on quydinh.MAQUYDINH equals nhomdocgia.MAQUYDINH
                                select quydinh.LEPHICAPTHE;
         if (lephicaptheQuery.Any())
         {
             lblPhiNhom.Text = lephicaptheQuery.First().ToString();
         }
         else
         {
             lblPhiNhom.Text = "0";
         }
     }
 }
Пример #8
0
        private void btnGopY_Click(object sender, EventArgs e)
        {
            string magopy = ThemMaGopY();

            using (QUANLYTHUVIENEntities db = new QUANLYTHUVIENEntities())
            {
                GOPYDOCGIA gopydocgia = new GOPYDOCGIA();
                gopydocgia.MAGOPY   = magopy;
                gopydocgia.MADOCGIA = lblMaDocGia.Text;
                gopydocgia.NOIDUNG  = tbxGopY.Text;
                gopydocgia.TIEUDE   = tbxTieuDe.Text;
                gopydocgia.EMAIL    = tbxEmail.Text;
                db.SaveChanges();

                MessageBox.Show("Đã gửi thành công. Cám ơn Độc Giả đã quan tâm.");
                this.Close();
            }
        }
Пример #9
0
 public bool CheckDNLanDau(string name)
 {
     using (QUANLYTHUVIENEntities db = new QUANLYTHUVIENEntities())
     {
         var sldnQuery = from dangnhap in db.DANGNHAPs
                         where dangnhap.TENDANGNHAP == name
                         select dangnhap.SOLANDN;
         if (sldnQuery.Any())
         {
             int sldn = Convert.ToInt32(sldnQuery.Single());
             if (sldn == 1)
             {
                 return(true);
             }
         }
         return(false);
     }
 }
Пример #10
0
 public bool CheckDoiMK(string name)
 {
     using (QUANLYTHUVIENEntities db = new QUANLYTHUVIENEntities())
     {
         var sldnQuery = from dangnhap in db.DANGNHAPs
                         where dangnhap.TENDANGNHAP == name
                         select new { dangnhap.SOLANDN, dangnhap.DOIMATKHAU };
         if (sldnQuery.Any())
         {
             var obj = sldnQuery.Single();
             if (obj.SOLANDN > 1 && obj.DOIMATKHAU == 0)
             {
                 return(true);
             }
         }
         return(false);
     }
 }
Пример #11
0
        private void cbbMaDocGia_TextChanged(object sender, EventArgs e)
        {
            using (QUANLYTHUVIENEntities db = new QUANLYTHUVIENEntities())
            {
                DataRow row      = ((DataRowView)cbbMaDocGia.SelectedItem).Row;
                string  madocgia = row[0].ToString();

                var thongtindocgiaQuery = from thongtindocgia in db.THONGTINDOCGIAs
                                          where thongtindocgia.MADOCGIA == madocgia
                                          select thongtindocgia;
                if (thongtindocgiaQuery.Any())
                {
                    THONGTINDOCGIA ttdg = thongtindocgiaQuery.Single();
                    tbxHoTen.Text    = ttdg.TENDOCGIA;
                    tbxNgaySinh.Text = ttdg.NGAYSINH.ToString();
                    tbxSDT.Text      = ttdg.SODIENTHOAIDOCGIA;
                }
            }
        }
Пример #12
0
 public bool CheckLoginNhanVien(string name, string pass)
 {
     using (QUANLYTHUVIENEntities db = new QUANLYTHUVIENEntities())
     {
         string encryptPass   = md5(pass);
         var    dangnhapQuery = from dangnhap in db.DANGNHAPs
                                where dangnhap.TENDANGNHAP == name && dangnhap.MATKHAU == encryptPass
                                select dangnhap;
         if (dangnhapQuery.Any())
         {
             var      capnhatDN   = from dangnhap in db.DANGNHAPs where dangnhap.TENDANGNHAP == name select dangnhap;
             DANGNHAP objDangnhap = capnhatDN.Single();
             objDangnhap.SOLANDN += 1;
             db.SaveChanges();
             return(true);
         }
         return(false);
     }
 }
Пример #13
0
        private void btnChuyenNhom_Click(object sender, EventArgs e)
        {
            using (QUANLYTHUVIENEntities db = new QUANLYTHUVIENEntities())
            {
                var manhomQuery = from nhomdocgia in db.NHOMDOCGIAs
                                  where nhomdocgia.TENNHOM == cbbTenNhomChuyen.Text
                                  select nhomdocgia.MANHOM;
                string manhom = manhomQuery.Single();

                var thongtindocgiaQuery = from thongtindocgia in db.THONGTINDOCGIAs
                                          where thongtindocgia.MADOCGIA == cbbMaDocGia.Text
                                          select thongtindocgia;
                THONGTINDOCGIA ttdgCapnhat = thongtindocgiaQuery.Single();
                ttdgCapnhat.MANHOM = manhom;
                db.SaveChanges();
            }

            MessageBox.Show("Đã chuyển thành công.");
            this.Close();
        }
Пример #14
0
        private void cbbMaDocGia_SelectionChangeCommitted(object sender, EventArgs e)
        {
            DataRow row      = ((DataRowView)cbbMaDocGia.SelectedItem).Row;
            string  madocgia = row[0].ToString();

            using (QUANLYTHUVIENEntities db = new QUANLYTHUVIENEntities())
            {
                var lephigiahanQuery = from thongtindocgia in db.THONGTINDOCGIAs
                                       join nhomdocgia in db.NHOMDOCGIAs on thongtindocgia.MANHOM equals nhomdocgia.MANHOM
                                       join quydinh in db.QUYDINHs on nhomdocgia.MAQUYDINH equals quydinh.MAQUYDINH
                                       where thongtindocgia.MADOCGIA == madocgia
                                       select quydinh.LEPHIGIAHAN;
                int lephigiahan = Convert.ToInt32(lephigiahanQuery.Single().ToString());
                if (cbbNamGiaHan.Text != "")
                {
                    lephigiahan *= Convert.ToInt32(cbbNamGiaHan.Text);
                }
                tbxPhi.Text = "" + lephigiahan.ToString();
            }
        }
Пример #15
0
 private void frmDoiMatKhau_Load(object sender, EventArgs e)
 {
     using (QUANLYTHUVIENEntities db = new QUANLYTHUVIENEntities())
     {
         var doimatkhauQuery = from dangnhap in db.DANGNHAPs
                               where dangnhap.TENDANGNHAP == lblUserName.Text
                               select dangnhap.DOIMATKHAU;
         if (doimatkhauQuery.Any())
         {
             if (doimatkhauQuery.Single() == 0)
             {
                 label5.Visible = true;
             }
             else
             {
                 MessageBox.Show("Không tìm thấy dữ liệu");
             }
         }
     }
 }
Пример #16
0
        private void cbbMaDocGia_TextChanged(object sender, EventArgs e)
        {
            using (QUANLYTHUVIENEntities db = new QUANLYTHUVIENEntities())
            {
                DataRow row             = ((DataRowView)cbbMaDocGia.SelectedItem).Row;
                String  madocgia        = row[0].ToString();
                var     chuyennhomQuery = from nhomdocgia in db.NHOMDOCGIAs
                                          join thongtindocgia in db.THONGTINDOCGIAs
                                          on nhomdocgia.MANHOM equals thongtindocgia.MANHOM
                                          where thongtindocgia.MADOCGIA == madocgia
                                          select new
                {
                    nhomdocgia.TENNHOM, thongtindocgia.TENDOCGIA, thongtindocgia.NGAYSINH, thongtindocgia.SODIENTHOAIDOCGIA
                };
                var obj = chuyennhomQuery.Single();

                tbxTenNhom.Text  = obj.TENNHOM;
                tbxHoTen.Text    = obj.TENDOCGIA;
                tbxNgaySinh.Text = obj.NGAYSINH.ToString();
                tbxSDT.Text      = obj.SODIENTHOAIDOCGIA;
            }
            cbbTenNhomChuyen.Enabled = true;
        }
Пример #17
0
        private void btnDoiMK_Click(object sender, EventArgs e)
        {
            Func data = new Func();

            if (data.CheckLoginNhanVien(lblUserName.Text, tbxMKCu.Text))
            {
                if (tbxMKMoi.Text.ToString() == tbxMKMoiXN.Text.ToString())
                {
                    using (QUANLYTHUVIENEntities db = new QUANLYTHUVIENEntities())
                    {
                        var doimatkhauQuery = from dangnhap in db.DANGNHAPs
                                              where dangnhap.TENDANGNHAP == lblUserName.Text
                                              select dangnhap;
                        if (doimatkhauQuery.Any())
                        {
                            DANGNHAP dangnhapObj = doimatkhauQuery.Single();
                            dangnhapObj.MATKHAU       = md5(tbxMKMoi.Text);
                            dangnhapObj.MATKHAUBANDAU = "";
                            dangnhapObj.DOIMATKHAU    = 1;
                            db.SaveChanges();

                            MessageBox.Show("Đã đổi mật khẩu thành công .");
                            this.Close();
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Mật khẩu xác nhận không đúng !!!");
                }
            }
            else
            {
                MessageBox.Show("Mật khẩu cũ nhập không đúng !!!");
            }
        }
Пример #18
0
        private void btnXacNhan_Click(object sender, EventArgs e)
        {
            using (QUANLYTHUVIENEntities db = new QUANLYTHUVIENEntities())
            {
                var ttdgQuery = from ttdg in db.THONGTINDOCGIAs where ttdg.MADOCGIA == tbxMaDG.Text select ttdg;
                if (ttdgQuery.Any())
                {
                    THONGTINDOCGIA objThongtindocgia = ttdgQuery.Single();
                    tbxTenDG.Text  = objThongtindocgia.TENDOCGIA;
                    tbxMaNhom.Text = objThongtindocgia.MANHOM;
                    string manhom = objThongtindocgia.MANHOM;
                    tbxNSinh.Text = objThongtindocgia.NGAYSINH.ToString();
                    if (objThongtindocgia.GIOITINH.ToString() == "1")
                    {
                        tbxGioiTinh.Text = "Nam";
                    }
                    else
                    {
                        tbxGioiTinh.Text = "Nu";
                    }
                    tbxCMND.Text = objThongtindocgia.SOCMND.ToString();
                    string ma   = tbxMaDG.Text;
                    string link = ".\\HinhAnh\\nguoidung.jpg";
                    pbxHinh.Image    = Image.FromFile(link);
                    tbxNgaySinh.Text = tbxNSinh.Text.Substring(3, 2) + "/" + tbxNSinh.Text.Substring(0, 2) + "/" +
                                       tbxNSinh.Text.Substring(6, 4);

                    var tennhomQuery = from nhom in db.NHOMDOCGIAs where nhom.MANHOM == manhom select nhom.TENNHOM;
                    tbxTenNhom.Text = tennhomQuery.Single().ToString();
                }
                else
                {
                    MessageBox.Show("Không tồn tại mã độc giã này !!!");
                }
            }
        }
Пример #19
0
        private void btnGiaHan_Click(object sender, EventArgs e)
        {
            DataRow row      = ((DataRowView)cbbMaDocGia.SelectedItem).Row;
            string  madocgia = row[0].ToString();

            SqlConnection Con = Conn.GetCon();

            Con.Open();
            string        a      = "select max(maphinop) from ThongTinNopPhi";
            SqlCommand    cmd    = new SqlCommand(a, Con);
            SqlDataReader reader = cmd.ExecuteReader();

            reader.Read();
            string b = reader.GetValue(0).ToString();

            Con.Close();
            string c  = "";
            int    d  = 0;
            string e1 = "";
            string f  = "";

            for (int i = 2; i < b.Length; i++)
            {
                c += b[i].ToString();
            }
            d  = Convert.ToInt32(c) + 1;
            e1 = Convert.ToString(d);
            for (int j = 0; j < (c.Length - e1.Length); j++)
            {
                f += c[j].ToString();
            }
            b = "NP" + f + e1;

            using (QUANLYTHUVIENEntities db = new QUANLYTHUVIENEntities())
            {
                //var thongtinnopphiQuery = from thongtinnopphi in db.THONGTINNOPPHIs
                THONGTINNOPPHI thongtinnopphi = new THONGTINNOPPHI();
                thongtinnopphi.PHIDINHKY   = int.Parse(tbxPhi.Text);
                thongtinnopphi.MADOCGIA    = madocgia;
                thongtinnopphi.PHICAPTHE   = 0;
                thongtinnopphi.PHATNOPTRE  = 0;
                thongtinnopphi.PHATHUSACH  = 0;
                thongtinnopphi.PHATMATSACH = 0;
                thongtinnopphi.NGAYNOP     = DateTime.Now;
                thongtinnopphi.MAPHINOP    = b;
                db.THONGTINNOPPHIs.Add(thongtinnopphi);

                db.SaveChanges();

                string str = tbxNgayHetHan.Text.ToString().Trim();
                str = str.Substring(6, 4);
                string day = tbxNgayHetHan.Text.ToString().Trim();
                day = day.Substring(3, 2);
                string month = tbxNgayHetHan.Text.ToString().Trim();
                month = month.Substring(0, 2);
                int    year   = Convert.ToInt32(str) + Convert.ToInt32(cbbNamGiaHan.Text);
                string hanmoi = month + "-" + day + "-" + year.ToString();

                var ngayhethanQuery = from thongtindocgia in db.THONGTINDOCGIAs
                                      where thongtindocgia.MADOCGIA == madocgia
                                      select thongtindocgia;
                var ngayhethanObj = ngayhethanQuery.First();
                ngayhethanObj.NGAYHETHAN      = DateTime.Parse(hanmoi);
                ngayhethanObj.TRANGTHAIDOCGIA = 1;

                db.SaveChanges();

                MessageBox.Show("Gia hạn thành công .");
                this.Close();
                frmCRGiaHanThe tt = new frmCRGiaHanThe();
                tt.Show();
            }
        }