private void Delete() { //Get selected row from user //Delete related services in service catalog if any //delete service catalog if (dataGridView1.CurrentRow.Index != -1) { serviceCatalog.service_catalog_id = Convert.ToInt32(dataGridView1.CurrentRow.Cells["service_catalog_id"].Value); serviceCatalog.name = Convert.ToString(dataGridView1.CurrentRow.Cells["name"].Value); if (MessageBox.Show($"Are you sure you want to delete {serviceCatalog.name} with its related services?. Proceed with caution", "Delete Service Catalog", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { DeleteServiceRelatedToServiceCatalog(); using (emedEntities db = new emedEntities()) { var result = db.Entry(serviceCatalog); if (result.State == EntityState.Detached) { db.service_catalog.Attach(serviceCatalog); } db.service_catalog.Remove(serviceCatalog); db.SaveChanges(); MessageBox.Show("Service Catalog Deleted Successfully", "Message"); } LoadServiceCatalog(); RefreshDGVService(); } } }
private void UpdateUserSetting(user user) { user.firstname = txtFirstName.Text.Trim(); user.lastname = txtLastName.Text.Trim(); user.skin_name = comboBoxStyle.Text.Trim(); user.password = txtPassword.Text.Trim(); user.confirm_password = txtConfirmPassword.Text.Trim(); var passwordValid = PaswordChecker(user.password, user.confirm_password); if (!passwordValid) { MessageBox.Show("Password is not valid or does not match", "Error"); } else { using (emedEntities db = new emedEntities()) { db.Entry(user).State = EntityState.Modified; db.SaveChanges(); MessageBox.Show("User Preference Saved Successfully", "Message"); Close(); UserLookAndFeel.Default.SetSkinStyle(comboBoxStyle.Text); } } }
private void UpdateServiceCatalog() { _editServiceCatalog.name = txtName.Text.Trim(); _editServiceCatalog.description = txtDescription.Text.Trim(); _editServiceCatalog.active = (checkBoxActive.Checked) ? active + 1 : active; using (emedEntities db = new emedEntities()) { db.Entry(_editServiceCatalog).State = EntityState.Modified; db.SaveChanges(); MessageBox.Show("Service Catalog Updated Successfully!", "Message"); Close(); } }
private void UpdateService() { _editServiceHelper.code = txtCode.Text.Trim(); _editServiceHelper.description = txtDescription.Text.Trim(); _editServiceHelper.price = Convert.ToDecimal(txtPrice.Text.Trim()); _editServiceHelper.isFavourite = (checkBoxFavourite.Checked) ? active + 1 : active; _editServiceHelper.active = (checkBoxActive.Checked) ? active + 1 : active; using (emedEntities db = new emedEntities()) { db.Entry(_editServiceHelper).State = EntityState.Modified; db.SaveChanges(); MessageBox.Show("Service Updated Successfully!", "Message"); Close(); } }
//Update user account private void UpdateUser() { _editUserHelper.skin_name = comboBoxStyle.Text.Trim(); _editUserHelper.salutation = comboBoxSalutaion.Text.Trim(); _editUserHelper.firstname = txtFirstName.Text.Trim(); _editUserHelper.lastname = txtSurname.Text.Trim(); _editUserHelper.other_name = txtOtherName.Text.Trim(); _editUserHelper.affix = comboBoxAffix.Text; _editUserHelper.sex = comboBoxSex.Text; _editUserHelper.email = txtEmail.Text.Trim(); _editUserHelper.doctor = txtDoctor.Text.Trim(); _editUserHelper.username = txtUsername.Text.Trim(); _editUserHelper.acronym = txtAcronym.Text.Trim(); _editUserHelper.password = txtPassword.Text.Trim(); _editUserHelper.confirm_password = txtConfirmPassword.Text.Trim(); _editUserHelper.image = (userPictureBox.ImageLocation != null) ? ConvertPicture(userPictureBox.ImageLocation) : _editUserHelper.image = null; _editUserHelper.isActive = (checkBoxActive.Checked) ? active + 1 : active; bool validationResult = ValidateFields(); bool chkPassword = PaswordChecker(_editUserHelper.password, _editUserHelper.confirm_password); if (!validationResult) { MessageBox.Show("Enter Required Fields!", "Error"); } else if (!chkPassword) { MessageBox.Show("Password is not valid or does not match", "Error"); } else { using (emedEntities db = new emedEntities()) { db.Entry(_editUserHelper).State = EntityState.Modified; db.SaveChanges(); MessageBox.Show("User Updated Successfully!", "Message"); Close(); } RefreshData(); } }
private void Delete(messaging msg) { if (dataGridViewEmailConfig.CurrentRow.Index != -1) { msg.messaging_id = Convert.ToInt32(dataGridViewEmailConfig.CurrentRow.Cells["messaging_id"].Value); if (MessageBox.Show($"Are you sure you want to delete this record?", "Delete Email Config", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { using (emedEntities db = new emedEntities()) { var result = db.Entry(msg); if (result.State == EntityState.Detached) { db.messagings.Attach(msg); } db.messagings.Remove(msg); db.SaveChanges(); MessageBox.Show("Record Deleted Successfully", "Message"); } RefreshData(); CheckButtonState(); } } }
private void Delete(category deleteCategory) { if (dataGridViewCategory.CurrentRow.Index != -1) { deleteCategory.category_id = Convert.ToInt32(dataGridViewCategory.CurrentRow.Cells["category_id"].Value); deleteCategory.name = Convert.ToString(dataGridViewCategory.CurrentRow.Cells["name"].Value); if (MessageBox.Show($"Are you sure you want to delete {deleteCategory.name} from the Record?", "Delete Category", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { using (emedEntities db = new emedEntities()) { var result = db.Entry(deleteCategory); if (result.State == EntityState.Detached) { db.categories.Attach(deleteCategory); } db.categories.Remove(deleteCategory); db.SaveChanges(); MessageBox.Show("Record Deleted Successfully", "Message"); } LoadCategory(); } } }
private void EditEmailConfig(messaging editConfig) { try { editConfig.username = txtUsername.Text.Trim(); editConfig.password = txtPassword.Text.Trim(); editConfig.port_nr = Convert.ToInt32(txtPortNumber.Text.Trim()); editConfig.server_address = txtServerAddress.Text.Trim(); editConfig.sslEnabled = (checkBoxSSL.Checked) ? isEnabled + 1 : isEnabled; using (emedEntities db = new emedEntities()) { db.Entry(editConfig).State = EntityState.Modified; db.SaveChanges(); MessageBox.Show("Email Config Updated Successfully!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); } MessagingControl.fromMsgControl.InitControls(); RefreshData(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void UpdateCategory(category updateCategory) { updateCategory.name = txtName.Text.Trim(); updateCategory.description = txtDescription.Text.Trim(); updateCategory.acronym = txtAcroymn.Text.Trim(); updateCategory.creator_id = StartPage._loggedInUser.user_id; updateCategory.active = (checkBoxActive.Checked) ? active + 1 : active; var validationResult = ValidateFields(updateCategory.acronym, updateCategory.name); if (!validationResult) { MessageBox.Show("Please enter required fields", "Error"); } else { using (emedEntities db = new emedEntities()) { db.Entry(updateCategory).State = EntityState.Modified; db.SaveChanges(); MessageBox.Show("Category Updated Successfully!", "Message"); Close(); } } }
private void Delete() { if (dataGridView1.CurrentRow.Index != -1) { user.user_id = Convert.ToInt32(dataGridView1.CurrentRow.Cells["user_id"].Value); user.firstname = Convert.ToString(dataGridView1.CurrentRow.Cells["firstname"].Value); user.lastname = Convert.ToString(dataGridView1.CurrentRow.Cells["lastname"].Value); if (MessageBox.Show($"Are you sure you want to delete {user.firstname} {user.lastname} from the Record?", "Delete User", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { using (emedEntities db = new emedEntities()) { var result = db.Entry(user); if (result.State == EntityState.Detached) { db.users.Attach(user); } db.users.Remove(user); db.SaveChanges(); MessageBox.Show("Record Deleted Successfully", "Message"); } LoadUsers(); } } }