public void Save(T_Time value, ref string msg) { T_Time valueupdate = new T_Time(); using (AttMonSysRFIDDataContext dc = new AttMonSysRFIDDataContext(SystemConnection.ConnectionString)) { if (Compare(value)) { if (value.ID == 0) { dc.T_Times.InsertOnSubmit(value); msg = string.Format("{0} " + Environment.NewLine + Environment.NewLine + "{1}" + Environment.NewLine + " {2}" + Environment.NewLine + " {3}", SystemProperties.MessageNotification.Saved, value.TimeCode, value.TimeStart, value.TimeEnd); } else { valueupdate = dc.T_Times.Where(x => x.ID == value.ID).FirstOrDefault(); valueupdate.TimeStart = value.TimeStart; valueupdate.TimeEnd = value.TimeEnd; valueupdate.Active = value.Active; valueupdate.TimeCode = value.TimeCode; msg = string.Format("{0} " + Environment.NewLine + Environment.NewLine + "{1}" + Environment.NewLine + " {2}" + Environment.NewLine + " {3}", SystemProperties.MessageNotification.Updated, value.TimeCode, valueupdate.TimeStart, valueupdate.TimeEnd); } dc.SubmitChanges(); } else { msg = string.Format("{0} " + Environment.NewLine + Environment.NewLine + "{1}" + Environment.NewLine + " {2}" + Environment.NewLine + " {3}", SystemProperties.MessageNotification.Exist, value.TimeCode, value.TimeStart, value.TimeEnd); } } }
public bool Compare(T_Time value) { using (AttMonSysRFIDDataContext dc = new AttMonSysRFIDDataContext(SystemConnection.ConnectionString)) { return(dc.T_Times.Where(x => x.TimeCode.ToLower() == value.TimeCode.ToLower() && x.Active == value.Active && x.TimeStart == value.TimeStart && x.TimeEnd == value.TimeEnd).FirstOrDefault() == null ? true : false); } }
void Save() { if (SystemProperties.ShowMessage.MessageQuestion(SystemProperties.MessageNotification.YouWantToSave, "Time duration") == DialogResult.Yes) { if (!string.IsNullOrWhiteSpace(txtCode.Text)) { using (Maintenance _maintain = new Maintenance()) { T_Time value = new T_Time(); value.ID = isAdd ? 0 : Convert.ToInt64(dgTime.SelectedRows[0].Cells[0].Value.ToString()); value.TimeStart = Convert.ToDateTime(dtStart.Value.ToString()); value.TimeEnd = Convert.ToDateTime(dtEnd.Value.ToString()); value.TimeCode = txtCode.Text; value.Active = cbActive.Checked; _maintain.Save(value, ref MsgReturned); LoadTime(); SystemProperties.ShowMessage.MessageInformation(MsgReturned, "Time duration"); SystemProperties.Cleared(this, false, true, true); } } else { SystemProperties.ShowMessage.MessageError(string.Format("{0}" + Environment.NewLine + Environment.NewLine + "Code", SystemProperties.MessageNotification.CheckInput), "Time duration"); } } }
public void Delete(T_Time value, ref string msg) { T_Time valuedelete = new T_Time(); using (AttMonSysRFIDDataContext dc = new AttMonSysRFIDDataContext(SystemConnection.ConnectionString)) { valuedelete = dc.T_Times.Where(x => x.ID == value.ID).FirstOrDefault(); dc.T_Times.DeleteOnSubmit(valuedelete); dc.SubmitChanges(); msg = string.Format("{0} " + Environment.NewLine + Environment.NewLine + "{1}" + Environment.NewLine + " {2}" + Environment.NewLine + " {3}", SystemProperties.MessageNotification.Deleted, valuedelete.TimeCode, valuedelete.TimeStart, valuedelete.TimeEnd); } }
void Delete() { if (SystemProperties.ShowMessage.MessageQuestion(SystemProperties.MessageNotification.YouWantToDelete, "Time duration") == DialogResult.Yes) { if (!string.IsNullOrWhiteSpace(txtCode.Text)) { T_Time value = new T_Time(); value.ID = Convert.ToInt64(dgTime.SelectedRows[0].Cells[0].Value.ToString()); using (Maintenance _maintain = new Maintenance()) { _maintain.Delete(value, ref MsgReturned); SystemProperties.ShowMessage.MessageInformation(MsgReturned, "Time duration"); LoadTime(); } } else { SystemProperties.ShowMessage.MessageError(SystemProperties.MessageNotification.SelectFirst + "delete", "ime duration"); } } }