private void btnSaveDefault_Click(object sender, EventArgs e) { try { if (cmbDepartmentList.Items.Count > 0 && cmbDepartmenttores.Items.Count > 0) { DialogResult dr = MessageBox.Show(this, "Are you sure you want to change default store?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (dr == DialogResult.Yes) { int res = objStoreDL.SetDefault(cmbDepartmenttores.SelectedValue.ToString(), Convert.ToInt64(cmbDepartmentList.SelectedValue)); if (res > 0) { MessageBox.Show(this, "Successfully changed the default store", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show(this, "Error occured while saving default Stores", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } else { MessageBox.Show(this, "Please select a department and a Store", "Empty List", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception) { MessageBox.Show(this, "Error occured while saving default Stores", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }