using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace StacjaProb { public partial class AggregateStockHistoryForm : Form { public int apeID = 0; public AggregateStockHistoryForm() { InitializeComponent(); } private void AggregateStockHistoryForm_Load(object sender, EventArgs e) { mySqlFunctions.initConnection(); if (mySqlFunctions.OpenConnection()) { try { int index = 0; dataGridViewAggHistory.Rows.Clear(); dataGridViewAggHistory.SelectionMode = DataGridViewSelectionMode.FullRowSelect; dataGridViewAggHistory.ColumnCount = 8; dataGridViewAggHistory.Columns[0].Name = "Typ pompy"; dataGridViewAggHistory.Columns[1].Name = "Numer pompy"; dataGridViewAggHistory.Columns[2].Name = "Typ silnika"; dataGridViewAggHistory.Columns[3].Name = "Numer silnika"; dataGridViewAggHistory.Columns[4].Name = "Studnia"; dataGridViewAggHistory.Columns[5].Name = "Kontrahent"; dataGridViewAggHistory.Columns[6].Name = "Data"; dataGridViewAggHistory.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; dataGridViewAggHistory.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; dataGridViewAggHistory.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; dataGridViewAggHistory.Columns[3].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; dataGridViewAggHistory.Columns[4].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; dataGridViewAggHistory.Columns[5].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; dataGridViewAggHistory.Columns[6].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand("select APE_ID,APE_PUP_NAME,APE_PUP_NO,APE_ENG_NAME,APE_ENG_NO,APE_WLL_NAME,(select PRT_DESCRIPTION from sys_participants where PRT_ID=APE_PRT_ID) PRT_DESCRIPTION,SUBSTRING(APE_AUDIT_CD,1,10) APE_AUDIT_CD,APE_PUP_ID,APE_ENG_ID,(select max(TST_ID) from tst_tests where TST_PUP_ID=APE_PUP_ID and TST_ENG_ID=APE_ENG_ID and TST_PUP_SN_NO=APE_PUP_NO and TST_ENG_SN_NO=APE_ENG_NO) TST_ID from seg_aggregate_pup_eng_his where APE_ID="+ apeID.ToString() + " order by APE_AUDIT_CD desc", mySqlFunctions.connection); MySql.Data.MySqlClient.MySqlDataReader dataReader = cmd.ExecuteReader(); while (dataReader.Read()) { if (index==0) { labelName.Text = dataReader["APE_PUP_NAME"].ToString() + " / " + dataReader["APE_ENG_NAME"].ToString(); labelDate.Text = dataReader["APE_AUDIT_CD"].ToString(); } dataGridViewAggHistory.Rows.Add( dataReader["APE_PUP_NAME"], dataReader["APE_PUP_NO"], dataReader["APE_ENG_NAME"], dataReader["APE_ENG_NO"], dataReader["APE_WLL_NAME"], dataReader["PRT_DESCRIPTION"], dataReader["APE_AUDIT_CD"], dataReader["TST_ID"] ); index++; } dataReader.Close(); dataGridViewAggHistory.Columns[7].Visible = false; DataGridViewButtonColumn btn = new DataGridViewButtonColumn(); dataGridViewAggHistory.Columns.Add(btn); btn.HeaderText = "Protokół próby"; btn.Text = "Szczegóły »"; btn.Name = "btn"; btn.UseColumnTextForButtonValue = true; } catch (Exception ex) { MessageBox.Show(ex.Message); } mySqlFunctions.CloseConnection(); } } private void dataGridViewAggHistory_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 8) { if (this.dataGridViewAggHistory.CurrentRow.Cells[7].Value.ToString().Length>0) { fullTestReportForm.spm_test_id = Convert.ToInt32(this.dataGridViewAggHistory.CurrentRow.Cells[7].Value.ToString()); fullTestReportForm formfullTestReportForm = new fullTestReportForm(); formfullTestReportForm.ShowDialog(); } else MessageBox.Show("Brak próby dla wybranego agregatu"); } } private void buttonClose_Click(object sender, EventArgs e) { this.Close(); } } }