/// <summary> /// 从表格中删除员工 /// </summary> /// <param name="staffs">员工列表</param> public void RemoveFromResultGrid(List <StaffInfo> staffs) { Dictionary <String, StaffInfo> existsIds = new Dictionary <String, StaffInfo>(); int staffsSize = staffs.Count; for (int i = 0; i < staffsSize; i++) { StaffInfo staff = staffs[i]; existsIds[staff.m_jobID] = staff; } int rowSize = m_gridResult.GetRows().Count; m_gridResult.BeginUpdate(); for (int i = 0; i < rowSize; i++) { GridRow row = m_gridResult.GetRow(i); StaffInfo staffInfo = DataCenter.StaffService.GetStaff(row.GetCell(0).GetString()); if (existsIds.ContainsKey(staffInfo.m_jobID)) { m_gridResult.RemoveRow(row); i--; rowSize--; } } m_gridResult.EndUpdate(); m_gridResult.Invalidate(); }
/// <summary> /// 添加嘉奖 /// </summary> /// <param name="award">嘉奖</param> public void AddAwardToGrid(AwardInfo award) { StaffService staffService = DataCenter.StaffService; StaffInfo staff = staffService.GetStaff(award.m_name); List <GridRow> rows = m_gridAwards.m_rows; int rowsSize = rows.Count; for (int i = 0; i < rowsSize; i++) { GridRow findRow = rows[i]; if (findRow.GetCell("colP1").GetString() == award.m_ID) { findRow.GetCell("colP2").SetString(award.m_name); findRow.GetCell("colP3").SetString(award.m_title); findRow.GetCell("colP4").SetString(award.m_createDate); return; } } GridRow row = new GridRow(); m_gridAwards.AddRow(row); row.AddCell("colP1", new GridStringCell(award.m_ID)); row.AddCell("colP2", new GridStringCell(award.m_name)); row.AddCell("colP3", new GridStringCell(award.m_title)); row.AddCell("colP4", new GridStringCell(award.m_createDate)); List <GridCell> cells = row.GetCells(); int cellsSize = cells.Count; for (int j = 1; j < cellsSize; j++) { cells[j].AllowEdit = true; } }
/// <summary> /// 添加成员到结果表格 /// </summary> /// <param name="staffs">成员</param> public void AddToResultGrid(List <StaffInfo> staffs) { Dictionary <String, String> existsIds = new Dictionary <String, String>(); List <GridRow> rows = m_gridResult.GetRows(); int rowSize = rows.Count; for (int i = 0; i < rowSize; i++) { GridRow row = rows[i]; String id = row.GetCell(0).GetString(); existsIds[id] = ""; } int staffsSize = staffs.Count; m_gridResult.BeginUpdate(); for (int i = 0; i < staffsSize; i++) { StaffInfo staff = staffs[i]; if (!existsIds.ContainsKey(staff.m_jobID)) { GridRow row = new GridRow(); m_gridResult.AddRow(row); row.AddCell(0, new GridStringCell(staff.m_jobID)); row.AddCell(1, new GridStringCell(staff.m_name)); existsIds[staff.m_jobID] = ""; } } m_gridResult.EndUpdate(); m_gridResult.Invalidate(); }
/// <summary> /// 根据工号获取姓名 /// </summary> /// <param name="jobIDs">工号</param> /// <returns>姓名</returns> public String GetNamesByJobsID(String jobIDs) { List <String> names = new List <String>(); String[] strs = jobIDs.Split(new String[] { "," }, StringSplitOptions.RemoveEmptyEntries); int strsSize = strs.Length; for (int i = 0; i < strsSize; i++) { StaffInfo staff = GetStaff(strs[i]); if (staff.m_jobID != null && staff.m_jobID.Length > 0) { names.Add(staff.m_name); } } int namesSize = names.Count; String strNames = ""; for (int i = 0; i < namesSize; i++) { strNames += names[i]; if (i != namesSize - 1) { strNames += ","; } } return(strNames); }
/// <summary> /// 添加 /// </summary> public void Add() { StaffInfo staff = new StaffInfo(); staff.m_jobID = DataCenter.StaffService.GetNewJobID(); DataCenter.StaffService.Save(staff); AddStaffToGrid(staff); m_gridStaffs.Update(); if (m_gridStaffs.VScrollBar != null) { m_gridStaffs.VScrollBar.ScrollToEnd(); } m_gridStaffs.Invalidate(); }
/// <summary> /// 绑定员工 /// </summary> private void BindStaffs() { m_gridStaffs.CellEditMode = GridCellEditMode.DoubleClick; List <StaffInfo> staffs = DataCenter.StaffService.m_staffs; int staffsSize = staffs.Count; m_gridStaffs.ClearRows(); m_gridStaffs.BeginUpdate(); for (int i = 0; i < staffsSize; i++) { StaffInfo staff = staffs[i]; AddStaffToGrid(staff); } m_gridStaffs.EndUpdate(); m_gridStaffs.Invalidate(); }
/// <summary> /// 单元格编辑结束事件 /// </summary> /// <param name="sender">调用者</param> /// <param name="cell">单元格</param> private void GridCellEditEnd(object sender, GridCell cell) { if (cell != null) { StaffInfo staff = DataCenter.StaffService.GetStaff(cell.Row.GetCell("colS1").GetString()); String colName = cell.Column.Name; String cellValue = cell.GetString(); if (colName == "colS2") { staff.m_name = cellValue; } else if (colName == "colS3") { staff.m_sex = cellValue; } else if (colName == "colS4") { staff.m_state = cellValue; } else if (colName == "colS5") { staff.m_education = cellValue; } else if (colName == "colS6") { staff.m_degree = cellValue; } else if (colName == "colS7") { staff.m_birthDay = cellValue; } else if (colName == "colS8") { staff.m_entryDay = cellValue; } else if (colName == "colS9") { staff.m_canSelect = cellValue; } else if (colName == "colS10") { staff.m_isManager = cellValue; } DataCenter.StaffService.Save(staff); } }
/// <summary> /// 绑定员工 /// </summary> public void BindStaffs() { m_gridStaffs.BeginUpdate(); List <StaffInfo> staffs = DataCenter.StaffService.GetAliveStaffs(); int staffsSize = staffs.Count; for (int i = 0; i < staffsSize; i++) { StaffInfo staff = staffs[i]; GridRow row = new GridRow(); m_gridStaffs.AddRow(row); row.AddCell(0, new GridStringCell(staff.m_jobID)); row.AddCell(1, new GridStringCell(staff.m_name)); } m_gridStaffs.EndUpdate(); m_gridStaffs.Invalidate(); }
/// <summary> /// 绑定员工到结果表格 /// </summary> public void BindJobIdsToResultGrid(String jobIDs) { m_gridResult.BeginUpdate(); String[] strs = jobIDs.Split(new String[] { "," }, StringSplitOptions.RemoveEmptyEntries); int strsSize = strs.Length; for (int i = 0; i < strsSize; i++) { StaffInfo staff = DataCenter.StaffService.GetStaff(strs[i]); GridRow row = new GridRow(); m_gridResult.AddRow(row); row.AddCell(0, new GridStringCell(staff.m_jobID)); row.AddCell(1, new GridStringCell(staff.m_name)); } m_gridResult.EndUpdate(); m_gridResult.Invalidate(); }
/// <summary> /// 添加员工 /// </summary> /// <param name="staff">员工</param> public void AddStaffToGrid(StaffInfo staff) { List <GridRow> rows = m_gridStaffs.m_rows; int rowsSize = rows.Count; for (int i = 0; i < rowsSize; i++) { GridRow findRow = rows[i]; if (findRow.GetCell("colS1").GetString() == staff.m_jobID) { findRow.GetCell("colS2").SetString(staff.m_name); findRow.GetCell("colS3").SetString(staff.m_sex); findRow.GetCell("colS4").SetString(staff.m_state); findRow.GetCell("colS5").SetString(staff.m_education); findRow.GetCell("colS6").SetString(staff.m_degree); findRow.GetCell("colS7").SetString(staff.m_birthDay); findRow.GetCell("colS8").SetString(staff.m_entryDay); findRow.GetCell("colS9").SetString(staff.m_canSelect); findRow.GetCell("colS10").SetString(staff.m_isManager); return; } } GridRow row = new GridRow(); m_gridStaffs.AddRow(row); row.AddCell("colS1", new GridStringCell(staff.m_jobID)); row.AddCell("colS2", new GridStringCell(staff.m_name)); row.AddCell("colS3", new GridStringCell(staff.m_sex)); row.AddCell("colS4", new GridStringCell(staff.m_state)); row.AddCell("colS5", new GridStringCell(staff.m_education)); row.AddCell("colS6", new GridStringCell(staff.m_degree)); row.AddCell("colS7", new GridStringCell(staff.m_birthDay)); row.AddCell("colS8", new GridStringCell(staff.m_entryDay)); row.AddCell("colS9", new GridStringCell(staff.m_canSelect)); row.AddCell("colS10", new GridStringCell(staff.m_isManager)); List <GridCell> cells = row.GetCells(); int cellsSize = cells.Count; for (int j = 1; j < cellsSize; j++) { cells[j].AllowEdit = true; } }
/// <summary> /// 保存信息 /// </summary> /// <param name="staff">员工信息</param> public void Save(StaffInfo staff) { bool modify = false; int staffsSize = m_staffs.Count; for (int i = 0; i < staffsSize; i++) { if (m_staffs[i].m_jobID == staff.m_jobID) { m_staffs[i] = staff; modify = true; break; } } if (!modify) { m_staffs.Add(staff); } Save(); }
/// <summary> /// 绑定员工 /// </summary> private void BindStaffs() { m_gridPersonals.CellEditMode = GridCellEditMode.DoubleClick; List <StaffInfo> staffs = DataCenter.StaffService.m_staffs; int staffsSize = staffs.Count; Dictionary <String, PersonalInfo> personalsMap = new Dictionary <String, PersonalInfo>(); List <PersonalInfo> personals = DataCenter.PersonalService.m_personals; int personalsSize = personals.Count; for (int i = 0; i < personalsSize; i++) { PersonalInfo personal = personals[i]; if (personal.m_jobID != null && personal.m_jobID.Length > 0) { personalsMap[personal.m_jobID] = personal; } } m_gridPersonals.ClearRows(); m_gridPersonals.BeginUpdate(); for (int i = 0; i < staffsSize; i++) { StaffInfo staff = staffs[i]; PersonalInfo personal = null; if (personalsMap.ContainsKey(staff.m_jobID)) { personal = personalsMap[staff.m_jobID]; } else { personal = new PersonalInfo(); } GridRow row = new GridRow(); m_gridPersonals.AddRow(row); row.AddCell("colS1", new GridStringCell(staff.m_jobID)); row.AddCell("colS2", new GridStringCell(staff.m_name)); row.AddCell("colS3", new GridStringCell(personal.m_marry)); row.AddCell("colS4", new GridStringCell(personal.m_loan)); row.AddCell("colS5", new GridStringCell(personal.m_house)); row.AddCell("colS6", new GridStringCell(personal.m_parent)); row.AddCell("colS7", new GridStringCell(personal.m_body)); row.AddCell("colS8", new GridStringCell(personal.m_sb)); row.AddCell("colS9", new GridStringCell(personal.m_eat)); row.AddCell("colS10", new GridStringCell(personal.m_teach)); row.AddCell("colS11", new GridStringCell(personal.m_pay)); row.AddCell("colS12", new GridStringCell(personal.m_dress)); row.AddCell("colS13", new GridStringCell(personal.m_cross)); row.AddCell("colS14", new GridStringCell(personal.m_game)); row.AddCell("colS15", new GridStringCell(personal.m_sports)); row.AddCell("colS16", new GridStringCell(personal.m_pet)); row.AddCell("colS17", new GridStringCell(personal.m_lead)); row.AddCell("colS18", new GridStringCell(personal.m_gay)); row.AddCell("colS19", new GridStringCell(personal.m_preference)); row.AddCell("colS20", new GridStringCell(personal.m_oldWork)); row.AddCell("colS21", new GridStringCell(personal.m_drink)); row.AddCell("colS22", new GridStringCell(personal.m_smoke)); List <GridCell> cells = row.GetCells(); int cellsSize = cells.Count; for (int j = 2; j < cellsSize; j++) { cells[j].AllowEdit = true; } } m_gridPersonals.EndUpdate(); m_gridPersonals.Invalidate(); personalsMap.Clear(); }
/// <summary> /// 绑定员工 /// </summary> private void BindStaffs() { m_gridStaffs.CellEditMode = GridCellEditMode.DoubleClick; List <StaffInfo> staffs = DataCenter.StaffService.GetAliveStaffs(); int staffsSize = staffs.Count; Dictionary <String, DimensionInfo> dimensionsMap = new Dictionary <String, DimensionInfo>(); List <DimensionInfo> dimensions = DataCenter.DimensionService.m_dimensions; int dimensionsSize = dimensions.Count; for (int i = 0; i < dimensionsSize; i++) { DimensionInfo dimension = dimensions[i]; if (dimension.m_jobID != null && dimension.m_jobID.Length > 0) { dimensionsMap[dimension.m_jobID] = dimension; } } m_gridStaffs.ClearRows(); m_gridStaffs.BeginUpdate(); for (int i = 0; i < staffsSize; i++) { StaffInfo staff = staffs[i]; DimensionInfo dimension = null; if (dimensionsMap.ContainsKey(staff.m_jobID)) { dimension = dimensionsMap[staff.m_jobID]; } else { dimension = new DimensionInfo(); dimension.m_business = 100; dimension.m_EQ = 100; dimension.m_IQ = 100; dimension.m_knowledge = 100; dimension.m_lead = 100; dimension.m_technology = 100; dimension.m_jobID = staff.m_jobID; } GridRow row = new GridRow(); m_gridStaffs.AddRow(row); row.AddCell("colF1", new GridStringCell(staff.m_jobID)); row.AddCell("colF2", new GridStringCell(staff.m_name)); row.AddCell("colF3", new GridIntCell(dimension.m_business)); row.AddCell("colF4", new GridIntCell(dimension.m_EQ)); row.AddCell("colF5", new GridIntCell(dimension.m_knowledge)); row.AddCell("colF6", new GridIntCell(dimension.m_IQ)); row.AddCell("colF7", new GridIntCell(dimension.m_lead)); row.AddCell("colF8", new GridIntCell(dimension.m_technology)); int avg = (dimension.m_business + dimension.m_EQ + dimension.m_knowledge + dimension.m_IQ + dimension.m_lead + dimension.m_technology) / 6; row.AddCell("colF9", new GridIntCell(avg)); List <GridCell> cells = row.GetCells(); int cellsSize = cells.Count; for (int j = 2; j < cellsSize - 1; j++) { cells[j].AllowEdit = true; } } m_gridStaffs.EndUpdate(); m_gridStaffs.Invalidate(); dimensionsMap.Clear(); }