private void btnSave_Click(object sender, EventArgs e) { if (txtPosition.Text.Trim() == "") { MessageBox.Show("Please fill the position name"); } else if (cmbDepartment.SelectedIndex == -1) { MessageBox.Show("Please select a department"); } else { if (!isUpdated) { POSITION position = new POSITION(); position.Position1 = txtPosition.Text; position.DepID = Convert.ToInt32(cmbDepartment.SelectedValue); PositionBLL.AddPosition(position); MessageBox.Show("Position added"); txtPosition.Clear(); cmbDepartment.SelectedIndex = -1; } else { POSITION position = new POSITION(); position.ID = detail.ID; position.Position1 = txtPosition.Text; position.DepID = Convert.ToInt32(cmbDepartment.SelectedValue); bool control = false; if (Convert.ToInt32(cmbDepartment.SelectedValue) != detail.OldDepartmentID) { control = true; } PositionBLL.UpdatePosition(position, control); MessageBox.Show("Position updated!"); this.Close(); } } }