Ejemplo n.º 1
0
        private void textBox_LotCode_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                textBox_LotCode.Text = "";
                textBox_LotCode.Text = scannedCode.ToString();
                scannedCode.Clear();

                using (conn = new SQLiteConnection(connStr))
                {
                    conn.Open();
                    codeCURD = new BarcodeReferenceCode_CRUD(conn);

                    BarcodeLotCodeInfo item = new BarcodeLotCodeInfo();
                    var id = codeCURD.GetMaxID(BarcodeReferenceCode_CRUD.Table.LOT_CODE) + 1;
                    item.ID      = id;
                    item.LotCode = textBox_LotCode.Text;

                    codeCURD.Insert(item);

                    ds = codeCURD.SelectAll_Dataset(BarcodeReferenceCode_CRUD.Table.LOT_CODE);
                    conn.Close();
                }

                DataGridViewRefreshBinding(BarcodeReferenceCode_CRUD.Table.LOT_CODE);
            }
            else
            {
                textBox_LotCode.Text = "";
                scannedCode.Append(KeyToUni.KeyCodeToUnicode(e.KeyCode).ToUpper());
            }
        }
        private void txtSerialScanData_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                txtSerialScanData.Text = scannedCode.ToString();
                scannedCode.Clear();

                if (txtSerialScanData.Text != "")
                {
                    if (txtSerialScanData.Text != txtSkuScanData.Text)
                    {
                        this.BeginInvoke(new Action(delegate()
                        {
                            if (!chbSerial.Checked)
                            {
                                sumOfPassCount++;
                                passCount++;

                                testResultInfo.Time           = DateTime.Now;
                                testResultInfo.Result         = true;
                                testResultInfo.Reason         = "TEST OK";
                                testResultInfo.Compared_Item += ";" + txtSerialScanData.Text.Trim();

                                this.btnPassFail.Text  = "PASS (" + (this.sumOfPassCount).ToString() + ") / FAIL (" + (this.failCount).ToString() + ")";
                                this.lblTestCount.Text = this.currentSeqQty.ToString();
                                try
                                {
                                    using (conn = new SQLiteConnection(connStr))
                                    {
                                        conn.Open();
                                        testResult_CRUD = new BarcodeTestResult_CRUD(conn);
                                        testResult_CRUD.Insert(testResultInfo);
                                    }
                                }
                                catch (Exception ex)
                                { MessageBox.Show(ex.Message); }

                                if (function.BOX_LOT_CODE == false && function.COUNT_SETUP == false)
                                {
                                    if (this.passCount >= this._unit_1Middle)
                                    {
                                        txtSerialScanData.Text = "Scan Middle Code !";
                                        txtSkuScanData.Text    = "";
                                        _scanMiddleCode        = true;
                                        timerBlink.Enabled     = true;
                                        this.ActiveControl     = txtSkuScanData;
                                        return;
                                    }
                                }
                            }
                            else
                            {
                                btnPassFail.Text = "OK";
                                sumOfPassCount++;
                                passCount++;

                                this.currentSeqQty++;
                                this.currentTestCount++;

                                testResultInfo.Time          = DateTime.Now;
                                testResultInfo.Origin_Item   = txtSerialScanData.Text.Trim();
                                testResultInfo.Compared_Item = txtSerialScanData.Text.Trim();
                                testResultInfo.Sample_1Box   = this._unit_1Carton;
                                testResultInfo.Sample_Tray   = this._unit_1Middle;
                                testResultInfo.TrayNumber    = this.sumOfLot;
                                testResultInfo.TestCount     = this.currentTestCount;
                                testResultInfo.Result        = true;
                                testResultInfo.Reason        = "TEST OK";

                                this.btnPassFail.Text  = "PASS (" + (this.sumOfPassCount).ToString() + ") / FAIL (" + (this.failCount).ToString() + ")";
                                this.lblTestCount.Text = this.currentSeqQty.ToString();

                                try
                                {
                                    using (conn = new SQLiteConnection(connStr))
                                    {
                                        conn.Open();
                                        testResult_CRUD = new BarcodeTestResult_CRUD(conn);
                                        testResult_CRUD.Insert(testResultInfo);
                                    }
                                }
                                catch (Exception ex)
                                { MessageBox.Show(ex.Message); }


                                if (function.BOX_LOT_CODE == true && chbSelectMiddle.Checked && chbSelectCarton.Checked)
                                {
                                    if (this.currentMiddleNumber >= this._middle_1Carton)
                                    {
                                        if (txtSerialScanData.Text.Trim() == _cartonCode)
                                        {
                                            txtSkuScanData.Text = "Complete Carton";

                                            this.sumOfPassCount = 0;
                                            this.failCount      = 0;
                                            this.sumOfLot++;
                                            this.currentMiddleNumber = 0;
                                            this.currentSeqQty       = 0;
                                            this.passCount           = 0;

                                            //this.btnPassFail.Text = "PASS (" + (this.sumOfPassCount).ToString() + ") / FAIL (" + (this.failCount).ToString() + ")";
                                            //this.lblMiddleBoxNumber.Text = this.currentMiddleNumber.ToString();
                                            txtSerialScanData.Text = "";

                                            _scanCartonCode          = false;
                                            timerBlink.Enabled       = false;
                                            this.cbbCarton.BackColor = Color.LightSkyBlue;

                                            this.ActiveControl = txtSerialScanData;
                                            //this.lblTestCount.Text = this.currentSeqQty.ToString();
                                            return;
                                        }
                                        else
                                        {
                                            //Phoung want
                                            errorAlarmForm = new ErrorAlarmForm(testResultInfo, false);
                                            errorAlarmForm.Show(this);
                                            txtSkuScanData.Text = "Scan Carton Code !";
                                            txtSerialScanData.Clear();
                                            this.ActiveControl = txtSerialScanData;
                                            return;
                                        }
                                    }
                                    if (this.passCount >= this._unit_1Middle) // lot + 1
                                    {
                                        // CHECK MIDDLE CODE
                                        if (this.passCount == this._unit_1Middle)
                                        {
                                            txtSkuScanData.Text = "Scan Middle Code !";
                                            txtSerialScanData.Clear();
                                            _scanMiddleCode    = true;
                                            timerBlink.Enabled = true;
                                            this.ActiveControl = txtSerialScanData;
                                            return;
                                        }

                                        if (txtSerialScanData.Text.Trim() == _middleCode && passCount > _unit_1Middle)
                                        {
                                            passCount = 0;
                                            this.currentMiddleNumber++;
                                            this.sumOfLot++;
                                            txtSerialScanData.Text       = "";
                                            txtSkuScanData.Text          = "";
                                            this.lblMiddleBoxNumber.Text = this.currentMiddleNumber.ToString();

                                            _scanMiddleCode          = false;
                                            timerBlink.Enabled       = false;
                                            this.cbbMiddle.BackColor = Color.Khaki;

                                            if (this.currentMiddleNumber >= this._middle_1Carton)
                                            {
                                                //this.sumOfLot--;
                                                this.lblMiddleBoxNumber.Text = (this._middle_1Carton).ToString();
                                                txtSkuScanData.Text          = "Scan Carton Code !";
                                                this.ActiveControl           = txtSerialScanData;
                                                _scanCartonCode    = true;
                                                timerBlink.Enabled = true;
                                            }
                                            this.ActiveControl = txtSerialScanData;
                                            return;
                                        }
                                        else
                                        {
                                            //Phoung want
                                            errorAlarmForm = new ErrorAlarmForm(testResultInfo, false);
                                            errorAlarmForm.Show(this);
                                            txtSkuScanData.Text    = "Scan Middle Code !";
                                            txtSerialScanData.Text = "";

                                            this.ActiveControl = txtSerialScanData;
                                            return;
                                        }
                                    }
                                }
                            }

                            txtSkuScanData.Text    = "";
                            txtSerialScanData.Text = "";
                        }));
                    }
                    else
                    {
                        this.BeginInvoke(new Action(delegate()
                        {
                            errorAlarmForm = new ErrorAlarmForm(testResultInfo, false);
                            errorAlarmForm.Show(this);
                            txtSerialScanData.Text = "";
                            failCount++;
                            this.btnPassFail.Text  = "PASS (" + (this.sumOfPassCount).ToString() + ") / FAIL (" + (this.failCount).ToString() + ")";
                            this.lblTestCount.Text = this.currentSeqQty.ToString();
                            this.ActiveControl     = txtSerialScanData;
                        }));
                    }
                }
                //this.txtSerialScanData.KeyUp -= this.txtSerialScanData_KeyUp;

                delay.Start();
                while (true)
                {
                    if (delay.ElapsedMilliseconds > 200)
                    {
                        delay.Stop();
                        break;
                    }
                }

                if (!chbSerial.Checked)
                {
                    this.ActiveControl = txtSkuScanData;
                }
                else
                {
                    this.ActiveControl = txtSerialScanData;
                }
                //this.txtSerialScanData.KeyUp += this.txtSerialScanData_KeyUp;
            }
            else
            {
                scannedCode.Append(KeyToUni.KeyCodeToUnicode(e.KeyCode).ToUpper()); //Khong duoc bam phim nao tren ban phim
            }
        }
Ejemplo n.º 3
0
        private void textBox_Scanned_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                this.BeginInvoke(new Action(delegate()
                {
                    textBox_Scanned.Text = scannedCode.ToString();
                    scannedCode.Clear();

                    if (function.BOX_LOT_CODE == false && function.COUNT_SETUP == false)
                    {
                        if (this.currentLotNumber > this.tray_1Box)
                        {
                            if (textBox_Scanned.Text == boxCode)
                            {
                                textBox_Scanned.Text = "Complete Box";

                                this.sumOfPassCount = 0;
                                this.failCount      = 0;
                                this.sumOfLot++;
                                this.currentLotNumber = 1;
                                this.currentSeqQty    = 0;

                                this.button_PassFail.Text  = "PASS (" + (this.sumOfPassCount).ToString() + ") / FAIL (" + (this.failCount).ToString() + ")";
                                this.label_TrayNumber.Text = this.currentLotNumber.ToString();
                                this.label_TestCount.Text  = this.currentSeqQty.ToString();
                                return;
                            }
                            else
                            {
                                // Phoung want
                                errorAlarmForm = new ErrorAlarmForm(testResultInfo, false);
                                errorAlarmForm.Show(this);
                                textBox_Scanned.Text = "Scan Box Code !";
                                return;
                            }
                        }

                        if (this.passCount >= this.sample_Tray) // lot + 1
                        {
                            // CHECK LOT CODE
                            if (textBox_Scanned.Text == lotCode)
                            {
                                passCount = 0;
                                this.currentLotNumber++;
                                this.sumOfLot++;
                                textBox_Scanned.Text       = "";
                                this.label_TrayNumber.Text = this.currentLotNumber.ToString();

                                if (this.currentLotNumber > this.tray_1Box)
                                {
                                    this.sumOfLot--;
                                    this.label_TrayNumber.Text = (this.tray_1Box).ToString();
                                    textBox_Scanned.Text       = "Scan Box Code !";
                                }
                                return;
                            }
                            else
                            {
                                // Phoung want
                                errorAlarmForm = new ErrorAlarmForm(testResultInfo, false);
                                errorAlarmForm.Show(this);
                                textBox_Scanned.Text = "Scan Lot Code !";
                                return;
                            }
                        }
                    }

                    this.currentSeqQty++;
                    this.currentTestCount++;

                    if (this.function.COUNT_SETUP == false)
                    {
                        this.label_TestCount.Text = this.currentSeqQty.ToString();
                    }


                    testResultInfo.Time          = DateTime.Now;
                    testResultInfo.Origin_Item   = masterCode;
                    testResultInfo.Compared_Item = textBox_Scanned.Text;
                    testResultInfo.Sample_1Box   = this.sample_1Box;
                    testResultInfo.Sample_Tray   = this.sample_Tray;
                    testResultInfo.TrayNumber    = this.sumOfLot;
                    testResultInfo.TestCount     = this.currentTestCount;

                    if (textBox_Scanned.Text == masterCode)
                    {
                        testResultInfo.Result = true;
                        testResultInfo.Reason = "TEST OK";

                        button_PassFail.Text = "OK";
                        sumOfPassCount++;
                        passCount++;

                        using (conn = new SQLiteConnection(connStr))
                        {
                            conn.Open();
                            testResult_CRUD = new BarcodeTestResult_CRUD(conn);
                            testResult_CRUD.Insert(testResultInfo);
                        }
                    }
                    else
                    {
                        testResultInfo.Result = false;
                        errorAlarmForm        = new ErrorAlarmForm(testResultInfo, true);
                        errorAlarmForm.Show(this);
                        failCount++;
                        button_PassFail.Text = "NG";
                    }

                    this.button_PassFail.Text = "PASS (" + (this.sumOfPassCount).ToString() + ") / FAIL (" + (this.failCount).ToString() + ")";

                    if (function.BOX_LOT_CODE == false && function.COUNT_SETUP == false)
                    {
                        if (this.passCount >= this.sample_Tray)
                        {
                            textBox_Scanned.Text = "Scan Lot Code !";
                        }
                    }
                }));

                this.textBox_Scanned.KeyUp -= this.textBox_Scanned_KeyUp;
                Stopwatch delay = new Stopwatch();
                delay.Start();

                while (true)
                {
                    if (delay.ElapsedMilliseconds > 900)
                    {
                        delay.Stop();
                        break;
                    }
                }

                this.textBox_Scanned.KeyUp += this.textBox_Scanned_KeyUp;
            }
            else
            {
                scannedCode.Append(KeyToUni.KeyCodeToUnicode(e.KeyCode).ToUpper());
            }
        }