private void btnInsert_Click(object sender, EventArgs e) { var selected = listBox1.SelectedItem; if (selected is null) { MessageBox.Show("Please Select Room", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { ActionResult saveResult = formCtrl._saveFormData(new RoomsforSessionModel() { Room = (string)selected, SessionId = Int32.Parse(comboBox1.SelectedItem.ToString()), }); if (saveResult.State) { RoomsforSessionModel saveObj = saveResult.Data; MessageBox.Show("Rooms With Session : " + saveObj.Room + "-" + saveObj.SessionId + " Sucessfully Saved!", "Save Message", MessageBoxButtons.OK, MessageBoxIcon.Information); initForm(); } else { MessageBox.Show(saveResult.Data, "Save Message", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void btnDelete_Click(object sender, EventArgs e) { var selected = listBox2.SelectedItem; if (selected is null) { MessageBox.Show("Please Select Room", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { int id = 0; ActionResult roomsWithSesResult = formCtrl._getFormData(typeof(RoomsforSessionModel), "RoomsforSession"); if (roomsWithSesResult.State) { foreach (RoomsforSessionModel room in roomsWithSesResult.Data) { if (room.Room == (string)selected && room.SessionId.ToString() == comboBox1.SelectedItem.ToString()) { id = room.RoomWithSessionID; } } } ActionResult deleteResult = formCtrl._deleteFormData(new RoomsforSessionModel() { RoomWithSessionID = id }); if (deleteResult.State) { RoomsforSessionModel deleteObj = deleteResult.Data; MessageBox.Show("Room " + (string)selected + " Sucessfully Deleted!", "Delete Message", MessageBoxButtons.OK, MessageBoxIcon.Information); initForm(); } else { MessageBox.Show(deleteResult.Data, "Delete Message", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }