private void tsDataCompare_Click(object sender, EventArgs e)
        {
            FrmDataCompare frm = new FrmDataCompare();

            frm.MdiParent = this;
            frm.Show();
        }
Exemple #2
0
        private void dgw1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (!btnStart.Enabled)
            {
                if (e.RowIndex >= 0)
                {
                    //if (e.ColumnIndex == 0)
                    {
                        string table = dgw1.Rows[e.RowIndex].Cells[0].FormattedValue.ToString();
                        lblDetails.Text = "details of table: " + table;

                        string query = "select * from CHANGETABLE(CHANGES "
                                       + table
                                       + ", " + changeVersion.ToString() + ") x ";

                        using (SqlConnection connection = new SqlConnection(GlobalVar.connString))
                        {
                            connection.Open();

                            SqlCommand sqlCmd = new SqlCommand();
                            sqlCmd.Connection  = connection;
                            sqlCmd.CommandType = CommandType.Text;
                            sqlCmd.CommandText = query;

                            SqlDataAdapter sqlDataAdap = new SqlDataAdapter(sqlCmd);
                            DataTable      dtRecord    = new DataTable();
                            sqlDataAdap.Fill(dtRecord);

                            dgw2.DataSource = dtRecord;
                            dgw2.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader);
                        }
                    }

                    if (e.ColumnIndex == 1)
                    {
                        string query = " select * from " + dgw1.Rows[e.RowIndex].Cells[0].FormattedValue.ToString();

                        for (int row = 0; row < dgw2.RowCount; row++)
                        {
                            query += (row == 0) ? " where (" : " or (";
                            for (int col = 5; col < dgw2.ColumnCount; col++)
                            {
                                query += (col == 5) ? "" : " and ";
                                query += dgw2.Columns[col].HeaderText.ToString() + "=";
                                query += "'" + dgw2.Rows[row].Cells[col].FormattedValue.ToString() + "'";
                            }
                            query += ") ";
                        }


                        FrmDataCompare frm = new FrmDataCompare();
                        frm.LoadFromCaller(query);
                        frm.MdiParent = this.MdiParent;
                        frm.Show();
                    }
                }
            }
        }