Пример #1
0
        private void btnLoadServers_Click(object sender, EventArgs e)
        {
            try
            {
                ClassCoreUtility.CaluculateAll(PBarSQLServer);
                // Create a instance of the SqlDataSourceEnumerator class
                servers = SqlDataSourceEnumerator.Instance;

                // Fetch all visible SQL server 2000 or SQL Server 2005 instances
                tableServers = new DataTable();

                // Check if datatable is empty
                if (tableServers.Rows.Count == 0)
                {
                    // Get a datatable with info about SQL Server 2000 and 2005 instances
                    tableServers = servers.GetDataSources();


                    // List that will be combobox’s datasource
                    List <string> listservers = new List <string>();


                    // For each element in the datatable add a new element in the list
                    foreach (DataRow rowServer in tableServers.Rows)
                    {
                        // Server instance could have instace name or only server name,
                        // check this for show the name
                        if (String.IsNullOrEmpty(rowServer["InstanceName"].ToString()))
                        {
                            listservers.Add(rowServer["ServerName"].ToString());
                        }
                        else
                        {
                            listservers.Add(rowServer["ServerName"] + "\\" + rowServer["InstanceName"]);
                        }
                    }

                    // Set servers list to combobox’s datasource
                    this.cmbSQLServer.DataSource = listservers;
                }
            }
            catch (Exception ex)
            { ex.ToString(); }
        }
Пример #2
0
        private void btnGetDiscrepency_Click(object sender, EventArgs e)
        {
            try
            {
                richTxtDiscrepency.Text = "";
                ClassCoreUtility.CaluculateAll(PBarDiscrepency);
                //ClassCoreUtility.CaluculateAll(pgrDiscrepency);
                if (string.IsNullOrEmpty(cmbDatabases.Text.ToString()) || string.IsNullOrEmpty(txtCoreAccountss.Text.ToString()))
                {
                    MessageBox.Show("Please select  Coredatabase and Account");
                    return;
                }

                string SQL;

                int count = 0;

                //Check whether Database exists on the SQL Server

                if (!(ClassCoreUtility.checkIfDatabaseExistsOnSQL(cmbDatabases.Text.ToString(), this.server.ToString(), txtUserID.Text.ToString(), txtPasswordsss.Text.ToString())))
                {
                    MessageBox.Show("Database does not exist on SQL Server");
                    return;
                }


                //Check whether database is Core Database

                if (!(ClassCoreUtility.checkIfCoreDatabase(cmbDatabases.Text.ToString(), this.server.ToString(), txtUserID.Text.ToString(), txtPasswordsss.Text.ToString())))
                {
                    MessageBox.Show("Selected Database not a Core Database!!");
                    return;
                }


                //Check whether Database exist in CORE

                if (!(ClassCoreUtility.checkIfDatabaseAlreadyAddedToCore(cmbDatabases.Text.ToString(), this.server.ToString(), txtUserID.Text.ToString(), txtPasswordsss.Text.ToString())))
                {
                    MessageBox.Show("Database does not exist  Core");
                    return;
                }

                //Get discrepency in Core database
                Dictionary <string, string> dctDiscrepency = ClassCoreUtility.GetDiscrepency(cmbDatabases.Text.ToString(), this.server.ToString(), txtUserID.Text.ToString(), txtPasswordsss.Text.ToString());


                foreach (var item in dctDiscrepency)
                {
                    string comment    = item.Key.ToString();
                    int    lencomment = comment.Length;

                    richTxtDiscrepency.Text += comment;

                    //richTxtDiscrepency.Select(richTxtDiscrepency.Text.IndexOf("--"), lencomment);
                    //richTxtDiscrepency.ForeColor = System.Drawing.Color.Green;

                    //richTxtDiscrepency.SelectionColor = Color.Green;
                    //richTxtDiscrepency.SelectedText = Environment.NewLine + item.Value;


                    richTxtDiscrepency.AppendText(Environment.NewLine);


                    int lenSQL = item.Value.Length;
                    richTxtDiscrepency.Text += item.Value.ToString();


                    richTxtDiscrepency.AppendText(Environment.NewLine);
                    richTxtDiscrepency.AppendText(Environment.NewLine);
                }


                if (richTxtDiscrepency.Text == "")
                {
                    MessageBox.Show("No Discrepency found!!");
                }
                else
                {
                    MessageBox.Show("Copy the Discrepencies!!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }