private void txtPath_EditValueChanged(object sender, EventArgs e) { if (txtPath.Text.Contains(@":\")) { if (Directory.Exists(txtPath.Text)) { MessageHelpers.SetDefaultStatus(true, "N/A", "N/A", lblStatus, lblMessage); CheckTextBoxNullValue.SetColorDefaultTextControl(txtPath); string path = txtPath.Text; SaveSettings("Folder", path); } else { MessageHelpers.SetErrorStatus(true, "NG", "'File/Directory' not exits. Please try again!", lblStatus, lblMessage); CheckTextBoxNullValue.SetColorErrorTextControl(txtPath); } } else { MessageHelpers.SetErrorStatus(true, "NG", "'File/Directory' invaild. Please try again!", lblStatus, lblMessage); CheckTextBoxNullValue.SetColorErrorTextControl(txtPath); } }
private void tmrEditNotify_Tick(object sender, EventArgs e) { if (m_bDirtys) { // Kiểm tra lại bản mạch đã OK trên WIP chưa? // Nếu OK => Đóng dấu // Nếu FAIL => Bỏ qua không đóng dấu, thông báo lỗi //trạng thái bản mạch hiện tại if (checkEditSerialPort.Checked == true) { var checkAgain = _workOrderItemService.Get_WORK_ORDER_ITEMS_By_BoardNo(productionId); if (checkAgain.BOARD_STATE == 1) { //com.WriteData("O"); lblMarking.Visible = true; } else if (checkAgain.BOARD_STATE == 2) { messageError = $"Board '{productionId}' NG Wip. Vui lòng kiểm tra lại!"; MessageHelpers.SetErrorStatus(true, "NG", messageError, lblStatus, lblMessage); CheckTextBoxNullValue.SetColorErrorTextControl(txtBarcode); var errorForm = new FormError(messageError); errorForm.ShowDialog(); txtBarcode.Focus(); } } int iHandle2 = NativeWin32.FindWindow(null, this.Text); NativeWin32.SetForegroundWindow(iHandle2); lblPass.Text = pass.ToString(); lblNG.Text = ng.ToString(); lblTotal.Text = total.ToString(); LoadData(productionId, modelId, gridLookUpEditProcessID.EditValue.ToString(), boardState); m_bDirtys = false; } }
private void txtPath_EditValueChanged(object sender, EventArgs e) { if (txtPath.Text.Contains(@":\")) { if (Directory.Exists(txtPath.Text)) { MessageHelpers.SetDefaultStatus(true, "N/A", "N/A", lblStatus, lblMessage); CheckTextBoxNullValue.SetColorDefaultTextControl(txtPath); if (checkPath.Checked == true) { Properties.Settings.Default["Folder"] = txtPath.Text; Properties.Settings.Default.Save(); // Saves settings in application configuration file } } else { MessageHelpers.SetErrorStatus(true, "NG", "'File/Directory' not exits. Please try again!", lblStatus, lblMessage); CheckTextBoxNullValue.SetColorErrorTextControl(txtPath); } } else { MessageHelpers.SetErrorStatus(true, "NG", "'File/Directory' invaild. Please try again!", lblStatus, lblMessage); CheckTextBoxNullValue.SetColorErrorTextControl(txtPath); } }
private void txtBarcode_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) { if (e.KeyCode == Keys.Enter) { barcode_no = txtBarcode.Text.Trim(); //if(barcode_no.Contains("-")) //{ // string[] array = barcode_no.Split('-'); // barcode_no = array[0]; // txtBarcode.Text = barcode_no; //} product_id = txtModels.EditValue.ToString(); dateFormat = DateTime.Now.ToString("yyMMddHHmmss"); if (CheckTextBoxNullValue.ValidationTextEditNullValue(txtBarcode)) { int lengthSerial; if (StringHelper.IsEmptyOrNull(barcodeLength)) { lengthSerial = int.Parse(barcodeLength); if (barcode_no.Length >= lengthSerial) { ActiveFormByWindowsTitle(processNo); txtBarcode.Enabled = false; //try //{ // scanningLogs = new SCANNING_LOGS_Service().Get_SCANNING_LOGS(barcode_no, product_id); //} //catch (Exception ex) //{ // MessageHelpers.SetErrorStatus(true, "NG", ex.Message, lblStatus, lblMessageInfo); //} } else { MessageHelpers.SetErrorStatus(true, "NG", $"Barcode[{barcode_no}] không đúng định dạng. Vui lòng kiểm tra lại!", lblStatus, lblMessageInfo); CheckTextBoxNullValue.SetColorErrorTextControl(txtBarcode); return; } } else { MessageHelpers.SetErrorStatus(true, "NG", $"Vui lòng kiểm tra lại cài đặt độ dài của Barcode!", lblStatus, lblMessageInfo); return; } } else { MessageHelpers.SetErrorStatus(true, "NG", "Không được để trống. Vui lòng bắn vào serial!", lblStatus, lblMessageInfo); return; } } }
private void btnStart_Click(object sender, EventArgs e) { if (CheckTextBoxNullValue.ValidationTextEditNullValue(txtModels)) { if (startWatching) { startWatching = false; fileWatcher.EnableRaisingEvents = false; fileWatcher.Dispose(); btnStart.Appearance.BackColor = Color.DarkGreen; btnStart.Text = "Start"; VisibleBarcodeControl(false, true); } else { startWatching = true; btnStart.Appearance.BackColor = Color.DarkRed; btnStart.Text = "Stop"; VisibleBarcodeControl(true, false); // Config file watching fileWatcher = new FileSystemWatcher(); fileWatcher.IncludeSubdirectories = true; if (extentionInputLog.Contains("*")) { fileWatcher.Filter = extentionInputLog; } else { fileWatcher.Filter = "*" + extentionInputLog; } fileWatcher.Path = inputLog + "\\"; fileWatcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.CreationTime | NotifyFilters.FileName | NotifyFilters.DirectoryName; fileWatcher.Created += new FileSystemEventHandler(OnFileChanged); fileWatcher.Changed += new FileSystemEventHandler(OnFileChanged); fileWatcher.EnableRaisingEvents = true; } } else { MessageHelpers.SetErrorStatus(true, "NG", "Vui lòng chọn Model!", lblStatus, lblMessageInfo); return; } }
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 btnWatchFile_Click(object sender, EventArgs e) { bool isVaild = true; if (!CheckTextBoxNullValue.ValidationTextEditNullValue(gridLookUpEditProcessID)) { MessageHelpers.SetErrorStatus(true, "NG", "Please select a 'Station No'!", lblStatus, lblMessage); isVaild = false; } else if (!CheckTextBoxNullValue.ValidationTextEditNullValue(txtPath)) { MessageHelpers.SetErrorStatus(true, "NG", "Please select a 'File/Directory'!", lblStatus, lblMessage); isVaild = false; } else if (isVaild) { if (m_bIsWatching) { m_bIsWatching = false; m_Watcher.EnableRaisingEvents = false; m_Watcher.Dispose(); btnWatchFile.Appearance.BackColor = Color.LightSkyBlue; btnWatchFile.Text = "Start Watching"; EnableControls(true); txtBarcode.Visible = false; } else { m_bIsWatching = true; if (checkEditSerialPort.Checked == true) { // Cấu hình COM PORT ConfigSerialPorts(); } btnWatchFile.ForeColor = Color.White; btnWatchFile.Appearance.BackColor = Color.DarkRed; btnWatchFile.Font = new Font(btnWatchFile.Font, FontStyle.Bold); btnWatchFile.Text = "Stop Watching"; EnableControls(false); txtBarcode.Visible = true; txtBarcode.Focus(); m_Watcher = new FileSystemWatcher(); if (rdbDir.Checked) { m_Watcher.Filter = "*.txt"; m_Watcher.Path = txtPath.Text + "\\"; } else { m_Watcher.Filter = txtPath.Text.Substring(txtPath.Text.LastIndexOf('\\') + 1); m_Watcher.Path = txtPath.Text.Substring(0, txtPath.Text.Length - m_Watcher.Filter.Length); } if (chkSubFolder.Checked) { m_Watcher.IncludeSubdirectories = true; } m_Watcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName; m_Watcher.Created += new FileSystemEventHandler(OnChanged); m_Watcher.Changed += new FileSystemEventHandler(OnChanged); //m_Watcher.Deleted += new FileSystemEventHandler(OnChanged); m_Watcher.Renamed += new RenamedEventHandler(OnRenamed); m_Watcher.EnableRaisingEvents = true; } } }
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; } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void txtBarcode_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) { if (e.KeyCode == Keys.Enter) { CancelAsyncBackgroundWorker(); // Active form ActiveFormByWindowsTitle(cboWindows.EditValue.ToString()); string boardNo = txtBarcode.Text; _dateCheck = Ultils.GetNetworkDateTime().ToString("yyMMddHHmmss") != "" ? Ultils.GetNetworkDateTime().ToString("yyMMddHHmmss") : DateTime.Now.ToString("yyMMddHHmmss"); if (boardNo.Contains("=")) { boardNo = boardNo.Replace("=", "_"); } string setStationNo = gridLookUpEditProcessID.EditValue.ToString(); if (txtBarcode.Text.Length <= 10) { CancelAsyncBackgroundWorker(); MessageHelpers.SetDefaultStatus(true, "N/A", "Waiting...", lblStatus, lblMessage); if (!backgroundWorker1.IsBusy) { backgroundWorker1.RunWorkerAsync(); } } else { _scanningLogs = _scanningLogsService.Get_SCANNING_LOGS(boardNo).FirstOrDefault(); if (_scanningLogs != null) { _inspectionProcesses = _inspectionProcessesService.GET_INSPECTION_PROCESSES_BY_PRODUCT_ID(_scanningLogs.PRODUCT_ID); if (_inspectionProcesses != null) { //trạng thái bản mạch hiện tại _workOrderItems = _workOrderItemService.Get_WORK_ORDER_ITEMS_By_BoardNo(boardNo); if (_workOrderItems != 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 (_workOrderItems.IS_FINISHED) { CancelAsyncBackgroundWorker(); _messageError = $"Board '{boardNo}' is finished!"; MessageHelpers.SetErrorStatus(true, "NG", _messageError, lblStatus, lblMessage); CheckTextBoxNullValue.SetColorErrorTextControl(txtBarcode); Reset(_messageError); } // 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 (_workOrderItems.STATION_NO != setStationNo && _workOrderItems.BOARD_STATE == 2) { CancelAsyncBackgroundWorker(); _messageError = $"Board '{boardNo}' bị 'NG' tại trạm trước đó!"; MessageHelpers.SetErrorStatus(true, "NG", _messageError, lblStatus, lblMessage); CheckTextBoxNullValue.SetColorErrorTextControl(txtBarcode); Reset(_messageError); } // 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 (_workOrderItems.STATION_NO == setStationNo && _workOrderItems.BOARD_STATE == 1) { Excute(boardNo, _scanningLogs.PRODUCT_ID); } else { var processDesigner = _inspectionProcessesDesignersService .GET_INSPECTION_PROCEDURE_DESIGNERS_BY_PROCESS_NO( _inspectionProcesses.PROCESS_NO); // Set station no var processByStationNo = processDesigner.FirstOrDefault(item => item.STATION_NO == setStationNo); // 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 (processByStationNo == null) { CancelAsyncBackgroundWorker(); _messageError = $"Board '{boardNo}' station '{setStationNo}' not invaild!"; MessageHelpers.SetErrorStatus(true, "NG", _messageError, lblStatus, lblMessage); CheckTextBoxNullValue.SetColorErrorTextControl(txtBarcode); Reset(_messageError); } // nếu hợp lệ thực hiện tiếp else { // Khi hai giá trị bằng nhau => ICT_FUJ if (_workOrderItems.PROCEDURE_INDEX < (processByStationNo.INDEX - 1)) { CancelAsyncBackgroundWorker(); _messageError = $"Board '{boardNo}' bỏ qua công đoạn ''!"; MessageHelpers.SetErrorStatus(true, "NG", _messageError, lblStatus, lblMessage); CheckTextBoxNullValue.SetColorErrorTextControl(txtBarcode); Reset(_messageError); } //// Nếu Index Board > Set Index else if (_workOrderItems.PROCEDURE_INDEX > processByStationNo.INDEX) { CancelAsyncBackgroundWorker(); // transferred to the next station. _messageError = $"Board '{boardNo}' transferred to the next station!"; MessageHelpers.SetErrorStatus(true, "NG", _messageError, lblStatus, lblMessage); CheckTextBoxNullValue.SetColorErrorTextControl(txtBarcode); Reset(_messageError); } else if (_workOrderItems.PROCEDURE_INDEX == (processByStationNo.INDEX - 1)) { Excute(boardNo, _scanningLogs.PRODUCT_ID); } else if (_workOrderItems.BOARD_STATE == 2) { Excute(boardNo, _scanningLogs.PRODUCT_ID); } } } } else { CancelAsyncBackgroundWorker(); _messageError = $"Không tìm thấy trạm với tên {setStationNo}!"; MessageHelpers.SetErrorStatus(true, "NG", _messageError, lblStatus, lblMessage); CheckTextBoxNullValue.SetColorErrorTextControl(txtBarcode); Reset(_messageError); } } else { CancelAsyncBackgroundWorker(); _messageError = $"Station No '{setStationNo}' không hợp lệ!"; MessageHelpers.SetErrorStatus(true, "NG", _messageError, lblStatus, lblMessage); CheckTextBoxNullValue.SetColorErrorTextControl(txtBarcode); Reset(_messageError); } } else { CancelAsyncBackgroundWorker(); _messageError = $"Board '{boardNo}' chưa được khởi tạo. Vui lòng kiểm tra lại!"; MessageHelpers.SetErrorStatus(true, "NG", _messageError, lblStatus, lblMessage); CheckTextBoxNullValue.SetColorErrorTextControl(txtBarcode); Reset(_messageError); } if (!backgroundWorker1.IsBusy) { backgroundWorker1.RunWorkerAsync(); } } } }
private void txtBarcode_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) { if (e.KeyCode == Keys.Enter) { lblMarking.Visible = false; string boardNo = txtBarcode.Text; 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); // Lấy toàn bộ thông tin bản mạch hiện tại bắn vào var boards = _scanningLogsService.Get_SCANNING_LOGS(boardNo).FirstOrDefault(); // Nếu đã được khởi tạo trước đó, thì thực hiện các bước kiểm tra tiếp theo if (boards != null) { //Lấy thông tin PROCESS_NO hiện tại theo PRODUCT_ID của board hiện tại var process_No = _inspectionProcessesService.GET_INSPECTION_PROCESSES_BY_PRODUCT_ID(boards.PRODUCT_ID); // Nếu có dữ liệu, thì thực hiện các bước tiếp theo 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(); } // 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.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; Excute(boardNo, boards.PRODUCT_ID); } // Nếu tên trạm hiện tại giống vs tên cài đặt, 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; Excute(boardNo, boards.PRODUCT_ID); } 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(); } // 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}' bỏ qua công đoạn!"; MessageHelpers.SetErrorStatus(true, "NG", messageError, lblStatus, lblMessage); CheckTextBoxNullValue.SetColorErrorTextControl(txtBarcode); var errorForm = new FormError(messageError); errorForm.ShowDialog(); txtBarcode.Focus(); } //// Nếu Index Board > Set Index else if (curentStationNo.PROCEDURE_INDEX > process_by_station_no.INDEX) { Excute(boardNo, boards.PRODUCT_ID); } else if (curentStationNo.PROCEDURE_INDEX == (process_by_station_no.INDEX - 1)) { Excute(boardNo, boards.PRODUCT_ID); } else if (curentStationNo.BOARD_STATE == 2) { Excute(boardNo, boards.PRODUCT_ID); } } } } else { messageError = $"Không tìm thấy trạm nào với tên '{curentStationNo.STATION_NO}'!"; MessageHelpers.SetErrorStatus(true, "NG", messageError, lblStatus, lblMessage); CheckTextBoxNullValue.SetColorErrorTextControl(txtBarcode); var errorForm = new FormError(messageError); errorForm.ShowDialog(); txtBarcode.Focus(); } } // PROCESS_NO = null thì thông báo lỗi else { messageError = $"Không tìm thấy trạm nào với tên '{set_station_no}'!"; MessageHelpers.SetErrorStatus(true, "NG", messageError, lblStatus, lblMessage); CheckTextBoxNullValue.SetColorErrorTextControl(txtBarcode); var errorForm = new FormError(messageError); errorForm.ShowDialog(); txtBarcode.Focus(); } } // Nếu chưa có thì thông báo lỗi cho người dùng else { messageError = $"Board '{boardNo}' chưa được khởi tạo. Vui lòng kiểm tra lại!"; MessageHelpers.SetErrorStatus(true, "NG", messageError, lblStatus, lblMessage); CheckTextBoxNullValue.SetColorErrorTextControl(txtBarcode); var errorForm = new FormError(messageError); errorForm.ShowDialog(); txtBarcode.Focus(); } } } }
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; } } } }