public bool themACC(DTO_Account acc) { if (CheckIfExist(acc.UserName)) { return(false); } Account acctemp = new Account(); acctemp.PassWord = acc.PassWord; acctemp.UserName = acc.UserName; acctemp.DisplayName = acc.DisplayName; db.Accounts.InsertOnSubmit(acctemp); db.SubmitChanges(); return(true); }
public bool themKhachHang(DTO_KhachHang khnew) { if (CheckIfExist(khnew.MaKhachHang)) { return(false); } KhachHang khtemp = new KhachHang(); khtemp.Ten_KhachHang = khnew.TenKhachHang; khtemp.DiaChi_KhachHang = khnew.DiaChi; khtemp.Sdt_KhachHang = khnew.SoDienThoai; khtemp.BenhAn_KhachHang = khnew.BenhAn; db.KhachHangs.InsertOnSubmit(khtemp); db.SubmitChanges(); return(true); }
public bool themNhaCC(DTO_NhaCungCap nccnew) { if (CheckIfExist(nccnew.MaNhaCC)) { return(false); } NhaCungCap ncc = new NhaCungCap(); ncc.Ma_NCC = nccnew.MaNhaCC; ncc.Ten_NCC = nccnew.TenNhaCC; ncc.DiaChi_NCC = nccnew.DiaChi; ncc.Sdt_NCC = nccnew.SoDT; ncc.LoaiThuoc_NCC = nccnew.LoaiThuoc; db.NhaCungCaps.InsertOnSubmit(ncc); db.SubmitChanges(); return(true); }
public bool xoaMaHoaDon(string maNCC) { var lit = db.Thuocs.Where(x => x.Ma_NCC.Equals(maNCC)); List <DTO_Thuoc> li = new List <DTO_Thuoc>(); if (lit != null) { foreach (Thuoc th in lit) { DTO_Thuoc t = new DTO_Thuoc(); t.MaThuoc = th.Ma_Thuoc; li.Add(t); } foreach (DTO_Thuoc th in li) { var hdtemp = db.HoaDons.Where(x => x.Ma_Thuoc == th.MaThuoc); if (hdtemp != null) { foreach (HoaDon item in hdtemp) { db.HoaDons.DeleteOnSubmit(item); db.SubmitChanges(); } } } foreach (Thuoc item in lit) { db.Thuocs.DeleteOnSubmit(item); db.SubmitChanges(); } return(true); } return(false); }
public bool themHoaDon(DTO_HoaDon hdnew, DTO_KhachHang khnew, DTO_Thuoc tnew) { if (CheckIfExist(hdnew.MaHoaDon)) { return(false); } HoaDon hdtemp = new HoaDon(); hdtemp.Ma_Thuoc = hdnew.MaThuoc; hdtemp.Ma_KhachHang = hdnew.MaKhach; DateTime date = Convert.ToDateTime(hdnew.NgayLap); hdtemp.NgayLap_HD = date; hdtemp.SoLuong_HD = hdnew.SoLuong; hdtemp.Loai_HD = hdnew.LoaiHoaDon; db.HoaDons.InsertOnSubmit(hdtemp); db.SubmitChanges(); return(true); }