private void SimpleMode_Form_Load(object sender, EventArgs e) { Int32 n_majorOSVersion = Environment.OSVersion.Version.Major; if (n_majorOSVersion == 5) { this.ConfigPath = @"C:\Documents and Settings\All Users\Application Data\SSManualReportGenerator\"; } else if (n_majorOSVersion == 6) { this.ConfigPath = @"C:\Users\Public\SSManualReportGenerator\"; } else { MessageBox.Show("Neznama verzia operacneho systemu. Zavolajte prosim testovacieho inziniera"); this.Dispose(); return; } this.ProductsConfig = new ProductsConfigurationFile(this.ConfigPath); try { ComboBox cb_TestTypesParentForm = (ComboBox)Application.OpenForms[0].Controls["gb_Product"].Controls["cb_TestType"]; foreach (String actTest in cb_TestTypesParentForm.Items) { this.cb_TestTypes.Items.Add(actTest); } Label lbl_operatorNr = (Label)Application.OpenForms[0].Controls["groupBox2"].Controls["lbl_OperatorNr"]; str_OperatorNr = lbl_operatorNr.Text.Trim(); if (this.cb_TestTypes.Items.Count == 1) { this.cb_TestTypes.SelectedIndex = 0; this.lbl_Info.Text = "Oskenujte SerialNumber z produktu"; } else { this.lbl_Info.Text = "Vyberte typ testu"; this.cb_TestTypes.Focus(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } this.Text = String.Concat("Simple Tracing - Operator: ", this.objBelMes.Emp.strEmployeeName, @"/", this.objBelMes.Emp.strEmployeeNumber); foreach (StationConfig.SerialNumberIP actSN in myStationConfig.GetSerialNumbersInProcess()) { String PassBtnText = "PASS"; Array actCTIs = ProductsConfig.GetChildTestsInfos(actSN.ProductID, actSN.TestType); if (actCTIs.Length > 0) { PassBtnText = "START"; } this.dgv_SNsIP.Rows.Add(actSN.SerialNumber, actSN.ProductID, actSN.TestType, actSN.Operator, actSN.StartTime, PassBtnText, "FAIL", "TERMINATE"); } for (int i = 1; i < 5000; i++) { this.cb_FromSN.Items.Add(i); this.cb_ToSN.Items.Add(i); } if (myStationConfig.SimpleModeBatchAvailable()) { this.BatchModeAvailable = true; this.label3.Enabled = true; this.label4.Enabled = true; this.label5.Enabled = true; this.tb_JobID.Enabled = true; } this.chb_ChecklistImmediatelyStart.Checked = myStationConfig.GetChecklistImmediatelyStart(); this.chb_JobIDChecking.Checked = this.myStationConfig.GetSimpleModeJobIDCheckingState(); int HeightOfScreen = Screen.PrimaryScreen.Bounds.Height - 30; this.Height = HeightOfScreen; this.lbl_Info.ForeColor = System.Drawing.Color.Green; this.Activate(); }
private void tb_SerialNumber_KeyUp(object sender, KeyEventArgs e) { if (e.KeyCode != Keys.Enter) { return; } DialogResult myDR = DialogResult.OK; if (NetworkInterface.GetIsNetworkAvailable()) { //Do your stuffs when network available } else { //Do stuffs when network not available myDR = MessageBox.Show("Nie je aktivne sietove pripojenie. Skontrolujte ho. \n\nV pripade nutnosti zavolajte nadriadeneho.", "CHYBA", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error); while ((myDR == DialogResult.Retry) && (!NetworkInterface.GetIsNetworkAvailable())) { myDR = MessageBox.Show("Nie je aktivne sietove pripojenie. Skontrolujte ho. \n\nV pripade nutnosti zavolajte nadriadeneho.", "CHYBA", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error); } if (myDR == DialogResult.Cancel) { this.tb_SerialNumber.SelectAll(); this.tb_SerialNumber.Focus(); return; } } Ping pingSender = new Ping(); String hostNameOrAddress = "dcasql14"; PingReply reply = pingSender.Send(hostNameOrAddress); myDR = DialogResult.Retry; while ((reply.Status != IPStatus.Success) && (myDR == DialogResult.Retry)) { myDR = MessageBox.Show("Nie je pristupny BelMes/dcasql14 server. \n\nKontaktujte nadriadeneho.", "CHYBA", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error); } if (reply.Status != IPStatus.Success) { this.tb_SerialNumber.SelectAll(); this.tb_SerialNumber.Focus(); return; } if (this.cb_TestTypes.SelectedIndex == -1) { MessageBox.Show("Najprv zvolte druh testu."); this.cb_TestTypes.Focus(); return; } try { String strTestType = this.cb_TestTypes.Text.Trim(); String strValidatedSerialNumber = this.tb_SerialNumber.Text; if (strValidatedSerialNumber.Substring(strValidatedSerialNumber.Length - 2) == "\n\t") { strValidatedSerialNumber = String.Concat(strValidatedSerialNumber.Substring(0, strValidatedSerialNumber.Length - 2), ";"); } if (strValidatedSerialNumber[0].ToString() == "#") { if (strValidatedSerialNumber[strValidatedSerialNumber.Length - 1].ToString() != ";") { String[] buffArr = strValidatedSerialNumber.Split(';'); if (buffArr.Length == 2) { MessageBox.Show(String.Concat("Nespravny format udajov v Barcode. Posledny znak musi byt bodkociarka - \";\". \nBarcode obsahuje udaj:\n\n", strValidatedSerialNumber), "POZOR", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); this.tb_SerialNumber.SelectAll(); this.tb_SerialNumber.Focus(); return; } } strValidatedSerialNumber = strValidatedSerialNumber.Substring(0, 14); } strValidatedSerialNumber = Regex.Match(tb_SerialNumber.Text.Trim(), @"\d+").Value; if (strValidatedSerialNumber.Length != 13) { tb_SerialNumber.SelectAll(); this.lbl_Info.Text = String.Concat(strValidatedSerialNumber, " nie je platné SN."); this.lbl_Info.ForeColor = System.Drawing.Color.Red; return; } String strProdID = this.objBelMes.GetProductID(strValidatedSerialNumber, strTestType); if (strProdID != "") { if (!ProductsConfig.TestStationAllowed(strTestType, strProdID, this.objBelMes.Env.strTracePoint)) { this.lbl_Info.Text = String.Concat("Tento typ vyrobku nie je mozne testovat na tejto stanici. Zavolajte prosim leadera."); this.lbl_Info.ForeColor = System.Drawing.Color.Purple; return; } } StationConfig.SerialNumberIP SNIPtoSAVE = new StationConfig.SerialNumberIP(); //SerialNumber In Process SNIPtoSAVE.ProductID = ""; if (this.myStationConfig.IsInProcessAndDelete(strValidatedSerialNumber, strTestType, true)) { this.objBelMes.LastSerialNumber = ""; foreach (DataGridViewRow actrow in this.dgv_SNsIP.Rows) { if (actrow.Cells[0].Value.ToString().Trim() != strValidatedSerialNumber) { continue; } String actTestType = actrow.Cells[2].Value.ToString().Trim(); if (act_SNS != null) { Array.Resize(ref act_SNS.Steps, 0); } bool nextSN = false; Array ar_actTestInstructions = this.ProductsConfig.GetChildTestsInfos(actrow.Cells[1].Value.ToString().Trim(), strTestType); if (ar_actTestInstructions.Length > 0) { frm_InstructionsOneByOne myInstructionsForm = new frm_InstructionsOneByOne(); myInstructionsForm.myStationConfig = this.myStationConfig.StationConfigXML; myInstructionsForm.actSN.SerialNumber = strValidatedSerialNumber; myInstructionsForm.Instructions = ar_actTestInstructions; myInstructionsForm.OperatorName = str_OperatorNr; myInstructionsForm.Item = actrow.Cells[1].Value.ToString().Trim(); myInstructionsForm.StationName = this.StationName; this.Visible = false; myInstructionsForm.ShowDialog(); this.Visible = true; if (myInstructionsForm.Response == "TERMINATED") { if (this.objBelMes.SetActualResult(strValidatedSerialNumber, strTestType, "TERMINATED", "")) { this.lbl_Info.ForeColor = System.Drawing.Color.Violet; } else { this.lbl_Info.ForeColor = System.Drawing.Color.Red; } this.lbl_Info.Text = this.objBelMes.Authorization.strResult; this.dgv_SNsIP.Rows.RemoveAt(actrow.Index); this.lbl_Info.Text = this.objBelMes.Authorization.strResult; continue; } else { this.act_SNS = myInstructionsForm.actSN; } /* * foreach (DataGridViewRow actRow in myInstructionsForm.dgv_Instructions.Rows) * { * StepInfo actSnStep = new StepInfo(); * actSnStep.Name = actRow.Cells[0].Value.ToString().Trim(); * while (actRow.Cells[0].Value.ToString().Trim() == "") * { * myInstructionsForm.ShowDialog(); * if (myInstructionsForm.Response == "TERMINATED") * { * if (this.objBelMes.SetActualResult(strValidatedSerialNumber, strTestType, "TERMINATED", "")) * { * this.lbl_Info.ForeColor = System.Drawing.Color.Violet; * } * else * { * this.lbl_Info.ForeColor = System.Drawing.Color.Red; * } * this.lbl_Info.Text = this.objBelMes.Authorization.strResult; * * break; * } * } * if (myInstructionsForm.Response == "TERMINATED") * { * nextSN = true; * break; * } * * if (actRow.DefaultCellStyle.BackColor == Color.Green) * { * actSnStep.Grade = "PASS"; * } * else * { * actSnStep.Grade = "FAIL"; * } * if (actRow.Cells[2].ToolTipText != "") * { * actSnStep.ResultValue = actRow.Cells[2].ToolTipText; * } * * } */ myInstructionsForm.Dispose(); if (nextSN) { continue; } } this.GenerateReport(strValidatedSerialNumber, DateTime.Now); dgv_SNsIP.Rows.Remove(actrow); break; } } else { if (this.chb_JobIDChecking.Checked) { if (this.dgv_SNsIP.Rows.Count > 0) { String actJobID = strValidatedSerialNumber.Substring(0, 8); String tableJobID = this.dgv_SNsIP.Rows[0].Cells[0].Value.ToString().Trim().Substring(0, 8); if (actJobID != tableJobID) { this.lbl_Info.Text = String.Concat("Zoskenovane seriove cislo ", strValidatedSerialNumber, " nie je zo zakazky ", tableJobID, "."); this.lbl_Info.ForeColor = Color.Red; this.tb_SerialNumber.Text = ""; this.tb_SerialNumber.Focus(); return; } } } this.objBelMes.BelMESAuthorization(strValidatedSerialNumber, strTestType, ref SNIPtoSAVE.ProductID, "", false); Boolean hasInstructions = false; if (this.objBelMes.Authorization.blnAuthorized) { SNIPtoSAVE.SerialNumber = strValidatedSerialNumber; SNIPtoSAVE.TestType = strTestType; SNIPtoSAVE.Operator = str_OperatorNr; SNIPtoSAVE.StartTime = DateTime.Now.ToString(); this.myStationConfig.SaveSerialNumberIP(SNIPtoSAVE); String PassBtnText = "PASS"; Array actCTIs = ProductsConfig.GetChildTestsInfos(SNIPtoSAVE.ProductID, SNIPtoSAVE.TestType); if (actCTIs.Length > 0) { PassBtnText = "START"; hasInstructions = true; } this.dgv_SNsIP.Rows.Add(SNIPtoSAVE.SerialNumber, SNIPtoSAVE.ProductID, SNIPtoSAVE.TestType, SNIPtoSAVE.Operator, SNIPtoSAVE.StartTime, PassBtnText, "FAIL", "TERMINATE"); this.lbl_Info.ForeColor = Color.Green; } else { this.lbl_Info.ForeColor = Color.Red; /* * if (this.objBelMes.Authorization.blnMustTraced) * { * this.lbl_Info.ForeColor = Color.Red; * } * else * { * SNIPtoSAVE.SerialNumber = strValidatedSerialNumber; * SNIPtoSAVE.TestType = strTestType; * SNIPtoSAVE.Operator = str_OperatorNr; * SNIPtoSAVE.StartTime = DateTime.Now.ToString(); * this.myStationConfig.SaveSerialNumberIP(SNIPtoSAVE); * this.dgv_SNsIP.Rows.Add(SNIPtoSAVE.SerialNumber, SNIPtoSAVE.ProductID, SNIPtoSAVE.TestType, SNIPtoSAVE.Operator, SNIPtoSAVE.StartTime, "PASS", "FAIL", "TERMINATE"); * this.lbl_Info.ForeColor = Color.FromArgb(255, 150, 0); * } */ } this.lbl_Info.Text = objBelMes.Authorization.strResult; if (this.chb_ChecklistImmediatelyStart.Checked && hasInstructions) { if (this.lbl_Info.ForeColor == Color.Green) { this.tb_SerialNumber.Text = strValidatedSerialNumber; this.tb_SerialNumber_KeyUp(new object(), new KeyEventArgs(Keys.Enter)); } } } } catch (Exception ex) { this.lbl_Info.Text = ex.Message; } this.tb_SerialNumber.Clear(); this.tb_SerialNumber.Focus(); }