public JsonResult getDanhSachNguoiDung(NguoiTaoPhieu nguoitaophieu) { var data = ThuChiobj.NguoiTaoPhieus.Where(g => g.Id == nguoitaophieu.Id).Select(c => new { Id = c.Id, Ten = c.Ten, DiaChi = c.DiaChi, Email = c.Email, SoDienThoai = c.SoDienThoai, LoaiNguoiTaoPhieuId = c.LoaiNguoiTaoPhieuId }).FirstOrDefault(); return Json(data, JsonRequestBehavior.AllowGet); }
public string TaoNhaCungCap(NguoiTaoPhieu nhacungcap) { if (ModelState.IsValid) { nhacungcap.LoaiNguoiTaoPhieuId = 3; ThuChiobj.NguoiTaoPhieus.Add(nhacungcap); ThuChiobj.SaveChanges(); return "Thanh cong"; } return "Khong thanh cong"; }
public string TaoNhanVien(NguoiTaoPhieu nhanvien) { if (ModelState.IsValid) { nhanvien.LoaiNguoiTaoPhieuId = 1; ThuChiobj.NguoiTaoPhieus.Add(nhanvien); ThuChiobj.SaveChanges(); return "Thanh cong"; } return "Khong thanh cong"; }
public string TaoKhachHang(NguoiTaoPhieu khachhang) { if (ModelState.IsValid) { khachhang.LoaiNguoiTaoPhieuId = 2; ThuChiobj.NguoiTaoPhieus.Add(khachhang); ThuChiobj.SaveChanges(); return "Thanh cong"; } return "Khong thanh cong"; }
public string SuaNhanVien(NguoiTaoPhieu nhanvien, int Id) { NguoiTaoPhieu nv = ThuChiobj.NguoiTaoPhieus.Find(Id); if (ModelState.IsValid) { nv.LoaiNguoiTaoPhieuId = 1; nv.Ten = nhanvien.Ten; nv.SoDienThoai = nhanvien.SoDienThoai; nv.Email = nhanvien.Email; nv.DiaChi = nhanvien.DiaChi; ThuChiobj.Entry(nv).State = EntityState.Modified; ThuChiobj.SaveChanges(); return "A"; } return "B"; }
public string SuaNhaCungCap(NguoiTaoPhieu nhacungcap, int Id) { NguoiTaoPhieu ncc = ThuChiobj.NguoiTaoPhieus.Find(Id); if (ModelState.IsValid) { ncc.LoaiNguoiTaoPhieuId = 1; ncc.Ten = nhacungcap.Ten; ncc.SoDienThoai = nhacungcap.SoDienThoai; ncc.Email = nhacungcap.Email; ncc.DiaChi = nhacungcap.DiaChi; ThuChiobj.Entry(ncc).State = EntityState.Modified; ThuChiobj.SaveChanges(); return "A"; } return "B"; }
public string SuaKhachHang(NguoiTaoPhieu khachhang, int Id) { NguoiTaoPhieu kh = ThuChiobj.NguoiTaoPhieus.Find(Id); if (ModelState.IsValid) { kh.LoaiNguoiTaoPhieuId = 2; kh.Ten = khachhang.Ten; kh.SoDienThoai = khachhang.SoDienThoai; kh.Email = khachhang.Email; kh.DiaChi = khachhang.DiaChi; ThuChiobj.Entry(kh).State = EntityState.Modified; ThuChiobj.SaveChanges(); return "A"; } return "B"; }
public string SuaKhac(NguoiTaoPhieu khac, int Id) { NguoiTaoPhieu kc = ThuChiobj.NguoiTaoPhieus.Find(Id); if( ModelState.IsValid) { kc.LoaiNguoiTaoPhieuId = 4; kc.Ten = khac.Ten; kc.SoDienThoai = khac.SoDienThoai; kc.Email = khac.Email; kc.DiaChi = khac.DiaChi; ThuChiobj.Entry(kc).State = EntityState.Modified; ThuChiobj.SaveChanges(); return "A"; } return "B"; }