public bool Update(CriminalEvent criminalEvent, out string result) { result = string.Empty; try { int index = criminalEvents.FindIndex(x => (x.Id == criminalEvent.Id)); if (index == Constants.NONE) { result = string.Format("Record With Index[{0}] Not Found", index); return(false); } criminalEvents[index] = criminalEvent; return(true); } catch (Exception e) { result = e.Message; return(false); } }
public bool Create(CriminalEvent criminalEvent, out string result) { result = string.Empty; try { if (criminalEvent == null) { result = "New Record Is Null"; return(false); } if (criminalEvents == null) { criminalEvents = new List <CriminalEvent>(); } criminalEvent.Id = Guid.NewGuid(); criminalEvents.Add(criminalEvent); return(true); } catch (Exception e) { result = e.Message; return(false); } }
private bool Retrieve(CriminalEvent criminalEvent, out string result) { result = string.Empty; try { if (criminalEvent == null) { result = "Record To Create Is Null"; return(false); } if (!crud.Create(criminalEvent, out result)) { return(false); } return(true); } catch (Exception e) { result = e.Message; return(false); } }
public bool Retrieve(Guid recordIndex, out CriminalEvent criminalEvent, out string result) { result = string.Empty; criminalEvent = null; try { int index = criminalEvents.FindIndex(x => (x.Id == recordIndex)); if (index == Constants.NONE) { result = string.Format("Record With Index[{0}] Not Found", index); return(false); } criminalEvent = criminalEvents[index]; return(true); } catch (Exception e) { result = e.Message; return(false); } }
private void btnSave_Click(object sender, EventArgs e) { string result; try { if (!ValidateRecord(out result)) { OnAudit("שגיאת שמירת אירוע", AuditSeverity.Error); return; } if (Save != null) { CriminalEvent newCriminalEvent = new CriminalEvent(); newCriminalEvent.Id = (criminalEvent == null) ? Guid.Empty : criminalEvent.Id; if (newCriminalEvent.Id != Guid.Empty) { DialogResult dialogResult = MessageBox.Show("?לעדכן", "עדכון אירוע", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogResult != DialogResult.Yes) { return; } } int criminalEventTypeIndex = cboEventType.SelectedIndex; newCriminalEvent.Type = (CriminalEventType)criminalEventTypeIndex; newCriminalEvent.Family = txtFamily.Text; newCriminalEvent.Street = cboStreet.Text; newCriminalEvent.HouseNumber = (int)nudHouseNumber.Value; newCriminalEvent.ArrivalDirection = txtArrivalDirection.Text; newCriminalEvent.WhatWasStolen = txtWhatWasStolen.Text; newCriminalEvent.WhoArrivedAfterTheEvent = txtWhoArrivedAfterTheEvent.Text; newCriminalEvent.Description = txtDescription.Text; newCriminalEvent.Time = new DateTime(dtDate.Value.Year, dtDate.Value.Month, dtDate.Value.Day, dtTime.Value.Hour, dtTime.Value.Minute, dtTime.Value.Second); Save(null, newCriminalEvent); Close(); } } catch (Exception ex) { OnAudit($"שגיאת שמירת אירוע: {ex.Message}", AuditSeverity.Error); } }
private string CriminalEventToolTip(CriminalEvent criminalEvent) { if (criminalEvent == null) { return(string.Empty); } string criminalEventDescription; criminalEventDescription = $"אירוע: {Utils.GetEnumDescription(criminalEvent.Type)}"; criminalEventDescription += Environment.NewLine; criminalEventDescription += $"כתובת: {criminalEvent.Street + " " + criminalEvent.HouseNumber}"; criminalEventDescription += Environment.NewLine; criminalEventDescription += $"תיאור: {criminalEvent.Description}"; return(criminalEventDescription); }
private void btnUpdateEvent_Click(object sender, EventArgs e) { try { int rowIndex = dgvEventsLog.SelectedRows[0].Index; if (rowIndex == Constants.NONE) { return; } CriminalEventType type = (CriminalEventType)(dgvEventsLog.Rows[rowIndex].Cells[14].Value); Guid id = (Guid)(dgvEventsLog.Rows[rowIndex].Cells[10].Value); int houseNumber = (int)(dgvEventsLog.Rows[rowIndex].Cells[13].Value); DateTime time = (DateTime)(dgvEventsLog.Rows[rowIndex].Cells[11].Value); string street = dgvEventsLog.Rows[rowIndex].Cells[12].Value.ToString(); string family = dgvEventsLog.Rows[rowIndex].Cells[5].Value.ToString(); string description = dgvEventsLog.Rows[rowIndex].Cells[0].Value.ToString(); string whatWasStolen = dgvEventsLog.Rows[rowIndex].Cells[3].Value.ToString(); string arrivalDirection = dgvEventsLog.Rows[rowIndex].Cells[2].Value.ToString(); string whoArrivedAfterTheEvent = dgvEventsLog.Rows[rowIndex].Cells[1].Value.ToString(); CriminalEvent criminalEvent = new CriminalEvent(type, id, houseNumber, time, street, family, description, whatWasStolen, arrivalDirection, whoArrivedAfterTheEvent); frmAddUpdateCriminalRecord updateCriminalRecord = new frmAddUpdateCriminalRecord(criminalEvent); updateCriminalRecord.Save += AddUpdateCriminalRecord_Save; updateCriminalRecord.Show(); } catch (Exception ex) { Audit($"שגיאת עדכון אירוע: {ex.Message}", AuditSeverity.Critical); } }
public frmAddUpdateCriminalRecord(CriminalEvent inCriminalEvent) { InitializeComponent(); criminalEvent = inCriminalEvent; }
public frmAddUpdateCriminalRecord() { InitializeComponent(); criminalEvent = null; }