2 u013342695 u013342695 于 2014.01.01 10:29 提问

求注释程序!!!最好一段一注释!!!,不行一行也行!!!!

namespace SoccerVIP
{
public partial class Form2 : Form

{
    DataSet myDataSet;//存放从数据库取来的数据的。
    OleDbConnection myOleConn;//连接对象,建立本程序和数据库的连接
    OleDbDataAdapter myDataAdapter;//用来执行SQL命令

    public Form2()
    {
        InitializeComponent();
    }
    public void RefreshDG()
    {
        if (myDataSet.Tables.Contains("SoccerClub"))
        {
            myDataSet.Tables.Remove("SoccerClub");
        }
        string sql = "select * from SoccerClub";
        myDataAdapter = new OleDbDataAdapter(sql, myOleConn);
        myDataAdapter.Fill(myDataSet, "SoccerClub");
        dataGridView1.DataSource = myDataSet.Tables["SoccerClub"];
    }

    private void Form2_Load(object sender, EventArgs e)
    {
        comboBox1.Items.Clear();
        comboBox1.Items.Add("tID");
        comboBox1.Items.Add("firstname");
        comboBox1.Items.Add("lastname");
        comboBox1.Items.Add("tel");
        comboBox1.Items.Add("address");
        comboBox1.Items.Add("favoriteTeam");
        comboBox1.Items.Add("rentTime");
        comboBox1.Items.Add("coach");

        try
        {
            string ConStr = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
              + System.Environment.CurrentDirectory + @"/dbSoccer.mdb";
            myOleConn = new OleDbConnection(ConStr);
            myOleConn.Open();

            myDataSet = new DataSet();
            RefreshDG();

        }

        catch
        {
            MessageBox.Show("连接数据库有问题,未连接成功。");
        }
    }

    private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
    {
        comboBox2.Items.Clear();
        comboBox2.Items.Add("=");
        if ((comboBox1.Text == "tID") ||
           (comboBox1.Text == "tel") ||
           (comboBox1.Text == "coach"))
        {
            comboBox2.Items.Add(">");
            comboBox2.Items.Add(">=");
            comboBox2.Items.Add("<");
            comboBox2.Items.Add("<=");

        }
    }

    private void button1_Click(object sender, EventArgs e)
    {
        if ((textBox1.Text == "") || (comboBox1.Text == "") || (comboBox2.Text == ""))
        {
            MessageBox.Show("查询条件不能为空");
            return;
        }

        string sql = "select * from SoccerClub where ";
        string str = "";
        if ((comboBox1.Text == "tID") ||
           (comboBox1.Text == "tel") ||
           (comboBox1.Text == "coach"))
        {
            str = comboBox1.Text + comboBox2.Text + textBox1.Text;
        }
        else
        {
            str = comboBox1.Text + comboBox2.Text + "'" + textBox1.Text + "'";
        }

        sql += str;

        if (myDataSet.Tables.Contains("SoccerClub"))
        {
            myDataSet.Tables.Remove("SoccerClub");

        }

        myDataAdapter = new OleDbDataAdapter(sql, myOleConn);
        myDataAdapter.Fill(myDataSet, "SoccerClub");
        dataGridView1.DataSource = myDataSet.Tables["SoccerClub"];
    }

    private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
    {
        System.Diagnostics.Process.Start(linkLabel1.Text);
    }

    private void label1_Click(object sender, EventArgs e)
    {

    }
}

}

Csdn user default icon
上传中...
上传图片
插入图片