private void buttonSaveToDb_Click(object sender, EventArgs e) { if (AllDataCorrect()) { using (TakePhotoForm photoForm = new TakePhotoForm(deviceMonikerString, textBoxPcbQr.Text)) { if (photoForm.ShowDialog() == DialogResult.OK) { ProductionHistory.AddModuleToHostory(currentLotInfo.Model, textBoxPcbQr.Text, comboBoxOperator.Text, ref historyTable); foreach (DataGridViewColumn col in dataGridViewHistory.Columns) { col.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; } List <SaveRecord> listToSave = new List <SaveRecord>(); string overallResult = "OK"; foreach (ListViewItem item in listViewOperations.Items) { string oper = comboBoxOperator.Text; string model = currentLotInfo.Model; string serialNo = textBoxPcbQr.Text; string jobDescription = item.SubItems[2].Text; string compRef = item.SubItems[0].Text; string result = "OK"; if (jobDescription.Contains("SCRAP")) { result = "NG"; overallResult = "NG"; } SaveRecord saveLine = new SaveRecord(oper, model, serialNo, jobDescription, compRef, result); listToSave.Add(saveLine); } LockListView(false); SqlOperations.SaveRecordToDb(listToSave); if (SqlOperations.CheckNgTableForSerial(textBoxPcbQr.Text)) { SqlOperations.UpdateReworkResultToNgTable(textBoxPcbQr.Text, overallResult, DateTime.Now); } comboBoxOperator.Items.Clear(); comboBoxOperator.Items.AddRange(SqlOperations.GetListOfOperators()); CleanUpForm(); textBoxPcbQr.Focus(); } } } }
private void ReadPcbQr() { bool serialRegistered = SqlOperations.CheckNgTableForSerial(textBoxPcbQr.Text); if (textBoxPcbQr.Text != "") { testData = SqlOperations.GetMeasurementsForPcb(textBoxPcbQr.Text); if (testData.Rows.Count > 0 & textBoxPcbQr.Text.Trim() != "") { string lot = testData.Rows[0]["wip_entity_name"].ToString(); currentLotInfo = SqlOperations.GetLotInfo(lot); visInspInfo = SqlOperations.GetVisualInspectionInfo(lot); if (visInspInfo.Rows.Count > 0) { var date = DateTime.ParseExact(visInspInfo.Rows[0]["Data_czas"].ToString(), "dd.MM.yyyy HH:mm:ss", CultureInfo.CurrentCulture); //Data_czas 03.04.2018 07:11:00 var images = TryGetFailureImages(lot, textBoxPcbQr.Text, date.ToString("dd-MM-yyyy")); if (images.Count > 0) { //auto register NG buttonFailureImages.Tag = images; buttonFailureImages.Visible = true; if (!serialRegistered) { ImageTag tag = (ImageTag)images[0].Tag; SqlOperations.InsertPcbToNgTable(tag.Serial, tag.Result, tag.Reason); } } else { buttonFailureImages.Visible = false; if (!serialRegistered) {//manual register NG ManualRegisterNg(); } } } if (textBoxPcbQr.Text != "") { labelLotItem.Text = "Nr zlecenia:" + Environment.NewLine + "Model:" + Environment.NewLine + "Kitting data: " + Environment.NewLine + "Koniec zl: " + Environment.NewLine + "Ilość wykonana: "; labelLotValue.Text = lot + Environment.NewLine + currentLotInfo.Model + Environment.NewLine + currentLotInfo.StartDate + Environment.NewLine + currentLotInfo.EndDate + Environment.NewLine + currentLotInfo.ManufacturedQty; labelLedItem.Text = "LED: " + Environment.NewLine + "RankA: " + Environment.NewLine + "RankB: "; labelLedValue.Text = currentLotInfo.LedFamily + Environment.NewLine + currentLotInfo.RankA + Environment.NewLine + currentLotInfo.RankB; string testResult = ""; string ngType = ""; string viResult = "OK"; foreach (DataRow row in testData.Rows) { //serial_no,inspection_time,tester_id,wip_entity_id,wip_entity_name,program_id,result,ng_type,lm,lm_w,sdcm,cri,cct,v,i,w,x,y,r9,bin,lx,retest,module_num,lm1_gain,x1_offset,y1_offset,vf1_offset,cri1_offset,cct1_offset,lm1_master,x1_master,y1_master,vf1_master,cri1_master,cct1_master,hi_pot,light_on,optical,result_int FROM tb_tester_measurements if (testResult != "OK") { testResult = row["result"].ToString(); } if (row["result"].ToString() == "NGV") { viResult = "NG"; } } if (testResult == "NG") { foreach (DataRow row in testData.Rows) { ngType += row["ng_type"].ToString() + ", "; } ngType = "Przyczyna NG: " + ngType; } labelTestItem.Text = "Wynik: " + Environment.NewLine + ngType; labelTestValue.Text = testResult + Environment.NewLine; labelViItem.Text = "Wynik: "; labelViValue.Text = viResult; } } else { labelLotInfo.Text = ""; labelLedInfo.Text = ""; labelTestInfo.Text = ""; labelViInfo.Text = ""; ManualRegisterNg(); } } }