void BindDataGridView() { try { //string StrWhere = CreateWhere(); EnabelAll(false); //StrWhere += " And EmployeeID is not null "; //intPageSize = Convert.ToInt32(cmbSelectCounts.Text); //DataSet ds = aBLL.GetEmployeeAttendanceParticulars(StrWhere, this.dtpBeginTime.Text, intPageIndex, intPageSize, out strErr); //clzt-2010-8-24--查询的表名称 //Czlt-2011-10-16 合并考勤注销 //DataSet ds = aBLL.GetEmployeeAttendanceParticulars(StrWhere, tableStartTime, intPageIndex, intPageSize, out strErr); //Czlt_GetEmployeeAttendanceParticulars //isUnoin = false; //不合并考勤 DataSet ds = aBLL.Czlt_GetEmployeeAttendanceParticulars(isUnoin, tableStartTime, tableEndTime, StrWhere, intPageIndex, intPageSize, endWhere, out strErr); if (ds != null && ds.Tables.Count > 0) { ds.Tables[0].Columns.Remove("ManHourNumber"); //工数 // ds.Tables[0].Columns.Remove("DataAttendance");//计工日期 ds.Tables[0].Columns.Remove("WorkTypeName"); //工种 ds.Tables[0].TableName = "A_AttendanceParticulars"; dgrd.Invoke(new BindData(DgvBindData), new object[] { ds.Tables[0] }); //dgrd.Columns[0].HeaderText = "标识卡号"; dgrd.Invoke(new HeadTextSet(SetHeadText), new object[] { 0, "卡号" }); //dgrd.Columns[1].HeaderText = "姓名"; //dgrd.Invoke(new HeadTextSet(SetHeadText), new object[] { 1, "卡号类型" }); dgrd.Invoke(new HeadTextSet(SetHeadText), new object[] { 1, "姓名" }); //dgrd.Columns[2].HeaderText = "部门"; dgrd.Invoke(new HeadTextSet(SetHeadText), new object[] { 2, "部门" }); //dgrd.Columns[3].HeaderText = "班次"; dgrd.Invoke(new HeadTextSet(SetHeadText), new object[] { 3, "班次" }); //dgrd.Columns[4].HeaderText = "所担职务"; dgrd.Invoke(new HeadTextSet(SetHeadText), new object[] { 4, "职务" }); //dgrd.Columns[4].HeaderText = "所担职务"; // dgrd.Invoke(new HeadTextSet(SetHeadText), new object[] { 5, "工种" }); //2011-02-23工种 //dgrd.Columns[5].HeaderText = "上班时间"; dgrd.Invoke(new HeadTextSet(SetHeadText), new object[] { 5, "下井时间" }); //dgrd.Columns[6].HeaderText = "下班时间"; dgrd.Invoke(new HeadTextSet(SetHeadText), new object[] { 6, "上井时间" }); //dgrd.Columns[7].HeaderText = "工作时长(分)"; dgrd.Invoke(new HeadTextSet(SetHeadText), new object[] { 7, "工作时长(时)" }); //dgrd.Columns[8].HeaderText = "工数"; //dgrd.Invoke(new HeadTextSet(SetHeadText), new object[] { 9, "工数" }); ////dgrd.Columns[9].HeaderText = "记工日期"; dgrd.Invoke(new HeadTextSet(SetHeadText), new object[] { 8, "记工日期" }); //Czlt-2012-04-22 设置上下井时间的显示样式 dgrd.Columns["BeginWorkTime"].DefaultCellStyle.Format = "yyyy-MM-dd HH:mm:ss"; dgrd.Columns["EndWorkTime"].DefaultCellStyle.Format = "yyyy-MM-dd HH:mm:ss"; intRowsCount = Convert.ToInt32(ds.Tables[1].Rows[0][0].ToString()); intPageCount = intRowsCount / intPageSize; if (intRowsCount % intPageSize != 0) { intPageCount++; } if (intPageCount == 0) { intPageCount = 1; } if (intPageIndex == 1) { //btnUpPage.Enabled = false; btnUpPage.Invoke(new ControlEnabelSet(SetControlEnabel), new object[] { btnUpPage, false }); } else { //btnUpPage.Enabled = true; btnUpPage.Invoke(new ControlEnabelSet(SetControlEnabel), new object[] { btnUpPage, true }); } if (intPageIndex == intPageCount) { //btnDownPage.Enabled = false; btnDownPage.Invoke(new ControlEnabelSet(SetControlEnabel), new object[] { btnDownPage, false }); } else { //btnDownPage.Enabled = true; btnDownPage.Invoke(new ControlEnabelSet(SetControlEnabel), new object[] { btnDownPage, true }); } lblCounts.Invoke(new LabelTextSet(SetLabelText), new object[] { lblCounts, "共有" + intRowsCount.ToString() + "条记录" }); lblCounts.Text = "共有" + intRowsCount.ToString() + "条记录"; lblPageCounts.Invoke(new LabelTextSet(SetLabelText), new object[] { lblPageCounts, intPageIndex.ToString() }); lblPageCounts.Text = intPageIndex.ToString(); lblSumPage.Invoke(new LabelTextSet(SetLabelText), new object[] { lblSumPage, "/" + intPageCount + "页" }); lblSumPage.Text = "/" + intPageCount + "页"; } else { DataTable dt = new DataTable("A_AttendanceParticulars_BindDataGridView"); dt.Columns.Add("卡号"); //dt.Columns.Add("卡号类型"); dt.Columns.Add("姓名"); dt.Columns.Add("部门"); dt.Columns.Add("班次"); dt.Columns.Add("职务"); dt.Columns.Add("下井时间"); dt.Columns.Add("上井时间"); dt.Columns.Add("工作时长(时)"); dt.Columns.Add("记工日期"); dgrd.Invoke(new BindData(DgvBindData), new object[] { dt }); lblCounts.Invoke(new LabelTextSet(SetLabelText), new object[] { lblCounts, "共有0条记录" }); } } catch (Exception ex) { try { pictureBox2.Invoke(new ControlVisiabelSet(SetControlVisiabel), new object[] { pictureBox2, false }); } catch (Exception exp) { } DataTable dt = new DataTable("A_AttendanceParticulars_BindDataGridView"); dt.Columns.Add("卡号"); //dt.Columns.Add("卡号类型"); dt.Columns.Add("姓名"); dt.Columns.Add("部门"); dt.Columns.Add("班次"); dt.Columns.Add("职务"); dt.Columns.Add("下井时间"); dt.Columns.Add("上井时间"); dt.Columns.Add("工作时长(时)"); dt.Columns.Add("记工日期"); dgrd.Invoke(new BindData(DgvBindData), new object[] { dt }); lblCounts.Invoke(new LabelTextSet(SetLabelText), new object[] { lblCounts, "共有0条记录" }); } //pictureBox2.Visible = false; try { EnabelAll(true); pictureBox2.Invoke(new ControlVisiabelSet(SetControlVisiabel), new object[] { pictureBox2, false }); } catch (Exception ex) { } }