protected virtual void QueryNGStatus() { string imageRecord = App.ImageRecord; bool flag = false; if (dateTimePicker1.Text.Equals(dateTimePicker2.Text)) { flag = true; } DateTime value; if (dateTimePicker2.Value < dateTimePicker2.Value) { dotNetLab.Tipper.Error = "第二个日期控件的日期必须大于或者等于前一个日期控件的日期。"; } else if (flag) { value = dateTimePicker1.Value; string arg = value.ToString("yyyy-MM-dd"); imageRecord = App.ImageRecord; dataGridView1.DataSource = ThisDB.ProvideTable(string.Format("SELECT * FROM {0} where 图像生成日期 like '{1}%' ;", imageRecord, arg), dotNetLab.Data.DBOperator.OPERATOR_QUERY_TABLE); } else { value = dateTimePicker1.Value; string arg2 = value.ToString("yyyy-MM-dd"); value = dateTimePicker2.Value; string arg3 = value.AddDays(1.0).ToString("yyyy-MM-dd"); string sql = string.Format("SELECT * FROM {0} where 图像生成日期 >='{1}' and 图像生成日期 <'{2}'", imageRecord, arg2, arg3); DataTable dataSource = ThisDB.ProvideTable(sql, dotNetLab.Data.DBOperator.OPERATOR_QUERY_TABLE); dataGridView1.DataSource = dataSource; } }
private void QueryLogs() { ThisDB = R.LogDB; string text = null; bool flag = false; if (dateTimePicker1.Text.Equals(dateTimePicker2.Text)) { flag = true; } DateTime value; if (dateTimePicker2.Value < dateTimePicker2.Value) { dotNetLab.Tipper.Error = "第二个日期控件的日期必须大于或者等于前一个日期控件的日期。"; } else if (flag) { value = dateTimePicker1.Value; string arg = value.ToString("yyyy-MM-dd"); value = dateTimePicker1.Value; object arg2 = value.Year; value = dateTimePicker1.Value; text = string.Format("_{0}_{1}", arg2, value.Month); dataGridView1.DataSource = ThisDB.ProvideTable(string.Format("SELECT Fire_Time as 触发时间,Message as 基本信息 FROM {0} where Fire_Time like '{1}%';", text, arg), dotNetLab.Data.DBOperator.OPERATOR_QUERY_TABLE); } else { value = dateTimePicker1.Value; string arg3 = value.ToString("yyyy-MM-dd"); value = dateTimePicker2.Value; string arg4 = value.AddDays(1.0).ToString("yyyy-MM-dd"); ThisDB.GetAllTableNames(); DataTable dataTable = new DataTable(); dataTable.Columns.Add(); dataTable.Columns[0].ColumnName = "触发时间"; dataTable.Columns.Add(); dataTable.Columns[1].ColumnName = "基本信息"; int num = 0; for (int i = 0; i < ThisDB.AllTableNames.Count; i++) { if (!ThisDB.DefaultTable.Equals(ThisDB.AllTableNames[i])) { text = ThisDB.AllTableNames[i]; DataTable dataTable2 = ThisDB.ProvideTable(string.Format("SELECT Fire_Time as 触发时间,Message as 基本信息 FROM {0} where Fire_Time >='{1}' and Fire_Time <'{2}';", text, arg3, arg4), dotNetLab.Data.DBOperator.OPERATOR_QUERY_TABLE); if (dataTable2 != null && dataTable2.Rows.Count > 0) { for (int j = 0; j < dataTable2.Rows.Count; j++) { dataTable.Rows.Add(); for (int k = 0; k < dataTable2.Columns.Count; k++) { dataTable.Rows[num][k] = dataTable2.Rows[j][k]; } num++; } } } } dataGridView1.DataSource = dataTable; } }