private void tbtnAdd_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e) { var source = new DbSourceStruct { Type = e.ClickedItem.Text }; using (var frm = new frmSourceEdit(source)) { if (frm.ShowDialog() == DialogResult.OK) { var item = new TreeListItem(); lstProvider.Items.Add(item); item.Group = source.Type; item.ImageIndex = 0; item.Tag = source; item.Cells[0].Value = source.Name; item.Cells[1].Value = source.ConnectionString; sources.Add(source); SaveDataSources(); lstProvider.Grouping(true); } } }
public List <Table> Preview() { IEnumerable <Table> tables = null; using (var frm = new frmSourceMgr()) { if (frm.ShowDialog() == DialogResult.OK) { con = frm.DbConStr; tables = OpenDb(); } } if (tables == null) { return(null); } using (var frm = new frmTableSelector(tables)) { if (frm.ShowDialog() == DialogResult.OK) { return(frm.Selected.Count == 0 ? null : frm.Selected); } } return(null); }
public frmSourceEdit(DbSourceStruct db) : this() { Current = db; providerName = db.Type; Text = "添加 " + db.Type + " 数据源"; txtName.Text = db.Name; txtConnStr.Text = db.ConnectionString; }
private void tbtnSelect_Click(object sender, EventArgs e) { if (lstProvider.SelectedItems.Count == 0) { return; } var item = lstProvider.SelectedItems[0]; DbConStr = new DbSourceStruct { Type = item.Group, ConnectionString = item.Cells[1].Value.ToString() }; DialogResult = System.Windows.Forms.DialogResult.OK; Close(); }