private void btnSave_Click(object sender, EventArgs e) { try { if (pic == "" && action == "add") { pic = @"..\..\..\DAL\App_Data\emppic\Noimage.jpg"; } if (pic == "" && action == "modify") { pic = gridEmployee.Rows[curRow].Cells["pic"].Value.ToString(); } clsEmployee tmpEmployee = new clsEmployee(); tmpEmployee.ID = (int)gridEmployee.Rows[curRow].Cells["id"].Value; tmpEmployee.Code = txtCode.Text; tmpEmployee.Fullname = txtFullName.Text; tmpEmployee.Username = txtUserName.Text; tmpEmployee.Password = txtPassword.Text; tmpEmployee.Cityzone = (enumCityzone)Enum.Parse(typeof(enumCityzone), cboCityZone.SelectedItem.ToString()); tmpEmployee.Lang = (enumLang)Enum.Parse(typeof(enumLang), cboLang.SelectedItem.ToString()); tmpEmployee.Gender = (enumGender)Enum.Parse(typeof(enumGender), cboGender.SelectedItem.ToString()); tmpEmployee.Employeetype = (enumEmployeeType)Enum.Parse(typeof(enumEmployeeType), cboType.SelectedItem.ToString()); tmpEmployee.Pic = pic; if (action == "add") { clsGlobals.remax.Employees.Add(tmpEmployee, txtCode.Text); clsDataSource.insertEmployee(tmpEmployee.toInsert()); curRow = gridEmployee.Rows.Count; } if (action == "modify") { clsGlobals.remax.Employees.Update(tmpEmployee, txtCode.Text); clsDataSource.updateEmployee(tmpEmployee.ID, tmpEmployee.toUpdate()); } tmpEmployee = null; pic = ""; getData(); gridEmployee.Rows[curRow].Selected = true; showCurHouse(); } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message + "\n\nPlease check you have entered the data correctly !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }