public bool SaveOrUpdate(DTO_ChiTietPhieuBanHang obj) { using (CellphoneComponentEntities db = new CellphoneComponentEntities()) { ChiTietPhieuBanHang chiTietPhieuBanHang = new ChiTietPhieuBanHang(); chiTietPhieuBanHang.MaChiTietPhieuBan = obj.MaChiTietPhieuBan; chiTietPhieuBanHang.MaPhieuBanHang = obj.MaPhieuBanHang; chiTietPhieuBanHang.MaHangHoa = obj.MaHangHoa; chiTietPhieuBanHang.SoLuong = obj.SoLuong; chiTietPhieuBanHang.Gia = obj.Gia; chiTietPhieuBanHang.ThanhTien = obj.ThanhTien; if (db.ChiTietPhieuBanHangs.Any(e => e.MaChiTietPhieuBan == chiTietPhieuBanHang.MaChiTietPhieuBan)) { db.ChiTietPhieuBanHangs.Attach(chiTietPhieuBanHang); db.Entry(chiTietPhieuBanHang).State = System.Data.Entity.EntityState.Modified; if (db.SaveChanges() > 0) { return(true); } return(false); } db.ChiTietPhieuBanHangs.Add(chiTietPhieuBanHang); if (db.SaveChanges() > 0) { return(true); } return(false); } }
public bool update(DTO_HangHoa obj) { using (CellphoneComponentEntities db = new CellphoneComponentEntities()) { var resultMaLoaiHangHoa = db.Database .SqlQuery <String>("select MaLoaiHangHoa from dbo.LoaiHangHoa where TenLoaiHangHoa = N'" + obj.TenLoaiHangHoa + "'") .FirstOrDefault(); HangHoa hanghoa = new HangHoa(); hanghoa.MaHangHoa = obj.MaHangHoa; hanghoa.TenHangHoa = obj.TenHangHoa; hanghoa.GiaBan = obj.GiaBan; hanghoa.GiamGia = obj.GiamGia; hanghoa.SoLuongTon = obj.SoLuongTon; hanghoa.DonViTinh = obj.DonViTinh; hanghoa.MoTa = obj.MoTa; hanghoa.ThongSoKyThuat = obj.ThongSoKyThuat; hanghoa.XuatXu = obj.XuatXu; hanghoa.ThoiGianBaoHang = obj.ThoiGianBaoHang; hanghoa.HinhAnh = obj.HinhAnh; hanghoa.MaLoaiHangHoa = resultMaLoaiHangHoa; hanghoa.TrangThai = obj.TrangThai; hanghoa.TenModel = obj.TenModel; db.HangHoas.Attach(hanghoa); db.Entry(hanghoa).State = System.Data.Entity.EntityState.Modified; if (db.SaveChanges() > 0) { return(true); } return(false); } }
public void update(DTO_PhieuBaoHanh obj) { using (CellphoneComponentEntities db = new CellphoneComponentEntities()) { var resultMaNhanVien = db.Database .SqlQuery <String>("select MaNhanVien from dbo.NhanVien where TenNhanVien = N'" + obj.TenNhanVien + "'") .FirstOrDefault(); var resultMaHangHoa = db.Database .SqlQuery <String>("select MaHangHoa from dbo.HangHoa where TenHangHoa = N'" + obj.TenHangHoa + "'") .FirstOrDefault(); PhieuBaoHanh item = new PhieuBaoHanh(); item.MaPhieuBaoHanh = obj.MaPhieuBaoHanh; item.NgayLap = obj.NgayLap; item.NgayGiao = obj.NgayGiao; item.MaNhanVien = resultMaNhanVien; item.TenKhachHang = obj.TenKhachHang; item.SoDienThoai = obj.SoDienThoai; item.TongTien = obj.TongTien; item.GhiChu = obj.GhiChu; item.DaGiao = obj.DaGiao; item.NgayChinhSua = obj.NgayChinhSua; item.MaHangHoa = resultMaHangHoa; db.PhieuBaoHanhs.Attach(item); db.Entry(item).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } }
public bool insert(DTO_PhieuDatHang obj) { using (CellphoneComponentEntities db = new CellphoneComponentEntities()) { var resultMaNhanVien = db.Database .SqlQuery <String>("select MaNhanVien from dbo.NhanVien where TenNhanVien = N'" + obj.TenNhanVien + "'") .FirstOrDefault(); var resultMaNhaCungCap = db.Database .SqlQuery <String>("select MaNhaCungCap from dbo.NhaCungCap where TenNhaCungCap = N'" + obj.TenNhaCungCap + "'") .FirstOrDefault(); PhieuDatHang phieuDatHang = new PhieuDatHang(); phieuDatHang.MaPhieuDatHang = obj.MaPhieuDatHang; phieuDatHang.MaNhaCungCap = resultMaNhaCungCap; phieuDatHang.MaNhanVien = resultMaNhanVien; phieuDatHang.NgayChinhSua = obj.NgayChinhSua; phieuDatHang.NgayDat = obj.NgayDat; phieuDatHang.TongTien = obj.TongTien; phieuDatHang.GhiChu = obj.GhiChu; db.PhieuDatHangs.Add(phieuDatHang); if (db.SaveChanges() > 0) { return(true); } return(false); } }
public bool InsertPBH(DTO_PhieuBanHang obj) { using (CellphoneComponentEntities db = new CellphoneComponentEntities()) { var result = db.Database .SqlQuery <String>("select MaNhanVien from dbo.NhanVien where TenNhanVien = N'" + obj.TenNhanVien + "'") .FirstOrDefault(); PhieuBanHang phieuBanHang = new PhieuBanHang(); phieuBanHang.MaPhieuBanHang = obj.MaPhieuBanHang; phieuBanHang.NgayBan = obj.NgayBan; phieuBanHang.MaNhanVien = result; phieuBanHang.TenKhachHang = obj.TenKhachHang; phieuBanHang.SoDienThoai = obj.SoDienThoai; phieuBanHang.TongTien = obj.TongTien; phieuBanHang.GhiChu = obj.GhiChu; phieuBanHang.NgayChinhSua = obj.NgayChinhSua; db.PhieuBanHangs.Add(phieuBanHang); if (db.SaveChanges() > 0) { return(true); } return(false); } }
public void delete(String id) { using (CellphoneComponentEntities db = new CellphoneComponentEntities()) { ChiTietPhieuNhap ctpn = (from item in db.ChiTietPhieuNhaps where item.MaChiTietPhieuNhap == id select item).SingleOrDefault(); db.ChiTietPhieuNhaps.Remove(ctpn); db.SaveChanges(); } }
public void DeleteNCC(DTO_NhaCungCap obj) { using (CellphoneComponentEntities db = new CellphoneComponentEntities()) { NhaCungCap ncc = (from item in db.NhaCungCaps where item.MaNhaCungCap == obj.MaNhaCungCap select item).SingleOrDefault(); db.NhaCungCaps.Remove(ncc); db.SaveChanges(); } }
public void DeletePC(String id) { using (CellphoneComponentEntities db = new CellphoneComponentEntities()) { PhieuChi nv = (from item in db.PhieuChis where item.MaPhieuChi == id select item).SingleOrDefault(); db.PhieuChis.Remove(nv); db.SaveChanges(); } }
public void delete(String id) { using (CellphoneComponentEntities db = new CellphoneComponentEntities()) { PhieuNhap phieunhap = (from item in db.PhieuNhaps where item.MaPhieuNhap == id select item).SingleOrDefault(); db.PhieuNhaps.Remove(phieunhap); db.SaveChanges(); } }
public void DeleteBC(DTO_BaoCaoTonKho obj) { using (CellphoneComponentEntities db = new CellphoneComponentEntities()) { BaoCaoTonKho bc = (from item in db.BaoCaoTonKhoes where item.MaBaoCao == obj.MaBaoCao select item).SingleOrDefault(); db.BaoCaoTonKhoes.Remove(bc); db.SaveChanges(); } }
public void delete(String id) { using (CellphoneComponentEntities db = new CellphoneComponentEntities()) { PhieuBaoHanh pbh = (from item in db.PhieuBaoHanhs where item.MaPhieuBaoHanh == id select item).SingleOrDefault(); db.PhieuBaoHanhs.Remove(pbh); db.SaveChanges(); } }
public void InsertNCC(DTO_NhaCungCap obj) { using (CellphoneComponentEntities db = new CellphoneComponentEntities()) { this.MaNhaCungCap = obj.MaNhaCungCap; this.TenNhaCungCap = obj.TenNhaCungCap; this.Email = obj.Email; this.DiaChi = obj.DiaChi; this.SoDienThoai = obj.SoDienThoai; db.NhaCungCaps.Add(this); db.SaveChanges(); } }
public void UpdateNCC(DTO_NhaCungCap obj) { using (CellphoneComponentEntities db = new CellphoneComponentEntities()) { this.MaNhaCungCap = obj.MaNhaCungCap; this.TenNhaCungCap = obj.TenNhaCungCap; this.Email = obj.Email; this.DiaChi = obj.DiaChi; this.SoDienThoai = obj.SoDienThoai; db.NhaCungCaps.Attach(this); db.Entry(this).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } }
public bool delete(String id) { using (CellphoneComponentEntities db = new CellphoneComponentEntities()) { LoaiHangHoa loaiHangHoa = (from item in db.LoaiHangHoas where item.MaLoaiHangHoa == id select item).SingleOrDefault(); db.LoaiHangHoas.Remove(loaiHangHoa); if (db.SaveChanges() > 0) { return(true); } return(false); } }
public bool DeletePBH(String id) { using (CellphoneComponentEntities db = new CellphoneComponentEntities()) { PhieuBanHang phieuBanHang = (from item in db.PhieuBanHangs where item.MaPhieuBanHang == id select item).SingleOrDefault(); db.PhieuBanHangs.Remove(phieuBanHang); if (db.SaveChanges() > 0) { return(true); } return(false); } }
public bool delete(String id) { using (CellphoneComponentEntities db = new CellphoneComponentEntities()) { ChiTietPhieuDatHang chiTietPhieuDatHang = (from item in db.ChiTietPhieuDatHangs where item.MaChiTietPhieuDat == id select item).SingleOrDefault(); db.ChiTietPhieuDatHangs.Remove(chiTietPhieuDatHang); if (db.SaveChanges() > 0) { return(true); } return(false); } }
public bool insert(DTO_LoaiHangHoa obj) { using (CellphoneComponentEntities db = new CellphoneComponentEntities()) { LoaiHangHoa loaiHangHoa = new LoaiHangHoa(); loaiHangHoa.MaLoaiHangHoa = obj.MaLoaiHangHoa; loaiHangHoa.TenLoaiHangHoa = obj.TenLoaiHangHoa; loaiHangHoa.PhanTramLoiNhuan = obj.PhanTramLoiNhuan; db.LoaiHangHoas.Add(loaiHangHoa); if (db.SaveChanges() > 0) { return(true); } return(false); } }
public bool update(DTO_LoaiHangHoa obj) { using (CellphoneComponentEntities db = new CellphoneComponentEntities()) { LoaiHangHoa loaiHangHoa = new LoaiHangHoa(); loaiHangHoa.MaLoaiHangHoa = obj.MaLoaiHangHoa; loaiHangHoa.TenLoaiHangHoa = obj.TenLoaiHangHoa; loaiHangHoa.PhanTramLoiNhuan = obj.PhanTramLoiNhuan; db.LoaiHangHoas.Attach(loaiHangHoa); db.Entry(loaiHangHoa).State = System.Data.Entity.EntityState.Modified; if (db.SaveChanges() > 0) { return(true); } return(false); } }
public void InsertNV(DTO_NhanVien obj) { using (CellphoneComponentEntities db = new CellphoneComponentEntities()) { var result = db.Database .SqlQuery <String>("select MaPhanQuyen from dbo.PhanQuyen where TenPhanQuyen = N'" + obj.TenPhanQuyen + "'") .FirstOrDefault(); NhanVien nhanVien = new NhanVien(); nhanVien.MaNhanVien = obj.MaNhanVien; nhanVien.TenNhanVien = obj.TenNhanVien; nhanVien.UserName = obj.UserName; nhanVien.Password = obj.Password; nhanVien.MaPhanQuyen = result; nhanVien.TrangThai = obj.TrangThai; db.NhanViens.Add(nhanVien); db.SaveChanges(); } }
public void insert(DTO_ChiTietPhieuNhap obj) { using (CellphoneComponentEntities db = new CellphoneComponentEntities()) { var resultMaHangHoa = db.Database .SqlQuery <String>("select MaHangHoa from dbo.HangHoa where TenHangHoa = N'" + obj.TenHangHoa + "'") .FirstOrDefault(); ChiTietPhieuNhap ctpn = new ChiTietPhieuNhap(); ctpn.MaChiTietPhieuNhap = obj.MaChiTietPhieuNhap; ctpn.MaHangHoa = resultMaHangHoa; ctpn.MaPhieuNhap = obj.MaPhieuNhap; ctpn.SoLuong = obj.SoLuong; ctpn.GiaNhap = obj.GiaNhap; ctpn.ThanhTien = obj.ThanhTien; db.ChiTietPhieuNhaps.Add(ctpn); db.SaveChanges(); } }
public void InsertPC(DTO_PhieuChi obj) { using (CellphoneComponentEntities db = new CellphoneComponentEntities()) { var result = db.Database .SqlQuery <String>("select MaNhanVien from dbo.NhanVien where TenNhanVien = N'" + obj.TenNhanVien + "'") .FirstOrDefault(); PhieuChi phieuChi = new PhieuChi(); phieuChi.MaPhieuChi = obj.MaPhieuChi; phieuChi.NgayChi = obj.NgayChi; phieuChi.NgayChinhSua = obj.NgayChinhSua; phieuChi.MaPhieuNhap = obj.MaPhieuNhap; phieuChi.GhiChu = obj.GhiChu; phieuChi.TongTienChi = obj.TongTienChi; phieuChi.MaNhanVien = result; db.PhieuChis.Add(phieuChi); db.SaveChanges(); } }
public bool checkExist(String username, String password, String passwordNew) { using (CellphoneComponentEntities db = new CellphoneComponentEntities()) { var result = (from s in db.NhanViens where s.UserName == username && s.Password == password select s).Count(); if (result != 0) { var item = db.NhanViens.SingleOrDefault(nv => nv.UserName == username); item.Password = passwordNew; db.SaveChanges(); return(true); } else { return(false); } } }
public void update(DTO_ChiTietPhieuNhap obj) { using (CellphoneComponentEntities db = new CellphoneComponentEntities()) { var resultMaHangHoa = db.Database .SqlQuery <String>("select MaHangHoa from dbo.HangHoa where TenHangHoa = N'" + obj.TenHangHoa + "'") .FirstOrDefault(); ChiTietPhieuNhap ctpn = new ChiTietPhieuNhap(); ctpn.MaChiTietPhieuNhap = obj.MaChiTietPhieuNhap; ctpn.MaHangHoa = resultMaHangHoa; ctpn.MaPhieuNhap = obj.MaPhieuNhap; ctpn.SoLuong = obj.SoLuong; ctpn.GiaNhap = obj.GiaNhap; ctpn.ThanhTien = obj.ThanhTien; db.ChiTietPhieuNhaps.Attach(ctpn); db.Entry(obj).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } }
public bool InsertCTPBH(DTO_ChiTietPhieuBanHang obj) { using (CellphoneComponentEntities db = new CellphoneComponentEntities()) { ChiTietPhieuBanHang chiTietPhieuBanHang = new ChiTietPhieuBanHang(); chiTietPhieuBanHang.MaChiTietPhieuBan = obj.MaChiTietPhieuBan; chiTietPhieuBanHang.MaPhieuBanHang = obj.MaPhieuBanHang; chiTietPhieuBanHang.MaHangHoa = obj.MaHangHoa; chiTietPhieuBanHang.SoLuong = obj.SoLuong; chiTietPhieuBanHang.Gia = obj.Gia; chiTietPhieuBanHang.ThanhTien = obj.ThanhTien; db.ChiTietPhieuBanHangs.Add(chiTietPhieuBanHang); if (db.SaveChanges() > 0) { return(true); } return(false); } }
public void InsertBC(DTO_BaoCaoTonKho obj) { using (CellphoneComponentEntities db = new CellphoneComponentEntities()) { var result = db.Database .SqlQuery <String>("select MaHangHoa from dbo.HangHoa where TenHangHoa = N'" + obj.TenHangHoa + "'") .FirstOrDefault(); BaoCaoTonKho bc = new BaoCaoTonKho(); bc.MaBaoCao = obj.MaBaoCao; bc.MaHangHoa = result; bc.Nam = obj.Nam; bc.Thang = obj.Thang; bc.SoLuongNhap = obj.SoLuongNhap; bc.SoLuongXuat = obj.SoLuongXuat; bc.SoLuongTonDau = obj.SoLuongTonDau; bc.SoLuongTonCuoi = obj.SoLuongTonCuoi; db.BaoCaoTonKhoes.Add(bc); db.SaveChanges(); } }
public void insert(DTO_PhieuNhap obj) { using (CellphoneComponentEntities db = new CellphoneComponentEntities()) { var resultMaNhanVien = db.Database .SqlQuery <String>("select MaNhanVien from dbo.NhanVien where TenNhanVien = N'" + obj.TenNhanVien + "'") .FirstOrDefault(); var resultMaNhaCungCap = db.Database .SqlQuery <String>("select MaNhaCungCap from dbo.NhaCungCap where TenNhaCungCap = N'" + obj.TenNhaCungCap + "'") .FirstOrDefault(); PhieuNhap phieuNhap = new PhieuNhap(); phieuNhap.MaPhieuNhap = obj.MaPhieuNhap; phieuNhap.MaNhaCungCap = resultMaNhaCungCap; phieuNhap.MaNhanVien = resultMaNhanVien; phieuNhap.NgayChinhSua = obj.NgayChinhSua; phieuNhap.NgayNhap = obj.NgayNhap; phieuNhap.TongTien = obj.TongTien; phieuNhap.GhiChu = obj.GhiChu; db.PhieuNhaps.Add(phieuNhap); db.SaveChanges(); } }
public bool insert(DTO_ChiTietPhieuDatHang obj) { using (CellphoneComponentEntities db = new CellphoneComponentEntities()) { var resultMaHangHoa = db.Database .SqlQuery <String>("select MaHangHoa from dbo.HangHoa where TenHangHoa = N'" + obj.TenHangHoa + "'") .FirstOrDefault(); ChiTietPhieuDatHang chiTietPhieuDatHang = new ChiTietPhieuDatHang(); chiTietPhieuDatHang.MaChiTietPhieuDat = obj.MaChiTietPhieuDat; chiTietPhieuDatHang.MaHangHoa = resultMaHangHoa; chiTietPhieuDatHang.MaPhieuDatHang = obj.MaPhieuDatHang; chiTietPhieuDatHang.SoLuong = obj.SoLuong; chiTietPhieuDatHang.Gia = obj.Gia; chiTietPhieuDatHang.ThanhTien = obj.ThanhTien; db.ChiTietPhieuDatHangs.Add(chiTietPhieuDatHang); if (db.SaveChanges() > 0) { return(true); } return(false); } }