public async Task <ActionResult> CreateOrUpdate(string userId, string[] array, DateTime ngayTra) { var muontra = new MuonTra(); var autoList = AutoCompleteTextHoSos(_taiLieuVanBanService.Gets(p => p.TrangThai == true, p => p.OrderBy(x => x.Ten)).ToList()); var users = await _userService.GetAllAsync(); var muonTras = new List <MuonTra>(); var model = Users(users, muonTras); muontra.UserId = model.FirstOrDefault(m => m.UserName == userId).Id; muontra.VanThu = User.Identity.GetUserName(); muontra.NgayMuon = DateTime.Now; muontra.NgayKetThuc = ngayTra; muontra.TinhTrang = EnumTinhTrang.DangMuon; _muonTraService.Insert(muontra); for (int i = 0; i < array.Length; i++) { var chitietmuontra = new ChiTietMuonTra(); var b = array[i]; var a = autoList.FirstOrDefault(p => p.Text == b).Id; chitietmuontra.TaiLieuVanBanId = a; chitietmuontra.MuonTraID = muontra.Id; _chiTietMuonTraService.Insert(chitietmuontra); var chiTietMuonTras = _chiTietMuonTraService.GetAll(); muontra.SoLuong = chiTietMuonTras.Count(m => m.MuonTraID == muontra.Id); _muonTraService.Update(muontra); var vanBan = _taiLieuVanBanService.Get(m => m.Id == a); vanBan.TinhTrang = EnumTinhTrang.DangMuon; _taiLieuVanBanService.Update(vanBan); } TempData["AlertMessage"] = "Tạo Mới Thành Công"; return(RedirectToAction("Index")); }
public ActionResult Payment() { try { var cart = (Cart)Session[CartSession]; foreach (var item in cart.Lines) { var obj = new MuonTra(); obj.SachID = item.sach.SachID; obj.soluong = item.Quantity; obj.Ngaymuon = DateTime.Now; obj.Ngaytra = DateTime.Now.AddMonths(2); obj.ThethuvienID = new TaiKhoanFunction().GetId(CommonConstant.USERNAME.username); obj.Datra = false; var id = new MuontraFunction().Insert(obj); } Session["CartSession"] = null; } catch (Exception ex) { //ghi log return(RedirectToAction("/Loi")); } return(RedirectToAction("DatHangThanhCong", "Cart")); }
public MuonTra GetMuonTraDAL(string s) { int a = Convert.ToInt32(s); MuonTra mt = new MuonTra(); mt = db.MuonTras.Where(p => p.STT == a).SingleOrDefault(); return(mt); }
public ActionResult DeleteConfirmed(string id) { MuonTra muonTra = db.MuonTras.Find(id); db.MuonTras.Remove(muonTra); db.SaveChanges(); return(RedirectToAction("Index")); }
public void DelMuonTraDAL(string s) { int a = Convert.ToInt32(s); MuonTra mt = db.MuonTras.Where(p => p.STT == a).SingleOrDefault(); db.MuonTras.Remove(mt); db.SaveChanges(); }
private MuonTra getTra() { MuonTra mt = new MuonTra(); int select = dgvDSTra.SelectedRows[0].Index; mt.Ma = int.Parse(dgvDSTra["clTma", select].Value.ToString()); mt.Ngaytra = dtpNgayTra.Value; return(mt); }
public ActionResult Edit([Bind(Include = "SoThuTu,SoThe,NgayMuon,NgayTra,NgayPhaiTra,MaSach,MaThuThu")] MuonTra muonTra) { if (ModelState.IsValid) { db.Entry(muonTra).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(muonTra)); }
public ActionResult Create([Bind(Include = "SoThuTu,SoThe,NgayMuon,NgayTra,NgayPhaiTra,MaSach,MaThuThu")] MuonTra muonTra) { if (ModelState.IsValid) { db.MuonTras.Add(muonTra); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(muonTra)); }
//public void AddDocGiaDAL(DocGia dg) //{ // try // { // db.DocGias.Add(dg); // db.SaveChanges(); // } // catch (Exception e) // { // MessageBox.Show("Ma Doc Gia trung, xin nhap lai"); // } //} //public void AddNhanVienDAL(NhanVien nv) //{ // try // { // db.NhanViens.Add(nv); // db.SaveChanges(); // } // catch (Exception e) // { // MessageBox.Show("Ma Nhan Vien trung, xin nhap lai"); // } //} //public void AddLoaiSachDAL(LoaiSach ls) //{ // try // { // db.LoaiSachs.Add(ls); // db.SaveChanges(); // } // catch (Exception e) // { // MessageBox.Show("Ma Loai Sach trung, xin nhap lai"); // } //} //public void AddSachDAL(Sach s) //{ // try // { // db.Sachs.Add(s); // db.SaveChanges(); // } // catch (Exception e) // { // MessageBox.Show("Ma Sach trung hoac Nhap Sai Ma Loai, xin nhap lai"); // } //} public void AddMuonTraDAL(MuonTra mt) { try { db.MuonTras.Add(mt); db.SaveChanges(); } catch (Exception e) { MessageBox.Show("Nhap sai Ma Doc gia, Nhan vien hoac Ma Sach, xin nhap lai"); } }
private MuonTra getMuon() { MuonTra mt = new MuonTra(); mt.Masach = txtMSach.Text; mt.Manhansu = int.Parse(txtNVMuon.Text); mt.Thethuvien = int.Parse(txtNMMuon.Text); mt.Ngaymuon = dtpNgayMuon.Value; mt.Hanmuon = dtpHanMuon.Value; return(mt); }
private void btSua_Click(object sender, EventArgs e) { if (tbMaDGMT.Text == "" || tbMaNVMT.Text == "" || tbMaSachMT.Text == "") { MessageBox.Show("Ban chua nhap day du Thong tin Muon Tra sach"); } else { MuonTra mt = GetFormMuontra(); bll.UpdateMuonTraBLL(mt); } }
public List <MuonTra> ModelByIdMuon(string idthethuvien) { List <MuonTra> ls = new List <MuonTra>(); DataTable dt = DataByIdMuon(idthethuvien); foreach (DataRow row in dt.Rows) { MuonTra item = new MuonTra(row); ls.Add(item); } return(ls); }
public bool XoaMuonTra(string MaThe, string MaCuon, string MaNV) { QLThuVienEntities qltvEntity = new QLThuVienEntities(); MuonTra mt = new MuonTra(); mt.MaThe = MaThe; mt.MaCuon = MaCuon; mt.MaNV = MaNV; qltvEntity.MuonTras.Attach(mt); qltvEntity.MuonTras.Remove(mt); qltvEntity.SaveChanges(); return(true); }
public void GiveBackOneOrTwo(List <ChiTietMuonTraViewModel> chiTietMuons) { if (chiTietMuons.Count() <= 0) { return; } string muontraId = ""; var muontraNew = new MuonTra { Id = Guid.NewGuid().ToString(), VanThu = User.Identity.GetUserName(), }; var chiTietMuonTras = new List <ChiTietMuonTra>(); foreach (var item in chiTietMuons) { var ctmt = _chiTietMuonTraService.GetById(item.Id); muontraId = item.MuonTraId; if (item.Checkbox) { ctmt.TrangThai = false; UpdateVanBan(ctmt.TaiLieuVanBanId); var chtmtNew = new ChiTietMuonTra { Id = Guid.NewGuid().ToString(), MuonTraID = muontraNew.Id, TaiLieuVanBanId = item.TaiLieuVanBanId, NgayTao = DateTime.Now, TrangThai = true }; chiTietMuonTras.Add(chtmtNew); } } var muonTraOld = _muonTraService.GetById(muontraId); _muonTraService.Update(muonTraOld); muontraNew.UserId = muonTraOld.UserId; muontraNew.NgayMuon = muonTraOld.NgayMuon; muontraNew.NgayKetThuc = muonTraOld.NgayKetThuc; muontraNew.SoLuong = chiTietMuons.Count(m => m.Checkbox == true); _muonTraService.Insert(muontraNew); _chiTietMuonTraService.Insert(chiTietMuonTras); UpdateMuonTra(muontraNew.Id); }
// GET: MuonTras/Delete/5 public ActionResult Delete(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } MuonTra muonTra = db.MuonTras.Find(id); if (muonTra == null) { return(HttpNotFound()); } return(View(muonTra)); }
public bool ThemMuonTra(string MaThe, string MaCuon, string MaNV, DateTime NgayMuon, DateTime NgayTra) { QLThuVienEntities qltvEntity = new QLThuVienEntities(); MuonTra mt = new MuonTra(); mt.MaThe = MaThe; mt.MaCuon = MaCuon; mt.MaNV = MaNV; mt.NgayMuon = NgayMuon; mt.NgayTra = NgayTra; qltvEntity.MuonTras.Add(mt); qltvEntity.SaveChanges(); return(true); }
private void dataGridView1_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e) { string stt; stt = dataGridView1.SelectedRows[0].Cells["STT"].Value.ToString(); MuonTra mt = bll.GetMuonTraBLL(stt); tbSTT.Text = mt.STT.ToString(); tbMaDGMT.Text = mt.MaDG; tbMaNVMT.Text = mt.MaNV; tbMaSachMT.Text = mt.MaSach; dtpNgayMuon.Value = mt.NgayMuon; dtpNgayTra.Value = mt.NgayTra; dtpNgayHenTra.Value = mt.NgayHenTra; }
private void btOK_Click(object sender, EventArgs e) { if (tbMaDGMT.Text == "" || tbMaNVMT.Text == "" || tbMaSachMT.Text == "") { MessageBox.Show("Ban chua nhap day du Thong tin Muon Tra sach"); } else { if (On_btOK != null) { On_btOK(); } MuonTra mt = GetFormMuontra(); bll.AddMuonTraBLL(mt); MessageBox.Show("Thanh cong"); Close(); } }
public void UpdateMuonTraDAL(MuonTra mt) { try { MuonTra mt1 = db.MuonTras.Where(p => p.STT == mt.STT).SingleOrDefault(); mt1.MaDG = mt.MaDG; mt1.MaNV = mt.MaNV; mt1.MaSach = mt.MaSach; mt1.NgayMuon = mt.NgayMuon; mt1.NgayTra = mt.NgayTra; mt1.NgayHenTra = mt.NgayHenTra; db.SaveChanges(); } catch (Exception) { MessageBox.Show("Sai ma DocGia, NhanVien, hoac ma Sach"); } }
public bool TraSach(MuonTra mt) { string query = "update MuonTra "; query += " set ngaytra = @ngaytra "; query += "where id = @id "; Dictionary <string, object> paras = new Dictionary <string, object>(); paras.Add("@id", mt.Ma); paras.Add("@ngaytra", mt.Ngaytra); if (DBConnect.Instance.InsertUpdateDelete(query, paras)) { return(true); } return(false); }
private MuonTraViewModel GetMuonTra(MuonTra muonTra) { var model = new MuonTraViewModel { Id = muonTra.Id, NgayMuon = muonTra.NgayMuon, NgayCapNhat = muonTra.NgayCapNhat, NgayTra = muonTra.NgayKetThuc, UserId = muonTra.UserId, TinhTrang = muonTra.TinhTrang, TrangThai = muonTra.TrangThai, User = muonTra.User, SoLuong = muonTra.SoLuong, VanThu = muonTra.VanThu, ChiTietMuonTras = muonTra.ChiTietMuonTras }; return(model); }
public bool MuonSach(MuonTra mt) { string query = "insert into MuonTra (ngaymuon, hanmuon, idnhansu, idthethuvien, idsach) "; query += " values (@ngaymuon, @hanmuon, @idnhansu, @idthethuvien, @idsach )"; Dictionary <string, object> paras = new Dictionary <string, object>(); paras.Add("@ngaymuon", mt.Ngaymuon); paras.Add("@hanmuon", mt.Hanmuon); paras.Add("@idnhansu", mt.Manhansu); paras.Add("@idthethuvien", mt.Thethuvien); paras.Add("@idsach", mt.Masach); if (DBConnect.Instance.InsertUpdateDelete(query, paras)) { return(true); } return(false); }
private MuonTraViewModel GetMuonTra(MuonTra muonTra) { var autoList = AutoCompleteTextHoSos(_taiLieuVanBanService.GetAll()); var chiTietMuonTras = _chiTietMuonTraService.GetAll(); var model = new MuonTraViewModel { Id = muonTra.Id, NgayMuon = muonTra.NgayMuon, NgayCapNhat = muonTra.NgayCapNhat, NgayTra = muonTra.NgayKetThuc, UserId = muonTra.UserId, TinhTrang = muonTra.TinhTrang, TrangThai = muonTra.TrangThai, User = muonTra.User, SoLuong = muonTra.SoLuong, VanThu = muonTra.VanThu, ChiTietMuonTras = chiTietMuonTras, }; return(model); }
public void AddMuonTraBLL(MuonTra mt) { dal.AddMuonTraDAL(mt); }
public int Insert(MuonTra model) { db.MuonTras.Add(model); db.SaveChanges(); return(model.MuontraID); }
public int Insert(MuonTra order) { db.MuonTras.Add(order); db.SaveChanges(); return(order.MuontraID); }
public void UpdateMuonTraBLL(MuonTra mt) { dal.UpdateMuonTraDAL(mt); }