public void addStaff(IStaff newStaff) { dataAccessObj.addStaff(newStaff); // fire the event to update the view getAllStaff(); }
public StaffController(IStaffServices staffServices, IStaff staff, IDesigantionServices designationServices) { _Staff = new Staff(); _IStaff = staff; _IStaffServices = staffServices; _IDesigantionServices = designationServices; }
/// <summary> /// Populates the staff data. /// </summary> private void PopulateStaffData() { if (StaffId.HasValue && StaffId.Value > 0) { _staffEntity = this.BrokerFactory.StaffBroker.GetStaffById(StaffId.GetValueOrDefault(-1)); if (_staffEntity != null) { txtInitial.Text = _staffEntity.InitialName; txtFirstName.Text = _staffEntity.FirstName; txtLastName.Text = _staffEntity.LastName; rbMale.Checked = _staffEntity.Gender == BMResto.BO.Master.Constant.GENDER_MALE; rbFemale.Checked = _staffEntity.Gender == BMResto.BO.Master.Constant.GENDER_FEMALE; txtDob.Text = _staffEntity.DateofBirth.ToFormatShortDateString().Replace("-", ""); txtAddress.Text = _staffEntity.Address; txtPostCode.Text = _staffEntity.PostCode; cmbProvince.SelectedValue = _staffEntity.Province; txtPhone.Text = _staffEntity.PhoneNo; lblUserGuidValue.Text = _staffEntity.UserGuid.GetValueOrDefault(Guid.Empty).ToString(); } } else { string dummy = string.Empty; NewCommand(ref dummy); } }
public StaffDetailViewModel(StaffTableViewModel viewModel, IStaff staffStore, IPageService pageService) { if (viewModel == null) { throw new ArgumentNullException(nameof(viewModel)); } _pageService = pageService; _staffStore = staffStore; SaveCommand = new Command(async() => await Save()); Staff = new Staff { id = viewModel.Id, staffID = viewModel.StaffID, firstName = viewModel.FirstName, lastName = viewModel.LastName, email = viewModel.Email, city = viewModel.City, postCode = viewModel.PostCode, accountType = viewModel.AccountType, active = viewModel.Active, dayOfBirth = viewModel.DayOfBirth, gender = viewModel.Gender, idNumber = viewModel.IdNumber, password = viewModel.Password, phoneNumber = viewModel.PhoneNumber, street = viewModel.Street }; }
public void getStaff_Test() { // this should return either a null or a staff object // arrange // set up the data access fake var staffDAO = A.Fake <Model.DataAccessLayer.IStaffDAO>(); int staffID = 1; string fullName = "Full Name"; string password = "******"; Staff.Privelege privelege = Staff.Privelege.Normal; A.CallTo(() => staffDAO.getStaff(0)).Returns(null); A.CallTo(() => staffDAO.getStaff(staffID)).Returns(new Staff(staffID, fullName, password, privelege)); // instantiate the class under test staffService = new StaffOps(staffDAO); // act IStaff staffThatDoesNotExist = this.staffService.getStaff(0); IStaff staffThatExists = this.staffService.getStaff(staffID); // assert NUnit.Framework.Assert.IsNull(staffThatDoesNotExist); NUnit.Framework.Assert.AreEqual(staffID, staffThatExists.StaffID); NUnit.Framework.Assert.AreEqual(fullName, staffThatExists.FullName); NUnit.Framework.Assert.AreEqual(password, staffThatExists.PasswordHash); NUnit.Framework.Assert.AreEqual(privelege, staffThatExists.privelege); }
public void Setup() { var repo = new StaffRepository(); //Grab the first staff member form the list _staff = repo.GetStaff().First(); }
public virtual void addNewStaffMemberToDB(IStaff theUser) { try { SqlDataReader rdr = null; SqlCommand cmd = new SqlCommand("dbo.CreateNewStaffMember", connection); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@UserID", theUser.UserID)); cmd.Parameters.Add(new SqlParameter("@isHod", theUser.isHOD)); cmd.Parameters.Add(new SqlParameter("@pps", theUser.PPS)); cmd.Parameters.Add(new SqlParameter("@email", theUser.Email)); cmd.Parameters.Add(new SqlParameter("@phone", theUser.PhoneNum)); cmd.Parameters.Add(new SqlParameter("@usertype", theUser.UserType)); rdr = cmd.ExecuteReader(); rdr.Close(); } catch (System.Exception excep) { if (connection.State.ToString() == "Open") { connection.Close(); } Application.Exit(); //Environment.Exit(0); //Force the application to close } }
public void importUpdateStaff(IStaff staff) { dataAccessObj.importUpdateStaff(staff); // fire the event to update the view getAllStaff(); }
// constructor with parameters public Transaction(int TransactionID, string Timestamp, ICustomer customer, IStaff staff, IProduct Product) { this.TransactionID = TransactionID; this.Timestamp = Timestamp; this.customer = customer; this.staff = staff; this.product = Product; }
public int StaffedPlane(IStaff plane) { if (plane != null) { return(plane.GetStaff()); } return(0); }
protected override void Dispose(bool isDisposing) { if (isDisposing) { _IDesigantionServices = null; _IStaff = null; _IStaffServices = null; } }
public StartViewModel(IStudent studentStore, IStaff staffStore, IPageService pageService) { _staffStore = staffStore; _studentStore = studentStore; _pageService = pageService; LoadDataCommand = new Command(async() => await LoadData()); Login = new Command(async() => await LoginPage()); }
public void AddStaff(IStaff staff) { bool result = _staffRepository.addStaff(staff); if (!result) { throw new Exception("Unable to Save Staff"); } }
public StaffViewModel(IStaff staffStore, IPageService pageService) { _staffStore = staffStore; _pageService = pageService; LoadDataCommand = new Command(async() => await LoadData()); AddStaff = new Command(async() => await AddStaffs()); SelectStaff = new Command <StaffTableViewModel>(async s => await SelectStaffs(s)); DeleteStaff = new Command <StaffTableViewModel>(async s => await DeleteStaffs(s)); }
/// <summary> /// Update a staff record in the database. /// </summary> /// <param name="staff">Staff object.</param> public void updateStaff(IStaff staff) { // StaffID in the database is PK and AI string queryUpdateCustomer = "UPDATE Staff " + "SET FullName = @name, Passwordhash = @passHash, Privelege = @privelege " + "WHERE StaffID = @id;"; using (SqlConnection conn = new SqlConnection(this.connString)) { SqlCommand cmd = new SqlCommand(queryUpdateCustomer, conn); // parameterise SqlParameter idParam = new SqlParameter(); idParam.ParameterName = "@id"; idParam.Value = staff.staffID; cmd.Parameters.Add(idParam); SqlParameter nameParam = new SqlParameter(); nameParam.ParameterName = "@name"; nameParam.Value = staff.fullName; cmd.Parameters.Add(nameParam); SqlParameter passParam = new SqlParameter(); passParam.ParameterName = "@passHash"; passParam.Value = staff.passwordHash; cmd.Parameters.Add(passParam); SqlParameter privParam = new SqlParameter(); privParam.ParameterName = "@privelege"; switch (staff.privelege) { case Privelege.Admin: privParam.Value = "Admin"; break; case Privelege.Normal: privParam.Value = "Normal"; break; default: // should never happen throw new Exception("Invalid staff data"); } cmd.Parameters.Add(privParam); // try a connection conn.Open(); // execute the query cmd.ExecuteNonQuery(); } }
/// <summary> /// Perform import/update operation. /// If there is no staff record with this ID, create it. /// Else, update it with the remaining fields. /// </summary> /// <param name="staff">Staff interface</param> public void importUpdateStaff(IStaff staff) { if (getStaff(staff.StaffID) == null) { addStaff(staff); } else { updateStaff(staff); } }
/// <summary> /// Add a staff record to the database. /// </summary> /// <param name="staff">Staff object.</param> public void addStaff(IStaff staff) { // StaffID in the database is PK and AI string queryAddStaff = "INSERT INTO Staff (FullName, PasswordHash, Privelege) " + "VALUES (@name, @password, @privelege);"; using (SqlConnection conn = new SqlConnection(this.connString)) { // prepare the command SqlCommand cmd = new SqlCommand(queryAddStaff, conn); // parameterise SqlParameter nameParam = new SqlParameter(); nameParam.ParameterName = "@name"; nameParam.Value = staff.fullName; cmd.Parameters.Add(nameParam); SqlParameter passParam = new SqlParameter(); passParam.ParameterName = "@password"; passParam.Value = staff.passwordHash; cmd.Parameters.Add(passParam); SqlParameter privParam = new SqlParameter(); privParam.ParameterName = "@privelege"; Privelege privelege = staff.privelege; switch (privelege) { case Privelege.Admin: privParam.Value = "Admin"; break; case Privelege.Normal: privParam.Value = "Normal"; break; default: // this shouldn't happen throw new Exception("Invalid staff data"); } cmd.Parameters.Add(privParam); // try a connection conn.Open(); // execute the query cmd.ExecuteNonQuery(); } return; }
public static bool SynchronizeTo(this IStaff source, IStaff target) { bool isModified = false; var sourceSupport = source as IStaffSynchronizationSourceSupport; // Back synch non-reference portion of PK (PK properties cannot be changed, therefore they can be omitted in the resource payload, but we need them for proper comparisons for persistence) if (source.StaffFirstName != target.StaffFirstName) { source.StaffFirstName = target.StaffFirstName; } if (source.StaffLastSurname != target.StaffLastSurname) { source.StaffLastSurname = target.StaffLastSurname; } // Copy non-PK properties // Sync lists if (sourceSupport == null || sourceSupport.IsStaffAddressesSupported) { isModified |= source.StaffAddresses.SynchronizeCollectionTo( target.StaffAddresses, onChildAdded: child => { child.Staff = target; }, includeItem: sourceSupport == null ? null : sourceSupport.IsStaffAddressIncluded); } if (sourceSupport == null || sourceSupport.IsStaffStudentSchoolAssociationsSupported) { isModified |= source.StaffStudentSchoolAssociations.SynchronizeCollectionTo( target.StaffStudentSchoolAssociations, onChildAdded: child => { child.Staff = target; }, includeItem: sourceSupport == null ? null : sourceSupport.IsStaffStudentSchoolAssociationIncluded); } return(isModified); }
public void ChangeDirector(Guid IdOfStaff, Guid IDOfDirector) { if (DataOfUnitOFWorkPattern.AppContext.EmployeeRepository.FindById(IdOfStaff) is Staff NewStaff) { if (NewStaff.DirectorId != null) { DataOfUnitOFWorkPattern.AppContext.EmployeeRepository.FindById((Guid)NewStaff.DirectorId).ListOfJuniorStaff.Remove(NewStaff); } NewStaff.DirectorId = IDOfDirector; IStaff director = DataOfUnitOFWorkPattern.AppContext.EmployeeRepository.FindById(IDOfDirector); director.ListOfJuniorStaff.Add(NewStaff); } }
public ActionResult PartialAppointmentView(StaffViewModel staff, DateTime date) { try { IStaff aStaff = _staffRepo.GetStaff().Where(m => m.ID == staff.SelectedStaffId).First(); IOrderedEnumerable <IAppointment> appointments = _appointmentRepo.GetStaffAppointments(aStaff, date).OrderByDescending(a => a.StartDateTime); return(PartialView(appointments)); } catch (Exception e) { List <IAppointment> appointments = new List <IAppointment>(); return(PartialView(appointments)); } }
private static void UpdateDetails(IStaff istaffObj) { Console.WriteLine("Enter Employee Id which you want to update:"); int staffID = int.Parse(Console.ReadLine()); var item = istaffObj.GetStaffByID(staffID); string subjectOrArea; if (item != null) { Console.WriteLine("Enter the details to update"); if (item.Designation == StaffType.Teaching) { Console.WriteLine("Old Subject is" + ((Teaching)item).Subject); string subject = GetSubjectFromUser(); ((Teaching)item).Subject = subject; } else if (item.Designation == StaffType.Administration) { Console.WriteLine("Old area is" + ((Administration)item).AdminArea); Console.WriteLine("Enter Administration area"); subjectOrArea = Console.ReadLine(); if (String.IsNullOrWhiteSpace(subjectOrArea)) { subjectOrArea = null; } ((Administration)item).AdminArea = subjectOrArea; } else { Console.WriteLine("Old area is" + ((Supporting)item).SupportArea); Console.WriteLine("Enter Administration area"); subjectOrArea = Console.ReadLine(); if (String.IsNullOrWhiteSpace(subjectOrArea)) { subjectOrArea = null; } ((Supporting)item).SupportArea = subjectOrArea; } istaffObj.UpdateStaff(item); Console.WriteLine("Staff Details are updated"); } else { Console.WriteLine("Staff with id" + staffID + "does not exists"); } }
public Boolean addNewStaffMember(string firstname, string lastname, object userType, string pps, string phone, string email, int hod) { string userID = firstname + "." + lastname; // some validation on userID. No duplicate userIDs; //IUser duplicateUser = this.StaffList.FirstOrDefault(user => user.UserID == userID.Trim()); //if (duplicateUser != null) // return false; //else //{ try { int count = 0; string id = userID; foreach (IUser user in UserList) { if (user.FirstName.Equals(firstname) && user.LastName.Equals(lastname)) { count++; } } if (count == 1) { } else { count--; userID += count.ToString(); } IStaff theUser = UserFactory.GetStaffMember(userID, hod, pps, email, phone, userType.ToString()); IUser usernameDetails = UserList.FirstOrDefault(user => user.UserID == theUser.UserID); theUser.FirstName = usernameDetails.FirstName; theUser.LastName = usernameDetails.LastName; StaffList.Add(theUser); // Add a reference to the newly created object to the Models UserList DataLayer.addNewStaffMemberToDB(theUser); //Gets the DataLayer to add the new user to the DB. return(true); } catch (System.Exception excep) { return(false); } //} }
public virtual List <IStaff> getStaffMembers() { List <IStaff> StaffList = new List <IStaff>(); try { dataset = new DataSet(); string sql = "SELECT * FROM Staff"; dataAdapter = new SqlDataAdapter(sql, connection); commandBuilder = new SqlCommandBuilder(dataAdapter); dataAdapter.Fill(dataset, "StaffData"); totUsers = dataset.Tables["StaffData"].Rows.Count; for (int i = 0; i < totUsers; i++) { DataRow dRow = dataset.Tables["StaffData"].Rows[i]; IStaff staff = UserFactory.GetStaffMember(dRow.ItemArray.GetValue(0).ToString(), Convert.ToInt16(dRow.ItemArray.GetValue(1).ToString()), dRow.ItemArray.GetValue(2).ToString(), dRow.ItemArray.GetValue(3).ToString(), dRow.ItemArray.GetValue(4).ToString(), dRow.ItemArray.GetValue(5).ToString()); foreach (IUser user in UserList) { if (dRow.ItemArray.GetValue(0).ToString().Equals(user.UserID)) { staff.FirstName = user.FirstName; staff.LastName = user.LastName; } } StaffList.Add(staff); } } catch (System.Exception excep) { MessageBox.Show(excep.Message); if (connection.State.ToString() == "Open") { connection.Close(); } Application.Exit(); //Environment.Exit(0); //Force the application to close } return(StaffList); }
public Client(IUsers users, IStaff staff, IStudents students, IGroups groups, ILogin login, IChat chat, IDetailInfo detailInfo, IHubConfigurator hubConfigurator) { Users = users; Staff = staff; Students = students; Groups = groups; Login = login; Chat = chat; DetailInfo = detailInfo; HubConfigurator = hubConfigurator; }
public bool updateDepartment(string depID, string name, string hodID, string newDepID, string newName, string newhodID) { IDepartment Dep = this.DepartmentList.FirstOrDefault(dep => dep.DepartmentID == depID.Trim()); if (hodID is null) { IStaff hod = this.StaffList.FirstOrDefault(user => user.UserID.Equals(newhodID)); this.StaffList.Remove(hod); hod.isHOD = 1; this.StaffList.Add(hod); DataLayer.updateStaffMemberToOrFromHODinDB(hod, hod.isHOD); DepartmentList.Remove(Dep); Dep.HeadOfDepartmentID = newhodID; DepartmentList.Add(Dep); DataLayer.UpdateDepartmentInDB(hod, Dep, depID); } else { IStaff hod = this.StaffList.FirstOrDefault(user => user.UserID.Equals(hodID)); // Remove department and hod from their lists // this.DepartmentList.Remove(Dep); this.StaffList.Remove(hod); // Add them back with changes // hod.isHOD = 0; DataLayer.updateStaffMemberToOrFromHODinDB(hod, hod.isHOD); this.StaffList.Add(hod); hod = this.StaffList.FirstOrDefault(user => user.UserID.Equals(newhodID)); this.StaffList.Remove(hod); hod.isHOD = 1; this.StaffList.Add(hod); DataLayer.updateStaffMemberToOrFromHODinDB(hod, hod.isHOD); Dep.DepartmentID = newDepID; Dep.HeadOfDepartmentID = newhodID; Dep.Name = newName; this.DepartmentList.Add(Dep); DataLayer.UpdateDepartmentInDB(hod, Dep, depID); } return(true); }
public LoginViewModel(LoginTableViewModel viewModel, IStudent studentStore, IStaff staffStore, IPageService pageService) { if (viewModel == null) { throw new ArgumentNullException(nameof(viewModel)); } _studentStore = studentStore; _staffStore = staffStore; _pageService = pageService; LoadDataCommand = new Command(async() => await LoadData()); LoginCommand = new Command(async() => await CheckLogin()); Login = new Login { login = viewModel.Login, password = viewModel.Password }; }
public override List <IAppointment> GetStaffAppointments(IStaff staff, DateTime appointmentDate) { string cacheKey = "StaffAppointments-" + staff.ID.ToString() + appointmentDate.ToShortTimeString(); var result = HttpRuntime.Cache[cacheKey] as List <IAppointment>; if (result == null) { lock (CacheLockObject) { result = HttpRuntime.Cache[cacheKey] as List <IAppointment>; if (result == null) { result = base.GetStaffAppointments(staff, appointmentDate); HttpRuntime.Cache.Insert(cacheKey, result, null, DateTime.Now.AddSeconds(60), TimeSpan.Zero); } } } return(result); }
public bool addStaff(IStaff staff) { int returnvalue = 0; try { DynamicParameters qp = new DynamicParameters(); qp.Add("@ID", staff.ID); qp.Add("@FirstName", staff.FirstName); qp.Add("@LastName", staff.LastName); qp.Add("@Designation", staff.Designation); using (IDbConnection connection = Connection) { returnvalue = SqlMapper.Execute(connection, "AddStaff", param: qp, commandType: CommandType.StoredProcedure); } } catch (Exception ex) { throw ex; } return(returnvalue == 1); // true only if one row is affected }
public virtual List <IAppointment> GetStaffAppointments(IStaff staff, DateTime appointmentDate) { // Appointments might span midnight DateTime endDate = appointmentDate.AddDays(1); var request = new GetStaffAppointmentsRequest { SourceCredentials = new SourceCredentials { SourceName = "MBO.Russel.Fritch", Password = "******", SiteIDs = new ArrayOfInt { -31100 } }, StaffCredentials = new StaffCredentials { Username = string.Format("{0}.{1}", staff.FirstName, staff.LastName), Password = string.Format("{0}{1}{2}", staff.FirstName.ToLower()[0], staff.LastName.ToLower()[0], staff.ID), SiteIDs = new ArrayOfInt { -31100 } }, StartDate = appointmentDate, EndDate = endDate, }; var proxy = new AppointmentServiceSoapClient(); GetStaffAppointmentsResult response = proxy.GetStaffAppointments(request); return(response.Appointments.Select(appointment => new AppointmentModel { ID = appointment.ID, StartDateTime = appointment.StartDateTime, EndDateTime = appointment.EndDateTime, ClientName = string.Format("{0} {1}", appointment.Client.FirstName, appointment.Client.LastName), SessionType = appointment.SessionType.Name }).Cast <IAppointment>().ToList()); }
public bool addDepartment(string depID, string name, string hodID) { IDepartment duplicateDep = this.DepartmentList.FirstOrDefault(dep => dep.DepartmentID == depID.Trim()); if (duplicateDep != null) { return(false); } else { IStaff newHOD = null; if (hodID.Equals("null")) { newHOD = null; } else { newHOD = this.StaffList.FirstOrDefault(hod => hod.UserID == hodID.Trim()); this.StaffList.Remove(newHOD); newHOD.isHOD = 1; this.StaffList.Add(newHOD); DataLayer.updateStaffMemberToOrFromHODinDB(newHOD, newHOD.isHOD); } try { IDepartment theDep = UserFactory.GetDepartment(depID, name, hodID); DepartmentList.Add(theDep); DataLayer.addNewDepartmentToDB(theDep); return(true); } catch (System.Exception excep) { return(false); } } }
public virtual bool updateStaffMemberToOrFromHODinDB(IStaff user, int isHod) { try { SqlDataReader rdr = null; SqlCommand cmd = new SqlCommand("dbo.UpdateStaffMemberToOrFromHOD", connection); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@userID", user.UserID)); cmd.Parameters.Add(new SqlParameter("@bool", isHod)); rdr = cmd.ExecuteReader(); rdr.Close(); } catch (System.Exception excep) { if (connection.State.ToString() == "Open") { connection.Close(); } Application.Exit(); //Environment.Exit(0); //Force the application to close } return(true); }
/// <summary> /// Deletes the staff. /// </summary> /// <param name="staff">The staff.</param> /// <returns></returns> public void DeleteStaff(IStaff staff, string deletedBy) { try { using (var context = GetUnPersistedDataContext()) { Staff staffToDelete = context.Staffs.SingleOrDefault(s => s.StaffID == staff.StaffID); if (staffToDelete != default(Staff)) { staffToDelete.IsDeleted = true; staffToDelete.DeletedDate = DateTime.Now; staffToDelete.DeletedBy = deletedBy; context.SubmitChanges(); } } } catch { throw; } }
/// <summary> /// Saves the staff. /// </summary> /// <param name="staff">The staff.</param> /// <param name="createdOrModifiedBy">The created or modified by.</param> /// <returns></returns> public IStaff SaveStaff(IStaff staff, string createdOrModifiedBy) { try { using (var context = GetUnPersistedDataContext()) { Staff staffToSave = null; if (staff.StaffID == 0) { staffToSave = new Staff(); staffToSave.CreatedBy = createdOrModifiedBy; } else { staffToSave = context.Staffs.SingleOrDefault(s => s.StaffID == staff.StaffID); } if (staffToSave != default(Staff)) { staffToSave.InitialName = staff.InitialName; staffToSave.FirstName = staff.FirstName; staffToSave.LastName = staff.LastName; staffToSave.DateofBirth = staff.DateofBirth; staffToSave.Gender = staff.Gender; staffToSave.PostCode = staff.PostCode; staffToSave.Address = staff.Address; staffToSave.Province = staff.Province; staffToSave.PhoneNo = staff.PhoneNo; staffToSave.IsDeleted = staff.IsDeleted; staffToSave.UserGuid = staff.UserGuid; } if (staff.StaffID <= 0) { context.Staffs.InsertOnSubmit(staffToSave); } else { staffToSave.ModifiedBy = createdOrModifiedBy; } context.SubmitChanges(); return (IStaff)staffToSave; } } catch { throw; } }
public StatisticFileCreator(IStaff staffEntity) { staff = staffEntity.Staff; }
public void Setup() { var service = new StaffService(); _staff = service.GetStaffMembers().First(); }
/// <summary> /// Resets the form and data. /// </summary> private void ResetFormAndData() { txtInitial.Text = string.Empty; txtFirstName.Text = string.Empty; txtLastName.Text = string.Empty; rbMale.Checked = false; rbFemale.Checked = false; txtDob.Text = string.Empty; txtAddress.Text = string.Empty; txtPostCode.Text = string.Empty; cmbProvince.SelectedValue = string.Empty; txtPhone.Text = string.Empty; lblUserGuidValue.Text = string.Empty; _staffEntity = null; StaffId = null; txtInitial.Focus(); }
/// <summary> /// Saves the command. /// </summary> /// <param name="message">The message.</param> /// <returns></returns> public override bool SaveCommand(ref string message) { ResetErrorProvider(); bool isValid = true; string initial = txtInitial.Text; string firstName = txtFirstName.Text; string lastName = txtLastName.Text; string strDob = txtDob.Text.Replace(" ", string.Empty); string address = txtAddress.Text; string postCode = txtPostCode.Text; string province = cmbProvince.SelectedValue == null ? string.Empty : cmbProvince.SelectedValue.ToString(); string phoneNo = txtPhone.Text; // validate first // firstname if (string.IsNullOrEmpty(firstName)) { isValid = false; errorProviderStaff.SetError(txtFirstName, "First Name is required"); } // date of birth DateTime? dob = null; if (string.IsNullOrEmpty(strDob)) { isValid = false; errorProviderStaff.SetError(flowLayoutPanelDob, "Date of Birth is required"); } else if (!strDob.TryParseToFormalDateFormat(out dob)) { isValid = false; errorProviderStaff.SetError(flowLayoutPanelDob, "Invalid date"); } // gender if (!rbFemale.Checked && !rbMale.Checked) { isValid = false; errorProviderStaff.SetError(flowLayoutPanelGender, "Gender is required"); } // address if (string.IsNullOrEmpty(address)) { isValid = false; errorProviderStaff.SetError(txtAddress, "Address is required"); } // then save if (isValid) { try { if (_staffEntity == null) _staffEntity = this.BrokerFactory.StaffBroker.CreateStaffInstance(); _staffEntity.Address = address; _staffEntity.DateofBirth = dob.GetValueOrDefault(DateTime.Now); _staffEntity.FirstName = firstName; _staffEntity.Gender = rbFemale.Checked ? BMResto.BO.Master.Constant.GENDER_FEMALE : BMResto.BO.Master.Constant.GENDER_MALE; _staffEntity.InitialName = initial; _staffEntity.LastName = lastName; _staffEntity.PhoneNo = phoneNo; _staffEntity.PostCode = postCode; _staffEntity.Province = province; _staffEntity = this.BrokerFactory.StaffBroker.SaveStaff(_staffEntity, MembershipHelper.CurrentUserName); StaffId = _staffEntity.StaffID; message = StaffConstants.STAFF_SUCCESS_SAVE_DATA; } catch (Exception ex) { isValid = false; message = ex.Message; } } return isValid; }