示例#1
0
 private void ConnectionEdit_Load(object sender, EventArgs e)
 {
     this.colConnectionType.DataSource = Enum.GetNames(typeof(WSH.CodeBuilder.DispatchServers.DataBaseType));
     if (IsSelect)
     {
         this.grid.AllowUserToAddRows    = false;
         this.grid.AllowUserToDeleteRows = false;
         this.grid.AllowMenuDelete       = false;
         this.grid.ReadOnly = true;
     }
     DataSource           = service.GetConnectionDataTable();
     this.grid.DataSource = DataSource;
     if (!string.IsNullOrEmpty(this.RecordID))
     {
         foreach (DataGridViewRow row in this.grid.Rows)
         {
             if (!row.IsNewRow)
             {
                 DataRowView rowView = (DataRowView)(row.DataBoundItem);
                 if (ConvertHelper.AsEmpty(rowView["ID"]) == this.RecordID)
                 {
                     row.Selected = true;
                     break;
                 }
             }
         }
     }
 }
示例#2
0
 public override bool SaveData()
 {
     if (IsSelect)
     {
         DataRowView row = (DataRowView)(this.grid.SelectedRows[0].DataBoundItem);
         this.RecordID       = row["ID"].ToString();
         this.ConnectionName = ConvertHelper.AsEmpty(row["ConnectionName"]);
         return(true);
     }
     else
     {
         return(service.BatchUpdateConnection(DataSource));
     }
 }
示例#3
0
 //测试连接
 private void grid_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.ColumnIndex == 3 && e.RowIndex > -1)
     {
         DataGridViewCellCollection cells = this.grid.Rows[e.RowIndex].Cells;
         string str    = ConvertHelper.AsEmpty(cells["colConnectionString"].Value);
         string dbType = ConvertHelper.AsEmpty(cells["colConnectionType"].Value);
         if (!string.IsNullOrEmpty(str) && !string.IsNullOrEmpty(dbType))
         {
             DbConnectionOptions option = new DbConnectionOptions()
             {
                 ConnectionString = str
             };
             Result r = DataBaseHelper.Test(DataBaseHelper.GetDbType(dbType), option);
             MsgBox.Alert(r.Msg);
         }
         else
         {
             MsgBox.Alert("连接字符串或者数据库类型为空");
         }
     }
 }