private void serialPortReceive_DataReceived(object sender, SerialDataReceivedEventArgs e) { Thread.Sleep(100); if (serialPortReceive.IsOpen == true) { string dataReceived = ElectricScaleProfileHelper.ConvertWeight(serialPortReceive.ReadExisting(), electricScaleProfile); if (string.IsNullOrEmpty(dataReceived) == false) { double actualWeight = 0; if (double.TryParse(dataReceived, out actualWeight) == false) { //Alert Here. } if (actualWeight > 0) { Dispatcher.Invoke(new Action(() => { txtNewWeight.Text = string.Format("{0}", actualWeight); txtNewWeight.Tag = actualWeight; btnWeight.IsEnabled = true; stkConfirm.Visibility = Visibility.Visible; })); serialPortReceive.Close(); } } } }
private void Window_Loaded(object sender, RoutedEventArgs e) { int profileId = 0; int.TryParse(AppSettingsHelper.ReadSetting("ElectricScaleProfile"), out profileId); electricScaleProfile = ElectricScaleProfileHelper.ElectricScaleProfileList().Where(p => p.ProfileId == profileId).FirstOrDefault(); if (electricScaleProfile == null) { this.Close(); } serialPortReceive = new SerialPort(); serialPortReceive.BaudRate = electricScaleProfile.BaudRate; serialPortReceive.DataReceived += new SerialDataReceivedEventHandler(serialPortReceive_DataReceived); portReceive = AppSettingsHelper.ReadSetting("ReceivePort"); string[] portList = SerialPort.GetPortNames(); if (portList.Count() > 0) { if (string.IsNullOrEmpty(portReceive) == true || portList.Contains(portReceive) == false) { portReceive = portList[0]; } serialPortReceive.PortName = portReceive; } txtBarcode.Focus(); }
private void serialPortReceive_DataReceived(object sender, SerialDataReceivedEventArgs e) { Thread.Sleep(100); if (serialPortReceive.IsOpen == true) { string dataReceived = ElectricScaleProfileHelper.ConvertWeight(serialPortReceive.ReadExisting(), electricScaleProfile); if (string.IsNullOrEmpty(dataReceived) == false) { double actualWeight = 0; if (double.TryParse(dataReceived, out actualWeight) == false) { } if (minActualWeight < actualWeight && actualWeight < maxActualWeight) { Dispatcher.Invoke(new Action(() => { tblActualWeight.Text = string.Format("{0}", actualWeight); tblActualWeight.Tag = actualWeight; })); serialPortReceive.Close(); CompareWeight(); } } } }
private void Window_Loaded(object sender, RoutedEventArgs e) { imgBackground.Visibility = Visibility.Collapsed; gridLogin.Visibility = Visibility.Visible; if (bwLoad.IsBusy == true) { return; } txtUserName.Focus(); this.Cursor = Cursors.Wait; bwLoad.RunWorkerAsync(); int profileId = 0; int.TryParse(AppSettingsHelper.ReadSetting("ElectricScaleProfile"), out profileId); if (String.IsNullOrEmpty(AppSettingsHelper.ReadSetting("Factory").ToUpper()) == false) { factory = AppSettingsHelper.ReadSetting("Factory").ToUpper(); } this.Title = String.Format("{0} - Storing System", factory); electricScaleProfile = ElectricScaleProfileHelper.ElectricScaleProfileList().Where(p => p.ProfileId == profileId).FirstOrDefault(); if (electricScaleProfile == null) { this.Close(); } }
private void serialPortReceive_DataReceived(object sender, SerialDataReceivedEventArgs e) { Thread.Sleep(100); if (serialPortReceive.IsOpen == true) { string dataReceived = ElectricScaleProfileHelper.ConvertWeight(serialPortReceive.ReadExisting(), electricScaleProfile); if (string.IsNullOrEmpty(dataReceived) == false) { double actualWeight = 0; if (double.TryParse(dataReceived, out actualWeight) == false) { } if (minActualWeight < actualWeight && actualWeight < maxActualWeight) { Dispatcher.Invoke(new Action(() => { tblActualWeight.Text = string.Format("{0}", actualWeight); tblActualWeight.Tag = actualWeight; if (insertFirstCarton_Size_PO == true) { InsertCarton(); insertFirstCarton_Size_PO = false; DefaultStatus(); } if (insertIncompleteCarton == true) { InsertCarton(); insertIncompleteCarton = false; IncompleteStatus(); } if (compareCartonSameSize == true) { CompareWeight(); compareCartonSameSize = false; DefaultStatus(); } })); serialPortReceive.Close(); } } } }
private void Window_Loaded(object sender, RoutedEventArgs e) { int profileId = 0; int.TryParse(AppSettingsHelper.ReadSetting("ElectricScaleProfile"), out profileId); electricScaleProfile = ElectricScaleProfileHelper.ElectricScaleProfileList().Where(p => p.ProfileId == profileId).FirstOrDefault(); //gridIssues.Children.Clear(); issuesList = IssuesController.Select(); txtSecurityCode.Focus(); if (receiveOutputModel != null) { this.Title = "Storing System - OUTPUT Report"; } if (receiveStoringModel != null) { if (issuesType == IssuesType.Issues.IssuesCompareWeight) { this.Title = "Storing System - INPUT Report - Weight Problem"; } if (issuesType == IssuesType.Issues.IssuesFirstCartonOfSizeOfPO) { this.Title = "Storing System - INPUT Report - First Carton Problem"; } } StackPanel stack = new StackPanel(); stack.Orientation = Orientation.Vertical; for (int i = 0; i < issuesList.Count; i++) { RadioButton rad = new RadioButton(); rad.Margin = new Thickness(0, 15, 0, 0); rad.GroupName = "Issues"; rad.Tag = i + 1; rad.Content = issuesList[i].IssuesName.ToString(); rad.Foreground = Brushes.Red; rad.Click += new RoutedEventHandler(rad_Click); stack.Children.Add(rad); } gridIssues.Children.Add(stack); }
private void bwReport_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (e.Error != null) { return; } this.Cursor = null; btnReport.IsEnabled = true; DataTable dtStoring = new StoringDataSet().Tables["StoringTable"]; if (output == false) { foreach (var storing in storingPerPOList) { DataRow dr = dtStoring.NewRow(); dr["ProductNo"] = storing.ProductNo; dr["CartonNo"] = storing.CartonNo; dr["Barcode"] = storing.Barcode; dr["SizeNo"] = storing.SizeNo; if (storing.GrossWeight > 0) { dr["GrossWeight"] = storing.GrossWeight; } if (storing.ActualWeight > 0) { dr["ActualWeight"] = storing.ActualWeight; } if (storing.DifferencePercent != 0) { dr["DifferencePercent"] = storing.DifferencePercent; } dr["IsPass"] = storing.IsPass; dr["InputtedTime"] = String.Format("{0:yyyy/MM/dd HH:mm:ss}", storing.CreatedTime); string locationString = ""; var account = accountList.Where(w => w.UserName == storing.WorkerId).FirstOrDefault(); if (account != null) { var location = ElectricScaleProfileHelper.ElectricScaleProfileList().Where(w => w.ProfileId == account.ElectricScaleId).FirstOrDefault(); locationString = location != null ? location.Location : ""; } dr["Location"] = locationString; dtStoring.Rows.Add(dr); } } if (output == true) { foreach (var outputing in outputingPerPOList) { DataRow dr = dtStoring.NewRow(); dr["ProductNo"] = outputing.ProductNo; dr["CartonNo"] = outputing.CartonNo; dr["Barcode"] = outputing.Barcode; dr["SizeNo"] = outputing.SizeNo; if (outputing.GrossWeight > 0) { dr["GrossWeight"] = outputing.GrossWeight; } if (outputing.ActualWeight > 0) { dr["ActualWeight"] = outputing.ActualWeight; } if (outputing.DifferencePercent != 0) { dr["DifferencePercent"] = outputing.DifferencePercent; } dr["IsPass"] = outputing.IsPass; dr["InputtedTime"] = String.Format("{0:yyyy/MM/dd HH:mm:ss}", outputing.CreatedTime); string locationString = ""; var account = accountList.Where(w => w.UserName == outputing.WorkerId).FirstOrDefault(); if (account != null) { var location = ElectricScaleProfileHelper.ElectricScaleProfileList().Where(w => w.ProfileId == account.ElectricScaleId).FirstOrDefault(); locationString = location != null ? location.Location : ""; } dr["Location"] = locationString; dtStoring.Rows.Add(dr); } } dgDetailReport.ItemsSource = dtStoring.AsDataView(); output = false; }