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 { POSITION position = new POSITION(); if (!isUpdate) { position.DepartmentID = Convert.ToInt32(cmbDepartment.SelectedValue); position.PositionName = txtPosition.Text; PositionBLL.addPosition(position); MessageBox.Show("Position added"); txtPosition.Clear(); cmbDepartment.SelectedIndex = -1; } else { position.ID = detail.ID; position.PositionName = txtPosition.Text; position.DepartmentID = 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(); } } }