/// <summary> /// Handles the Click event of the btnSearch control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void btnSearch_Click(object sender, EventArgs e) { StaffService staffService = new StaffService(); ds = staffService.GetAllStaffs(); string name = txtStaffName.Text.ToString().Trim(); string id = txtStaffId.Text.ToString().Trim(); string cname = txtChineseName.Text.ToString().Trim(); DateTime sOnboard = dtpOnboardStart.Value; DateTime eOnboard = dtpOnboardEnd.Value; dv.Table = ds.Tables[0]; dv.RowFilter = "ChineseName like '%" + cname + "%' And StaffName like '%" + name + "%' And EmployeeId like '%" + id + "%' And OnboardDate >= '" + sOnboard + "' And OnboardDate <= '" + eOnboard + "' "; dgrdDisplayStaffInfo.DataSource = dv; //dgrdDisplayStaffInfo.DataSource = ds.Tables[0]; dgrdDisplayStaffInfo.Columns["StaffId"].DataPropertyName = ds.Tables[0].Columns[0].ToString(); dgrdDisplayStaffInfo.Columns["Login Id"].DataPropertyName = ds.Tables[0].Columns[1].ToString(); dgrdDisplayStaffInfo.Columns["English Name"].DataPropertyName = ds.Tables[0].Columns[2].ToString(); dgrdDisplayStaffInfo.Columns["Chinese Name"].DataPropertyName = ds.Tables[0].Columns[3].ToString(); dgrdDisplayStaffInfo.Columns["Position"].DataPropertyName = ds.Tables[0].Columns[4].ToString(); dgrdDisplayStaffInfo.Columns["Hire Date"].DataPropertyName = ds.Tables[0].Columns[5].ToString(); dgrdDisplayStaffInfo.Columns["Email address"].DataPropertyName = ds.Tables[0].Columns[6].ToString(); dgrdDisplayStaffInfo.Columns["Telephone"].DataPropertyName = ds.Tables[0].Columns[7].ToString(); dgrdDisplayStaffInfo.Columns["Gender"].DataPropertyName = ds.Tables[0].Columns[8].ToString(); dgrdDisplayStaffInfo.Columns["Married"].DataPropertyName = ds.Tables[0].Columns[9].ToString(); dgrdDisplayStaffInfo.Columns["StatusName"].DataPropertyName = ds.Tables[0].Columns[10].ToString(); dgrdDisplayStaffInfo.Columns["Location"].DataPropertyName = ds.Tables[0].Columns[11].ToString(); dgrdDisplayStaffInfo.Columns["DepartementName"].DataPropertyName = ds.Tables[0].Columns[12].ToString(); dgrdDisplayStaffInfo.Columns["Employee Category"].DataPropertyName = ds.Tables[0].Columns[13].ToString(); dgrdDisplayStaffInfo.Columns["Contract Term"].DataPropertyName = ds.Tables[0].Columns[14].ToString(); dgrdDisplayStaffInfo.CellFormatting += new DataGridViewCellFormattingEventHandler(dgrdDisplayStaffInfo_CellFormatting); }
public void Can_Retrieve_All_Staffs() { var service = new StaffService(_staffRepoMock.Object); var allStaffs = service.GetAllStaffs(); Assert.AreEqual(_sampleStaffs.Count, allStaffs.Count); }
/// <summary> /// Shows the staff. /// </summary> /// <param name="dataGridView">The data grid view.</param> public void showStaff(DataGridView dataGridView) { dgrdDisplayStaffInfo.AutoGenerateColumns = false; this.dgrdDisplayStaffInfo.AllowUserToAddRows = false; DataGridViewCheckBoxColumn checkbox = new DataGridViewCheckBoxColumn(); checkbox.HeaderText = ""; checkbox.Width = 50; checkbox.FalseValue = 0; checkbox.TrueValue = 1; dgrdDisplayStaffInfo.Columns.Add(checkbox); DataGridViewTextBoxColumn staffId = new DataGridViewTextBoxColumn(); staffId.Name = "StaffId"; dgrdDisplayStaffInfo.Columns.Add(staffId); dgrdDisplayStaffInfo.Columns["staffId"].Visible = false; DataGridViewTextBoxColumn employeeId = new DataGridViewTextBoxColumn(); employeeId.Name = "Login ID"; dgrdDisplayStaffInfo.Columns.Add(employeeId); DataGridViewTextBoxColumn staffName = new DataGridViewTextBoxColumn(); staffName.Name = "English Name"; dgrdDisplayStaffInfo.Columns.Add(staffName); DataGridViewTextBoxColumn chineseName = new DataGridViewTextBoxColumn(); chineseName.Name = "Chinese Name"; dgrdDisplayStaffInfo.Columns.Add(chineseName); DataGridViewTextBoxColumn title = new DataGridViewTextBoxColumn(); title.Name = "Position"; dgrdDisplayStaffInfo.Columns.Add(title); DataGridViewTextBoxColumn onboardDate = new DataGridViewTextBoxColumn(); onboardDate.Name = "Hire Date"; dgrdDisplayStaffInfo.Columns.Add(onboardDate); DataGridViewTextBoxColumn email = new DataGridViewTextBoxColumn(); email.Name = "Email address"; email.Width = 150; dgrdDisplayStaffInfo.Columns.Add(email); DataGridViewTextBoxColumn phoneNumber = new DataGridViewTextBoxColumn(); phoneNumber.Name = "Telephone"; dgrdDisplayStaffInfo.Columns.Add(phoneNumber); DataGridViewTextBoxColumn gender = new DataGridViewTextBoxColumn(); gender.Name = "Gender"; dgrdDisplayStaffInfo.Columns.Add(gender); DataGridViewTextBoxColumn married = new DataGridViewTextBoxColumn(); married.Name = "Married"; dgrdDisplayStaffInfo.Columns.Add(married); DataGridViewTextBoxColumn statusName = new DataGridViewTextBoxColumn(); statusName.Name = "StatusName"; dgrdDisplayStaffInfo.Columns.Add(statusName); DataGridViewTextBoxColumn location = new DataGridViewTextBoxColumn(); location.Name = "Location"; dgrdDisplayStaffInfo.Columns.Add(location); DataGridViewTextBoxColumn departementName = new DataGridViewTextBoxColumn(); departementName.Name = "DepartementName"; dgrdDisplayStaffInfo.Columns.Add(departementName); DataGridViewTextBoxColumn employeeCategory = new DataGridViewTextBoxColumn(); employeeCategory.Name = "Employee Category"; dgrdDisplayStaffInfo.Columns.Add(employeeCategory); DataGridViewTextBoxColumn contractTerm = new DataGridViewTextBoxColumn(); contractTerm.Name = "Contract Term"; dgrdDisplayStaffInfo.Columns.Add(contractTerm); StaffService staffService = new StaffService(); ds = staffService.GetAllStaffs(); dgrdDisplayStaffInfo.DataSource = ds.Tables[0]; dgrdDisplayStaffInfo.Columns["StaffId"].DataPropertyName = ds.Tables[0].Columns[0].ToString(); dgrdDisplayStaffInfo.Columns["Login ID"].DataPropertyName = ds.Tables[0].Columns[1].ToString(); dgrdDisplayStaffInfo.Columns["English Name"].DataPropertyName = ds.Tables[0].Columns[2].ToString(); dgrdDisplayStaffInfo.Columns["Chinese Name"].DataPropertyName = ds.Tables[0].Columns[3].ToString(); dgrdDisplayStaffInfo.Columns["Position"].DataPropertyName = ds.Tables[0].Columns[4].ToString(); dgrdDisplayStaffInfo.Columns["Hire Date"].DataPropertyName = ds.Tables[0].Columns[5].ToString(); dgrdDisplayStaffInfo.Columns["Email address"].DataPropertyName = ds.Tables[0].Columns[6].ToString(); dgrdDisplayStaffInfo.Columns["Telephone"].DataPropertyName = ds.Tables[0].Columns[7].ToString(); dgrdDisplayStaffInfo.Columns["Gender"].DataPropertyName = ds.Tables[0].Columns[8].ToString(); dgrdDisplayStaffInfo.Columns["Married"].DataPropertyName = ds.Tables[0].Columns[9].ToString(); dgrdDisplayStaffInfo.Columns["StatusName"].DataPropertyName = ds.Tables[0].Columns[10].ToString(); dgrdDisplayStaffInfo.Columns["Location"].DataPropertyName = ds.Tables[0].Columns[11].ToString(); dgrdDisplayStaffInfo.Columns["DepartementName"].DataPropertyName = ds.Tables[0].Columns[12].ToString(); dgrdDisplayStaffInfo.Columns["Employee Category"].DataPropertyName = ds.Tables[0].Columns[13].ToString(); dgrdDisplayStaffInfo.Columns["Contract Term"].DataPropertyName = ds.Tables[0].Columns[14].ToString(); dgrdDisplayStaffInfo.CellFormatting += new DataGridViewCellFormattingEventHandler(dgrdDisplayStaffInfo_CellFormatting); int t = dgrdDisplayStaffInfo.Columns.Count; for (int j = 1; j < t; j++) { dgrdDisplayStaffInfo.Columns[j].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; dgrdDisplayStaffInfo.Columns[j].ReadOnly = true; } }