/* * 方法 */ #region [ 方法: DataGridView数据绑定 ] void BindDataGridView() { string strWhere = string.Empty; if (ddlDept.SelectedValue.ToString() != "0") { strWhere += " and D.DeptID = " + ddlDept.SelectedValue.ToString(); } DataSet ds = aBLL.GetEmployeeAttendanceDayByDayStatistic(dtpStartTime.Value.ToString("yyyy-MM-dd"), dtpEndTime.Value.ToString("yyyy-MM-dd"), strWhere, 1, 10000, out strErr); if (ds != null) { DataTable dt = new DataTable(); dgrd.DataSource = ds.Tables[0]; if (ds.Tables[0].Rows.Count != 0) { if (ds.Tables[0].Columns.Count == 6) { dgrd.AddSpanHeader(3, 3, ds.Tables[0].Columns[3].ColumnName.ToString()); dgrd.Columns[3].HeaderText = "出勤次数"; dgrd.Columns[4].HeaderText = "工时合计(分)"; dgrd.Columns[5].HeaderText = "均工时数(分)"; } if (ds.Tables[0].Columns.Count == 9) { dgrd.AddSpanHeader(3, 3, ds.Tables[0].Columns[3].ColumnName.ToString()); dgrd.Columns[3].HeaderText = "出勤次数"; dgrd.Columns[4].HeaderText = "工时合计(分)"; dgrd.Columns[5].HeaderText = "均工时数(分)"; dgrd.AddSpanHeader(6, 3, ds.Tables[0].Columns[6].ColumnName.ToString()); dgrd.Columns[6].HeaderText = "出勤次数"; dgrd.Columns[7].HeaderText = "工时合计(分)"; dgrd.Columns[8].HeaderText = "均工时数(分)"; } if (ds.Tables[0].Columns.Count == 12) { dgrd.AddSpanHeader(3, 3, ds.Tables[0].Columns[3].ColumnName.ToString()); dgrd.Columns[3].HeaderText = "出勤次数"; dgrd.Columns[4].HeaderText = "工时合计(分)"; dgrd.Columns[5].HeaderText = "均工时数(分)"; dgrd.AddSpanHeader(6, 3, ds.Tables[0].Columns[6].ColumnName.ToString()); dgrd.Columns[6].HeaderText = "出勤次数"; dgrd.Columns[7].HeaderText = "工时合计(分)"; dgrd.Columns[8].HeaderText = "均工时数(分)"; dgrd.AddSpanHeader(9, 3, ds.Tables[0].Columns[9].ColumnName.ToString()); dgrd.Columns[9].HeaderText = "出勤次数"; dgrd.Columns[10].HeaderText = "工时合计(分)"; dgrd.Columns[11].HeaderText = "均工时数(分)"; } } } }