private void Save() { if (mode == TransMode.NewRecord) { CompanyDto company = (CompanyDto)txtCompany.Tag; UserDto newUser = new UserDto() { FirstName = txtFName.Text, LastName = txtLName.Text, NationalNo = txtNationalCode.Text, PersonelCode = txtPersonelCode.Text, IsLocked = chkEnabled.Checked, IsReal = chkIsReal.Checked }; if (company != null) { newUser.NationalNo = company.NationalNo; } view.AddUser(newUser); } else if (mode == TransMode.EditRecord) { if (user != null) { user.FirstName = txtFName.Text; user.LastName = txtLName.Text; user.NationalNo = txtNationalCode.Text; user.PersonelCode = txtPersonelCode.Text; user.IsLocked = chkEnabled.Checked; user.IsReal = chkIsReal.Checked; CompanyDto company = (CompanyDto)txtCompany.Tag; if (company != null && company.NationalNo != user.NationalNo) { user.NationalNo = company.NationalNo; } view.UpdateUser(user); } } }