예제 #1
0
 private void btSave_Click(object sender, RoutedEventArgs e)
 {
     using (var db = new QLTV_DBContext())
     {
         if (CheckNull() == true)
         {
             return;
         }
         else
         {
             var dg = new DOCGIA(txtMaDocGia.Text,
                                 txtTenDocGia.Text,
                                 DateTime.Parse(dpNgaySinh.Text),
                                 cbLoaiDG.SelectedValue.ToString(),
                                 txtDiaChi.Text,
                                 txtPhone.Text,
                                 txtEmail.Text,
                                 DateTime.Parse(dpNgayLapPhieu.Text),
                                 DateTime.Parse(dpNgayHetHan.Text));
             db.DOCGIAs.Add(dg);
             db.SaveChanges();
             DocGiaList.ItemsSource = db.DOCGIAs.ToList();
             DocGiaList.Items.Refresh();
         }
     }
 }
예제 #2
0
        public void DeleteDocGia(int idDocGia)
        {
            DOCGIA docgia = QLThuVienDC.DOCGIAs.FirstOrDefault(s => s.MaDocGia.Equals(idDocGia));

            QLThuVienDC.DOCGIAs.DeleteOnSubmit(docgia);
            QLThuVienDC.SubmitChanges();
        }
        public ActionResult Delete(int id, FormCollection formCollection)
        {
            try
            {
                using (ModelDbContext modeldbContext = new ModelDbContext())
                {
                    DOCGIA dOCGIA = modeldbContext.DOCGIAs.Where(x => x.MASINHVIEN == id).FirstOrDefault();

                    if (dOCGIA.IMAGE != null)
                    {
                        string filePath = Path.Combine(Server.MapPath("~/Images"), dOCGIA.IMAGE);
                        System.IO.File.Delete(filePath);
                    }


                    modeldbContext.DOCGIAs.Remove(dOCGIA);
                    modeldbContext.SaveChanges();
                }
                // TODO: Add delete logic here

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
        private void timer_Tick(object sender, EventArgs e)
        {
            string qrdecode = "";

            if (BitImage is null)
            {
                return;
            }
            Bitmap        bit      = BitmapImageToBitmap(BitImage);
            BarcodeReader Reader   = new BarcodeReader();
            Result        qrResult = Reader.Decode(bit);

            try
            {
                qrdecode = qrResult?.Text.Trim();
            }
            catch (Exception ex)
            {
                qrdecode = "error";
            }
            QRString = qrdecode;
            if (!string.IsNullOrEmpty(qrdecode))
            {
                int    t  = int.Parse(QRString);
                DOCGIA dg = ClientList.FirstOrDefault(x => x.MADG == t);
                dataProvider.SelectedClient = dg;
                StopCamera();
                IsDialogOpen = false;
                eventAggregator.PublishOnCurrentThread("OpenClientView");
            }
        }
예제 #5
0
        public IHttpActionResult PostDOCGIA(DOCGIA dOCGIA)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.DOCGIAs.Add(dOCGIA);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (DOCGIAExists(dOCGIA.MaDG))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = dOCGIA.MaDG }, dOCGIA));
        }
예제 #6
0
        public void xoaDocGia(string mathe)
        {
            if (string.IsNullOrEmpty(mathe))
            {
                MessageBox.Show("Vui lòng chọn dữ liệu để xoá.");
            }
            DOCGIA dg = db.DOCGIAs.Where(a => a.MaTheThuVien == mathe).FirstOrDefault();

            if (MessageBox.Show("Bạn có muốn xoá?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
            {
                if (dg != null)
                {
                    dg.TinhTrangXoa = true;
                    db.SubmitChanges();
                    MessageBox.Show("Xoá thành công.");
                }
                else
                {
                    MessageBox.Show("Xoá không thành công.");
                }
            }
            else
            {
                return;
            }
        }
예제 #7
0
        public ActionResult Login(FormCollection collection)
        {
            var tendn = collection["username"];
            var mk    = collection["pass"];

            if (String.IsNullOrEmpty(tendn) || String.IsNullOrEmpty(mk))
            {
                ViewData["Loi2"] = "Phải điền đầy đủ thông tin";
            }
            else
            {
                DOCGIA dg = data.DOCGIAs.SingleOrDefault(n => n.TenDN == tendn && n.MatKhau == mk);
                {
                    if (dg != null)
                    {
                        ViewBag.Thongbao    = "Đăng nhập thành công";
                        Session["Taikhoan"] = dg;
                        Session["HoTen"]    = dg.TenDG;
                        return(RedirectToAction("Index", "Library"));
                    }
                    else
                    {
                        ViewBag.Thongbao = "Tên đăng nhập hoặc mật khẩu không đúng";
                    }
                }
            }
            return(View());
        }
        public ActionResult Edit(int id, DOCGIA dOCGIA, HttpPostedFileBase uploadImage)
        {
            try
            {
                if (uploadImage != null && uploadImage.ContentLength > 0)
                {
                    if (dOCGIA.IMAGE != null)
                    {
                        string filePathOld = Path.Combine(Server.MapPath("~/Images"), dOCGIA.IMAGE);
                        System.IO.File.Delete(filePathOld);
                    }

                    string fileName    = Path.GetFileNameWithoutExtension(uploadImage.FileName);
                    string extension   = Path.GetExtension(uploadImage.FileName);
                    string filePathNew = Path.Combine(Server.MapPath("~/Images"), fileName);
                    filePathNew = filePathNew + extension;
                    uploadImage.SaveAs(filePathNew);
                    dOCGIA.IMAGE = fileName + extension;
                }
                using (ModelDbContext modelDbContext = new ModelDbContext())
                {
                    modelDbContext.Entry(dOCGIA).State = EntityState.Modified;
                    if (uploadImage == null)
                    {
                        modelDbContext.Entry(dOCGIA).Property(m => m.IMAGE).IsModified = false;
                    }
                    modelDbContext.SaveChanges();
                }
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
예제 #9
0
        public void suaDocGia(string mathethuvien, string tendocgia, string maloaidocgia, string manganh, string cmnd, string ngaysinh, string gioitinh, string sdt, string diachi, string email, string hansudungthethuvien, bool tinhtrangthethuvien, string ngaylamthe, string hinhanh, string matkhau)
        {
            if (!checkMaThe(mathethuvien))
            {
                MessageBox.Show("Mã thẻ thư viện không tồn tại.");
                return;
            }
            if (string.IsNullOrEmpty(mathethuvien) || string.IsNullOrEmpty(maloaidocgia) || string.IsNullOrEmpty(manganh) || string.IsNullOrEmpty(tendocgia) || string.IsNullOrEmpty(cmnd) || string.IsNullOrEmpty(ngaysinh) || string.IsNullOrEmpty(gioitinh) || string.IsNullOrEmpty(sdt) || string.IsNullOrEmpty(diachi) || string.IsNullOrEmpty(email) || string.IsNullOrEmpty(hansudungthethuvien) || string.IsNullOrEmpty(tinhtrangthethuvien.ToString()) || string.IsNullOrEmpty(ngaylamthe))
            {
                MessageBox.Show("Vui lòng nhập đầy đủ dữ liệu");
                return;
            }

            DOCGIA item = db.DOCGIAs.Where(a => a.MaTheThuVien == mathethuvien).FirstOrDefault();

            item.MaTheThuVien        = mathethuvien;
            item.TenDocGia           = tendocgia;
            item.MaLoaiDocGia        = int.Parse(maloaidocgia);
            item.MaNganh             = manganh;
            item.CMND                = cmnd;
            item.NgaySinh            = DateTime.Parse(ngaysinh);
            item.GioiTinh            = gioitinh;
            item.SoDienThoai         = sdt;
            item.DiaChi              = diachi;
            item.Email               = email;
            item.HanSuDungTheThuVien = DateTime.Parse(hansudungthethuvien);
            item.TinhTrangTheThuVien = tinhtrangthethuvien;
            item.NgayLamThe          = DateTime.Parse(ngaylamthe);
            if (!string.IsNullOrEmpty(hinhanh))
            {
                string uploadsPath = System.IO.Path.GetFullPath("..\\..\\..\\");
                string ext         = Path.GetExtension(hinhanh);
                string delPath     = System.IO.Path.GetFullPath("..\\..\\..\\") + "Images\\DocGia\\" + item.HinhAnh;
                uploadsPath += "Images\\DocGia\\" + item.MaTheThuVien.ToString() + ext;
                if (System.IO.File.Exists(delPath))
                {
                    System.GC.Collect();
                    System.GC.WaitForPendingFinalizers();
                    try
                    {
                        System.IO.File.Delete(delPath);
                    }
                    catch (Exception ex)
                    {
                    }
                }
                try
                {
                    System.IO.File.Copy(hinhanh, uploadsPath.ToString());
                    item.HinhAnh = item.MaTheThuVien + "" + ext;
                }
                catch (Exception ex)
                {
                }
            }
            //item.MatKhau = matkhau;
            item.TinhTrangXoa = false;
            db.SubmitChanges();
            MessageBox.Show("Sửa thành công.");
        }
 public void Cancel()
 {
     Client = new DOCGIA()
     {
         HINHANH = @"/Resources/Images/ClientAccount/DefaultAccount.png"
     };
 }
예제 #11
0
        public IHttpActionResult PutDOCGIA(string id, DOCGIA dOCGIA)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != dOCGIA.MaDG)
            {
                return(BadRequest());
            }

            db.Entry(dOCGIA).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DOCGIAExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #12
0
        public void add(DocGiaFrm f)
        {
            DOCGIA        dg = new DOCGIA();
            PHIEUMUONSACH pm = new PHIEUMUONSACH();

            if (f.emailTxt.Text == "" || f.tenDocGiaTxt.Text == "")
            {
                MessageBox.Show("Tên và Email không được trống", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                dg.HoTenDocGia = f.tenDocGiaTxt.Text;
                dg.NgaySinh    = Convert.ToDateTime(f.ngaySinhDT.Text);
                dg.DiaChi      = f.diaChiTxt.Text;
                dg.Email       = f.emailTxt.Text;
                dg.NgayLapThe  = Convert.ToDateTime(f.ngayLapTheDT.Text);
                dg.NgayHetHan  = Convert.ToDateTime(f.ngayHetHanDT.Text);

                db.database().DOCGIAs.InsertOnSubmit(dg);
                db.database().SubmitChanges();

                pm.TinhTrangThanhToan = "Chưa thanh toán";
                pm.MaDocGia           = db.database().LAST_DOCGIA_FUNC().Value;
                pm.MaNhanVien         = 1;
                pm.NgayMuon           = DateTime.Now;
                pm.MaSach             = 1;

                db.database().PHIEUMUONSACHes.InsertOnSubmit(pm);
                db.database().SubmitChanges();
                loadAllData(f);
            }
        }
예제 #13
0
        private void LoadDocGia()
        {
            DOCGIA dg = DocGiaBUS.FindDocGiaById(idDocGia);

            txtIDDocGia.Text  = dg.IDDocGia.ToString();
            txtTenDocGia.Text = dg.HoTen;
            txtTongNo.Text    = dg.TongNo.ToString();
        }
예제 #14
0
        private void LoadDocGia()
        {
            DOCGIA dg = DocGiaBUS.FindDocGiaById(idDocGia);

            txtIDDocGia.Text         = dg.IDDocGia.ToString();
            txtTenDocGia.Text        = dg.HoTen;
            dtPickerNgayLapThe.Value = dg.NgayLapThe;
        }
예제 #15
0
파일: admin.cs 프로젝트: minhthaojr/demo05
        private void qldocgia_Click(object sender, EventArgs e)
        {
            DOCGIA a = new DOCGIA();

            this.Hide();
            a.ShowDialog();
            this.Show();
        }
예제 #16
0
        public ActionResult DeleteConfirmed(int id)
        {
            DOCGIA dOCGIA = db.DOCGIAs.Find(id);

            db.DOCGIAs.Remove(dOCGIA);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #17
0
        public DOCGIA layDGtuPM(DOCGIA dg, ref string tiencoc)
        {
            DOCGIA    dgs = qltv.DOCGIAs.Where(d => d.MaTheThuVien == dg.MaTheThuVien).FirstOrDefault();
            PHIEUMUON pms = qltv.PHIEUMUONs.Where(m => m.MaTheThuVien == dg.MaTheThuVien).FirstOrDefault();

            dg      = dgs;
            tiencoc = pms.PhiCoc.ToString();
            return(dg);
        }
예제 #18
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            DOCGIA dOCGIA = await db.DOCGIAs.FindAsync(id);

            db.DOCGIAs.Remove(dOCGIA);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
예제 #19
0
        private void btnSua_Click(object sender, EventArgs e)
        {
            DOCGIA tg = getItemById();

            if (tg.ID == 0)
            {
                MessageBox.Show("Chưa có độc giả nào được chọn", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (btnSua.Text == "Sửa")
            {
                btnSua.Text     = "Lưu";
                btnThem.Enabled = false;
                btnXoa.Text     = "Hủy";

                groupThongTin.Enabled = true;
                dgvDOCGIA.Enabled     = false;

                btnTimKiem.Enabled = false;
                txtTimKiem.Enabled = false;
                return;
            }

            if (btnSua.Text == "Lưu")
            {
                if (Check())
                {
                    btnSua.Text     = "Sửa";
                    btnThem.Enabled = true;
                    btnXoa.Text     = "Xóa";

                    groupThongTin.Enabled = false;
                    dgvDOCGIA.Enabled     = true;

                    btnTimKiem.Enabled = true;
                    txtTimKiem.Enabled = true;

                    DOCGIA tgs = getItemByForm();
                    bool   ok  = DOCGIA_Service.Update(tgs, tg.ID);

                    if (ok)
                    {
                        MessageBox.Show("Sửa thông tin độc giả thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("Sửa thông tin độc giả thất bại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }

                    LoadDgvDOCGIA();
                }

                return;
            }
        }
예제 #20
0
        public bool checkMaThe(string mathe)
        {
            DOCGIA dg = db.DOCGIAs.Where(a => a.MaTheThuVien == mathe).FirstOrDefault();

            if (dg != null)
            {
                return(true);
            }
            return(false);
        }
 public ActionResult Edit([Bind(Include = "docgiaid,msdocgia,tendocgia,diachidocgia,ngaysinhdocgia,emaildocgia,gioitinhdocgia,sodienthoaidocgia")] DOCGIA dOCGIA)
 {
     if (ModelState.IsValid)
     {
         db.Entry(dOCGIA).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(dOCGIA));
 }
예제 #22
0
 public ActionResult Edit([Bind(Include = "MaDG,TenDG,DiaChi,DienThoai,Email")] DOCGIA dOCGIA)
 {
     if (ModelState.IsValid)
     {
         db.Entry(dOCGIA).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(dOCGIA));
 }
        public ActionResult Create([Bind(Include = "docgiaid,msdocgia,tendocgia,diachidocgia,ngaysinhdocgia,emaildocgia,gioitinhdocgia,sodienthoaidocgia")] DOCGIA dOCGIA)
        {
            if (ModelState.IsValid)
            {
                db.dOCGIAs.Add(dOCGIA);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(dOCGIA));
        }
예제 #24
0
        public async Task <ActionResult> Edit([Bind(Include = "MaDG,TenDG,DiaChi,DienThoai,Email,TenDN,MatKhau")] DOCGIA dOCGIA)
        {
            if (ModelState.IsValid)
            {
                db.Entry(dOCGIA).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(dOCGIA));
        }
예제 #25
0
        public ActionResult Create([Bind(Include = "MaDG,TenDG,DiaChi,DienThoai,Email")] DOCGIA dOCGIA)
        {
            if (ModelState.IsValid)
            {
                db.DOCGIAs.Add(dOCGIA);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(dOCGIA));
        }
예제 #26
0
        public ActionResult Delete(int id)
        {
            DOCGIA ctpm = db.DOCGIAs.SingleOrDefault(n => n.MaDG == id);

            //if (ctpm == null)
            //{
            //    Response.StatusCode = 404;
            //    return null;
            //}
            return(View(ctpm));
        }
예제 #27
0
        public PHIEUMUON tinhTienCoc(DOCGIA dg, float money)
        {
            PHIEUMUON d = qltv.PHIEUMUONs.Where(n => n.MaTheThuVien == dg.MaTheThuVien).FirstOrDefault();

            if (d != null)
            {
                d.PhiCoc -= money;
                qltv.SubmitChanges();
            }
            return(d);
        }
예제 #28
0
        public IHttpActionResult GetDOCGIA(string id)
        {
            DOCGIA dOCGIA = db.DOCGIAs.Find(id);

            if (dOCGIA == null)
            {
                return(NotFound());
            }

            return(Ok(dOCGIA));
        }
예제 #29
0
 public bool XoaDG(DOCGIA dg)
 {
     try
     {
         SQLDataContext.SQLData.SP_XOADG(dg.MADG);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
예제 #30
0
 public bool SuaDG(DOCGIA dg)
 {
     try
     {
         SQLDataContext.SQLData.SP_SUADG(dg.MADG, dg.TENDG, dg.GIOITINH, dg.NGAYSINH, dg.NOISINH, dg.DIACHI, dg.DIENTHOAI, dg.EMAIL, dg.MALOP, dg.MALOAIDOCGIA);
         return(true);
     }
     catch
     {
         return(false);
     }
 }