private void btnDelete_Click(object sender, EventArgs e) { if (Id == 0) { MessageBox.Show("Please select Non Allocate time first!", "Delete Message", MessageBoxButtons.OK, MessageBoxIcon.Error); initForm(); } else { ActionResult deleteResult = formCtrl._deleteFormData(new RoomsforTimeNotReservedModel() { Id = Id }); if (deleteResult.State) { RoomsforTimeNotReservedModel deleteObj = deleteResult.Data; MessageBox.Show("Room " + deleteObj.Room + " Sucessfully Deleted!", "Delete Message", MessageBoxButtons.OK, MessageBoxIcon.Information); initForm(); } else { MessageBox.Show(deleteResult.Data, "Delete Message", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void btnUpdate_Click(object sender, EventArgs e) { if (comboBuilding.SelectedIndex == 0) { MessageBox.Show("Please Select Building!", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); comboBuilding.Focus(); } else if (comboRoom.SelectedIndex == 0) { MessageBox.Show("Please Select Room!", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); comboRoom.Focus(); } else if (comboDay.SelectedIndex == 0) { MessageBox.Show("Please Select Day!", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); comboDay.Focus(); } else if (string.IsNullOrEmpty(txtFrom.Text)) { MessageBox.Show("Please Enter From!", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtFrom.Focus(); } else if (string.IsNullOrEmpty(txtTo.Text)) { MessageBox.Show("Please Enter To", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtTo.Focus(); } else { ActionResult updateResult = formCtrl._updateFormData(new RoomsforTimeNotReservedModel() { Id = Id, Building = comboBuilding.SelectedItem.ToString(), Room = comboRoom.SelectedItem.ToString(), Day = comboDay.SelectedItem.ToString(), From = txtFrom.Text.Trim(), To = txtTo.Text.Trim(), }); if (updateResult.State) { RoomsforTimeNotReservedModel updateObj = updateResult.Data; MessageBox.Show("Room " + updateObj.Id + " Sucessfully Updated!", "Update Message", MessageBoxButtons.OK, MessageBoxIcon.Information); initForm(); } else { MessageBox.Show(updateResult.Data, "Update Message", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }