Beispiel #1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="line"></param>
 /// <returns></returns>
 public bool Delete(tbl_test_log entity)
 {
     using (var connection = GetOpenConnection())
     {
         try
         {
             connection.Delete <tbl_test_log>(entity);
             return(true);
         }
         catch (Exception ex)
         {
             return(false);
         }
     }
 }
Beispiel #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="entity"></param>
 /// <returns></returns>
 public bool Insert(tbl_test_log entity)
 {
     using (var connection = GetOpenConnection())
     {
         try
         {
             connection.Insert <string>(entity);
             return(true);
         }
         catch (Exception ex)
         {
             return(false);
         }
     }
 }
Beispiel #3
0
 public void UpdateOQCCheck(tbl_test_log production, string operatorCode)
 {
     if (production != null)
     {
         production.QA_Check  = true;
         production.CheckBy   = operatorCode;
         production.DateCheck = DateTime.Now;
         try
         {
             _context.Entry(production).State = EntityState.Modified;
             _context.SaveChanges();
         }
         catch (Exception ex)
         {
             throw new Exception(ex.Message);
         }
     }
 }
Beispiel #4
0
 private void txtProductionID_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         if (string.IsNullOrEmpty(txtProductionID.Text))
         {
             Ultils.TextControlNotNull(txtProductionID, "Production ID");
         }
         else
         {
             string productionId = txtProductionID.Text.Trim();
             if (checkBox1.Checked == true)
             {
                 productionId         = productionId.Replace("_", "");
                 txtProductionID.Text = productionId;
             }
             foreach (var item in _modelService.GetModels())
             {
                 if (productionId.Contains(item.ModelName.ToUpper()))
                 {
                     lblQuantityModel.Visible      = true;
                     lblQuantityModel.Text         = $"/{item.Quantity}";
                     tableLayoutPanelModel.Visible = true;
                     lblCurentModel.Text           = item.ModelName;
                     lblSerialNo.Text = item.SerialNo;
                     break;
                 }
             }
             _log = _oqcService.GetLogByProductionId(productionId);
             if (_log != null)
             {
                 if (_log.QA_Check == false)
                 {
                     txtJudge.Focus();
                     SetErrorStatus(false, "OK", null);
                 }
                 else
                 {
                     SetSuccessStatus(true, "OK",
                                      $"PCB [{productionId}] đã được kiểm tra rồi.\n" +
                                      $"Box ID: {_log.BoxID} \n" +
                                      $"Operator: {_log.OperatorCode} \n" +
                                      $"Date Check: {_log.DateCheck} \n");
                     txtProductionID.SelectAll();
                     Ultils.EditTextErrorNoMessage(txtProductionID);
                 }
             }
             else
             {
                 SetErrorStatus(true, "NG", $"Production ID[{txtProductionID.Text.Trim()}]\nChưa có trong hệ thống. Vui lòng kiểm tra lại!");
                 txtProductionID.SelectAll();
                 Ultils.EditTextErrorNoMessage(txtProductionID);
             }
         }
     }
     if (e.KeyCode == Keys.Tab)
     {
         if (string.IsNullOrEmpty(txtProductionID.Text))
         {
             Ultils.TextControlNotNull(txtProductionID, "Production ID");
         }
     }
 }
Beispiel #5
0
        /// <summary>
        /// Insert Log
        /// </summary>
        /// <param name="boxId"></param>
        private void InsertLog(string boxId, string boardNo)
        {
            int    lineId      = Program.CurrentUser.LineID;
            int    operationId = Program.CurrentUser.OperationID;
            string operatorId  = Program.CurrentUser.OperatorCode;

            string status = null;
            bool   judge  = false;

            if (checkOK.Checked == true)
            {
                status = "P";
                judge  = true;
            }
            if (checkNG.Checked == true)
            {
                status = "F";
                judge  = false;
            }
            var logs = testLogService.Get(boxId);

            if (operationId == 1)
            {
                try
                {
                    var testLog = new tbl_test_log()
                    {
                        ProductionID = boardNo,
                        LineID       = lineId,
                        MacAddress   = txtMacAddress.Text.Trim(),
                        BoxID        = boxId,
                        DateCheck    = DateTimeServer.Date,
                        TimeCheck    = DateTimeServer.TimeOfDay,
                        OperatorCode = operatorId,
                        Target       = 1,
                        Actual       = 1,
                        FullBox      = false,
                        QA_Check     = false,
                        CheckBy      = operatorId,
                        ModelID      = _model.ModelID,
                    };

                    if (testLogService.Insert(testLog) == true)
                    {
                        var checkExists = testResultService.GetSingle(boardNo, operationId);

                        if (checkExists == null)
                        {
                            var result = new tbl_test_result()
                            {
                                ProductionID  = boardNo,
                                OperationID   = operationId,
                                OperationDate = DateTimeServer,
                                OperatorID    = operatorId,
                                JudgeResult   = judge,
                            };
                            testResultService.Insert(result);
                        }
                        else
                        {
                            checkExists.JudgeResult   = judge;
                            checkExists.OperatorID    = operatorId;
                            checkExists.OperationDate = DateTimeServer;

                            testResultService.Update(checkExists);
                        }
                    }

                    logs = testLogService.Get(boxId);
                    dataGridViewX1.DataSource = logs;

                    SuccessMessage("OK", string.Format("Thêm thành công!\nPCB [{0}]", boardNo));
                }
                catch (Exception ex)
                {
                    ErrorMessage("NG", "Error Insert! \n" + ex.Message);
                }

                // Create log
                Ultils.CreateFileLog(_model.ModelName, boardNo, status, Program.CurrentUser.ProcessID, DateTimeServer);

                txtBarcode.ResetText();
                txtBarcode.Focus();

                sw.Stop();
                MessageBox.Show(sw.Elapsed.ToString());
            }
        }