private void skuOptionInputBox_KeyDown(object sender, KeyEventArgs e) { skuOpButtonClicked = false; if (e.KeyCode == Keys.Enter) { skuOpButtonClicked = true; if (skuOptionInputBox.Text.Trim().ToUpper() == "VALIDATE") { string s = skuDataGridView.Rows[0].Cells[0].Value != null ? skuDataGridView.Rows[0].Cells[0].Value.ToString() : null; Console.WriteLine(s); if (s != null) { skuString = s; bool isValid = true; StringBuilder falseString = new StringBuilder(); if (skuString.Contains("(")) { int length = s.IndexOf(")") - s.IndexOf("(") - 1; string[] halfString = s.Split('('); string[] splitHalfString = halfString[0].Split(' '); s = s.Substring(s.IndexOf("(") + 1, length); carrierString = s; foreach (string st in splitHalfString) { if (st.Length != 0) { if (!deviceSpecsBox.Text.ToUpper().Contains(st.ToUpper().Trim())) { isValid = false; falseString.AppendLine(st); } } } } else { string[] splitSkuString = s.Split(' '); foreach (string st in splitSkuString) { if (st.Length != 0) { if (!deviceSpecsBox.Text.ToUpper().Contains(st.ToUpper().Trim())) { isValid = false; falseString.AppendLine(st); } } } } if (skuString.Contains("-")) { for (int i = 0; i < skuString.Count(c => c == '-'); i++) { skuString = skuString.Replace('-', ' '); } } if (carrierString != null) { if (carrierString.Contains("-")) { for (int i = 0; i < carrierString.Count(c => c == '-'); i++) { carrierString = carrierString.Replace('-', ' '); } } } if (!isValid) { if (MessageBox.Show($"Specs Don't Match\n\n{falseString}\nContinue?", "Warning", MessageBoxButtons.YesNo) == DialogResult.Yes) { LocationPrompt locs = new LocationPrompt(); locationString = locs.location; caseIDString = locs.theCase; if (locationString != null && caseIDString != null) { this.Close(); } else { skuOptionInputBox.Clear(); skuOptionInputBox.Enabled = false; skuPromptInputBox.Focus(); skuPromptInputBox.SelectAll(); skuOpButtonClicked = false; } } else { skuOptionInputBox.Clear(); skuOptionInputBox.Enabled = false; skuPromptInputBox.Focus(); skuPromptInputBox.SelectAll(); skuOpButtonClicked = false; } } else { LocationPrompt locs = new LocationPrompt(); StringBuilder builder = new StringBuilder(); builder.AppendLine(deviceSpecsBox.Lines[1]); builder.AppendLine(skuPromptInputBox.Text); builder.AppendLine(locs.location); Console.WriteLine(builder.ToString()); QRCodeGenerator generator = new QRCodeGenerator(); QRCodeData data = generator.CreateQrCode(builder.ToString(), QRCodeGenerator.ECCLevel.L); QRCode code = new QRCode(data); locationString = locs.location; caseIDString = locs.theCase; this.Close(); //CheckInPrompt cp = new CheckInPrompt(); //cp.Initialize(code); } } } else if (skuOptionInputBox.Text.Trim().ToUpper() == "CLEAR") { skuPromptInputBox.Clear(); skuPromptInputBox.Focus(); skuOptionInputBox.Clear(); skuOptionInputBox.Enabled = false; } } }
private async void printButton_Clicked(object sender, EventArgs e) { List <LabelObject> labels = new List <LabelObject>(); List <DeviceObject> devices = new List <DeviceObject>(); try { foreach (DataGridViewRow v in deviceList.SelectedRows) { StringBuilder builder = new StringBuilder(); LabelObject label = new LabelObject(); Task <DeviceObject> t1 = Task.Run(() => RunDataGridView(v)); await t1; Console.WriteLine("THIS IS VALIUE: " + v.Cells[0].Value); label.title = v.Cells[0].Value == null ? " " : v.Cells[0].Value.ToString(); builder.AppendLine(v.Cells[1].Value == null ? " " : v.Cells[1].Value.ToString()); builder.AppendLine(v.Cells[2].Value == null ? " " : v.Cells[2].Value.ToString()); builder.AppendLine(v.Cells[3].Value == null ? " " : v.Cells[3].Value.ToString()); builder.AppendLine(v.Cells[4].Value == null ? " " : v.Cells[4].Value.ToString()); builder.AppendLine(v.Cells[6].Value == null ? " " : v.Cells[6].Value.ToString()); label.content = builder.ToString(); label.qrCodeLocation = "code.png"; label.uuid = v.Cells[1].Value == null ? " " : v.Cells[1].Value.ToString(); labels.Add(label); if (!skuCheckBox.Checked) { LocationPrompt locs = new LocationPrompt(); DeviceObject device = new DeviceObject(); device.serialID = v.Cells[1].Value == null ? " " : v.Cells[1].Value.ToString(); device.location = locs.location; device.caseID = locs.theCase; devices.Add(device); } else { if (t1.Result != null) { devices.Add(t1.Result); } } } if (devices.Count != 0) { Console.WriteLine(labels.Count); await ProcessLabels(labels, @"C:\Users\Vince\Documents\QrCodeLabelTemp2.dotx", true); CheckInDevices(devices); } } catch (Exception ex) { Trace.WriteLine(ex.ToString()); } }