/* * 方法 */ #region [ 方法: DataGridView绑定函数 ] void BindDataGridView() { lblCounts.Text = ""; if (txtBlock.Text.ToString() != "") { try { Convert.ToInt32(txtBlock.Text); } catch { lblCounts.ForeColor = Color.Red; lblCounts.Text = "卡号只能为数字!"; return; } } #region 得到查询条件 string strWhere = string.Empty; string strTime = string.Empty; strWhere = " and DataAttendance >='" + dtpStartTime.Text + "' and DataAttendance <='" + dtpEndTime.Text + "'"; if (ddlDept.SelectedValue.ToString() != "0") { strTime = " en.DeptID =" + ddlDept.SelectedValue.ToString(); } if (ddlDuty.SelectedValue.ToString() != "0") { if (strTime != "") { strTime = strTime + " and en.DutyID =" + ddlDuty.SelectedValue.ToString(); } else { strTime = " en.DutyID =" + ddlDuty.SelectedValue.ToString(); } } if (this.txtEmployeeName.Text.Trim() != "") { if (strTime != "") { strTime = strTime + " and ei.EmpName like ('" + txtEmployeeName.Text.Trim() + "')"; } else { strTime = " ei.EmpName like ('" + txtEmployeeName.Text.Trim() + "')"; } } if (txtBlock.Text.Trim() != "") { if (strTime != "") { strTime = strTime + " and A.卡号 = " + txtBlock.Text.Trim(); } else { strTime = " A.卡号 = " + txtBlock.Text.Trim(); } } if (strTime != "") { strTime = " where " + strTime; } #endregion strWhere += " And EmployeeID is not null "; DataSet ds = aBLL.GetAttendanceStatisticByDuty(strWhere, strTime, out strErr); if (strErr.ToString() == "Succeeds") { ds.Tables[0].Columns[1].ColumnName = HardwareName.Value(CorpsName.CodeSenderAddress); dgrd.DataSource = ds.Tables[0]; dgrd.AddSpanHeader(6, 3, "其 中"); lblCounts.ForeColor = Color.Blue; lblCounts.Text = "共有 " + ds.Tables[0].Rows.Count.ToString() + " 条记录"; } }