首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET Framework >

根据学号和日期查询(程序补完整),该如何解决

2012-03-21 
根据学号和日期查询(程序补完整)如题:以下是我做得,后面的不知道怎么赋值?using Systemusing System.Coll

根据学号和日期查询(程序补完整)
如题:以下是我做得,后面的不知道怎么赋值?



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using ShineSoft.CountryInsure.InsureBPLOra;
using ShineSoft.CountryInsure.InsureEntityOra;


namespace WindowsApplication2
{
  public partial class Form1 : Form
  {
  public Form1()
  {
  InitializeComponent();
  }

  private void Form1_Load(object sender, EventArgs e)
  {

  }
  private System.Data.DataTable QQ;
  private void eulute()
  {
  QQ = new DataTable("STUDENT");
  QQ.Columns.Add(new DataColumn("ID"));
  QQ.Columns.Add(new DataColumn("NAME"));
  QQ.Columns.Add(new DataColumn("CHINESE"));
  QQ.Columns.Add(new DataColumn("MATH"));
  QQ.Columns.Add(new DataColumn("ENGLISH"));
  QQ.Columns.Add(new DataColumn("POLITY"));
  QQ.Columns.Add(new DataColumn("PCLASS"));
  QQ.Columns.Add(new DataColumn("TIME"));
  }

  private void button1_Click(object sender, EventArgs e)
  {
  this.Search(this.textBox1.SelectionLength,this.dateTimePicker1.Value.ToString(),this.dateTimePicker2.Value.AddDays(1).ToString());
  }

  private void button2_Click(object sender, EventArgs e)
  {
  Application.Exit();
  }
  private void Search(int ID, string dateTimePicker1, string dateTimePicker2)
  {
  this.listView1.Items.Clear();
  string SQL = "select *form STUDENT where ID='" + textBox1 + "'and TIME BETWEEN'" + dateTimePicker1 + "'AND'" + dateTimePicker2 + "'";
   
  string ww = "";

  if (Convert.ToInt32(textBox1.Text) <= 11 && Convert.ToInt32(textBox1.Text) >= 1)
  {
  ww = "where ID='" + textBox1 + "'and TIME BETWEEN'" + dateTimePicker1 + "'AND'" + dateTimePicker2 + "'";
  }
  else
  {
  MessageBox.Show("您的输入有误!!!");
  this.DialogResult = DialogResult.Cancel;
  return;
  }
  ww = "where TIME BETWEEN'" + dateTimePicker1 + "'AND'" + dateTimePicker2 + "'";
  SQL = SQL + ww;
  System.Data.DataTable a = new ManageReport().GetReportData(SQL);
  for (int i = 0; i < this.listView1.Items.Count; i++)
  {
  DataRow OO = this.QQ.NewRow();
  OO["NAME"] = this.listView1.Items[i].SubItems[1].Text;
  OO["CHINESE"] = this.listView1.Items[i].SubItems[2].Text;
  OO["MATH"] = this.listView1.Items[i].SubItems[3].Text;
  OO["ENGLISH"] = this.listView1.Items[i].SubItems[4].Text;
  OO["POLITY"] = this.listView1.Items[i].SubItems[5].Text;
  OO["PCLASS"] = this.listView1.Items[i].SubItems[6].Text;
  QQ.Rows.Add(OO);
  }
  }
  }
}


[解决办法]
private DataTable ww()
{
this.listView1.Items.Clear();
OracleConnection conn = new OracleConnection(@"Data Source=insure155;User ID=WZH;Password=zhezhua");
conn.Open();

string SQL1 = "", SQL2 = "", SQL3 = "", SQL4 = "";

if (comboBox1.Text != "全部")
{
SQL1 = " and CO='" + comboBox1.Text + "'";
}
else
SQL1 = "";

if (comboBox2.Text != "全部")
{
SQL2 = " and SEX='" + comboBox2.Text + "'";
}
else
SQL2 = "";

if (comboBox3.Text != "全部")
{
SQL3 = " and DEPT='" + comboBox3.Text + "'";
}
else
SQL3 = "";

if (comboBox4.Text != "全部")
{
SQL4 = " and PAY='" + comboBox4.Text + "'";
}
else
SQL4 = "";

string sql = "Select *from people where TIME>=to_date('" + dateTimePicker1.Value.ToString() + "','yyyy-mm-dd hh24:mi;ss')" +
"and TIME<to_date('" + dateTimePicker2.Value.ToString() + "','yyyy-mm-dd hh24:mi;ss') ";

sql = sql + SQL1 + SQL2 + SQL3 + SQL4;
OracleCommand cmd = new OracleCommand(sql, conn);
OracleDataAdapter odr = new OracleDataAdapter(cmd);
DataTable dt = new DataTable();
odr.Fill(dt);

//return dt;
for (int i = 0; i < dt.Rows.Count; i++)
{
ListViewItem lvi = new ListViewItem();
lvi.Text = (i+1).ToString();
lvi.SubItems.Add(dt.Rows[i]["NAME"].ToString());
lvi.SubItems.Add(dt.Rows[i]["RFNUMBER"].ToString());
lvi.SubItems.Add(dt.Rows[i]["HIGH"].ToString());
lvi.SubItems.Add(dt.Rows[i]["WEIGHT"].ToString());
lvi.SubItems.Add(dt.Rows[i]["XUELI"].ToString());
lvi.SubItems.Add(dt.Rows[i]["FACE"].ToString());
lvi.SubItems.Add(dt.Rows[i]["MARRY"].ToString());
this.listView1.Items.Add(lvi);
}
conn.Close();
cmd.Dispose();
return dt;
}


热点排行