public SACHKHUYENMAI deleteSachKhuyenMai(string MaSachKhuyenMai) { SACHKHUYENMAI skm = (from c in entity.SACHKHUYENMAIs where c.MASACH == MaSachKhuyenMai select c).FirstOrDefault(); entity.SACHKHUYENMAIs.Remove(skm); entity.SaveChanges(); return(skm); }
private SACHKHUYENMAI ViewToModel() { SACHKHUYENMAI skm = new SACHKHUYENMAI(); skm.MASACH = view.MASACH; skm.MUCGIAMGIA = view.MUCGIAMGIA; return(skm); }
public void showSelected() { if (view.selectedSackKhuyenMai != "") { SACHKHUYENMAI kho = repository.getSachKhuyenMai(view.selectedSackKhuyenMai); ModelToView(kho); //view.SachKhuyenMai = kho; } }
public SACHKHUYENMAI saveSachKhuyenMai(SACHKHUYENMAI sachkhuyenmai) { try { entity.SACHKHUYENMAIs.Add(sachkhuyenmai); entity.SaveChanges(); return(sachkhuyenmai); } catch (DbUpdateException) // tranh loi update { return(null); } }
public void saveSachKhuyenMai() { //SACHKHUYENMAI kho = repository.getSachKhuyenMai(view.selectedSachKhuyenMai); SACHKHUYENMAI kho = ViewToModel(); if (valid(kho)) { SACHKHUYENMAI kq = repository.saveSachKhuyenMai(kho); //view.Log("Đã lưu thành công"); getListSachKhuyenMai(); } }
public SACHKHUYENMAI editSachKhuyenMai(SACHKHUYENMAI sachkhuyenmai, string oldMasach) { SACHKHUYENMAI skm = (from c in entity.SACHKHUYENMAIs where c.MASACH == oldMasach select c).FirstOrDefault(); //kho_re.MASACH = kho.MASACH; //saveSachKhuyenMai(sachkhuyenmai); //deleteSachKhuyenMai(skm.MASACH); //kho_re.SOLUONGCON = kho.SOLUONGCON; //kho_re.TONGSOLUONG = kho.TONGSOLUONG; skm.MUCGIAMGIA = sachkhuyenmai.MUCGIAMGIA; entity.SaveChanges(); return(skm); //kho cu }
public void deleteSachKhuyenMai() { //SACHKHUYENMAI kho = repository.getSachKhuyenMai(view.selectedSachKhuyenMai); string makho = view.selectedSackKhuyenMai; if (makho != "") { SACHKHUYENMAI kho = repository.getSachKhuyenMai(makho); SACHKHUYENMAI kq = repository.deleteSachKhuyenMai(makho); //view.Log("Đã lưu thành công"); getListSachKhuyenMai(); } }
public bool valid(SACHKHUYENMAI skm) { //xet null state.Clear(); if (repository.getSachKhuyenMai(skm.MASACH) != null) { state.addError("masach", "Mã Sách đã tồn tại được chọn"); } //if (kho.TONGSOLUONG < 0) // state.addError("tongsoluong", "Tổng số lượng không được nhỏ hơn 0"); //if (kho.SOLUONGCON > kho.TONGSOLUONG) // state.addError("lonhon", "Số lượng còn không được lớn hơn tổng số lượng"); //if (kho.MASACH == "") // state.addError("sach", "Không còn sách để thêm thông tin"); return(state.isValid()); }
public void editSachKhuyenMai() { SACHKHUYENMAI kho_moi = ViewToModel(); string makho_cu = view.selectedSackKhuyenMai; if (makho_cu != "") { kho_moi.MASACH = makho_cu; SACHKHUYENMAI kq = repository.editSachKhuyenMai(kho_moi, makho_cu); getListSachKhuyenMai(); } }
private void ModelToView(SACHKHUYENMAI skm) { view.MASACH = skm.MASACH; view.MUCGIAMGIA = skm.MUCGIAMGIA; }