174 lines
7.6 KiB
C#
174 lines
7.6 KiB
C#
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 searchTestForm : Form
|
|
{
|
|
public searchTestForm()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private bool dragging = false;
|
|
|
|
private void LoadCurrentReports(string searchCondition = null)
|
|
{
|
|
string query="";
|
|
searchCondition = textBoxSearchTest.Text;
|
|
|
|
dataGridViewRaporty.Rows.Clear();
|
|
|
|
dataGridViewRaporty.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
|
dataGridViewRaporty.ColumnCount = 11;
|
|
dataGridViewRaporty.Columns[0].Name = "Nr próby";
|
|
dataGridViewRaporty.Columns[1].Name = "Typ pompy";
|
|
dataGridViewRaporty.Columns[2].Name = "Qn [m3/min]";
|
|
dataGridViewRaporty.Columns[3].Name = "Nr pompy";
|
|
dataGridViewRaporty.Columns[4].Name = "Typ silnika";
|
|
dataGridViewRaporty.Columns[5].Name = "Moc [kW]";
|
|
dataGridViewRaporty.Columns[6].Name = "Nr silnika";
|
|
dataGridViewRaporty.Columns[7].Name = "Status";
|
|
dataGridViewRaporty.Columns[8].Name = "Data próby";
|
|
dataGridViewRaporty.Columns[9].Name = "Prowadzący";
|
|
dataGridViewRaporty.Columns[10].Name = "Kontrahent";
|
|
|
|
|
|
dataGridViewRaporty.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
|
|
dataGridViewRaporty.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
|
dataGridViewRaporty.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
|
|
dataGridViewRaporty.Columns[3].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
|
dataGridViewRaporty.Columns[4].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
|
dataGridViewRaporty.Columns[5].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
|
|
dataGridViewRaporty.Columns[6].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
|
dataGridViewRaporty.Columns[7].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
|
dataGridViewRaporty.Columns[8].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
|
dataGridViewRaporty.Columns[9].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
|
dataGridViewRaporty.Columns[10].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
|
|
|
if (dragging == false)
|
|
query = "select TST_ID,PUP_NAME,PUP_Q_N,TST_PUP_SN_NO,ENG_NAME,ENG_POWER,TST_ENG_SN_NO,case when TST_STATUS='0' then 'POZA ZAKRESEM' when TST_STATUS='1' then 'OK' when TST_STATUS='2' then 'PRZERWANA' else 'BRAK DANYCH' end TST_STAT,TST_AUDIT_CU,TST_AUDIT_CD,PRT_DESCRIPTION from tst_tests left join seg_pumps on TST_PUP_ID=PUP_ID left join seg_engines on TST_ENG_ID=ENG_ID left join sys_participants on PRT_ID=TST_PRT_ID where TST_ID like '%" + searchCondition + "%' or TST_PUP_NAME like '%" + searchCondition + "%' or TST_ENG_NAME like '%" + searchCondition + "%' order by TST_AUDIT_CD desc LIMIT 100";
|
|
else
|
|
query = "select TST_ID,PUP_NAME,PUP_Q_N,TST_PUP_SN_NO,ENG_NAME,ENG_POWER,TST_ENG_SN_NO,case when TST_STATUS='0' then 'POZA ZAKRESEM' when TST_STATUS='1' then 'OK' when TST_STATUS='2' then 'PRZERWANA' else 'BRAK DANYCH' end TST_STAT,TST_AUDIT_CU,TST_AUDIT_CD,PRT_DESCRIPTION from tst_tests left join seg_pumps on TST_PUP_ID=PUP_ID left join seg_engines on TST_ENG_ID=ENG_ID left join sys_participants on PRT_ID=TST_PRT_ID where TST_ID like '%" + searchCondition + "%' or TST_PUP_NAME like '%" + searchCondition + "%' or TST_ENG_NAME like '%" + searchCondition + "%' order by TST_AUDIT_CD desc";
|
|
|
|
MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand(query, mySqlFunctions.connection);
|
|
MySql.Data.MySqlClient.MySqlDataReader dataReader = cmd.ExecuteReader();
|
|
while (dataReader.Read())
|
|
{
|
|
double valQn = 0.0;
|
|
if (double.TryParse(dataReader["PUP_Q_N"].ToString(), out double tmpVal))
|
|
{
|
|
valQn = Math.Round(tmpVal / 60.0, 3); // dzielimy przez 60 i zaokrąglamy do 3 miejsc
|
|
}
|
|
|
|
dataGridViewRaporty.Rows.Add(
|
|
dataReader["TST_ID"],
|
|
dataReader["PUP_NAME"],
|
|
valQn,
|
|
//dataReader["PUP_Q_N"],
|
|
dataReader["TST_PUP_SN_NO"],
|
|
dataReader["ENG_NAME"],
|
|
dataReader["ENG_POWER"],
|
|
dataReader["TST_ENG_SN_NO"],
|
|
dataReader["TST_STAT"],
|
|
dataReader["TST_AUDIT_CD"],
|
|
dataReader["TST_AUDIT_CU"],
|
|
dataReader["PRT_DESCRIPTION"]
|
|
);
|
|
}
|
|
|
|
mySqlFunctions.CloseConnection();
|
|
}
|
|
|
|
|
|
private void searchTestForm_Load(object sender, EventArgs e)
|
|
{
|
|
|
|
mySqlFunctions.initConnection();
|
|
if (mySqlFunctions.OpenConnection())
|
|
{
|
|
LoadCurrentReports();
|
|
}
|
|
|
|
}
|
|
|
|
private void dataGridViewRaporty_CellContentClick(object sender, DataGridViewCellEventArgs e)
|
|
{
|
|
|
|
try
|
|
{
|
|
int rowIndex = e.RowIndex;
|
|
DataGridViewRow row = dataGridViewRaporty.Rows[rowIndex];
|
|
|
|
if (String.Compare(row.Cells[7].Value.ToString(), "BRAK DANYCH", true) != 0)
|
|
{
|
|
PleaseWait komunikat = new PleaseWait();
|
|
komunikat.Top = (dataGridViewRaporty.Height / 2) - 25;
|
|
komunikat.Left = (dataGridViewRaporty.Width / 2) - 250;
|
|
dataGridViewRaporty.Controls.Add(komunikat);
|
|
komunikat.Visible = true;
|
|
Application.DoEvents();
|
|
|
|
//MessageBox.Show(row.Cells[0].Value.ToString());
|
|
fullTestReportForm.spm_test_id = Convert.ToInt32(row.Cells[0].Value);
|
|
fullTestReportForm formfullTestReportForm = new fullTestReportForm();
|
|
formfullTestReportForm.ShowDialog();
|
|
|
|
komunikat.Visible = false;
|
|
|
|
}
|
|
else
|
|
MessageBox.Show("Próba niekompletna.");
|
|
|
|
|
|
//this.Close();
|
|
}
|
|
catch { }
|
|
|
|
|
|
|
|
}
|
|
|
|
private void textBoxSearchTest_TextChanged(object sender, EventArgs e)
|
|
{
|
|
Cursor.Current = Cursors.WaitCursor; // ustawienie kursora na klepsydrę
|
|
mySqlFunctions.initConnection();
|
|
if (mySqlFunctions.OpenConnection())
|
|
{
|
|
LoadCurrentReports();
|
|
mySqlFunctions.CloseConnection();
|
|
}
|
|
Cursor.Current = Cursors.Default; // przywrócenie domyślnego kursora
|
|
}
|
|
|
|
private void buttonSzowAll_Click(object sender, EventArgs e)
|
|
{
|
|
dragging = true;
|
|
Cursor.Current = Cursors.WaitCursor; // ustawienie kursora na klepsydrę
|
|
|
|
mySqlFunctions.initConnection();
|
|
if (mySqlFunctions.OpenConnection())
|
|
{
|
|
LoadCurrentReports();
|
|
mySqlFunctions.CloseConnection();
|
|
}
|
|
Cursor.Current = Cursors.Default; // przywrócenie domyślnego kursora
|
|
dragging = false;
|
|
}
|
|
|
|
private void buttonClose_Click(object sender, EventArgs e)
|
|
{
|
|
this.Close();
|
|
}
|
|
|
|
|
|
}
|
|
}
|