private void BtnOk_Click(object sender, RoutedEventArgs e) { PrinterUtil.SetPrinterName(this.CBPrinters.SelectedItem.ToString()); string sec = TBSecond.Text; int i = 3000; if (int.TryParse(sec, out i) && i > 0) { PrinterUtil.SetPrinterAutoInterVal(i * 1000); } int copy = 1; if (int.TryParse(TBCopy.Text, out copy) && copy > 0) { PrinterUtil.SetPrintCopy(copy); } // PrinterUtil.Save(); ConfigUtil config = new ConfigUtil("STORE", "config.ini"); config.Set("WAREHOUSE", TBWarehouse.Text); config.Set("POSITION", TBPosition.Text); config.Save(); config = new ConfigUtil("DATEFORMAT", "config.ini"); config.Set("DATEFORMAT", TBDateFormat.Text); config.Save(); new InfoBoard(MsgLevel.Successful, "参数设置成功").ShowDialog(); this.Close(); }
private void Window_Loaded(object sender, RoutedEventArgs e) { Hashtable ht = PrinterUtil.GetPrinterConfig(); foreach (string printer in PrinterSettings.InstalledPrinters) { CBPrinters.Items.Add(printer); } CBPrinters.SelectedIndex = 0; for (int i = 0; i < CBPrinters.Items.Count; i++) { if (CBPrinters.Items[i].Equals(ht["PrinterName"].ToString())) { CBPrinters.SelectedIndex = i; break; } } this.TBSecond.Text = (int.Parse(ht["AutoClose"].ToString()) / 1000).ToString(); this.TBCopy.Text = ht["Copy"].ToString(); ConfigUtil config = new ConfigUtil("STORE", "config.ini"); TBWarehouse.Text = config.Get("WAREHOUSE"); TBPosition.Text = config.Get("POSITION"); config = new ConfigUtil("DATEFORMAT", "config.ini"); TBDateFormat.Text = config.Get("DATEFORMAT"); }
private async void BtnPrnt_Click(object sender, RoutedEventArgs e) { protoWeightLabel = await ApplicationData.Current.LocalFolder.GetFileAsync(@"Labels\Supplier.x"); //edit label with real dat if (txtBoxLot.Text == string.Empty || txtBoxLot.Text == null) { App.PrintOkMessage(ResourceLoader.GetForViewIndependentUse("Resources").GetString("msgLot"), ResourceLoader.GetForViewIndependentUse("Resources").GetString("titleLabelError")); return; } if (protoWeightLabel != null) { //fill the data IBuffer bf = await FileIO.ReadBufferAsync(protoWeightLabel); DataReader reader = DataReader.FromBuffer(bf); byte[] fileContent = new byte[reader.UnconsumedBufferLength]; reader.ReadBytes(fileContent); string protoVal = encoding.GetString(fileContent, 0, fileContent.Length); string newVal = protoVal.Replace("supplierdescr", SelectedSupplier.SupplierDescr); newVal = newVal.Replace("grsupplier", SelectedSupplier.GrSupplier); newVal = newVal.Replace("lot", txtBoxLot.Text); newVal = newVal.Replace("datereceipt", DateTime.Now.ToString("dd-MM-yyyy")); newVal = newVal.Replace("nums", printsSpinner.TextValueProperty.ToString()); dataWeightLabel = await ApplicationData.Current.LocalFolder.CreateFileAsync("Data" + protoWeightLabel.Name, CreationCollisionOption.ReplaceExisting); File.WriteAllText(dataWeightLabel.Path, newVal, encoding); } PrinterUtil.SendToPrinterFile(dataWeightLabel); }
public static Message PrintTrayLabel(string trayId) { Message msg = new Message(); PrintService printService = new PrintService(); PrintDataMessage pmsg = printService.GenSingleTrayLabel(trayId , new ConfigUtil("DATEFORMAT", "config.ini").Get("DATEFORMAT") , new ConfigUtil("KEEPER", "config.ini").Get("KEEPER").Split(',')); if (pmsg.ReturnedResult) { Hashtable printConfig = PrinterUtil.GetPrinterConfig();; ProcessMsg prmsg = printService.Print(printConfig, pmsg); msg.Result = prmsg.result; msg.Content = prmsg.GetAllLevelMsgs(); } else { msg.Result = pmsg.ReturnedResult; msg.Content = pmsg.GetMsgText(); } return(msg); }
private async void BtnPrnt_Click(object sender, RoutedEventArgs e) { protoWeightLabel = await ApplicationData.Current.LocalFolder.GetFileAsync(@"Labels\Customer.x"); //edit label with real data if (protoWeightLabel != null) { //fill the data IBuffer bf = await FileIO.ReadBufferAsync(protoWeightLabel); DataReader reader = DataReader.FromBuffer(bf); byte[] fileContent = new byte[reader.UnconsumedBufferLength]; reader.ReadBytes(fileContent); string protoVal = App.encoding.GetString(fileContent, 0, fileContent.Length); string newVal = protoVal.Replace("customerdescr", SelectedCustomer.CustomerDescr); newVal = newVal.Replace("nums", printsSpinner.TextValueProperty.ToString()); dataWeightLabel = await ApplicationData.Current.LocalFolder.CreateFileAsync("Data" + protoWeightLabel.Name, CreationCollisionOption.ReplaceExisting); File.WriteAllText(dataWeightLabel.Path, newVal, App.encoding); } PrinterUtil.SendToPrinterFile(dataWeightLabel); }
private async void BtnPrnt_Click(object sender, RoutedEventArgs e) { //edit label with real data if (SelectedSupplier.Code == "000" && (SelectedMaterial.Type == PackagedMaterialItem.MaterialType.BIO || SelectedMaterial.Type == PackagedMaterialItem.MaterialType.SEMIBIO)) { App.PrintOkMessage(ResourceLoader.GetForViewIndependentUse("Resources").GetString("msgGrSupplier"), ResourceLoader.GetForViewIndependentUse("Resources").GetString("titleLabelError")); return; } if (String.IsNullOrEmpty(CBoxLotNums.Text) || String.IsNullOrEmpty(SelectedLot.Code)) { App.PrintOkMessage(ResourceLoader.GetForViewIndependentUse("Resources").GetString("msgLot"), ResourceLoader.GetForViewIndependentUse("Resources").GetString("titleLabelError")); return; } //Check printer settings if (AppSettings.SumPrints > 1 || AppSettings.PalletsNum > 1) { step++; sum += Double.Parse(txtNetW.Text.Remove(txtNetW.Text.Length - 3, 3)); txtSum.Text = ResourceLoader.GetForCurrentView().GetString("lblPallet") + pallet.ToString() + " - " + ResourceLoader.GetForCurrentView().GetString("Step") + step.ToString() + "/" + AppSettings.SumPrints + " - " + ResourceLoader.GetForCurrentView().GetString("lblTotal") + sum.ToString() + AppSettings.TrailingUnit; } if (currentLabel != null) { //copy label file to public folder for editing rights //await protoWeightLabel.CopyAsync(ApplicationData.Current.LocalFolder, "WeightData.x",NameCollisionOption.ReplaceExisting); //fill the data IBuffer bf = await FileIO.ReadBufferAsync(currentLabel); DataReader reader = DataReader.FromBuffer(bf); byte[] fileContent = new byte[reader.UnconsumedBufferLength]; reader.ReadBytes(fileContent); string protoVal = App.encoding.GetString(fileContent, 0, fileContent.Length); string newVal = protoVal.Replace("materialdescr", SelectedMaterial.MaterialReadableDescr); newVal = newVal.Replace("country", SelectedMaterial.Country); newVal = newVal.Replace("region", SelectedMaterial.Region); newVal = newVal.Replace("grsupplier", SelectedSupplier.GrSupplier + SelectedMaterial.GRmaterial); newVal = newVal.Replace("category", SelectedMaterial.Category); newVal = newVal.Replace("variety", SelectedMaterial.Variety); newVal = newVal.Replace("datereceipt", DateTime.Now.ToString("dd-MM-yyyy")); if (Decimal.Parse(txtNetW.Text.Substring(0, txtNetW.Text.Length - 3)) > 0) { newVal = newVal.Replace("descrweightval", "Καθαρό Βάρος:"); newVal = newVal.Replace("weightval", txtNetW.Text); } else { newVal = newVal.Replace("descrweightval", " "); newVal = newVal.Replace("weightval", " "); } newVal = newVal.Replace("lot", SelectedLot.Code); newVal = newVal.Replace("nums", printsSpinner.TextValueProperty.ToString()); dataLabel = await ApplicationData.Current.LocalFolder.CreateFileAsync("Data" + currentLabel.Name, CreationCollisionOption.ReplaceExisting); File.WriteAllText(dataLabel.Path, newVal, App.encoding); //StorageFolder publicFolder = ApplicationData.Current.LocalFolder; //dataLabelFile = await publicFolder.GetFileAsync("WeightData.x"); } PrinterUtil.SendToPrinterFile(dataLabel); if (step == AppSettings.SumPrints) { await Task.Delay(TimeSpan.FromSeconds(2)); //Thread.Sleep(2000); if ((pallet + 1) == AppSettings.PalletsNum) { //print last pallet sum PrinterUtil.SendTestToPrinter(sum.ToString() + AppSettings.TrailingUnit, AppSettings.CopiesPrints.ToString()); AppSettings.CopiesPrints = 1; AppSettings.SumPrints = 1; AppSettings.PalletsNum = 1; txtSum.Text = String.Empty; } else { PrinterUtil.SendTestToPrinter(sum.ToString() + AppSettings.TrailingUnit, AppSettings.CopiesPrints.ToString()); pallet++; step = 0; sum = 0; txtSum.Text = ResourceLoader.GetForCurrentView().GetString("lblPallet") + pallet.ToString() + " - " + ResourceLoader.GetForCurrentView().GetString("Step") + step.ToString() + "/" + AppSettings.SumPrints + " - " + ResourceLoader.GetForCurrentView().GetString("lblTotal") + sum.ToString() + AppSettings.TrailingUnit; } } }
private void BtnPrnt_Click(object sender, RoutedEventArgs e) { PrinterUtil.SendTestToPrinter(txtBoxTestText.Text, copiesSpinner.TextValueProperty.ToString()); }