private void btnAdd_Click(object sender, EventArgs e) { // // Creating a new class for the new character // EventClass NewEvent = new EventClass(); NewEvent.Name = txtName.Text; NewEvent.Description = txtDescription.Text; NewEvent.Date = txtDate.Text; NewEvent.Location = txtLocation.Text; // // Add character to main form's list // MainForm.AddNewEvent(NewEvent, pbImage.Image); // // Show main form // Enable main form // Close this form // MainForm.Show(); MainForm.Enabled = true; this.Close(); }
private void btnUpdate_Click(object sender, EventArgs e) { EventClass EditEvent= new EventClass(); EditEvent.Date = txtDate.Text; EditEvent.Description = txtDescription.Text; EditEvent.Name = txtName.Text; EditEvent.Location= txtLocation.Text; MainForm.EditEvent(GetEventByName(lbEvents.SelectedItem.ToString()), EditEvent, pbImage.Image, this); }
public void AddNewEvent(EventClass evtNew, Image Picture) { evtNew.SavePicture = ImageToString(Picture); CBC[0].Events.Add(evtNew); blDataSaved = false; CheckStatus(); }
public void DeleteEvent(EventClass evtDel, frmListEvents FLE) { bool Found = false; if (evtDel != null) { foreach (EventClass EC in CBC[0].Events) { if (!Found) { if (EC == evtDel) Found = true; } } } if (Found) { CBC[0].Events.Remove(evtDel); MessageBox.Show("Event has been deleted.", "Success"); } else MessageBox.Show("Couldn't delete Event.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); FLE.PopulateEvents(CBC[0].Events); blDataSaved = false; CheckStatus(); }
public void EditEvent(EventClass evtOld, EventClass evtUpdate, Image Picture, frmListEvents FLE) { bool Found = false; if (evtOld != null) { foreach (EventClass EE in CBC[0].Events) { if (!Found) { if (EE.Name == evtOld.Name) { EE.Name = evtUpdate.Name; EE.Description = evtUpdate.Description; EE.SavePicture = ImageToString(Picture); EE.Date = evtUpdate.Date; EE.Location = evtUpdate.Location; Found = true; blDataSaved = false; } } } } if (Found) MessageBox.Show("Event edit successful!", "Editing..."); else MessageBox.Show("Failed to edit event!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }