public bool SuaCTHDN(int MaHDN, int MaSP, int MaMau, int MaSize, int SoLuong, decimal DonGia) { try { using (DBGiayDepEntities db = new DBGiayDepEntities()) { var item = db.CTHDNs.Single(p => p.MaHDN == MaHDN && p.MaSP == MaSP); if (item != null) { item.MaMau = MaMau; item.MaSize = MaSize; item.SL = SoLuong; item.GiaNhap = (decimal)DonGia; db.SaveChanges(); return true; } return false; } } catch (Exception e) { Debug.WriteLine(e); return false; } }
public bool DuyetHD(int MaHDN) { try { using (DBGiayDepEntities db = new DBGiayDepEntities()) { var item = db.HDNhaps.SingleOrDefault(p => p.MaHDN == MaHDN); if (item != null) { item.TinhTrang = 1; db.SaveChanges(); return true; } return false; } } catch (Exception e) { Debug.WriteLine(e); return false; } }
public bool SuaLoai(int MaLoai, string TenLoai) { try { using (DBGiayDepEntities db = new DBGiayDepEntities()) { var item = db.Loais.Single(p => p.MaLoai == MaLoai); if (item != null) { item.TenLoai = TenLoai; db.SaveChanges(); return true; } return false; } } catch (Exception e) { Debug.WriteLine(e); return false; } }
public bool CapNhatBanHang(int MaSP, int Mau, int MaSize, int Soluong) { try { using (DBGiayDepEntities db = new DBGiayDepEntities()) { var item = db.Khoes.SingleOrDefault(p => p.MaSP == MaSP && p.MaMau == Mau && p.MaSize == MaSize); if (item != null) { item.SL = item.SL - Soluong; db.SaveChanges(); return true; } return false; } } catch (Exception e) { Debug.WriteLine(e); return false; } }
public bool SuaMau(int MaMau, string Mau) { try { using (DBGiayDepEntities db = new DBGiayDepEntities()) { var item = db.Maus.Single(p => p.MaMau == MaMau); if (item != null) { item.TenMau = Mau; db.SaveChanges(); return true; } return false; } } catch (Exception e) { Debug.WriteLine(e); return false; } }
public bool SuaSize(int MaSize, int TenSize) { try { using (DBGiayDepEntities db = new DBGiayDepEntities()) { var item = db.Sizes.SingleOrDefault(p => p.MaSize == MaSize); if (item != null) { item.Size1 = TenSize; db.SaveChanges(); return true; } return false; } } catch (Exception e) { Debug.WriteLine(e); return false; } }
public bool ThemSize(int TenSize) { Size s = new Size(); s.Size1 = TenSize; try { using (DBGiayDepEntities db = new DBGiayDepEntities()) { db.Sizes.Add(s); db.SaveChanges(); return true; } } catch (Exception e) { Debug.WriteLine(e); return false; } }
public bool ThemKhachHang(string HoTen, DateTime NgaySinh, string Email, string MatKhau, string SDT, string DiaChi, string GioiTinh) { KhachHang kh = new KhachHang(); kh.HoTen = HoTen; kh.NgaySinh = NgaySinh; kh.Email = Email; kh.MatKhau = MatKhau; kh.SDT = SDT; kh.DiaChi = DiaChi; kh.GioiTinh = GioiTinh; kh.NgayDangKi = DateTime.Now; try { using (DBGiayDepEntities db = new DBGiayDepEntities()) { //Lưu add kh mới vào model db.KhachHangs.Add(kh); //Lưu vào CSDL db.SaveChanges(); return true; } } catch (Exception e) { Debug.WriteLine(e); return false; } }
public bool XoaSanPham(int MaSP) { try { using (DBGiayDepEntities db = new DBGiayDepEntities()) { var SpDelete = db.SanPhams.SingleOrDefault(p => p.MaSP == MaSP); if (SpDelete != null) { SpDelete.TrangThai = 0; db.SaveChanges(); return true; } return false; } } catch (Exception e) { Debug.WriteLine(e); return false; } }
public bool ThemSanPham(string TenSP, int MaLoai, string ThuongHieu, string HinhAnh, string MoTa, int MaKM, DateTime NgayDang, string MoTaCT) { SanPham sanpham = new SanPham(); sanpham.TenSP = TenSP; sanpham.MaLoai = (int)MaLoai; sanpham.ThuongHieu = ThuongHieu; sanpham.HinhAnh = HinhAnh; sanpham.MoTa = MoTa; sanpham.MaKM = (int)MaKM; sanpham.NgayDang = NgayDang; sanpham.MoTaCT = MoTaCT; try { using (DBGiayDepEntities db = new DBGiayDepEntities()) { //Lưu add sản phẩm mới vào model db.SanPhams.Add(sanpham); //Lưu vào CSDL db.SaveChanges(); return true; } } catch (Exception e) { Debug.WriteLine(e); return false; } }
public bool SuaSanPham(int MaSP, string TenSP, int MaLoai, string ThuongHieu, string HinhAnh, string MoTa, int MaKM, DateTime NgayDang, string MoTaCT) { try { using (DBGiayDepEntities db = new DBGiayDepEntities()) { //Tìm MaSP trong bảng SanPham trong DB var item = db.SanPhams.Single(p => p.MaSP == MaSP); //Nếu có thì lấy các thông tin ra để sửa if (item != null) { item.TenSP = TenSP; item.MaLoai = (int)MaLoai; item.ThuongHieu = ThuongHieu; item.HinhAnh = HinhAnh; item.MoTa = MoTa; item.MaKM = (int)MaKM; item.NgayDang = NgayDang; item.MoTaCT = MoTaCT; db.SaveChanges(); return true; } else return false; } } catch (Exception e) { Debug.WriteLine(e); return false; } }
public bool SuaDH(int MaDH, int TinhTrang) { try { using (DBGiayDepEntities db = new DBGiayDepEntities()) { var item = db.DonHangs.Single(p => p.MaDH == MaDH); if (item != null) { //item.MaKH = MaKH; //item.NgayMua = DateTime.Parse(NgayMua); //item.TongTien = (decimal)TongTien; item.TinhTrang = TinhTrang; //item.NVDuyet = NVDuyet; db.SaveChanges(); return true; } return false; } } catch (Exception e) { Debug.WriteLine(e); return false; } }
public bool XoaNhaCungCap(int MaNCC) { try { using (DBGiayDepEntities db = new DBGiayDepEntities()) { var SpDelete = db.NhaCungCaps.SingleOrDefault(p => p.MaNCC == MaNCC); if (SpDelete != null) { db.NhaCungCaps.Remove(SpDelete); db.SaveChanges(); return true; } return false; } } catch (Exception e) { Debug.WriteLine(e); return false; } }
public bool ThemCTHDN(int MaHDN, int MaSP, int MaMau, int MaSize, int SoLuong, decimal DonGia) { CTHDN CT = new CTHDN(); CT.MaHDN = MaHDN; CT.MaSP = MaSP; CT.MaMau = MaMau; CT.MaSize = MaSize; CT.SL = SoLuong; CT.GiaNhap = (decimal)DonGia; try { using (DBGiayDepEntities db = new DBGiayDepEntities()) { db.CTHDNs.Add(CT); db.SaveChanges(); return true; } } catch (Exception e) { Debug.WriteLine(e); return false; } }
public bool SuaHDN(int MaHDN, int MaNCC, int MaNV, string NgayLap, decimal TongTien, int TinhTrang) { try { using (DBGiayDepEntities db = new DBGiayDepEntities()) { var item = db.HDNhaps.Single(p => p.MaHDN == MaHDN); if (item != null) { item.MaNCC = MaNCC; item.MaNV = MaNV; item.NgayNhap = DateTime.Parse(NgayLap); item.TongTien = (decimal)TongTien; item.TinhTrang = TinhTrang; db.SaveChanges(); return true; } return false; } } catch (Exception e) { Debug.WriteLine(e); return false; } }
public bool ThemLoai(string TenLoai) { Loai loai = new Loai(); loai.TenLoai = TenLoai; try { using (DBGiayDepEntities db = new DBGiayDepEntities()) { db.Loais.Add(loai); db.SaveChanges(); return true; } } catch (Exception e) { Debug.WriteLine(e); return false; } }
public int ThemHDNVaTraVeMaDHN(int MaNCC, int MaNV, string NgayLap, decimal TongTien, int TinhTrang) { int MaHDN = 0; HDNhap HDN = new HDNhap(); HDN.MaNCC = MaNCC; HDN.MaNV = MaNV; HDN.NgayNhap = DateTime.Parse(NgayLap); HDN.TongTien = (decimal)TongTien; HDN.TinhTrang = TinhTrang; try { using (DBGiayDepEntities db = new DBGiayDepEntities()) { db.HDNhaps.Add(HDN); db.SaveChanges(); return MaHDN = HDN.MaHDN; } } catch (Exception e) { Debug.WriteLine(e); return MaHDN; } }
public bool ThemMau(string Mau) { Mau mau = new Mau(); mau.TenMau = Mau; try { using (DBGiayDepEntities db = new DBGiayDepEntities()) { db.Maus.Add(mau); db.SaveChanges(); return true; } } catch (Exception e) { Debug.WriteLine(e); return false; } }
public bool XoaCTHDN(int MaHDN, int MaSP, int MaMau, int MaSize) { try { using (DBGiayDepEntities db = new DBGiayDepEntities()) { var SpDelete = db.CTHDNs.SingleOrDefault(p => p.MaHDN == MaHDN && p.MaSP == MaSP && p.MaSize == MaSize && p.MaMau == MaMau); if (SpDelete != null) { db.CTHDNs.Remove(SpDelete); db.SaveChanges(); return true; } return false; } } catch (Exception e) { Debug.WriteLine(e); return false; } }
public bool ThemNhanVien(string HoTen, string Email, string MatKhau, string DiaChi, string SDT, string CMND, int QuyenAdmin) { NhanVien nv = new NhanVien(); nv.HoTen = HoTen; nv.Email = Email; nv.MatKhau = MatKhau; nv.DiaChi = DiaChi; nv.SDT = SDT; nv.CMND = CMND; nv.QuyenAdmin = QuyenAdmin; try { using (DBGiayDepEntities db = new DBGiayDepEntities()) { db.NhanViens.Add(nv); db.SaveChanges(); return true; } } catch (Exception e) { Debug.WriteLine(e); return false; } }
public bool NhapMoi(int MaSP, int Mau, int MaSize, int Soluong, decimal GiaNhap) { Kho kho = new Kho(); kho.MaSP = MaSP; kho.MaMau = Mau; kho.MaSize = MaSize; kho.SL = Soluong; kho.GiaNhap = GiaNhap; kho.GiaBan = 0; try { using (DBGiayDepEntities db = new DBGiayDepEntities()) { db.Khoes.Add(kho); db.SaveChanges(); return true; } } catch (Exception e) { Debug.WriteLine(e); return false; } }
public int ThemDH(int MaKH, DateTime NgayMua, decimal TongTien, int TinhTrang, string NVDuyet) { DonHang dh = new DonHang(); dh.MaKH = MaKH; dh.NgayMua = (DateTime)NgayMua; dh.TongTien = (decimal)TongTien; dh.TinhTrang = TinhTrang; dh.NVDuyet = NVDuyet; try { using (DBGiayDepEntities db = new DBGiayDepEntities()) { db.DonHangs.Add(dh); db.SaveChanges(); return dh.MaDH; } } catch (Exception e) { Debug.WriteLine(e); return 0; } }
public bool ThemNhaCungCap(string TenNCC, string DiaChi, string SDT, string SoTK) { NhaCungCap ncc = new NhaCungCap(); ncc.TenNCC = TenNCC; ncc.DiaChi = DiaChi; ncc.SDT = SDT; ncc.SoTK = SoTK; try { using (DBGiayDepEntities db = new DBGiayDepEntities()) { db.NhaCungCaps.Add(ncc); db.SaveChanges(); return true; } } catch (Exception e) { Debug.WriteLine(e); return false; } }
public bool CapNhatGiaBanMoi(int MaSP, int MaMau, decimal GiaBan) { try { using (DBGiayDepEntities db = new DBGiayDepEntities()) { var item = db.Khoes.Where(p => p.MaSP == MaSP && p.MaMau == MaMau).ToList(); if (item != null) { for (int i = 0; i < item.Count; i++) item[i].GiaBan = GiaBan; db.SaveChanges(); return true; } else return false; } } catch (Exception e) { Debug.WriteLine(e); return false; } }
public bool SuaNhaCungCap(int MaNCC, string TenNCC, string DiaChi, string SDT, string SoTK) { try { using (DBGiayDepEntities db = new DBGiayDepEntities()) { var item = db.NhaCungCaps.Single(p => p.MaNCC == MaNCC); if (item != null) { if (!TenNCC.Equals("")) { item.TenNCC = TenNCC; } if (!DiaChi.Equals("")) { item.DiaChi = DiaChi; } if (!SDT.Equals("")) { item.SDT = SDT; } if (!SoTK.Equals("")) { item.SoTK = SoTK; } db.SaveChanges(); return true; } return false; } } catch (Exception e) { Debug.WriteLine(e); return false; } }
public bool SuaNhanVien(int MaNV, string HoTen, string Email, string MatKhau, string DiaChi, string SDT, string CMND, int QuyenAdmin) { try { using (DBGiayDepEntities db = new DBGiayDepEntities()) { var item = db.NhanViens.Single(p => p.MaNV == MaNV); if (item != null) { if (!HoTen.Equals("")) { item.HoTen = HoTen; } if (!Email.Equals("")) { item.Email = Email; } if (!SDT.Equals("")) { item.SDT = SDT; } if (!CMND.Equals("")) { item.CMND = CMND; } if (!DiaChi.Equals("")) { item.DiaChi = DiaChi; } if (!MatKhau.Equals("")) { item.MatKhau = MatKhau; } item.QuyenAdmin = QuyenAdmin; db.SaveChanges(); return true; } return false; } } catch (Exception e) { Debug.WriteLine(e); return false; } }