private void button6_Click(object sender, EventArgs e) { _soluongPass++; _dataCamera.CounterPASS = _soluongPass; _dataCamera.ReceviedString = "NamDepzai"; lblPassFail.Text = ReceviedDataFromCamera.Result.PASS.ToString(); lblPassFail.BackColor = Color.Green; lblChuoiNhan.Text = _dataCamera.ReceviedString; lblCounterPass.Text = _dataCamera.CounterPASS.ToString(); lblCounter.Text = _dataCamera.CounterPASS.ToString(); _dulieuSP = SQLite.Instance().LayDuLieuSanPham("12345676"); frmCheck.lblChuoiNhan.Text = _dulieuSP.MaSP; frmCheck.lblMaDL.Text = _dulieuSP.MaDL; frmCheck.lblTenDL.Text = _dulieuSP.TenDL; frmCheck.lblNgayGioXuat.Text = _dulieuSP.Time; if (frmCheck.cbbChonDaiLy.SelectedItem.ToString() == _dulieuSP.TenDL) { frmCheck.lblKetQua.Text = "KHỚP"; frmCheck.lblKetQua.BackColor = Color.Green; } else { frmCheck.lblKetQua.Text = "KHÔNG KHỚP"; frmCheck.lblKetQua.BackColor = Color.Red; } }
private void btnKiemTra_Click(object sender, EventArgs e) { _dulieuSP = SQLite.Instance().LayDuLieuSanPham(txtMaNhapTay.Text.Trim()); lblChuoiNhan.Text = _dulieuSP.MaSP; lblMaDL.Text = _dulieuSP.MaDL; lblTenDL.Text = _dulieuSP.TenDL; lblNgayGioXuat.Text = _dulieuSP.Time; lblKhoangThoiGian.Text = Convert.ToDateTime(DateTime.Now.ToString("dd/MM/yyyy")) .Subtract(Convert.ToDateTime(_dulieuSP.Time)).ToString("dd") + " ngày"; if (cbbChonDaiLy.SelectedItem.ToString() == _dulieuSP.TenDL) { lblKetQua.Text = "KHỚP"; lblKetQua.BackColor = Color.Green; lblTenDL.BackColor = Color.SeaGreen; cbbChonDaiLy.BackColor = Color.SeaGreen; } else { lblKetQua.Text = "KHÔNG KHỚP"; lblKetQua.BackColor = Color.Red; lblTenDL.BackColor = Color.Red; cbbChonDaiLy.BackColor = Color.Red; Form1.Fx1s.SetDevice2("M2", 1); } }
public DuLieuSanPham LayDuLieuSanPham(string maSP) { DuLieuSanPham duLieuSanPham = new DuLieuSanPham(); OpenConnection(); if (_SqliteConnected) { string query = "SELECT *FROM DuLieuSanPham WHERE MaSP=@MaSP"; using (SQLiteCommand command = new SQLiteCommand(query, con)) { command.Parameters.AddWithValue("MaSP", maSP); using (SQLiteDataReader reader = command.ExecuteReader()) { try { while (reader.Read()) { duLieuSanPham.ID = reader.GetInt32(0); duLieuSanPham.TimeStamp = reader.GetString(1); duLieuSanPham.Time = reader.GetString(2); duLieuSanPham.MaDL = reader.GetString(3); duLieuSanPham.TenDL = reader.GetString(4); duLieuSanPham.MaSP = reader.GetString(5); } CloseConnection(); } catch (Exception ex) { CloseConnection(); MessageBox.Show(ex.Message); } } } return(duLieuSanPham); } else { return(null); } }
private void _cameraMV_ConnectionEventCallback(Enum_ConnectionEvent e, object obj) { switch (e) { case Enum_ConnectionEvent.DISCOVERED_NEW_CAMERA: this.Invoke(new Action(() => { Visionscape.Devices.VsDeviceClass dev = obj as Visionscape.Devices.VsDeviceClass; if (dev.Name != null) { VisionDevice = dev.Name; } })); break; case Enum_ConnectionEvent.DISCOVERED_CAMERA: _cameraMV.ConnectJob(job_path + cbbCongViec.SelectedItem.ToString()); break; case Enum_ConnectionEvent.CONNECTED_JOB: _cameraMV.DownloadJob(); break; case Enum_ConnectionEvent.DOWNLOADING_JOB: break; case Enum_ConnectionEvent.DOWNLOADED_JOB: _cameraMV.ConnectIO(); _cameraMV.ConnectReport(); break; case Enum_ConnectionEvent.CONNECTED_REPORT: break; case Enum_ConnectionEvent.RECEIVED_REPORT: break; case Enum_ConnectionEvent.RECEIVED_IMAGE: Visionscape.Communications.InspectionReport report = obj as Visionscape.Communications.InspectionReport; this.Invoke(new Action(() => { //Update Image bufferView2.Buffer = report.Images[0]; //Update Tool Data foreach (Visionscape.Communications.InspectionReportValue result in report.Results) { try { //if (result.NameSym == "Snapshot1.OCRX1.OutStr") //{ // _dataCamera.ReceviedString = result.AsString; // lblChuoiNhan.Text = _dataCamera.ReceviedString; //} if (result.NameSym == _stringOfToolVS) { _dataCamera.ReceviedString = result.AsString; lblChuoiNhan.Text = _dataCamera.ReceviedString; } } catch { } } if (!chbChayTest.Checked) { //Pass - Fail Processing if (report.InspectionStats.Passed) { if (_dataCamera.ReceviedString.Length == 10) { if (_mode.RunModeCurrent == RunMode.mode.NORMAL) { _soluongPass++; _dataCamera.CounterPASS = _soluongPass; lblPassFail.Text = ReceviedDataFromCamera.Result.PASS.ToString(); lblPassFail.BackColor = Color.Green; lblCounterPass.Text = _dataCamera.CounterPASS.ToString(); lblCounter.Text = _dataCamera.CounterPASS.ToString(); SQLite.Instance().ThemDuLieuSanPham(DateTime.Now.ToString("ddMMyyyyHHmmss"), DateTime.Now.ToString("dd/MM/yyyy"), _dsDaiLy.MaDL, _dsDaiLy.TenDL, _dataCamera.ReceviedString); if (_soluongPass == int.Parse(numericUpDown1.Value.ToString())) { if (MessageBox.Show("Đã chạy đủ số lượng", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { btnChayDung.PerformClick(); } } } else if (_mode.RunModeCurrent == RunMode.mode.CHECK) { lblPassFail.Text = ReceviedDataFromCamera.Result.PASS.ToString(); lblPassFail.BackColor = Color.Green; _dulieuSP = SQLite.Instance().LayDuLieuSanPham(_dataCamera.ReceviedString); frmCheck.lblChuoiNhan.Text = _dulieuSP.MaSP; frmCheck.lblMaDL.Text = _dulieuSP.MaDL; frmCheck.lblTenDL.Text = _dulieuSP.TenDL; frmCheck.lblNgayGioXuat.Text = _dulieuSP.Time; frmCheck.lblKhoangThoiGian.Text = Convert.ToDateTime(DateTime.Now.ToString("dd/MM/yyyy")) .Subtract(Convert.ToDateTime(_dulieuSP.Time)).ToString("dd") + " ngày"; if (frmCheck.cbbChonDaiLy.SelectedItem.ToString() == _dulieuSP.TenDL) { frmCheck.lblKetQua.Text = "KHỚP"; frmCheck.lblKetQua.BackColor = Color.Green; frmCheck.lblTenDL.BackColor = Color.SeaGreen; frmCheck.cbbChonDaiLy.BackColor = Color.SeaGreen; } else { frmCheck.lblKetQua.Text = "KHÔNG KHỚP"; frmCheck.lblKetQua.BackColor = Color.Red; frmCheck.lblTenDL.BackColor = Color.Red; frmCheck.cbbChonDaiLy.BackColor = Color.Red; Fx1s.SetDevice2("M2", 1); } } } else { if (_mode.RunModeCurrent == RunMode.mode.NORMAL) { _soluongFail++; _dataCamera.CounterFAIL = _soluongFail; lblPassFail.Text = ReceviedDataFromCamera.Result.FAIL.ToString(); lblPassFail.BackColor = Color.OrangeRed; lblCounterFail.Text = _dataCamera.CounterFAIL.ToString(); lblCounterFail.Text = _dataCamera.CounterFAIL.ToString(); Fx1s.SetDevice2("M2", 1); string name = DateTime.Now.ToString("dd/MM/yy-HHmmssfff") + "_F"; string imagePath = Properties.Settings.Default.PathLuuAnh + "\\NORMAL\\" + name + ".bmp"; bufferView2.Buffer.SaveImage(imagePath, Visionscape.Steps.EnumImgFileType.ftWithGraphics); } else if (_mode.RunModeCurrent == RunMode.mode.CHECK) { lblPassFail.Text = ReceviedDataFromCamera.Result.FAIL.ToString(); lblPassFail.BackColor = Color.OrangeRed; Fx1s.SetDevice2("M2", 1); string name = DateTime.Now.ToString("dd/MM/yy-HHmmssfff") + "_F"; string imagePath = Properties.Settings.Default.PathLuuAnh + "\\CHECK\\" + name + ".bmp"; bufferView2.Buffer.SaveImage(imagePath, Visionscape.Steps.EnumImgFileType.ftWithGraphics); } } } else { if (_mode.RunModeCurrent == RunMode.mode.NORMAL) { _soluongFail++; _dataCamera.CounterFAIL = _soluongFail; lblPassFail.Text = ReceviedDataFromCamera.Result.FAIL.ToString(); lblPassFail.BackColor = Color.OrangeRed; lblCounterFail.Text = _dataCamera.CounterFAIL.ToString(); lblCounterFail.Text = _dataCamera.CounterFAIL.ToString(); Fx1s.SetDevice2("M2", 1); string name = DateTime.Now.ToString("dd/MM/yy-HHmmssfff") + "_F"; string imagePath = Properties.Settings.Default.PathLuuAnh + "\\NORMAL\\" + name + ".bmp"; bufferView2.Buffer.SaveImage(imagePath, Visionscape.Steps.EnumImgFileType.ftWithGraphics); } else if (_mode.RunModeCurrent == RunMode.mode.CHECK) { lblPassFail.Text = ReceviedDataFromCamera.Result.FAIL.ToString(); lblPassFail.BackColor = Color.OrangeRed; Fx1s.SetDevice2("M2", 1); string name = DateTime.Now.ToString("dd/MM/yy-HHmmssfff") + "_F"; string imagePath = Properties.Settings.Default.PathLuuAnh + "\\CHECK\\" + name + ".bmp"; bufferView2.Buffer.SaveImage(imagePath, Visionscape.Steps.EnumImgFileType.ftWithGraphics); } } } else { if (report.InspectionStats.Passed) { if (_dataCamera.ReceviedString.Length == 10) { lblPassFail.Text = ReceviedDataFromCamera.Result.PASS.ToString(); lblPassFail.BackColor = Color.Green; } else { lblPassFail.Text = ReceviedDataFromCamera.Result.FAIL.ToString(); lblPassFail.BackColor = Color.OrangeRed; Fx1s.SetDevice2("M2", 1); } } else { lblPassFail.Text = ReceviedDataFromCamera.Result.FAIL.ToString(); lblPassFail.BackColor = Color.OrangeRed; Fx1s.SetDevice2("M2", 1); } } //Save Image })); break; case Enum_ConnectionEvent.CONNECTED_IO: break; case Enum_ConnectionEvent.TRIGGERED_IO: break; case Enum_ConnectionEvent.STATECHANGED_IO: break; case Enum_ConnectionEvent.DISCONNECTED_DEVICE: break; case Enum_ConnectionEvent.DISCONNECTED_JOB: break; case Enum_ConnectionEvent.DISCONNECTED_REPORT: break; case Enum_ConnectionEvent.DISCONNECTED_IO: break; case Enum_ConnectionEvent.DISCONNECTED_ALL: break; case Enum_ConnectionEvent.ERROR: break; default: break; } }