public override void Delete() { LongTimeAbsence absence = FocusedEntity; if (absence != null) { if (QuestionMessageYes(GetLocalized("QuestionDeleteLongTimeAbsence"))) { try { ClientEnvironment.LongTimeAbsenceService.DeleteByID(absence.ID); m_absenceList.RemoveEntityById(absence.ID); } catch (ValidationException) { ErrorMessage(GetLocalized("CantDeleteLongTimeAbsence")); return; } catch (EntityException ex) { ProcessEntityException(ex); return; } } UpdateButtonState(); } }
public LongTimeAbsence GetById(long id) { LongTimeAbsence absence = null; _diction.TryGetValue(id, out absence); return(absence); }
private void UpdateButtonState() { LongTimeAbsence absence = FocusedEntity; bi_EditLongTimeAbsence.Enabled = absence != null; bi_DeleteLongTimeAbsence.Enabled = absence != null; }
private void contextMenuStrip1_Opening(object sender, CancelEventArgs e) { LongTimeAbsence absence = FocusedEntity; mi_EditLongtimeAbsence.Enabled = absence != null;; mi_DeleteLongtimeAbsence.Enabled = absence != null;; }
public override bool Commit() { if (IsModified() && IsValid()) { LongTimeAbsence copyAbsence = new LongTimeAbsence(); CopyAbsence(EntityAbsence, copyAbsence); copyAbsence.CodeName = AbsenceName; // if (copyAbsence.IsNew) // copyAbsence = ClientEnvironment.LongTimeAbsenceService.Save(copyAbsence); // else try { copyAbsence = ClientEnvironment.LongTimeAbsenceService.SaveOrUpdate(copyAbsence); CopyAbsence(copyAbsence, EntityAbsence); Modified = true; return(base.Commit()); } catch (DBDuplicateKeyException) { ErrorMessage(GetLocalized("LongTimeAbsenceNameExists")); teAbsenceName.Focus(); return(false); } } else { return(false); } }
LongTimeAbsence GetEntityByRowHandle(int rowHandle) { LongTimeAbsence absence = null; if (gridViewEntities.IsDataRow(rowHandle)) { absence = (LongTimeAbsence)gridViewEntities.GetRow(rowHandle); } return(absence); }
public string GetLongTimeAbbreviation(long id) { LongTimeAbsence absence = LongAbsences.GetById(id);; string result = String.Empty; if (absence != null) { result = (absence.CharID != null) ? absence.CharID : String.Empty; } return(result); }
private void CopyAbsence(LongTimeAbsence source, LongTimeAbsence dest) { Debug.Assert(source != null); Debug.Assert(dest != null); Debug.Assert(!source.Equals(dest)); dest.ID = source.ID; dest.Code = source.Code; dest.CodeName = source.CodeName; dest.Import = source.Import; }
public string GetAbbreviation(long id) { LongTimeAbsence a = GetById(id); String s = String.Empty; if (a != null) { s = a.CharID; } return(s); }
public int?GetColor(long id) { LongTimeAbsence a = GetById(id); int? s = null; if (a != null) { s = a.Color; } return(s); }
private void gridControl_MouseDoubleClick(object sender, MouseEventArgs e) { GridHitInfo info = gridViewEntities.CalcHitInfo(e.X, e.Y); if (info.InRowCell && gridViewEntities.IsDataRow(info.RowHandle)) { LongTimeAbsence entity = GetEntityByRowHandle(info.RowHandle); if (entity != null) { Edit(); } } }
public override void Add() { using (FormLongTimeAbsence newAbsenceForm = new FormLongTimeAbsence()) { LongTimeAbsence newAbsence = new LongTimeAbsence(); newAbsenceForm.Entity = newAbsence; if (newAbsenceForm.ShowDialog() == DialogResult.OK) { m_absenceList.Add(newAbsence); } UpdateButtonState(); } }
public override void Edit() { LongTimeAbsence absence = FocusedEntity; if (absence != null) { using (FormLongTimeAbsence newAbsenceForm = new FormLongTimeAbsence()) { newAbsenceForm.Entity = absence; if (newAbsenceForm.ShowDialog() == DialogResult.OK) { m_absenceList.SetEntity(absence); } } UpdateButtonState(); } }
public override bool Commit() { if (!IsModified()) { return(base.Commit()); } else if (IsValid()) { if (!isChecked && ((AbsenceColor < lightWhite && AbsenceColor > darkWhite) || (AbsenceColor < lightBlack && AbsenceColor > darkBlack))) { InfoMessage(GetLocalized("err_enter_absence_colour")); cbLongTimeColor.Focus(); isChecked = true; return(false); } LongTimeAbsence copyAbsence = new LongTimeAbsence(); LongTimeAbsence.CopyTo(EntityAbsence, copyAbsence); //CopyAbsence(); copyAbsence.CodeName = AbsenceName; copyAbsence.CharID = AbsenceAbbreviation; copyAbsence.Color = AbsenceColor; try { Debug.Assert(copyAbsence.CountryID > 0); copyAbsence = ClientEnvironment.LongTimeAbsenceService.SaveOrUpdate(copyAbsence); LongTimeAbsence.CopyTo(copyAbsence, EntityAbsence); Modified = true; return(base.Commit()); } catch (DBDuplicateKeyException) { ErrorMessage(GetLocalized("ErrorLongTimeAbsenceNameExists")); teAbsenceName.Focus(); return(false); } } else { return(false); } }