Пример #1
0
 public void DBAdapter(object SQL)
 {
     MyInvoke mi = new MyInvoke(miCMDSQL);
     MyInvoke end = new MyInvoke(miEND);
     MainForm f1 = new MainForm();
     UpdateItemInfo uii = new UpdateItemInfo(f1.GetItemInfo);
     DataSet ds = new DataSet();
     MySqlConnection Conn = new MySqlConnection(MainForm.GetConnStr());
     MySqlCommand setname = new MySqlCommand("set names 'gbk';", Conn);
     MySqlDataAdapter adp = new MySqlDataAdapter(SQL.ToString(), Conn);
     try
     {
         Conn.Open();
         setname.ExecuteNonQuery();
         setname.Dispose();
         adp.Fill(ds);
         this.Invoke(uii, ds);
         this.Invoke(mi, "执行成功!");
         Thread.Sleep(1000);
         this.Invoke(end, "true");
     }
     catch (Exception err)
     {
         ItemInfo.Stat = false;
         this.Invoke(mi, "执行失败!");
         this.Invoke(end, err.Message);
     }
 }
Пример #2
0
 private void RowsPerPageTextBox_TextChanged(object sender, EventArgs e)
 {
     MainForm f1 = new MainForm();
     if (f1.GetValue("\\d+", RowsPerPageTextBox.Text).Length > 0)
     {
         if (Convert.ToInt32(f1.GetValue("\\d+", RowsPerPageTextBox.Text)) > 1000)
             toolTip1.Show("每页显示数量过多容易导致程序无响应,建议不要超过500", this, RowsPerPageTextBox.Location.X, RowsPerPageTextBox.Location.Y + RowsPerPageTextBox.Height+30);
     }
 }
Пример #3
0
 private void ResaultList_SelectedIndexChanged(object sender, EventArgs e)
 {
     MainForm f1 = new MainForm();
     if(f1.GetValue("\\d+",RowsPerPageTextBox.Text).Length>0)
         RowsPerPage = Convert.ToInt32(f1.GetValue("\\d+",RowsPerPageTextBox.Text));
     dataGridView1.Columns.Clear();
     dataGridView1.Rows.Clear();
     if (ResaultDataSet[ResaultList.SelectedIndex].Tables.Count > 0)
     {
         foreach (DataColumn dc in ResaultDataSet[ResaultList.SelectedIndex].Tables[0].Columns)
         {
             dataGridView1.Columns.Add(dc.ColumnName.ToString(), dc.ColumnName.ToString());
         }
         if (ResaultDataSet[ResaultList.SelectedIndex].Tables[0].Rows.Count > 0)
         {
             if (ResaultDataSet[ResaultList.SelectedIndex].Tables[0].Rows.Count > RowsPerPage)
             {
                 PageList.Items.Clear();
                 GetPage(ResaultList.SelectedIndex);
                 PageList.SelectedItem = PageList.Items[0];
                 PageList.Enabled = true;
             }
             else
             {
                 foreach (DataRow dr in ResaultDataSet[ResaultList.SelectedIndex].Tables[0].Rows)
                 {
                     object[] dtrow = new object[dr.Table.Columns.Count];
                     for (int ii = 0; ii < dr.Table.Columns.Count; ii++)
                     {
                         if (dr[ii] == DBNull.Value)
                         {
                             dtrow[ii] = "null";
                         }
                         else
                         {
                             dtrow[ii] = dr[ii].ToString();
                         }
                     }
                     dataGridView1.Rows.Add(dtrow);
                 }
                 BackBtn.Enabled = false;
                 NextBtn.Enabled = false;
                 PageList.Enabled = false;
             }
         }
         else
         {
             dataGridView1.Rows.Add("没有记录。");
         }
         ResaultStatLabel.Text = "返回" + ResaultDataSet[ResaultList.SelectedIndex].Tables[0].Columns.Count.ToString() + "列" + ResaultDataSet[ResaultList.SelectedIndex].Tables[0].Rows.Count.ToString() + "行数据。";
     }
     else
     {
         dataGridView1.Columns.Add("column1", string.Empty);
         dataGridView1.Rows.Add("没有返回数据。");
     }
 }
Пример #4
0
 private void SearchBtn_Click(object sender, EventArgs e)
 {
     MainForm f1 = new MainForm();
     if (f1.GetValue("\\d+", RowsPerPageTextBox.Text).Length > 0)
         RowsPerPage = Convert.ToInt32(f1.GetValue("\\d+", RowsPerPageTextBox.Text));
     SearchBtn.Enabled = false;
     PageList.Enabled = false;
     BackBtn.Enabled = false;
     NextBtn.Enabled = false;
     PageList.Items.Clear();
     Thread SearchThread = new Thread(new ParameterizedThreadStart(SearchItem));
     SearchThread.IsBackground = true;
     if (ItemNameTextBox.Text.Trim().Length > 0)
     {
         SearchThread.Start(ItemNameTextBox.Text.Trim());
     }
     else
     {
         SearchThread.Start("%");
     }
 }