コード例 #1
0
        private void btnAppListLoadAll_Click(object sender, EventArgs e)
        {
            bool         proceedWithExport = true;
            DialogResult dr = MessageBox.Show("Show Data loads all data available in the database for your choosen tab which may take a long time and use a large amount of your System Memory.  If you proceed, the application will freeze until the data load is completed.  Do you wish to continue?",
                                              "Show Data Notice", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (dr == DialogResult.Yes)
            {
                proceedWithExport = true;
            }
            else
            {
                proceedWithExport = false;
            }

            if (proceedWithExport == true)
            {
                switch (tcMain.SelectedTab.Name)
                {
                case "tabApplicationList":
                    dgvAppList.DataSource = MSSqlServer.ExecuteRead(SqlConnection, Properties.Sql.GetApplicationListAll, cmdTimeout: DatabaseCommandTimeout);
                    lblReturnedRows.Text  = string.Format("Rows: {0:N0}", dgvAppList.RowCount);
                    break;

                case "tabUnassignedList":
                    dgvUnassignedList.DataSource = MSSqlServer.ExecuteRead(SqlConnection, Properties.Sql.GetUnassignedApplicationListAll, cmdTimeout: DatabaseCommandTimeout);
                    lblReturnedRows.Text         = string.Format("Rows: {0:N0}", dgvUnassignedList.RowCount);
                    break;
                }
            }
        }
コード例 #2
0
        private void FrmConnectionNew_Load(object sender, EventArgs e)
        {
            AuthenticationMethod();

            try
            {
                foreach (var i in MSSqlServer.GetServerList())
                {
                    cbSqlServer.Items.Add(i);
                }
            } catch
            {
                // do nothing
            }
        }
コード例 #3
0
        private void btnAppListSearch_Click(object sender, EventArgs e)
        {
            try
            {
                if (cSearchColumns.Text.Length > 0 || cSearchOperator.Text.Length > 0 || txtSearchCriteria.Text.Length > 0)
                {
                    List <SqlParameter> SqlParameters = new List <SqlParameter> {
                        new SqlParameter("@SearchTerm", txtSearchCriteria.Text)
                    };
                    string column = cSearchColumns.Text;
                    switch (tcMain.SelectedTab.Name)
                    {
                    case "tabApplicationList":
                        switch (column)
                        {
                        case "Application": column = "A.Name"; break;

                        case "Manufacturer": column = "M.Name"; break;

                        case "Family Name": column = "AF.Name"; break;

                        default: column = cSearchColumns.Text; break;
                        }
                        dgvAppList.DataSource = MSSqlServer.ExecuteRead(SqlConnection, Properties.Sql.GetApplicationSearch.Replace("{ColumnName}", column).Replace("{Operator}", cSearchOperator.Text), SqlParameters, DatabaseCommandTimeout);
                        lblReturnedRows.Text  = string.Format("Rows: {0:N0}", dgvAppList.RowCount);
                        break;

                    case "tabUnassignedList":
                        dgvUnassignedList.DataSource = MSSqlServer.ExecuteRead(SqlConnection, Properties.Sql.GetUnassignedApplicationListSearch.Replace("{ColumnName}", column).Replace("{Operator}", cSearchOperator.Text), SqlParameters, DatabaseCommandTimeout);
                        lblReturnedRows.Text         = string.Format("Rows: {0:N0}", dgvUnassignedList.RowCount);
                        break;

                    default:
                        break;
                    }
                }
            } catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Uncaught Exception", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
コード例 #4
0
        private void btnTest_Click(object sender, EventArgs e)
        {
            try
            {
                if (cbSqlServer.Text.Length > 0 || txtSqlPassword.Text.Length > 0 || txtSqlUsername.Text.Length > 0)
                {
                    bool ConnectionStatus = false;

                    if (rbWindowsAuth.Checked == true)
                    {
                        SqlConnectionString = "Data Source=" + cbSqlServer.Text + ";Application Name=SRD;Integrated Security=SSPI" + txtSqlParameters.Text;
                    }
                    else
                    {
                        SqlConnectionString = "Data Source=" + cbSqlServer.Text + ";Application Name=SRD;User="******";Password="******"Connection Successful", "Connection Test", MessageBoxButtons.OK, MessageBoxIcon.Information); ConnectionStatus = true;
                    }
                    else
                    {
                        MessageBox.Show("Connection Unsuccessful", "Connection Test", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); ConnectionStatus = false;
                    }

                    if (ConnectionStatus == true)
                    {
                        btnSave.Enabled = true;
                    }
                }
                else
                {
                    MessageBox.Show("One of the required fields are empty.", "New Connection", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            } catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #5
0
        private void FrmMain_Load(object sender, EventArgs e)
        {
            /* Enable Double Buffer to stop weird grid lag */
            foreach (string v in MemorySavingDoubleBuffer) // checks for all datagridviews that should have doublebuffer enabled
            {
                if (!string.IsNullOrEmpty(v))              // checks if the value is empty
                {
                    if (Controls.Find(v, true).Length > 0) // checks if the control exists
                    {
                        Utility.SetDoubleBuffered(this.Controls.Find(v, true)[0]);
                    }
                }
            }

            /* Populate the DataGridViews with default columns */
            Local.DgvOnLoadPopulator(dgvAppList, MSSqlServer.ExecuteRead(SqlConnection, Properties.Sql.GetApplicationListEmpty, cmdTimeout: DatabaseCommandTimeout), HiddenColumnsAppList);
            Local.DgvOnLoadPopulator(dgvUnassignedList, MSSqlServer.ExecuteRead(SqlConnection, Properties.Sql.GetUnassignedApplicationListEmpty, cmdTimeout: DatabaseCommandTimeout), HiddenColumnsAppUnassignedList);

            /* Populate the column selector with the first view columns (App List)*/
            Local.ColumnPopulator(dgvAppList, cSearchColumns);

            /* Enable Column Selectors for the DataGridViews */
            _ = new ColumnSelector.DataGridViewColumnSelector()
            {
                DataGridView = dgvAppList, MaxHeight = 200, Width = 110
            };
            _ = new ColumnSelector.DataGridViewColumnSelector()
            {
                DataGridView = dgvAppListRules, MaxHeight = 200, Width = 110
            };
            _ = new ColumnSelector.DataGridViewColumnSelector()
            {
                DataGridView = dgvUnassignedList, MaxHeight = 200, Width = 110
            };

            /* Design thing */
            aboutApplicationToolStripMenuItem.Text = string.Format("About {0}", ProductName);
        }
コード例 #6
0
        /// <summary>
        /// If the user clicks on the App List DataGridView
        /// </summary>
        private void dgvAppList_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 1 && e.RowIndex >= 0)
            {
                scAppList.Panel2Collapsed = false;
                dgvAppList.Size           = new Size(tabApplicationList.Width - 161, tabApplicationList.Height - 130);
                string sql = Properties.Sql.GetApplicationRules;
                List <SqlParameter> SqlParameters = new List <SqlParameter>
                {
                    new SqlParameter("@AppID", dgvAppList.Rows[e.RowIndex].Cells[0].Value)
                };
                dgvAppListRules.DataSource = MSSqlServer.ExecuteRead(SqlConnection, sql, SqlParameters, DatabaseCommandTimeout);

                /* Hides the columns */
                foreach (DataGridViewColumn col in dgvAppListRules.Columns)
                {
                    if (HiddenColumnsAppListRules.Contains(col.Name))
                    {
                        col.Visible = false;
                    }
                }
            }
        }
コード例 #7
0
        private void FrmDgvPopup_Load(object sender, EventArgs e)
        {
            try
            {
                switch (PopupType)
                {
                case "UnassignedCompSearch":
                    Text = "Computers with Unassigned Application";
                    List <SqlParameter> SqlParameters = new List <SqlParameter> {
                        new SqlParameter("@SearchTerm", SearchString)
                    };
                    dgvPopup.DataSource = MSSqlServer.ExecuteRead(SqlConnection, Properties.Sql.GetUnassignedApplicationListComp.Replace("{ColumnName}", "FS.SwPathName"), SqlParameters, DatabaseCommandTimeout);
                    break;

                default:
                    Text = "Data Popup";
                    break;
                }
            } catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Uncaught Exception", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
コード例 #8
0
 // Confirms if the sql connection is valid
 public static bool IsSqlCorrect(string sqlConnection)
 {
     return(MSSqlServer.CheckConnnection(sqlConnection));
 }
コード例 #9
0
 internal string RunResourceString(string resourceName, string connectionString)
 {
     return(MSSqlServer.ExecuteReadString(connectionString, Utilities.ReadXMLValue(dc.Resources + SqlResourceFileName, resourceName, "Resource")));
     //return MSSqlServer.ExecuteReadString(connectionString, Resources.SqlScripts.ResourceManager.GetString(resourceName));
 }