private void resultDataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (ChekForColumnName(e.RowIndex, e.ColumnIndex, "Edit")) // Edit Button { int id = (int)resultDataGridView.Rows[e.RowIndex].Cells[0].Value; string name = resultDataGridView.Rows[e.RowIndex].Cells[1].Value.ToString(); string location = resultDataGridView.Rows[e.RowIndex].Cells[2].Value.ToString(); string beginningDate = resultDataGridView.Rows[e.RowIndex].Cells[3].Value.ToString(); string endDate = resultDataGridView.Rows[e.RowIndex].Cells[4].Value.ToString(); //this.Hide(); UpdateForm updateForm = new UpdateForm(id, name, location, beginningDate, endDate); updateForm.ShowDialog(); //this.Close(); resultDataGridView.Rows.Clear(); AllElement(); } else if (ChekForColumnName(e.RowIndex, e.ColumnIndex, "Delete")) //Delete Button { Controllers.EventController controller = new Controllers.EventController(); int id = (int)resultDataGridView.Rows[e.RowIndex].Cells[0].Value; controller.DeleteEvent(id); resultDataGridView.Rows.Clear(); AllElement(); } }
private void buttonAddEvent_Click(object sender, EventArgs e) { string name = addFormNameTextBox.Text; string location = addFormLocationTextBox.Text; string beginningDate = addFormBeginningDateDateTimePicker.Text; string endDate = addFormEndDateDateTimePicker.Text; Controllers.EventController controller = new Controllers.EventController(); controller.AddEvent(name, location, beginningDate, endDate); }
private void buttonUpdateEvent_Click(object sender, EventArgs e) { Controllers.EventController controller = new Controllers.EventController(); string name = updateFormNameTextBox.Text; string location = updateFormLocationTextBox.Text; string beginningDate = updateFormBeginningDateDateTimePicker.Text; string endDate = updateFormEndDateDateTimePicker.Text; controller.UpdateEvent(id, name, location, beginningDate, endDate); this.Hide(); this.Close(); }
private void AllElement() { Controllers.EventController controller = new Controllers.EventController(); for (int i = 0; i < controller.MyGridView().Count; i++) { resultDataGridView.Rows.Add(); resultDataGridView.Rows[i].Cells[0].Value = controller.MyGridView()[i].id; resultDataGridView.Rows[i].Cells[1].Value = controller.MyGridView()[i].name; resultDataGridView.Rows[i].Cells[2].Value = controller.MyGridView()[i].location; resultDataGridView.Rows[i].Cells[3].Value = controller.MyGridView()[i].beginningDate; resultDataGridView.Rows[i].Cells[4].Value = controller.MyGridView()[i].endDate; } }