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 stanIzolacjiPoProbie : Form { public stanIzolacjiPoProbie() { InitializeComponent(); } private void stanIzolacjiPoProbie_Load(object sender, EventArgs e) { buttonSave.Enabled = false; } private void buttonSave_Click(object sender, EventArgs e) { // zmiana statusu dla pompy i silnika try { mySqlFunctions.initConnection(); if (mySqlFunctions.OpenConnection()) { if (vGlobal.ape_aggregate_id > 0) { string pumpDevID = "0"; string engDevID = "0"; MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand("SELECT * FROM tst_aggregate_remonty WHERE TAR_ID=" + vGlobal.ape_aggregate_id.ToString(), mySqlFunctions.connection); MySql.Data.MySqlClient.MySqlDataReader dataReader = cmd.ExecuteReader(); while (dataReader.Read()) { pumpDevID = dataReader["TAR_PUP_DRS_ID"].ToString(); engDevID = dataReader["TAR_ENG_DRS_ID"].ToString(); } dataReader.Close(); // aktualizacja danych (statusów - po próbie) // pompa MySql.Data.MySqlClient.MySqlCommand update1 = new MySql.Data.MySqlClient.MySqlCommand("UPDATE seg_dev_resources SET DRS_STATUS_DIC_ID=6, DRS_RESOURCES_DIC_ID=704, DRS_AUDIT_DATE=now() WHERE DRS_ID=" + pumpDevID, mySqlFunctions.connection); update1.ExecuteNonQuery(); MySql.Data.MySqlClient.MySqlCommand update2 = new MySql.Data.MySqlClient.MySqlCommand("insert into seg_dev_resources_his select * from seg_dev_resources where DRS_ID=" + pumpDevID, mySqlFunctions.connection); update2.ExecuteNonQuery(); // silnik MySql.Data.MySqlClient.MySqlCommand update3 = new MySql.Data.MySqlClient.MySqlCommand("UPDATE seg_dev_resources SET DRS_STATUS_DIC_ID=6, DRS_RESOURCES_DIC_ID=704, DRS_AUDIT_DATE=now() WHERE DRS_ID=" + engDevID, mySqlFunctions.connection); update3.ExecuteNonQuery(); MySql.Data.MySqlClient.MySqlCommand update4 = new MySql.Data.MySqlClient.MySqlCommand("insert into seg_dev_resources_his select * from seg_dev_resources where DRS_ID=" + engDevID, mySqlFunctions.connection); update4.ExecuteNonQuery(); // lista agregatów MySql.Data.MySqlClient.MySqlCommand update5 = new MySql.Data.MySqlClient.MySqlCommand("UPDATE tst_aggregate_remonty SET TAR_TST_ID='" + vGlobal.tst_global_id.ToString() + "',TAR_DEV_RESOURCES_ID=704,TAR_AUDIT_CD=now() WHERE TAR_ID=" + vGlobal.ape_aggregate_id.ToString(), mySqlFunctions.connection); update5.ExecuteNonQuery(); //kopiujemy do historii MySql.Data.MySqlClient.MySqlCommand update6 = new MySql.Data.MySqlClient.MySqlCommand("INSERT INTO tst_aggregate_export_spm SELECT NULL,TAR_TST_ID,TAR_PUP_ID,TAR_PUP_DRS_ID,TAR_PUP_NAME,TAR_PUP_SN_NO,TAR_ENG_ID,TAR_ENG_DRS_ID,TAR_ENG_NAME,TAR_ENG_SN_NO,TAR_CABLE_TYP,TAR_CABLE_DLUGOSC,TAR_CABLE_OZNAK_01,TAR_CABLE_OZNAK_02,TAR_CABLE_MEMO,TAR_DEPARTMENT,TAR_DEV_RESOURCES_ID,TAR_AUDIT_CD FROM tst_aggregate_remonty WHERE TAR_ID=" + vGlobal.ape_aggregate_id.ToString(), mySqlFunctions.connection); update6.ExecuteNonQuery(); } mySqlFunctions.CloseConnection(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } mySqlFunctions.Insert("UPDATE tst_tests SET TST_STAN_WARM='" + textBoxStanPo.Text + "' WHERE TST_ID="+vGlobal.tst_global_id.ToString()); this.Close(); reportAfterTestForm formreportAfterTestForm = new reportAfterTestForm(); formreportAfterTestForm.ShowDialog(); } private void textBoxStanPo_TextChanged(object sender, EventArgs e) { if (textBoxStanPo.Text.Length > 0) buttonSave.Enabled = true; } private void textBoxStanPo_KeyPress(object sender, KeyPressEventArgs e) { textBoxStanPo.Text = textBoxStanPo.Text.Replace(".", ","); if ((e.KeyChar < 44 || e.KeyChar > 46) && (e.KeyChar < 48 || e.KeyChar > 57)) { e.Handled = true; } } } }