public bool quydoidiem(Entities.KhachHang.KhachHang kh, string maThe) { try { Tbl_TheThanhVien ttv = DB.Tbl_TheThanhViens.Single(record => record.maThe == maThe); ///trường hợp chưa có thẻ thành viên if (ttv == null) { Tbl_TheThanhVien newTheTV = new Tbl_TheThanhVien(); newTheTV.maThe = maThe; newTheTV.maKH = kh.Makh; newTheTV.tongTien = tinhTongTien(); newTheTV.diemTichLuy = (int)newTheTV.tongTien / 1000; DB.Tbl_TheThanhViens.InsertOnSubmit(newTheTV); DB.SubmitChanges(); } else { ttv.diemTichLuy += (int)tinhTongTien() / 1000; DB.SubmitChanges(); } return(true); } catch (Exception) { return(false); } }
public int setDiemTL(string ma, decimal tongTien) { try { Tbl_TheThanhVien ttv = DB.Tbl_TheThanhViens.Where(x => x.maThe == ma).FirstOrDefault(); ttv.tongTien = tongTien; ttv.diemTichLuy = Convert.ToInt16(ttv.tongTien / 10000); return(ttv.diemTichLuy); } catch (Exception) { return(-1); } }
/*public bool Delete(string deleteID) * { * try * { * Tbl_KhachHang deleteRecord = DB.Tbl_KhachHangs.Single(record => record.maKH == deleteID); * * DB.Tbl_KhachHangs.DeleteOnSubmit(deleteRecord); * DB.SubmitChanges(); * * return true; * } * catch { return false; } * }*/ public bool UpdateThe(eThethanhvien updateThe) { try { Tbl_TheThanhVien updateRecord = DB.Tbl_TheThanhViens.Single(record => record.maThe == updateThe.Mathe); updateRecord.maKH = updateThe.Makh; updateRecord.diemTichLuy = Convert.ToInt32(updateThe.Diemtichluy); updateRecord.ngayLap = updateThe.Ngaylap; updateRecord.ngayHetHan = updateThe.Ngayhethan; updateRecord.ghiChu = updateThe.Ghichu; updateRecord.tongTien = Convert.ToDecimal(updateThe.Tongtien); DB.SubmitChanges(); return(true); } catch { return(false); } }
/* private eThethanhvien eThethanhvien() * { * throw new NotImplementedException(); * }*/ public int AddThe(eThethanhvien the) { var mathe = DB.Tbl_TheThanhViens.Where(x => x.maThe == the.Makh).FirstOrDefault(); if (mathe != null) { return(0); } Tbl_TheThanhVien khTmp = new Tbl_TheThanhVien(); khTmp.maThe = the.Mathe; khTmp.maKH = the.Makh; khTmp.tongTien = Convert.ToDecimal(the.Tongtien); khTmp.ngayHetHan = the.Ngayhethan; khTmp.ngayLap = the.Ngaylap; khTmp.ghiChu = the.Ghichu; DB.Tbl_TheThanhViens.InsertOnSubmit(khTmp); DB.SubmitChanges(); return(1); }