Example #1
0
        public void searchDatabase3()
        {
            System.Data.DataTable dataTableSearched = new System.Data.DataTable();
            mySQLFunction.dataTableDUT = new System.Data.DataTable();

            setStatus("Searching data ", Color.Red, 0);

            try
            {
                for (int i = 0; i < dataGridViewTrackpad.Rows.Count - 1; i++)
                {
                    StringBuilder mySQLString = new StringBuilder();
                    DeviceConfig.partType = dataGridViewTrackpad["PartType", i].Value.ToString();
                    mySQLFunction.Commonds = new DataSet();
                    mySQLString.Append("select * from " + dataBase + " where DUTID = " + dataGridViewTrackpad["Id", i].Value.ToString());
                    MySql.Data.MySqlClient.MySqlDataAdapter mySQLData = new MySqlDataAdapter(mySQLString.ToString(), mySQLFunction.conn);
                    mySQLData.Fill(mySQLFunction.Commonds);
                    dataTableSearched = mySQLFunction.Commonds.Tables[0];

                    if (i % 50 == 0)
                    {
                        setStatus("Searching data ***************", Color.Red, (int)(i * 100 / (dataGridViewTrackpad.Rows.Count - 1)));
                    }

                    DataColumn column = new DataColumn();
                    column.DataType = System.Type.GetType("System.String");
                    column.AllowDBNull = false;
                    string columnName = dataGridViewTrackpad["Id", i].Value.ToString();
                    column.Caption = columnName;
                    column.ColumnName = columnName;
                    column.DefaultValue = "";

                    // Add the column to the table.

                    mySQLFunction.dataTableDUT.Columns.Add(column);

                    for (int k = 0; k < dataTableSearched.Rows.Count; k++)
                    {

                        if (i == 0)
                        {
                            DataRow row;
                            row = mySQLFunction.dataTableDUT.NewRow();
                            row[columnName] = dataTableSearched.Rows[k][dataType].ToString();
                            mySQLFunction.dataTableDUT.Rows.Add(row);
                        }
                        else
                        {
                            mySQLFunction.dataTableDUT.Rows[k][columnName] = dataTableSearched.Rows[k][dataType].ToString();
                        }

                    }

                }
                setStatus("Search finished ", Color.Green, 100);

            }

            catch (Exception ex)
            {
                MessageBox.Show("ERROR: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

            }

            FormDistChart DistForm = new FormDistChart();
            DistForm.distDT = mySQLFunction.dataTableDUT;
            DistForm.dataTypeString = dataType;
            DistForm.ShowDialog();
        }
Example #2
0
        public void searchDatabase3()
        {
            System.Data.DataTable dataTableSearched = new System.Data.DataTable();
            mySQLFunction.dataTableDUT = new System.Data.DataTable();

            setStatus("Searching data ", Color.Red, 0);

            try
            {
                for (int i = 0; i < dataGridViewTrackpad.Rows.Count - 1; i++)
                {
                    StringBuilder mySQLString = new StringBuilder();
                    DeviceConfig.partType  = dataGridViewTrackpad["PartType", i].Value.ToString();
                    mySQLFunction.Commonds = new DataSet();
                    mySQLString.Append("select * from " + dataBase + " where DUTID = " + dataGridViewTrackpad["Id", i].Value.ToString());
                    MySql.Data.MySqlClient.MySqlDataAdapter mySQLData = new MySqlDataAdapter(mySQLString.ToString(), mySQLFunction.conn);
                    mySQLData.Fill(mySQLFunction.Commonds);
                    dataTableSearched = mySQLFunction.Commonds.Tables[0];

                    if (i % 50 == 0)
                    {
                        setStatus("Searching data ***************", Color.Red, (int)(i * 100 / (dataGridViewTrackpad.Rows.Count - 1)));
                    }

                    DataColumn column = new DataColumn();
                    column.DataType    = System.Type.GetType("System.String");
                    column.AllowDBNull = false;
                    string columnName = dataGridViewTrackpad["Id", i].Value.ToString();
                    column.Caption      = columnName;
                    column.ColumnName   = columnName;
                    column.DefaultValue = "";

                    // Add the column to the table.

                    mySQLFunction.dataTableDUT.Columns.Add(column);

                    for (int k = 0; k < dataTableSearched.Rows.Count; k++)
                    {
                        if (i == 0)
                        {
                            DataRow row;
                            row             = mySQLFunction.dataTableDUT.NewRow();
                            row[columnName] = dataTableSearched.Rows[k][dataType].ToString();
                            mySQLFunction.dataTableDUT.Rows.Add(row);
                        }
                        else
                        {
                            mySQLFunction.dataTableDUT.Rows[k][columnName] = dataTableSearched.Rows[k][dataType].ToString();
                        }
                    }
                }
                setStatus("Search finished ", Color.Green, 100);
            }

            catch (Exception ex)
            {
                MessageBox.Show("ERROR: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }


            FormDistChart DistForm = new FormDistChart();

            DistForm.distDT         = mySQLFunction.dataTableDUT;
            DistForm.dataTypeString = dataType;
            DistForm.ShowDialog();
        }