public bool Compare(T_RoomTime value) { using (AttMonSysRFIDDataContext dc = new AttMonSysRFIDDataContext(SystemConnection.ConnectionString)) { return(dc.T_RoomTimes.Where(x => x.RoomCode == value.RoomCode && x.TimeCode == value.TimeCode).FirstOrDefault() == null ? true : false); } }
void DeleteTime() { using (Maintenance maintain = new Maintenance()) { T_RoomTime value = new T_RoomTime(); value.RoomCode = txtRoomCode.Text; maintain.Delete(value); } }
public void Delete(T_RoomTime value) { List <T_RoomTime> valuedelete = new List <T_RoomTime>(); using (AttMonSysRFIDDataContext dc = new AttMonSysRFIDDataContext(SystemConnection.ConnectionString)) { valuedelete = dc.T_RoomTimes.Where(x => x.RoomCode == value.RoomCode).ToList(); dc.T_RoomTimes.DeleteAllOnSubmit(valuedelete); dc.SubmitChanges(); } }
void SaveTime() { T_RoomTime value = new T_RoomTime(); using (Maintenance maintain = new Maintenance()) { for (int i = 0; i <= dgTime.Rows.Count - 1; i++) { value.ID = Convert.ToInt64(dgTime.Rows[0].Cells[0].Value.ToString()); value.RoomCode = txtRoomCode.Text; value.Status = Convert.ToBoolean(dgTime.Rows[i].Cells[3].Value.ToString()); value.TimeCode = dgTime.Rows[i].Cells[4].Value.ToString(); maintain.Save(value); } } }
public void Save(T_RoomTime value) { T_RoomTime valueupdate = new T_RoomTime(); using (AttMonSysRFIDDataContext dc = new AttMonSysRFIDDataContext(SystemConnection.ConnectionString)) { if (Compare(value)) { dc.T_RoomTimes.InsertOnSubmit(value); } else { valueupdate = dc.T_RoomTimes.Where(x => x.ID == value.ID).FirstOrDefault(); valueupdate.RoomCode = value.RoomCode; valueupdate.TimeCode = value.TimeCode; valueupdate.Status = value.Status; } dc.SubmitChanges(); } }