/// <summary> /// Shows a wait window with the specified text while executing the passed method. /// </summary> /// <param name="workerMethod">Pointer to the method to execute while displaying the wait window.</param> /// <param name="message">The text to display.</param> /// <param name="args">Arguments to pass to the worker method.</param> /// <returns>The result argument from the worker method.</returns> public static object Show(EventHandler <WaitWindowEventArgs> workerMethod, string message, params object[] args) { List <object> arguments = new List <object>(); arguments.AddRange(args); WaitWindow instance = new WaitWindow(); return(instance.Show(workerMethod, message, arguments)); }
public WaitWindowGUI(WaitWindow parent) { // // The InitializeComponent() call is required for Windows Forms designer support. // InitializeComponent(); this._Parent = parent; // Position the window in the top right of the main screen. this.Top = Screen.PrimaryScreen.WorkingArea.Top + 32; this.Left = Screen.PrimaryScreen.WorkingArea.Right - this.Width - 32; }
/// <summary> /// Shows a wait window with the specified text while executing the passed method. /// </summary> /// <param name="workerMethod">Pointer to the method to execute while displaying the wait window.</param> /// <param name="message">The text to display.</param> /// <returns>The result argument from the worker method.</returns> public static object Show(EventHandler <WaitWindowEventArgs> workerMethod, string message) { WaitWindow instance = new WaitWindow(); return(instance.Show(workerMethod, message, new List <object>())); }
/// <summary> /// Shows a wait window with the text 'Please wait...' while executing the passed method. /// </summary> /// <param name="workerMethod">Pointer to the method to execute while displaying the wait window.</param> /// <returns>The result argument from the worker method.</returns> public static object Show(EventHandler <WaitWindowEventArgs> workerMethod) { return(WaitWindow.Show(workerMethod, null)); }
/// <summary> /// Initialises a new intance of the WaitWindowEventArgs class. /// </summary> /// <param name="GUI">The associated WaitWindow instance.</param> /// <param name="args">A list of arguments to be passed.</param> public WaitWindowEventArgs(WaitWindow GUI, List <object> args) : base() { this._Window = GUI; this._Arguments = args; }
private void btnCopyRows_Click(object sender, EventArgs e) { if (cmbFROM.Text.Length == 0 || cmbTO.Text.Length == 0 || DG.Rows.Count == 0) { return; } //if ((General.dbTypes)General.DB. == General.dbTypes.Access) // if (General.Connections[cmbSourceServer.SelectedIndex].filename.ToLower().EndsWith("xlsx")) // if (General.Mes("WARNING! XLSX import is broken, I couldnt find a solution, shows that rows imported but in the end there is no rows in sheet!\r\n\r\nContinue?",MessageBoxIcon.Exclamation,MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.No) // return; DataTable sourceDT; if (cmbFROM.SelectedIndex == 0) { sourceDT = sourceDB.getDatatable(txtCustomSQL.Text); } else { //for xls if (sourceDB is ADOnet) { sourceDT = sourceDB.getDatatable("select * from [" + cmbFROM.Text + "]"); } else { sourceDT = sourceDB.getDatatable("select * from " + cmbFROM.Text); } } if (sourceDT != null && sourceDT.Rows.Count == 0) { MessageBox.Show("Source has no rows!", General.apTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); sourceDT.Dispose(); return; } List <string> sourceFields = new List <string>(); List <string> destFields = new List <string>(); string INSsql = ""; string INSfields = ""; string INSvalues = ""; string mySQLtunnel_Q_VARS = ""; string mySQLtunnel_Q_S_VARS = ""; for (int i = DG.Rows.Count - 1; i >= 0; i--) { if (DG.Rows[i].Cells[1].Value == null || DG.Rows[i].Cells[1].Value.ToString().Length == 0) { DG.Rows.RemoveAt(i); } else { //INSfields += "[" + DG.Rows[i].Cells[1].Value.ToString() + "],"; if (General.DB is MySQLTunnel) { INSfields += DG.Rows[i].Cells[1].Value.ToString() + ","; INSvalues += " ?,"; } else { INSfields += DG.Rows[i].Cells[1].Value.ToString() + ","; INSvalues += "@" + DG.Rows[i].Cells[1].Value.ToString() + ","; } sourceFields.Add(DG.Rows[i].Cells[0].Value.ToString()); destFields.Add(DG.Rows[i].Cells[1].Value.ToString()); } } if (INSfields.Length == 0) { MessageBox.Show("Nothing to do!", General.apTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } INSfields = INSfields.Substring(0, INSfields.Length - 1); INSvalues = INSvalues.Substring(0, INSvalues.Length - 1); INSsql = "INSERT INTO " + cmbTO.Text + "(" + INSfields + ") VALUES (" + INSvalues + ")"; General.dbTypes destDBtype = General.dbTypes.Access; if (General.DB is SQLServer) { destDBtype = General.dbTypes.SQLSERVER; } else if (General.DB is MySQL) { destDBtype = General.dbTypes.MySQL; } else if (General.DB is MySQLTunnel) { destDBtype = General.dbTypes.MySQLtunnel; } else if (General.DB is SQLite) { destDBtype = General.dbTypes.SQLite; } else if (General.DB is ADOnet) { INSsql = "INSERT INTO [" + cmbTO.Text + "](" + INSfields + ") VALUES (" + INSvalues + ")"; destDBtype = General.dbTypes.Access; } object result = null; if (destDBtype != General.dbTypes.MySQLtunnel) { result = WaitWindow.Show(CopyRows, "Init...", INSsql, sourceDT, sourceFields, destFields, cmbTO.Text, destDBtype); } else { if (chkMYSQLtunnelBATCH.Checked) { result = WaitWindow.Show(mySQLtunnel_CopyRowsBATCH, "Init...", INSsql, sourceDT, sourceFields, destFields, cmbTO.Text, destDBtype); } else { result = WaitWindow.Show(mySQLtunnel_CopyRows, "Init...", INSsql, sourceDT, sourceFields, destFields, cmbTO.Text, destDBtype); } } if (sourceDT != null) { sourceDT.Dispose(); } if (result == null) { MessageBox.Show("Aborted by user!", General.apTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (result.ToString() == "ok") { sourceDB.Disconnect(); this.DialogResult = System.Windows.Forms.DialogResult.Yes; } else { if (destDBtype != General.dbTypes.MySQLtunnel) { MessageBox.Show(result.ToString(), General.apTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { frmInformation i = new frmInformation(result.ToString()); i.ShowDialog(); } } if (cmbFROM.Text.Length == 0 || cmbTO.Text.Length == 0 || DG.Rows.Count == 0) { return; } }