public bool editSP(string id, string ten, string hinhanh, string maloai, string mancc) { db = new CMART8Entities(); SANPHAM SP = db.SANPHAMs.Single(st => st.MASP.Equals(id)); try { if (maloai != SP.MALOAI) { LOAISANPHAM lsp1 = db.LOAISANPHAMs.Single(st => st.MALOAI.Equals(maloai)); LOAISANPHAM lsp2 = db.LOAISANPHAMs.Single(st => st.MALOAI.Equals(SP.MALOAI)); SP.TENSP = ten; SP.HINHANH = hinhanh; SP.MALOAI = maloai; SP.MANCC = mancc; lsp2.SOLUONGSP = lsp2.SOLUONGSP - 1; lsp1.SOLUONGSP = lsp1.SOLUONGSP + 1; db.SaveChanges(); } else { SP.TENSP = ten; SP.HINHANH = hinhanh; SP.MANCC = mancc; db.SaveChanges(); } return(true); } catch (Exception) { return(false); } }
public bool addSP(string mahd, string masp, string sl, string dongia) { db = new CMART8Entities(); try { try { CTHOADON cthd = db.CTHOADONs.Single(st => st.SOHD.Equals(mahd) && st.MASP.Equals(masp)); int dem = int.Parse(cthd.SOLUONG.ToString()) + int.Parse(sl); cthd.SOLUONG = dem; db.SaveChanges(); return(true); } catch { CTHOADON cthd = new CTHOADON(); cthd.SOHD = mahd; cthd.MASP = masp; cthd.DONGIA = float.Parse(dongia); cthd.SOLUONG = int.Parse(sl); db.CTHOADONs.Add(cthd); db.SaveChanges(); return(true); } } catch { return(false); } }
public bool addTTKM(string masp, float giakm, DateTime tgbd, DateTime tgkt, string noidung, string hinhanh) { db = new CMART8Entities(); KHUYENMAI TTKM = new KHUYENMAI(); try { TTKM.MAKM = DateTime.Now.ToString(); TTKM.MASP = masp; TTKM.GIAKM = giakm; TTKM.HINHANH = hinhanh; //TTKM.THOIGIANBD = DateTime.Parse(tgbd); //TTKM.THOIGIANKT = DateTime.Parse(tgkt); TTKM.THOIGIANBD = tgbd; TTKM.THOIGIANKT = tgkt; TTKM.NOIDUNG = noidung; db.KHUYENMAIs.Add(TTKM); db.SaveChanges(); return(true); } catch (Exception) { return(false); } }
public bool deleteTTKM(String id) { db = new CMART8Entities(); KHUYENMAI TTKM = db.KHUYENMAIs.Single(st => st.MAKM.Contains(id)); db.KHUYENMAIs.Remove(TTKM); db.SaveChanges(); return(true); }
public bool deleteTK(string ID) { db = new CMART8Entities(); TAIKHOAN TK = db.TAIKHOANs.ToList().Single(st => st.MATK.Equals(ID)); db.TAIKHOANs.Remove(TK); db.SaveChanges(); return(true); }
public bool deleteLSG(string ID, string gia, string ngayhl) { db = new CMART8Entities(); LICHSUGIA LSG = db.LICHSUGIAs.ToList().Single(st => st.MASP.Equals(ID) && st.GIABAN.ToString().Equals(gia) && st.NGAYHIEULUC.ToString().Equals(ngayhl)); db.LICHSUGIAs.Remove(LSG); db.SaveChanges(); return(true); }
public void deleteListCTNHTS(string sophieuts) { db = new CMART8Entities(); List <CTPHIEUNHAPHANGTRUSO> tmp = db.CTPHIEUNHAPHANGTRUSOes.Where(x => x.SOPHIEUNHTS.Equals(sophieuts)).ToList(); foreach (CTPHIEUNHAPHANGTRUSO p in tmp) { db.CTPHIEUNHAPHANGTRUSOes.Remove(p); } db.SaveChanges(); }
public bool deleteHD(string sohd) { db = new CMART8Entities(); try { HOADON HD = db.HOADONs.Single(st => st.SOHD.Equals(sohd)); List <CTHOADON> cthd = db.CTHOADONs.Where(st => st.SOHD.Equals(sohd)).ToList(); foreach (CTHOADON tmp in cthd) { db.CTHOADONs.Remove(tmp); } db.SaveChanges(); db.HOADONs.Remove(HD); db.SaveChanges(); return(true); } catch { return(false); } }
public PHIEUNHAPHANGCHINHANH createNHCN(TAIKHOAN tk) { db = new CMART8Entities(); PHIEUNHAPHANGCHINHANH pnh = new PHIEUNHAPHANGCHINHANH(); pnh.SOPHIEU = autoID(); pnh.NGAYNHAP = DateTime.Now; pnh.MATK = tk.MATK; db.PHIEUNHAPHANGCHINHANHs.Add(pnh); db.SaveChanges(); return(pnh); }
public PHIEUNHAPHANGTRUSO createNHTS(string matk) { db = new CMART8Entities(); string id = autoID(); PHIEUNHAPHANGTRUSO nhts = new PHIEUNHAPHANGTRUSO(); nhts.SOPHIEU = id; nhts.MATK = matk; nhts.NGAYNHAP = DateTime.Now; db.PHIEUNHAPHANGTRUSOes.Add(nhts); db.SaveChanges(); return(nhts); }
public bool deleteSP(string sohd, string masp) { db = new CMART8Entities(); try { CTHOADON cthd = db.CTHOADONs.Single(st => st.SOHD.Equals(sohd) && st.MASP.Equals(masp)); db.CTHOADONs.Remove(cthd); db.SaveChanges(); return(true); } catch { return(false); } }
//Delete PN public bool deletePN(PHIEUNHAPHANGTRUSO PN) { try { db = new CMART8Entities(); PHIEUNHAPHANGTRUSO pn = db.PHIEUNHAPHANGTRUSOes.Find(PN.SOPHIEU); db.PHIEUNHAPHANGTRUSOes.Remove(pn); db.SaveChanges(); return(true); } catch { return(false); } }
public bool deleteNCC(String id) { try { db = new CMART8Entities(); NHACUNGCAP ncc = db.NHACUNGCAPs.Single(st => st.MANCC.Contains(id)); db.NHACUNGCAPs.Remove(ncc); db.SaveChanges(); return(true); } catch { return(false); } }
public bool deleteLSP(String id) { try { db = new CMART8Entities(); LOAISANPHAM LSP = db.LOAISANPHAMs.Single(st => st.MALOAI.Contains(id)); db.LOAISANPHAMs.Remove(LSP); db.SaveChanges(); return(true); } catch { return(false); } }
//add list Chi tiết phiếu nhập hàng trụ sở public bool addListCTNHTS(List <CTPHIEUNHAPHANGTRUSO> list) { try { db = new CMART8Entities(); foreach (CTPHIEUNHAPHANGTRUSO item in list) { db.CTPHIEUNHAPHANGTRUSOes.Add(item); } db.SaveChanges(); return(true); } catch { return(false); } }
//update Phieu nhap hang tru so public bool updatePNHTS(PHIEUNHAPHANGTRUSO PN, string tongTien, string soPhieuDX) { try { db = new CMART8Entities(); PHIEUNHAPHANGTRUSO pn = db.PHIEUNHAPHANGTRUSOes.Find(PN.SOPHIEU); pn.TONGTIEN = ulong.Parse(tongTien); pn.SOPHIEUDX = soPhieuDX; db.Entry(pn).State = System.Data.EntityState.Modified; db.SaveChanges(); return(true); } catch { return(false); } }
public bool editLSP(string id, string ten) { db = new CMART8Entities(); LOAISANPHAM LSP = db.LOAISANPHAMs.Single(st => st.MALOAI.Equals(id)); try { LSP.TENLOAI = ten; db.SaveChanges(); return(true); } catch (Exception) { return(false); } }
//Update Phiếu nhập hàng chi nhánh public bool updatePNHTS(PHIEUNHAPHANGCHINHANH PN, string sophieuTS, string chinhanh) { try { db = new CMART8Entities(); PHIEUNHAPHANGCHINHANH pn = db.PHIEUNHAPHANGCHINHANHs.Find(PN.SOPHIEU); pn.SOPHIEUNHTS = sophieuTS; pn.CHINHANH = chinhanh; db.Entry(pn).State = System.Data.EntityState.Modified; db.SaveChanges(); return(true); } catch { return(false); } }
public bool deleteSP(String id) { try { db = new CMART8Entities(); SANPHAM SP = db.SANPHAMs.Single(st => st.MASP.Contains(id)); LOAISANPHAM lsp = db.LOAISANPHAMs.Single(st => st.MALOAI.Equals(SP.MALOAI)); db.SANPHAMs.Remove(SP); lsp.SOLUONGSP = lsp.SOLUONGSP - 1; db.SaveChanges(); return(true); } catch { return(false); } }
public bool updateHD(string id, string tongtien, string tienkh, string tientra, string tongsl) { try { db = new CMART8Entities(); HOADON hd = db.HOADONs.Single(st => st.SOHD.Equals(id)); hd.TONGTIEN = tongtien; hd.TIENKHACHDUA = tienkh; hd.TIENKHATRA = tientra; hd.TONGSL = int.Parse(tongsl); db.SaveChanges(); return(true); } catch { return(false); } }
public HOADON createHD(string POS, string maTK) { db = new CMART8Entities(); string id = autoID(); HOADON hd = new HOADON(); hd.SOHD = id; hd.NGAYBAN = DateTime.Now; hd.MATK = maTK; hd.POS = POS; hd.TONGSL = 0; hd.TONGTIEN = "0"; hd.TIENKHACHDUA = "0"; hd.TIENKHATRA = "0"; db.HOADONs.Add(hd); db.SaveChanges(); return(hd); }
public void addCTNHTS(string tmp, PHIEUNHAPHANGTRUSO PN, TAIKHOAN TK) { db = new CMART8Entities(); var ctpdx = db.CTPHIEUDEXUATs.Where(x => x.SOPHIEU.Equals(tmp)).ToList(); foreach (var item in ctpdx) { CTPHIEUNHAPHANGTRUSO nhts = new CTPHIEUNHAPHANGTRUSO(); nhts.SOPHIEUNHTS = PN.SOPHIEU; nhts.MASP = item.MASP; nhts.SOLUONG = item.SOLUONG; nhts.GIANHAP = 0; nhts.HANSD = DateTime.Now.AddMonths(6); nhts.TINHTRANG = "Đủ"; db.CTPHIEUNHAPHANGTRUSOes.Add(nhts); db.SaveChanges(); } }
public bool addLSP(string ten) { db = new CMART8Entities(); LOAISANPHAM LSP = new LOAISANPHAM(); try { LSP.MALOAI = DateTime.Now.ToString(); LSP.TENLOAI = ten; LSP.SOLUONGSP = 0; db.LOAISANPHAMs.Add(LSP); db.SaveChanges(); return(true); } catch (Exception) { return(false); } }
public bool addLSG(string ID, string gia, DateTime ngayhl) { db = new CMART8Entities(); LICHSUGIA LSG = new LICHSUGIA(); try { LSG.MASP = ID; LSG.GIABAN = int.Parse(gia); LSG.NGAYHIEULUC = ngayhl; db.LICHSUGIAs.Add(LSG); db.SaveChanges(); return(true); } catch (Exception) { return(false); } }
public bool addNCC(string ten, string diachi, string sdt) { db = new CMART8Entities(); NHACUNGCAP ncc = new NHACUNGCAP(); try { ncc.MANCC = DateTime.Now.ToString(); ncc.TENNCC = ten; ncc.DIACHI = diachi; ncc.SDT = sdt; db.NHACUNGCAPs.Add(ncc); db.SaveChanges(); return(true); } catch (Exception) { return(false); } }
public bool editNCC(string id, string ten, string diachi, string sdt) { db = new CMART8Entities(); NHACUNGCAP ncc = db.NHACUNGCAPs.Single(st => st.MANCC.Equals(id)); try { ncc.TENNCC = ten; ncc.DIACHI = diachi; ncc.SDT = sdt; db.SaveChanges(); return(true); } catch (Exception) { return(false); } }
public bool editTK(string ID, string hoten, string diachi, string sdt, string cmnd, string tendn, string quyen) { db = new CMART8Entities(); try { TAIKHOAN TK = db.TAIKHOANs.ToList().Single(st => st.MATK.Equals(ID)); TK.HOTEN = hoten; TK.DIACHI = diachi; TK.SDT = sdt; TK.CMND = cmnd; TK.TENDANGNHAP = tendn; TK.QUYEN = quyen; db.SaveChanges(); return(true); } catch (Exception) { return(false); } }
public bool addSP(string ten, string hinhanh, string maloai, string mancc) { db = new CMART8Entities(); SANPHAM SP = new SANPHAM(); LOAISANPHAM lsp = db.LOAISANPHAMs.Single(st => st.MALOAI.Equals(maloai)); try { SP.MASP = DateTime.Now.ToString(); SP.TENSP = ten; SP.HINHANH = hinhanh; SP.MALOAI = maloai; SP.MANCC = mancc; db.SANPHAMs.Add(SP); lsp.SOLUONGSP = lsp.SOLUONGSP + 1; db.SaveChanges(); return(true); } catch (Exception) { return(false); } }
public bool editLSG(string ID, string gia, string ngayhl, string ID2, string gia2, DateTime ngayhl2) { db = new CMART8Entities(); try { LICHSUGIA LSG = db.LICHSUGIAs.ToList().Single(st => st.MASP.Equals(ID) && st.GIABAN.ToString().Equals(gia) && st.NGAYHIEULUC.ToString().Equals(ngayhl)); LICHSUGIA tmp = LSG; db.LICHSUGIAs.Remove(LSG); db.SaveChanges(); db = new CMART8Entities(); tmp.GIABAN = int.Parse(gia2); tmp.NGAYHIEULUC = ngayhl2; tmp.MASP = ID2; db.LICHSUGIAs.Add(tmp); db.SaveChanges(); return(true); } catch (Exception) { return(false); } }
public bool editTTKM(string makm, string masp, float giakm, DateTime tgbd, DateTime tgkt, string noidung, string hinhanh) { db = new CMART8Entities(); KHUYENMAI TTKM = db.KHUYENMAIs.Single(st => st.MAKM.Equals(makm)); try { TTKM.MASP = masp; TTKM.GIAKM = giakm; TTKM.HINHANH = hinhanh; //TTKM.THOIGIANBD = DateTime.Parse(tgbd); //TTKM.THOIGIANKT = DateTime.Parse(tgkt); TTKM.THOIGIANBD = tgbd; TTKM.THOIGIANKT = tgkt; TTKM.NOIDUNG = noidung; db.SaveChanges(); return(true); } catch (Exception) { return(false); } }