private void btnStartLab_Click(object sender, RoutedEventArgs e) { if (cmbType.SelectedIndex >= 0) { try { switch (cmbType.SelectedIndex) { case 0: Add(int.Parse(txtlblPrompt1.Text), int.Parse(txtlblPrompt2.Text)); break; case 2: Upd(cmbField.Text, int.Parse(txtlblPrompt2.Text), txtlblPrompt3.Text); break; case 1: Del(int.Parse(txtlblPrompt1.Text), int.Parse(txtlblPrompt2.Text)); break; } DBlink myLink = new DBlink(); dgvDB.ItemsSource = myLink.Read(TableName, DBType).DefaultView; } catch { MessageBox.Show("参数错误!", "操作提示"); } } else { MessageBox.Show("请您先选择实验类型!", "操作提示"); } }
public ViewForm(string TableName, string DBType) { InitializeComponent(); this.TableName = TableName; this.DBType = DBType; lbTitle.Content = TableName; DBlink mylink = new DBlink(); dgvDBView.ItemsSource = mylink.Read(TableName, DBType).DefaultView; }
/// <summary> /// 打开SQL Server数据库 /// </summary> /// <param name="filePath"></param> private void SelectSQL() { DBlink mylink = new DBlink(); TableList = mylink.SQLconection(txtDBPath.Text); if (TableList == null) { MessageBox.Show("数据库打开失败", "操作提示"); } else { dgvDB.ItemsSource = mylink.Read(TableName, DBType).DefaultView; } }
private void btnStartLab_Click(object sender, RoutedEventArgs e) { if (cmbType.SelectedIndex >= 0) { try { switch (cmbType.SelectedIndex) { case 0: Add(int.Parse(txtlblPrompt1.Text), int.Parse(txtlblPrompt2.Text)); break; case 2: Upd(cmbField.Text, int.Parse(txtlblPrompt2.Text), txtlblPrompt3.Text ); break; case 1: Del(int.Parse(txtlblPrompt1.Text), int.Parse(txtlblPrompt2.Text)); break; } DBlink myLink = new DBlink(); dgvDB.ItemsSource = myLink.Read(TableName, DBType).DefaultView; } catch { MessageBox.Show("参数错误!", "操作提示"); } } else { MessageBox.Show("请您先选择实验类型!", "操作提示"); } }
private void btnRefresh_Click(object sender, RoutedEventArgs e) { DBlink myLink = new DBlink(); dgvDBView.ItemsSource = myLink.Read(TableName, DBType).DefaultView; }