public void DoGetList(object sender, GetListEventArgs e) { if (this.GetList != null) this.GetList(sender, e); }
void FillServerNameList() { if (this.comboBox_server.Items.Count > 0) return; GetListEventArgs e1 = new GetListEventArgs(); this.Container.DoGetList(this, e1); if (string.IsNullOrEmpty(e1.ErrorInfo) == false) { MessageBox.Show(this.Container, e1.ErrorInfo); return; } foreach (string value in e1.Values) { comboBox_server.Items.Add(value); } }
void FillDbNameList(bool bMessageBox = true) { if (this.comboBox_dbName.Items.Count > 0) return; if (HasServerColumn == true) { if (string.IsNullOrEmpty(this.comboBox_server.Text) == true) { if (bMessageBox == true) MessageBox.Show(this.Container, "请先选定服务器"); return; } } GetListEventArgs e1 = new GetListEventArgs(); if (HasServerColumn == true) e1.Path = this.comboBox_server.Text; else e1.Path = ""; this.Container.DoGetList(this, e1); if (string.IsNullOrEmpty(e1.ErrorInfo) == false) { if (bMessageBox == true) MessageBox.Show(this.Container, e1.ErrorInfo); return; } foreach (string value in e1.Values) { comboBox_dbName.Items.Add(value); } }
void FillFromList(bool bMessageBox = true) { if (this.comboBox_from.Items.Count > 0) return; // TODO: 如果Container没有挂接GetList事件,则可以尽早返回 if (HasServerColumn == true) { if (string.IsNullOrEmpty(this.comboBox_server.Text) == true) { if (bMessageBox == true) MessageBox.Show(this.Container, "请先选定服务器"); return; } } if (string.IsNullOrEmpty(this.comboBox_dbName.Text) == true) { if (bMessageBox == true) MessageBox.Show(this.Container, "请先选定数据库"); return; } GetListEventArgs e1 = new GetListEventArgs(); e1.Path = (HasServerColumn == true ? this.comboBox_server.Text + "/" : "") + this.comboBox_dbName.Text; this.Container.DoGetList(this, e1); if (string.IsNullOrEmpty(e1.ErrorInfo) == false) { if (bMessageBox == true) MessageBox.Show(this.Container, e1.ErrorInfo); return; } foreach (string value in e1.Values) { comboBox_from.Items.Add(value); } }
private void dp2QueryControl1_GetList(object sender, GetListEventArgs e) { // 获得所有数据库名 if (string.IsNullOrEmpty(e.Path) == true) { if (this.MainForm.BiblioDbProperties != null) { for (int i = 0; i < this.MainForm.BiblioDbProperties.Count; i++) { BiblioDbProperty property = this.MainForm.BiblioDbProperties[i]; if (this.DbType == "item") { if (String.IsNullOrEmpty(property.ItemDbName) == false) e.Values.Add(property.ItemDbName); } else if (this.DbType == "comment") { if (String.IsNullOrEmpty(property.CommentDbName) == false) e.Values.Add(property.CommentDbName); } else if (this.DbType == "order") { if (String.IsNullOrEmpty(property.OrderDbName) == false) e.Values.Add(property.OrderDbName); } else if (this.DbType == "issue") { if (String.IsNullOrEmpty(property.IssueDbName) == false) e.Values.Add(property.IssueDbName); } else throw new Exception("未知的DbType '" + this.DbType + "'"); } } } else { // 获得特定数据库的检索途径 // 每个库都一样 List<string> froms = GetFromList(); foreach (string from in froms) { e.Values.Add(from); } } }
private void dp2QueryControl1_GetList(object sender, GetListEventArgs e) { // 列出服务器 if (string.IsNullOrEmpty(e.Path) == true) { e.Values = this.dp2ResTree1.GetServerNames(); return; } try { string[] parts = e.Path.Split(new char[] { '/' }); if (parts.Length == 1) { e.Values = this.dp2ResTree1.GetDbNames(parts[0]); } else if (parts.Length == 2) { e.Values = this.dp2ResTree1.GetFromNames(parts[0], parts[1]); } } catch (Exception ex) { if (string.IsNullOrEmpty(ex.Message) == true) e.ErrorInfo = "error"; else e.ErrorInfo = ex.Message; return; } }