Exemplo n.º 1
0
 public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
 {
     if (context != null && context.Instance != null && provider != null)
     {
         IWindowsFormsEditorService service = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
         if (service != null)
         {
             Connection cnn = context.Instance as Connection;
             if (cnn != null)
             {
                 if (cnn.DatabaseType != null)
                 {
                     if (typeof(OleDbConnection).Equals(cnn.DatabaseType))
                     {
                         dlgDBAccess dlg = new dlgDBAccess();
                         dlg.SetForDatabaseEdit();
                         dlg.LoadData(cnn.ConnectionString);
                         if (service.ShowDialog(dlg) == System.Windows.Forms.DialogResult.OK)
                         {
                             cnn.SetCredential0(dlg.sUser, dlg.sPass, dlg.sDBPass);
                             return(dlg.sConnectionString);
                         }
                     }
                     if (typeof(SqlConnection).Equals(cnn.DatabaseType))
                     {
                         dlgSQLServer dlg = new dlgSQLServer();
                         dlg.LoadData(cnn.ConnectionString);
                         if (service.ShowDialog(dlg) == System.Windows.Forms.DialogResult.OK)
                         {
                             cnn.SetCredential(dlg.sDBUser, dlg.sPassword, null);
                             return(dlg.sConnectionString);
                         }
                     }
                     else
                     {
                         DlgText dlg = new DlgText();
                         dlg.LoadData(cnn.ConnectionString, "Specify connection string");
                         if (service.ShowDialog(dlg) == System.Windows.Forms.DialogResult.OK)
                         {
                             return(dlg.GetText());
                         }
                     }
                 }
                 else
                 {
                     MessageBox.Show("DatabaseType has not been set", "Connection string", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                 }
             }
         }
     }
     return(value);
 }
Exemplo n.º 2
0
 private void buttonEdit_Click(object sender, EventArgs e)
 {
     try
     {
         DlgText dlg = new DlgText();
         dlg.LoadData(editor1.BodyHtml, "Edit HTML Text");
         if (dlg.ShowDialog(this) == DialogResult.OK)
         {
             editor1.BodyHtml = dlg.GetText();
         }
     }
     catch (Exception err)
     {
         MessageBox.Show(this, err.Message, "Edit HTML", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }