private void btnDelete_Click_2(object sender, EventArgs e) { DialogResult dr = MessageBox.Show("Are you sure to delete this row?", "Confirmation Message", MessageBoxButtons.YesNo); if (dr == DialogResult.Yes) { Service service = new Service(); service.ID = Convert.ToInt32(txtID.Text); MessageModel aMessageModel = new MessageModel(); aMessageModel = new ServiceManager().DeleteService(service); if (aMessageModel.MessageTitle == "Successfull") { MessageBox.Show(aMessageModel.MessageBody, aMessageModel.MessageTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); SetNew(); } else { MessageBox.Show(aMessageModel.MessageBody, aMessageModel.MessageTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } }
private void SaveService() { try { if (txtRate.Text == "" || Convert.ToInt32(txtRate.Text) < 0) { MessageBox.Show("Please enter the valid rate of this service!", "Invalid", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } Service service = new Service(); service.ID = Convert.ToInt16(txtID.Text); service.ServiceName = Convert.ToString(txtName.Text); service.Description = Convert.ToString(txtDescription.Text); service.Rate = Convert.ToDouble(txtRate.Text); service.ServiceId = "Serv-0" + txtID.Text; service.Catgory = cmbCatgory.Text; if (btnEdit.Enabled) { MessageModel messageModel = new ServiceManager().UpdateService(service); MessageBox.Show(messageModel.MessageBody, messageModel.MessageTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); SetNew(); } else { MessageModel messageModel = new ServiceManager().SaveService(service); MessageBox.Show(messageModel.MessageBody, messageModel.MessageTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); SetNew(); } } catch (Exception error) { MessageBox.Show("Failed to save service! " + error.Message.ToString(), "Failed", MessageBoxButtons.OK, MessageBoxIcon.Information); } }