private void radioButtonClickProc(RadioButton rd, string way) { foreach (ListViewItem item in this.listView_TblSel.SelectedItems) { SDBTable tbl = m_SelTables[item.Text]; if (way == "delete") { if (rd.Checked) { tbl.delete_method = rd.Text; } else { tbl.delete_method = ""; } } else if ("import" == way) { if (rd.Checked) { tbl.import_method = rd.Text; } else { tbl.import_method = ""; } } } }
private void listView_TblSel_Click(object sender, EventArgs e) { radioButton_delete.Checked = false; radioButton_truncate.Checked = false; radioButton_replace.Checked = false; radioButton_insert.Checked = false; radioButton_insert_update.Checked = false; radioButton_delete_clear.Checked = false; foreach (ListViewItem item in this.listView_TblSel.SelectedItems) { SDBTable tbl = m_SelTables[item.Text]; if (radioButton_delete.Text == tbl.delete_method) { radioButton_delete.Checked = true; } if (radioButton_truncate.Text == tbl.delete_method) { radioButton_truncate.Checked = true; } if (radioButton_replace.Text == tbl.import_method) { radioButton_replace.Checked = true; } if (radioButton_insert.Text == tbl.import_method) { radioButton_insert.Checked = true; } if (radioButton_insert_update.Text == tbl.import_method) { radioButton_insert_update.Checked = true; } } }
private void button_select_Click(object sender, EventArgs e) { var items = this.listView_table.SelectedItems; foreach (ListViewItem item in items) { bool badd = true; if (item.SubItems[1].Text.Trim().Length > 1) { foreach (ListViewItem item2 in this.listView_TblSel.Items) { if (item.Text == item2.Text) { badd = false; } } if (badd) { this.listView_TblSel.Items.Add(item.Text); SDBTable tbl = new SDBTable(); tbl.name = item.Text; tbl.schema = m_Schema; m_SelTables.Add(tbl.name, tbl); item.ForeColor = Color.Red; item.Selected = false; } } else { MessageBox.Show("目标数据库中没有表" + item.Text + ",无法同步表数据!"); } } }
private void button_sync_Click(object sender, EventArgs e) { if (m_Schema.Length < 1) { MessageBox.Show("请选择Schema!"); return; } CGenDB2ExpImpBat batFile = new CGenDB2ExpImpBat(); getSourceDBAndDestDBInfo(out batFile.m_sDB2Info, out batFile.m_dDB2Info); batFile.m_sDB2Info.user = textBox_sDBUser.Text; batFile.m_sDB2Info.passwd = textBox_sDBPwd.Text; batFile.m_dDB2Info.user = textBox_dDBUser.Text; batFile.m_dDB2Info.passwd = textBox_dDBPwd.Text; { SDB2Connection sConn, dConn; getSourceDBAndDestDBInfo(out sConn, out dConn); CDB2Option opt = new CDB2Option(dConn); //opt.TableSchema = m_Schema; foreach (KeyValuePair <string, SDBTable> kv in m_SelTables) { batFile.m_tables.Add(kv.Value); SDBTable stbl = kv.Value; opt.TableSchema = stbl.schema; if (stbl.delete_method == "delete") { opt.delete(stbl.name); } else if (stbl.delete_method == "truncate") { opt.truncate(stbl.name); } } } CTool.CheckPathExistOrCreate("./export_data/"); CTool.DeleteDirAllFiles("./export_data/"); batFile.m_TableSchema = m_Schema; batFile.m_FileName = "./export_data/NJFKDJHSJFLSJFLS.bat"; batFile.GenFile(); CCmd cmd = new CCmd(); cmd.cmd("db2cmd " + batFile.m_FileName); }