/// <summary> /// Thực hiện lệnh gửi đi /// </summary> /// <param name="boardNo"></param> /// <param name="productId"></param> private void Excute(string boardNo, string productId) { CancelAsyncBackgroundWorker(); txtBarcode.ResetText(); txtBarcode.Focus(); _productionId = boardNo; _modelId = productId; _result = ""; MessageHelpers.SetSuccessStatus(true, "OK", $"Board '{boardNo}' OK!", lblStatus, lblMessage); // Thực hiện gửi dữ liệu đi //_serial = boardNo.Split(new[] { "_" }, 4, StringSplitOptions.None); //_maxaddress = boardNo.Split(new[] { "." }, 4, StringSplitOptions.None); //SendKeys.Send("{TAB}"); //SendKeys.Send("{ENTER}"); //SendKeys.Send(_serial[0]); //SendKeys.Send("{ENTER}"); //SendKeys.Send(_maxaddress[1]); //SendKeys.Send("{ENTER}"); if (checkComWrite.Checked) { // Start machine FCT Check Thread.Sleep(200); _comWrite.WriteData("S"); } ActiveFormByWindowsTitle(cboWindows.EditValue.ToString()); }
private void Excute(string boardNo, string product_id) { this.TopMost = false; StopTimerReadBarcode(); txtBarcode.ResetText(); txtBarcode.Focus(); productionId = boardNo; modelId = product_id; MessageHelpers.SetSuccessStatus(true, "OK", $"Board '{boardNo}' OK!", lblStatus, lblMessage); // Thực hiện gửi dữ liệu đi int iHandle = NativeWin32.FindWindow(null, cboWindows.Text); NativeWin32.SetForegroundWindow(iHandle); serial = boardNo.Split(separator: new[] { "_" }, count: 4, options: StringSplitOptions.None); //maxaddress = boardNo.Split(separator: new[] { "." }, count: 4, options: StringSplitOptions.None); //SendKeys.Send("{TAB}"); //SendKeys.Send("{ENTER}"); SendKeys.Send(serial[0]); SendKeys.Send("{ENTER}"); //SendKeys.Send(maxaddress[1]); //SendKeys.Send("{ENTER}"); if (checkComWrite.Checked == true) { // Start machine FCT Check Thread.Sleep(200); comWrite.WriteData("S"); } }
/// <summary> /// Thực hiện lệnh gửi đi /// </summary> /// <param name="boardNo"></param> /// <param name="productId"></param> private void Excute(string boardNo, string productId) { //CancelAsyncBackgroundWorker(); _barcodeOld = txtBarcode.Text; txtBarcode.ResetText(); txtBarcode.Focus(); _productionId = boardNo; _modelId = productId; _result = ""; MessageHelpers.SetSuccessStatus(true, "OK", $"Board '{boardNo}' OK!", lblStatus, lblMessage); if (checkEditSerialPort.Checked) { // Start machine FCT Check Thread.Sleep(200); com.WriteData("S"); } ActiveFormByWindowsTitle(cboWindows.EditValue.ToString()); }
/// <summary> /// Thực hiện lệnh gửi đi /// </summary> /// <param name="boardNo"></param> /// <param name="product_id"></param> private void Excute(string boardNo, string product_id) { this.TopMost = false; txtBarcode.ResetText(); txtBarcode.Focus(); productionId = boardNo; modelId = product_id; MessageHelpers.SetSuccessStatus(true, "OK", $"Board '{boardNo}' OK!", lblStatus, lblMessage); // Thực hiện gửi dữ liệu đi int iHandle = NativeWin32.FindWindow(null, cboWindows.Text); NativeWin32.SetForegroundWindow(iHandle); SendKeys.Send(boardNo); SendKeys.Send("{ENTER}"); if (checkEditSerialPort.Checked == true) { // Start machine FCT Check Thread.Sleep(200); com.WriteData("S"); } }
private void txtBarcode_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) { if (e.KeyCode == Keys.Enter) { string boardNo = txtBarcode.Text; dateCheck = Ultils.GetNetworkDateTime().ToString("yyMMddHHmmss"); if (boardNo.Contains("=")) { boardNo = boardNo.Replace("=", "_"); } string set_station_no = gridLookUpEditProcessID.EditValue.ToString(); if (!CheckTextBoxNullValue.ValidationTextEditNullValue(txtBarcode)) { MessageHelpers.SetErrorStatus(true, "NG", "Please input a barcode!", lblStatus, lblMessage); return; } else if (txtBarcode.Text.Length <= 5) { MessageHelpers.SetErrorStatus(true, "NG", "Board No invaild. Please try again!", lblStatus, lblMessage); CheckTextBoxNullValue.SetColorErrorTextControl(txtBarcode); return; } else { MessageHelpers.SetDefaultStatus(true, "N/A", "N/A", lblStatus, lblMessage); CheckTextBoxNullValue.SetColorDefaultTextControl(txtBarcode); var boards = _scanningLogsService.Get_SCANNING_LOGS(boardNo).FirstOrDefault(); if (boards != null) { var process_No = _inspectionProcessesService.GET_INSPECTION_PROCESSES_BY_PRODUCT_ID(boards.PRODUCT_ID); if (process_No != null) { // //trạng thái bản mạch hiện tại var curentStationNo = _workOrderItemService.Get_WORK_ORDER_ITEMS_By_BoardNo(boardNo); if (curentStationNo != null) { // nếu đã đã chạy qua các bước, với trạng thái là Finished // thì thông báo cho người dùng biết if (curentStationNo.IS_FINISHED == true) { messageError = $"Board '{boardNo}' is finished!"; MessageHelpers.SetErrorStatus(true, "NG", messageError, lblStatus, lblMessage); CheckTextBoxNullValue.SetColorErrorTextControl(txtBarcode); var errorForm = new FormError(messageError); errorForm.ShowDialog(); txtBarcode.Focus(); return; } // Kiểm tra nếu trạng thái bản mạch hiện tại bị NG // mà khác với với trạm được cài đặt "FCT" thì thông báo lỗi else if (curentStationNo.STATION_NO != set_station_no && curentStationNo.BOARD_STATE == 2) { messageError = $"Board '{boardNo}' bị 'NG' tại trạm '{set_station_no}'!"; MessageHelpers.SetErrorStatus(true, "NG", messageError, lblStatus, lblMessage); CheckTextBoxNullValue.SetColorErrorTextControl(txtBarcode); var errorForm = new FormError(messageError); errorForm.ShowDialog(); txtBarcode.Focus(); return; } // Nếu tên giống nhau, thì thông báo đã chạy qua công đoạn này rồi else if (curentStationNo.STATION_NO == set_station_no && curentStationNo.BOARD_STATE == 1) { messageError = $"Board '{boardNo}' is pass '{set_station_no}'!"; MessageHelpers.SetErrorStatus(true, "NG", messageError, lblStatus, lblMessage); CheckTextBoxNullValue.SetColorErrorTextControl(txtBarcode); var errorForm = new FormError(messageError); errorForm.ShowDialog(); txtBarcode.Focus(); return; } else { var process_Designer = _inspectionProcessesDesignersService.GET_INSPECTION_PROCEDURE_DESIGNERS_BY_PROCESS_NO(process_No.PROCESS_NO); // Set station no var process_by_station_no = process_Designer.FirstOrDefault(item => item.STATION_NO == set_station_no); // Nếu trong process_Designer không có STATION_NO giống với // station_no curent thì thông báo cho người dùng biết if (process_by_station_no == null) { messageError = $"Board '{boardNo}' station '{set_station_no}' not invaild!"; MessageHelpers.SetErrorStatus(true, "NG", messageError, lblStatus, lblMessage); CheckTextBoxNullValue.SetColorErrorTextControl(txtBarcode); var errorForm = new FormError(messageError); errorForm.ShowDialog(); txtBarcode.Focus(); return; } // nếu hợp lệ thực hiện tiếp else { // Khi hai giá trị bằng nhau => ICT_FUJ if (curentStationNo.PROCEDURE_INDEX < (process_by_station_no.INDEX - 1)) { messageError = $"Board '{boardNo}' skip stations!"; MessageHelpers.SetErrorStatus(true, "NG", messageError, lblStatus, lblMessage); CheckTextBoxNullValue.SetColorErrorTextControl(txtBarcode); var errorForm = new FormError(messageError); errorForm.ShowDialog(); txtBarcode.Focus(); return; } //// Nếu Index Board > Set Index else if (curentStationNo.PROCEDURE_INDEX > process_by_station_no.INDEX) { // transferred to the next station. messageError = $"Board '{boardNo}' transferred to the next station!"; MessageHelpers.SetErrorStatus(true, "NG", messageError, lblStatus, lblMessage); CheckTextBoxNullValue.SetColorErrorTextControl(txtBarcode); var errorForm = new FormError(messageError); errorForm.ShowDialog(); txtBarcode.Focus(); return; } else if (curentStationNo.PROCEDURE_INDEX == (process_by_station_no.INDEX - 1)) { //Ultils.SuspendOrResumeCurentProcess(cboWindows.Text, false); this.TopMost = false; txtBarcode.ResetText(); txtBarcode.Focus(); productionId = boardNo; modelId = boards.PRODUCT_ID; MessageHelpers.SetSuccessStatus(true, "OK", $"Board '{boardNo}' OK!", lblStatus, lblMessage); // Thực hiện gửi dữ liệu đi int iHandle = NativeWin32.FindWindow(null, cboWindows.Text); NativeWin32.SetForegroundWindow(iHandle); SendKeys.Send(boardNo); SendKeys.Send("{ENTER}"); if (checkEditSerialPort.Checked == true) { // Start machine FCT Check Thread.Sleep(200); com.WriteData("S"); } } else if (curentStationNo.BOARD_STATE == 2) { this.TopMost = false; txtBarcode.ResetText(); txtBarcode.Focus(); productionId = boardNo; modelId = boards.PRODUCT_ID; MessageHelpers.SetSuccessStatus(true, "OK", $"Board '{boardNo}' OK!", lblStatus, lblMessage); // Thực hiện gửi dữ liệu đi int iHandle = NativeWin32.FindWindow(null, cboWindows.Text); NativeWin32.SetForegroundWindow(iHandle); SendKeys.Send(boardNo); SendKeys.Send("{ENTER}"); if (checkEditSerialPort.Checked == true) { // Start machine FCT Check Thread.Sleep(200); com.WriteData("S"); } } } } } else { messageError = $"Station No '{curentStationNo.STATION_NO}' not found!"; MessageHelpers.SetErrorStatus(true, "NG", messageError, lblStatus, lblMessage); CheckTextBoxNullValue.SetColorErrorTextControl(txtBarcode); var errorForm = new FormError(messageError); errorForm.ShowDialog(); txtBarcode.Focus(); return; } } else { messageError = $"Station No '{set_station_no}' invaild!"; MessageHelpers.SetErrorStatus(true, "NG", messageError, lblStatus, lblMessage); CheckTextBoxNullValue.SetColorErrorTextControl(txtBarcode); var errorForm = new FormError(messageError); errorForm.ShowDialog(); txtBarcode.Focus(); return; } } else { messageError = $"Board '{boardNo}' not initialized!"; MessageHelpers.SetErrorStatus(true, "NG", messageError, lblStatus, lblMessage); CheckTextBoxNullValue.SetColorErrorTextControl(txtBarcode); var errorForm = new FormError(messageError); errorForm.ShowDialog(); return; } } } }
private void timerEditNotify_Tick(object sender, EventArgs e) { if (RunTaks) { if (barcode_no != null || barcode_no != "") { if (product_id.Contains(ModelName(pathFileChanged))) { boardState = GetState(pathFileChanged); itemDetails = new List <ItemDetail>(); Ultils.CreateFileLog(product_id, barcode_no, boardState, stationNo, dateFormat); ItemDetail itemCheck = new ItemDetail() { BOARD_NO = barcode_no, ProductID = product_id, STATION_NO = stationNo, DATE_CHECK = DateTime.Now.ToShortDateString(), TIME_CHECK = DateTime.Now.ToShortTimeString(), STATE = boardState, }; itemDetails.Add(itemCheck); ActiveFormByWindowsTitle(Text); gridControl1.DataSource = itemDetails; // Show lblPASS.Text = pass.ToString(); lblNG.Text = ng.ToString(); lblTotal.Text = total.ToString(); if (boardState == "P") { // Reset TextBarcode MessageHelpers.SetSuccessStatus(true, "OK", $"Board [{barcode_no}] OK!", lblStatus, lblMessageInfo); barcode_no = ""; txtBarcode.Enabled = true; txtBarcode.ResetText(); txtBarcode.Focus(); } if (boardState == "F") { MessageHelpers.SetErrorStatus(true, "NG", $"Board [{barcode_no}] NG. Please check again", lblStatus, lblMessageInfo); } } else { ActiveFormByWindowsTitle(Text); MessageHelpers.SetErrorStatus(true, "NG", $"Sai Model. Vui lòng chọn lại Model cho chính xác!" + $"\nModel: {ModelName(pathFileChanged)}" + $"\nBoard No: {barcode_no}", lblStatus, lblMessageInfo); barcode_no = ""; txtBarcode.Enabled = true; txtBarcode.ResetText(); txtBarcode.Focus(); } } else { ActiveFormByWindowsTitle(Text); MessageHelpers.SetErrorStatus(true, "NG", $"Vui lòng bắn vào Serial trước khi chạy!", lblStatus, lblMessageInfo); txtBarcode.Focus(); } RunTaks = false; } }
private void txtBarcode_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) { if (e.KeyCode == Keys.Enter) { string boardNo = txtBarcode.Text; string set_station_no = gridLookUpEditProcessID.EditValue.ToString(); if (!CheckTextBoxNullValue.ValidationTextEditNullValue(txtBarcode)) { MessageHelpers.SetErrorStatus(true, "NG", "Please input a barcode!", lblStatus, lblMessage); return; } else if (txtBarcode.Text.Length <= 5) { MessageHelpers.SetErrorStatus(true, "NG", "Board No invaild. Please try again!", lblStatus, lblMessage); CheckTextBoxNullValue.SetColorErrorTextControl(txtBarcode); return; } else { MessageHelpers.SetDefaultStatus(true, "N/A", "N/A", lblStatus, lblMessage); CheckTextBoxNullValue.SetColorDefaultTextControl(txtBarcode); var boards = _scanningLogsService.Get_SCANNING_LOGS(boardNo).FirstOrDefault(); // nếu board đã được bắn vào trước đó if (boards != null) { var process_No = _inspectionProcessesService.GET_INSPECTION_PROCESSES_BY_PRODUCT_ID(boards.PRODUCT_ID); if (process_No != null) { // //trạng thái bản mạch hiện tại var curentStationNo = _workOrderItemService.Get_WORK_ORDER_ITEMS_By_BoardNo(boardNo); if (curentStationNo != null) { // nếu đã đã chạy qua các bước, với trạng thái là Finished // thì thông báo cho người dùng biết if (curentStationNo.IS_FINISHED == true) { // Thông tin lỗi messageError = $"Board '{boardNo}' is finished!"; MessageHelpers.SetErrorStatus(true, "NG", messageError, lblStatus, lblMessage); CheckTextBoxNullValue.SetColorErrorTextControl(txtBarcode); var errorForm = new FormError(messageError); errorForm.ShowDialog(); txtBarcode.Focus(); return; } // Nếu tên giống nhau, thì thông báo đã chạy qua công đoạn này rồi else if (curentStationNo.STATION_NO == set_station_no && curentStationNo.BOARD_STATE == 1) { MessageHelpers.SetErrorStatus(true, "NG", $"Board '{boardNo}' is pass '{set_station_no}'!", lblStatus, lblMessage); CheckTextBoxNullValue.SetColorErrorTextControl(txtBarcode); var errorForm = new FormError($"Board '{boardNo}' is pass '{set_station_no}'!"); errorForm.ShowDialog(); txtBarcode.Focus(); return; } else { var process_Designer = _inspectionProcessesDesignersService.GET_INSPECTION_PROCEDURE_DESIGNERS_BY_PROCESS_NO(process_No.PROCESS_NO); // Set station no var process_by_station_no = process_Designer.FirstOrDefault(item => item.STATION_NO == set_station_no); // Nếu trong process_Designer không có STATION_NO giống với // station_no curent thì thông báo cho người dùng biết if (process_by_station_no == null) { // Thông tin lỗi messageError = $"Board '{boardNo}' station '{set_station_no}' not invaild!"; MessageHelpers.SetErrorStatus(true, "NG", messageError, lblStatus, lblMessage); CheckTextBoxNullValue.SetColorErrorTextControl(txtBarcode); var errorForm = new FormError(messageError); errorForm.ShowDialog(); txtBarcode.Focus(); return; } // nếu hợp lệ thực hiện tiếp else { // Khi hai giá trị bằng nhau => ICT_FUJ if (curentStationNo.PROCEDURE_INDEX < (process_by_station_no.INDEX - 1)) { // Lấy tên trạm bị bỏ qua string station_skip = process_Designer.FirstOrDefault(item => item.INDEX == (process_by_station_no.INDEX - 1)).STATION_NO; // Thông tin lỗi messageError = $"Board '{boardNo}' skip station '{station_skip}'!"; // Hiển thị thông báo cho người dùng MessageHelpers.SetErrorStatus(true, "NG", messageError, lblStatus, lblMessage); CheckTextBoxNullValue.SetColorErrorTextControl(txtBarcode); var errorForm = new FormError(messageError); errorForm.ShowDialog(); txtBarcode.Focus(); return; } //// Nếu Index Board > Set Index else if (curentStationNo.PROCEDURE_INDEX > process_by_station_no.INDEX) { // Lấy tên trạm tiếp theo mà broad cần chạy qua. string station_skip = process_Designer.FirstOrDefault(item => item.INDEX == (curentStationNo.PROCEDURE_INDEX + 1)).STATION_NO; // Thông tin lỗi messageError = $"Board '{boardNo}' transferred to the next station '{station_skip}'!"; // transferred to the next station. MessageHelpers.SetErrorStatus(true, "NG", messageError, lblStatus, lblMessage); CheckTextBoxNullValue.SetColorErrorTextControl(txtBarcode); var errorForm = new FormError(messageError); errorForm.ShowDialog(); txtBarcode.Focus(); return; } // Nếu trạm hiện tại mà giống với trạm cài đặt thì gửi dữ liệu đi else if (curentStationNo.PROCEDURE_INDEX == (process_by_station_no.INDEX - 1)) { this.TopMost = false; txtBarcode.ResetText(); txtBarcode.Focus(); productionId = boardNo; modelId = boards.PRODUCT_ID; MessageHelpers.SetSuccessStatus(true, "OK", $"Board '{boardNo}' OK!", lblStatus, lblMessage); // Thực hiện gửi dữ liệu đi int iHandle = NativeWin32.FindWindow(null, cboWindows.EditValue.ToString()); NativeWin32.SetForegroundWindow(iHandle); SendKeys.Send(boardNo); SendKeys.Send("{ENTER}"); } // Nếu board này đã chạy rồi, với trạng thái là FAILD thì thực hiện chạy lại. else if (curentStationNo.BOARD_STATE == 2) { this.TopMost = false; txtBarcode.ResetText(); txtBarcode.Focus(); productionId = boardNo; modelId = boards.PRODUCT_ID; MessageHelpers.SetSuccessStatus(true, "OK", $"Board '{boardNo}' OK!", lblStatus, lblMessage); // Thực hiện gửi dữ liệu đi int iHandle = NativeWin32.FindWindow(null, cboWindows.EditValue.ToString()); NativeWin32.SetForegroundWindow(iHandle); SendKeys.Send(boardNo); SendKeys.Send("{ENTER}"); } else { // Thông tin lỗi messageError = $"Broad '{boardNo} lỗi không rõ nguyên nhân. Vui lòng liên hệ với bộ phần 'PE-IT' để được hỗ trợ!'"; MessageHelpers.SetErrorStatus(true, "NG", messageError, lblStatus, lblMessage); CheckTextBoxNullValue.SetColorErrorTextControl(txtBarcode); var errorForm = new FormError(messageError); errorForm.ShowDialog(); txtBarcode.Focus(); return; } } } } else { // Thông tin lỗi messageError = $"Station No '{curentStationNo.STATION_NO}' not found!"; MessageHelpers.SetErrorStatus(true, "NG", messageError, lblStatus, lblMessage); CheckTextBoxNullValue.SetColorErrorTextControl(txtBarcode); var errorForm = new FormError(messageError); errorForm.ShowDialog(); txtBarcode.Focus(); return; } } else { // Thông tin lỗi messageError = $"Station No '{set_station_no}' invaild!"; MessageHelpers.SetErrorStatus(true, "NG", messageError, lblStatus, lblMessage); CheckTextBoxNullValue.SetColorErrorTextControl(txtBarcode); var errorForm = new FormError(messageError); errorForm.ShowDialog(); txtBarcode.Focus(); return; } } else { // Thông tin lỗi messageError = $"Board '{boardNo}' not initialized!"; MessageHelpers.SetErrorStatus(true, "NG", messageError, lblStatus, lblMessage); CheckTextBoxNullValue.SetColorErrorTextControl(txtBarcode); var errorForm = new FormError(messageError); errorForm.ShowDialog(); return; } } } }