public int UpdateMasterLabel(MasterLabelSettingModel model) { try { MasterLabelSetting masterLabelSetting = new MasterLabelSetting(model.Id, model.LabelSettingCode, model.PrintItemCode, model.PrintItemDetail, model.PrintUnitMeasure, model.PrintItemPrice, model.PrintBarCode, model.BarCodeHeight, model.LabelSheet, model.StartRow, model.StartColumn); return(_labelSettingRepository.UpdateMasterLabel(masterLabelSetting)); } catch (Exception ex) { fault.Result = false; fault.ErrorMessage = "Error in UpdateMasterLabel method"; fault.ErrorDetails = ex.ToString(); throw new FaultException <FaultData>(fault); } }
public int SaveUpdateMasterLabel(MasterLabelSettingModel model) { try { return(objProductService.ProductServiceInstance().UpdateMasterLabel(model)); } catch (Exception ex) { throw ex; } finally { objProductService.ProductServiceInstanceClosed(); } }
public MasterLabelSetting() { InitializeComponent(); btn_remove.IsEnabled = false; btn_remove.Background = Brushes.Gray; ResponseVm responce = productController.GetProductsByCompanyAndBranch(); _masterLabel = productController.GetMasaterLabelSetting(); BindPrinters(); GridLengthConverter gridLengthConverter = new GridLengthConverter(); if (responce.FaultData == null) { _products = responce.Response.Cast <ProductModel>().ToList(); dgPurchases.ItemsSource = _products; dgPurchases.Visibility = Visibility.Visible; } if (_masterLabel != null) { List <ProductLabelSettingModel> productLabel = productController.GetProductLabelSettings(_masterLabel.Id.Value); _productLabelSetting = productLabel?.Select(x => new ProductLabelSettingModel(x.Id, x.MasterLabelCode, x.ProductCode, x.Quantity, _products.Any(j => j.Id == x.ProductCode) == true ? _products.Where(z => z.Id == x.ProductCode).FirstOrDefault().ItemName : string.Empty)).ToList(); purchaseStocks = new ObservableCollection <ProductLabelSettingModel>(_productLabelSetting); print_item_code.IsChecked = _masterLabel.PrintItemCode ? true : false; print_item_price.IsChecked = _masterLabel.PrintItemPrice ? true : false; chk_print_barcode.IsChecked = _masterLabel.PrintBarCode ? true : false; chk_item_detail.IsChecked = _masterLabel.PrintItemDetail ? true : false; if (_masterLabel.BarCodeHeight != "") { //bar_code_height.SelectedItem = (Common.barcodeHeight)Enum.Parse(typeof(Common.barcodeHeight), _masterLabel.BarCodeHeight); //;Enum.GetValues(typeof(CommonFunction.Common.barcodeHeight)); } } if (purchaseStocks == null) { additems(); } lstPurchase.ItemsSource = purchaseStocks; }
private void btn_Save_Click(object sender, RoutedEventArgs e) { productController.DeleteMasterLabelSetting(); productController.DeleteProductLabelSetting(); MasterLabelSettingModel model = new MasterLabelSettingModel(0, 0, print_item_code.IsChecked.Value, chk_item_detail.IsChecked.Value, "0", print_item_price.IsChecked.Value, chk_print_barcode.IsChecked.Value, "", "", string.Empty, "", ""); //MasterLabelSettingModel model = new MasterLabelSettingModel(0, 0, print_item_code.IsChecked.Value, chk_item_detail.IsChecked.Value, "0", print_item_price.IsChecked.Value, chk_print_barcode.IsChecked.Value, bar_code_height.Text, label_sheet_dd.SelectedValue.ToString(), string.Empty, nud_start_row.Value.ToString(), nud_start_column.Value.ToString()); int masterLabelId = productController.SaveUpdateMasterLabel(model); List <ProductLabelSettingModel> newStocks = new List <ProductLabelSettingModel>(); List <ProductLabelSettingModel> Stocks = lstPurchase.Items.Cast <ProductLabelSettingModel>().Select(x => x).ToList(); if (Stocks.Any(x => x.ProductCode > 0 && x.Quantity > 0)) { // stocks = lstPurchase.ItemsSource.Cast<StockModel>().ToList(); newStocks.AddRange(Stocks.Where(z => z.ProductCode > 0 && z.Quantity > 0).Select(x => { return(new ProductLabelSettingModel(0, masterLabelId, Convert.ToInt32(x.ProductCode), x.Quantity, x.ProductName)); // newStocks.Add(stock); }).ToList()); } productController.SaveProductLabel(newStocks); //inventory product = new inventory(); // NavigationService.Navigate(product); }
public MasterPrintInvoice(MasterLabelSettingModel row, List <ProductLabelSettingModel> productlabel) { InitializeComponent(); List <PrintMasterSettingModel> models = new List <PrintMasterSettingModel>(); ResponseVm responce = productController.GetProductsByCompanyAndBranch(); _products = responce.Response.Cast <ProductModel>().ToList(); //for (var i = 0; i <= Convert.ToInt32(row.StartRow); i++) //{ //if (i == Convert.ToInt32(row.StartRow)) //{ //for (var k = 0; k <= Convert.ToInt32(row.StartColumn); k++) //{ //if (k == Convert.ToInt32(row.StartColumn)) //{ foreach (var data in productlabel) { var product = _products?.FirstOrDefault(x => x.Id == data.ProductCode); for (var j = 1; j <= data.Quantity; j++) { PrintMasterSettingModel model = new PrintMasterSettingModel(); if (row.PrintBarCode) { model.Barcode = product.BarCode; } else { model.Barcode = string.Empty; } if (row.PrintItemCode) { model.ProductCode = Convert.ToString(product.Id); } else { model.ProductCode = string.Empty; } if (row.PrintItemDetail) { model.ProductName = product.ItemName; } else { model.ProductName = string.Empty; } if (row.PrintItemPrice) { model.Price = Convert.ToString(product.RetailPrice); } else { model.Price = string.Empty; } var content = model.Barcode; var writer = new BarcodeWriter { Format = BarcodeFormat.CODE_128 }; var bitmap = writer.Write(content); bitmap.SetResolution(100, 150); //Linear barcode = new Linear(); //barcode.Type = BarcodeType.CODE128; //barcode.Data = model.Barcode; //barcode.drawBarcodeAsBytes(); //Utility.CommonMethods.CommonFunctions.ByteToImage(barcode.drawBarcodeAsBytes()); model.ImageData = Common.ToBitmapImage(bitmap); model.Barcode = string.Empty; models.Add(model); } } TvBox.ItemsSource = models; }
//private void dgPurchase_PreviewMouseDoubleClick(object sender, MouseButtonEventArgs e) //{ // item = (sender as ListViewItem); // // btn_remove.IsEnabled = true; // // btn_remove.Background = (Brush)color.ConvertFrom("#eb5151"); //} //public static FixedDocument GetFixedDocument(FrameworkElement toPrint, PrintDialog printDialog) //{ // PrintCapabilities capabilities = printDialog.PrintQueue.GetPrintCapabilities(printDialog.PrintTicket); // Size pageSize = new Size(printDialog.PrintableAreaWidth, printDialog.PrintableAreaHeight); // Size visibleSize = new Size(capabilities.PageImageableArea.ExtentWidth, capabilities.PageImageableArea.ExtentHeight); // FixedDocument fixedDoc = new FixedDocument(); // //If the toPrint visual is not displayed on screen we neeed to measure and arrange it // toPrint.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); // toPrint.Arrange(new Rect(new Point(0, 0), toPrint.DesiredSize)); // // // Size size = toPrint.DesiredSize; // //Will assume for simplicity the control fits horizontally on the page // double yOffset = 0; // while (yOffset < size.Height) // { // VisualBrush vb = new VisualBrush(toPrint); // vb.Stretch = Stretch.None; // vb.AlignmentX = AlignmentX.Left; // vb.AlignmentY = AlignmentY.Top; // vb.ViewboxUnits = BrushMappingMode.Absolute; // vb.TileMode = TileMode.None; // vb.Viewbox = new Rect(0, yOffset, visibleSize.Width, visibleSize.Height); // PageContent pageContent = new PageContent(); // FixedPage page = new FixedPage(); // ((IAddChild)pageContent).AddChild(page); // fixedDoc.Pages.Add(pageContent); // page.Width = pageSize.Width; // page.Height = pageSize.Height; // Canvas canvas = new Canvas(); // FixedPage.SetLeft(canvas, capabilities.PageImageableArea.OriginWidth); // FixedPage.SetTop(canvas, capabilities.PageImageableArea.OriginHeight); // canvas.Width = visibleSize.Width; // canvas.Height = visibleSize.Height; // canvas.Background = vb; // page.Children.Add(canvas); // yOffset += visibleSize.Height; // } // return fixedDoc; //} private void btnPrint_Click(object sender, RoutedEventArgs e) { if (cmbPrinters.SelectedIndex != 0) { MasterLabelSettingModel model = new MasterLabelSettingModel(0, 0, print_item_code.IsChecked.Value, chk_item_detail.IsChecked.Value, "0", print_item_price.IsChecked.Value, chk_print_barcode.IsChecked.Value, "", "", string.Empty, "", ""); //MasterLabelSettingModel model = new MasterLabelSettingModel(0, 0, print_item_code.IsChecked.Value, chk_item_detail.IsChecked.Value, "0", print_item_price.IsChecked.Value, chk_print_barcode.IsChecked.Value, bar_code_height.Text, label_sheet_dd.SelectedValue.ToString(), string.Empty, nud_start_row.Value.ToString(), nud_start_column.Value.ToString()); // int masterLabelId = controller.SaveUpdateMasterLabel(model); List <ProductLabelSettingModel> newStocks = new List <ProductLabelSettingModel>(); List <ProductLabelSettingModel> Stocks = lstPurchase.Items.Cast <ProductLabelSettingModel>().Select(x => x).ToList(); if (Stocks.Any(x => x.ProductCode > 0 && x.Quantity > 0)) { // stocks = lstPurchase.ItemsSource.Cast<StockModel>().ToList(); newStocks.AddRange(Stocks.Where(z => z.ProductCode > 0 && z.Quantity > 0).Select(x => { return(new ProductLabelSettingModel(0, 0, Convert.ToInt32(x.ProductCode), x.Quantity, x.ProductName)); // newStocks.Add(stock); }).ToList()); } MasterPrintInvoice form = new MasterPrintInvoice(model, newStocks); PrintDialog printDlg = new PrintDialog(); //PageMediaSizeName pazesize = (PageMediaSizeName)Enum.Parse(typeof(PageMediaSizeName), CommonConstants._pazeSize + model.LabelSheet); //printDlg.PrintTicket.PageMediaSize = new PageMediaSize(pazesize); PageSettings obj = GetPrinterPageInfo(this.cmbPrinters.Text); #region CommentedCode /// System.Windows.Forms.PrintPreviewDialog printPreviewDialog1 = new System.Windows.Forms.PrintPreviewDialog(); // if (printDlg.ShowDialog() == true) // { //PrintCapabilities capabilities = printDlg.PrintQueue.GetPrintCapabilities(printDlg.PrintTicket); //Size pageSize = new Size(printDlg.PrintableAreaWidth, printDlg.PrintableAreaHeight); //Size visibleSize = new Size(capabilities.PageImageableArea.ExtentWidth, capabilities.PageImageableArea.ExtentHeight); // FixedDocument fixedDoc = new FixedDocument(); ////If the toPrint visual is not displayed on screen we neeed to measure and arrange it //form.TvBox.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); //form.TvBox.Arrange(new Rect(new Point(0, 0), form.TvBox.DesiredSize)); //// //Size size = form.TvBox.DesiredSize; ////Will assume for simplicity the control fits horizontally on the page //double yOffset = 0; //while (yOffset < size.Height) //{ // VisualBrush vb = new VisualBrush(form.TvBox); // vb.Stretch = Stretch.None; // vb.AlignmentX = AlignmentX.Left; // vb.AlignmentY = AlignmentY.Top; // vb.ViewboxUnits = BrushMappingMode.Absolute; // vb.TileMode = TileMode.None; // vb.Viewbox = new Rect(0, yOffset, visibleSize.Width, visibleSize.Height); // PageContent pageContent = new PageContent(); // FixedPage page = new FixedPage(); // ((IAddChild)pageContent).AddChild(page); // fixedDoc.Pages.Add(pageContent); // form.TvBox.Width = printDlg.PrintableAreaWidth; //pageSize.Width; // form.TvBox.Height = pageSize.Height; // Canvas canvas = new Canvas(); // FixedPage.SetLeft(canvas, capabilities.PageImageableArea.OriginWidth); // FixedPage.SetTop(canvas, capabilities.PageImageableArea.OriginHeight); // canvas.Width = visibleSize.Width; // canvas.Height = visibleSize.Height; // canvas.Background = vb; // canvas.Margin = new Thickness(2, 2, 2, 2); // page.Children.Add(canvas); // yOffset += visibleSize.Height; //} //; // return fixedDoc; // form.TvBox.MaxWidth = pageSize.Width; #endregion #region EarlierCode //// get selected printer capabilities //System.Printing.PrintCapabilities capabilities = printDlg.PrintQueue.GetPrintCapabilities(printDlg.PrintTicket); ////get scale of the print wrt to screen of WPF visual //double scale = Math.Min(capabilities.PageImageableArea.ExtentWidth / this.ActualWidth, capabilities.PageImageableArea.ExtentHeight / // this.ActualHeight); //// //Transform the Visual to scale //form.TvBox.LayoutTransform = new ScaleTransform(scale, scale); //form.TvBox.Margin = new Thickness(5, 5, 5, 5); //form.Height = 1150; //// //get the size of the printer page //Size sz = new Size(capabilities.PageImageableArea.ExtentWidth, capabilities.PageImageableArea.ExtentHeight); //// //update the layout of the visual to the printer page size. //form.TvBox.Height = capabilities.PageImageableArea.ExtentHeight; //form.TvBox.Width = capabilities.PageImageableArea.ExtentWidth; //form.TvBox.Measure(sz); ////// form.Width = 850; //form.Arrange(new Rect(new Point(capabilities.PageImageableArea.OriginWidth, capabilities.PageImageableArea.OriginHeight), sz)); //// now print the visual to printer to fit on the one page. //for (var i = 0; i <= Convert.ToInt32(model.StartRow); i++) //{ // if (i == Convert.ToInt32(model.StartRow)) // { // printDlg.PrintVisual(form.TvBox, "First Fit to Page WPF Print"); // } //} // printDlg.PrintDocument(fixedDoc.DocumentPaginator, "My Document"); #endregion //PrintDialog pd = new PrintDialog(); //pd.PrintQueue = new PrintQueue(new PrintServer(), cmbPrinters.Text); //if (DialogResult.OK == pd.ShowDialog(this)) //{ // // Send a printer-specific to the printer. // RawPrinterHelper.SendStringToPrinter(cmbPrinters.Text, "Check"); //} //GenerateThermalLabelWorker(form); form.TvBox.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); form.TvBox.Arrange(new Rect(new Point(0, 0), form.TvBox.DesiredSize)); PrintDialog dialog = new PrintDialog(); StackPanel myPanel = new StackPanel(); myPanel.RenderSize = form.TvBox.DesiredSize; foreach (PrintMasterSettingModel item in form.TvBox.Items) { TextBlock myBlock = new TextBlock(); myBlock.Text = "Item :" + item.ProductName; myBlock.TextAlignment = System.Windows.TextAlignment.Center; myPanel.Children.Add(myBlock); Image myImage = new Image(); myImage.Width = item.ImageData.Width; myImage.Height = item.ImageData.Height; myImage.Stretch = Stretch.None; myImage.Source = item.ImageData; myPanel.Children.Add(myImage); TextBlock myBlock1 = new TextBlock(); myBlock1.Text = "Price :" + item.Price; myBlock1.TextAlignment = System.Windows.TextAlignment.Center; myPanel.Children.Add(myBlock1); } myPanel.Arrange(new Rect(0, 20, form.TvBox.DesiredSize.Width, form.TvBox.DesiredSize.Height)); dialog.PrintQueue = new PrintQueue(new PrintServer(), cmbPrinters.Text); //dialog.PrintDocument() // dialog.ShowDialog(); //System.Windows.Forms.PrintPreviewDialog printPrvDlg = new System.Windows.Forms.PrintPreviewDialog(); //printPrvDlg.Document = myPanel; //printPrvDlg.Width = 1200; //printPrvDlg.Height = 800; //printPrvDlg.ShowDialog(); dialog.PrintVisual(myPanel, "A Great Image."); //PrintCapabilities capabilities = printDlg.PrintQueue.GetPrintCapabilities(printDlg.PrintTicket); //Size pageSize = new Size(obj.Bounds.Width, obj.Bounds.Height); //Size visibleSize = new Size(obj.Bounds.Width, obj.Bounds.Height); //FixedDocument fixedDoc = new FixedDocument(); ////If the toPrint visual is not displayed on screen we neeed to measure and arrange it //form.TvBox.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); //form.TvBox.Arrange(new Rect(new Point(0, 0), form.TvBox.DesiredSize)); //// //Size size = form.TvBox.DesiredSize; ////Will assume for simplicity the control fits horizontally on the page //double yOffset = 0; //while (yOffset < size.Height) //{ // VisualBrush vb = new VisualBrush(form.TvBox); // vb.Stretch = Stretch.None; // vb.AlignmentX = AlignmentX.Left; // vb.AlignmentY = AlignmentY.Top; // vb.ViewboxUnits = BrushMappingMode.Absolute; // vb.TileMode = TileMode.None; // vb.Viewbox = new Rect(0, yOffset, visibleSize.Width, visibleSize.Height); // PageContent pageContent = new PageContent(); // FixedPage page = new FixedPage(); // ((IAddChild)pageContent).AddChild(page); // fixedDoc.Pages.Add(pageContent); // page.Width = pageSize.Width; // page.Height = pageSize.Height; // Canvas canvas = new Canvas(); // FixedPage.SetLeft(canvas, capabilities.PageImageableArea.OriginWidth); // FixedPage.SetTop(canvas, capabilities.PageImageableArea.OriginHeight); // canvas.Width = visibleSize.Width; // canvas.Height = visibleSize.Height; // canvas.Background = vb; // page.Children.Add(canvas); // yOffset += visibleSize.Height; //} ////for (var i = 0; i <= Convert.ToInt32(model.StartRow); i++) ////{ //// if (i == Convert.ToInt32(model.StartRow)) //// { //// printDlg.PrintVisual(form.TvBox, "First Fit to Page WPF Print"); //// } ////} ////printDlg.ShowDialog(); //printDlg.PrintQueue = new PrintQueue(new PrintServer(), cmbPrinters.Text); ////PrintDocument pd=printDlg. //printDlg.PrintDocument(fixedDoc.DocumentPaginator, "First Fit to Page WPF Print"); } else { ConfirmationPopup obj = new ConfirmationPopup((string)Application.Current.Resources["select_printer"], (string)Application.Current.Resources["masterLabel_Header_Popup"], false); obj.ShowDialog(); //CommonFunction.Common.((string)Application.Current.Resources["select_printer"], "", false); } }