예제 #1
0
        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);
                }
            }
        }
예제 #2
0
        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);
        }
예제 #3
0
 public frmSourceEdit(DbSourceStruct db)
     : this()
 {
     Current         = db;
     providerName    = db.Type;
     Text            = "添加 " + db.Type + " 数据源";
     txtName.Text    = db.Name;
     txtConnStr.Text = db.ConnectionString;
 }
예제 #4
0
        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();
        }