private void onFromPrinterClick(object sender, EventArgs e) { PrinterWidth.Text = PrinterHelper.getPrinterWidth(Printer.Text).ToString(); PrinterHeight.Text = PrinterHelper.getPrinterHeight(Printer.Text).ToString(); }
private void onStartClick(object sender, EventArgs e) { updateSettings(); if (Program.settings.buildingMode == true) { try { Program.BuildingInfo = Util.FetchBuildingInfo(); if (Program.BuildingInfo.Activities.Count == 0) { CancelClose = true; return; } } catch (Exception) { MessageBox.Show("Cannot find " + Program.settings.createURL()); CancelClose = true; } } if (CancelClose == false && !BuildingAccessMode.Checked) { bool bHorizontalCheck = false; bool bVerticalCheck = false; if (AdvancedPageSize.Checked) { if (PrinterWidth.Text.Length == 0) { PrinterWidth.Text = "0"; } if (PrinterHeight.Text.Length == 0) { PrinterHeight.Text = "0"; } bHorizontalCheck = int.Parse(PrinterWidth.Text) >= 290; bVerticalCheck = (int.Parse(PrinterHeight.Text) > 70 && int.Parse(PrinterHeight.Text) < 130) || (int.Parse(PrinterHeight.Text) > 170 && int.Parse(PrinterHeight.Text) < 230); } else { bHorizontalCheck = PrinterHelper.getPrinterWidth(Printer.Text) > 290; bVerticalCheck = (PrinterHelper.getPrinterHeight(Printer.Text) > 70 && PrinterHelper.getPrinterHeight(Printer.Text) < 130) || (PrinterHelper.getPrinterHeight(Printer.Text) > 170 && PrinterHelper.getPrinterHeight(Printer.Text) < 230); } if (!bHorizontalCheck || !bVerticalCheck) { if (MessageBox.Show("The selected printer does not have a recommended page size. Do you want to continue?", "Printer Configuration Error", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { CancelClose = true; } } } if (CancelClose == false) { DialogResult = DialogResult.OK; this.Hide(); } }
private void onPrinterChanged(object sender, EventArgs e) { LabelPrinterSize.Text = "Label Size: " + PrinterHelper.getPrinterWidth(Printer.Text) + " X " + PrinterHelper.getPrinterHeight(Printer.Text); }
private void button1_Click(object sender, EventArgs e) { Settings1.Default.URL = URL.Text; Settings1.Default.username = username.Text; Settings1.Default.Kiosks = PrintKiosks.Text; Settings1.Default.PrintMode = PrintMode.Text; Settings1.Default.Printer = Printer.Text; Settings1.Default.DisableLocationLabels = DisableLocationLabels.Checked; Settings1.Default.BuildingMode = BuildingAccessMode.Checked; Settings1.Default.Building = building.Text; Settings1.Default.PrinterWidth = PrinterWidth.Text; Settings1.Default.PrinterHeight = PrinterHeight.Text; Settings1.Default.AdvancedPageSize = AdvancedPageSize.Checked; Settings1.Default.UseSSL = UseSSL.Checked; Settings1.Default.AdminPIN = AdminPIN.Text; if (AdminPINTimeout.Text.Length > 0) { try { Program.AdminPINTimeout = int.Parse(AdminPINTimeout.Text); Settings1.Default.AdminPINTimeout = AdminPINTimeout.Text; } catch (Exception) { Program.AdminPINTimeout = 0; Settings1.Default.AdminPINTimeout = "0"; } } else { Program.AdminPINTimeout = 0; } Settings1.Default.Save(); if (URL.Text.StartsWith("localhost") || !UseSSL.Checked) { Program.URL = "http://" + URL.Text; } else if (Settings1.Default.UseSSL) { Program.URL = "https://" + URL.Text; } else { Program.URL = "http://" + URL.Text; } Program.Username = username.Text; Program.Password = password.Text; Program.PrinterWidth = PrinterWidth.Text; Program.PrinterHeight = PrinterHeight.Text; Program.DisableLocationLabels = DisableLocationLabels.Checked; Program.AdminPIN = AdminPIN.Text; if (BuildingAccessMode.Checked == true) { try { Program.Building = building.Text; Program.BuildingInfo = Util.FetchBuildingInfo(); if (Program.BuildingInfo.Activities.Count == 0) { CancelClose = true; return; } } catch (Exception) { MessageBox.Show("cannot find " + Program.URL); CancelClose = true; } } var wc = Util.CreateWebClient(); try { var url = new Uri(new Uri(Program.URL), "Checkin2/Campuses"); var str = wc.DownloadString(url); if (str == "not authorized") { MessageBox.Show(str); CancelClose = true; return; } campuses = XDocument.Parse(str); } catch (WebException) { MessageBox.Show("cannot find " + Program.URL); CancelClose = true; } if (CancelClose == false && !BuildingAccessMode.Checked) { bool bHorizontalCheck = false; bool bVerticalCheck = false; if (AdvancedPageSize.Checked) { if (PrinterWidth.Text.Length == 0) { PrinterWidth.Text = "0"; } if (PrinterHeight.Text.Length == 0) { PrinterHeight.Text = "0"; } bHorizontalCheck = int.Parse(PrinterWidth.Text) >= 290; bVerticalCheck = (int.Parse(PrinterHeight.Text) > 70 && int.Parse(PrinterHeight.Text) < 130) || (int.Parse(PrinterHeight.Text) > 170 && int.Parse(PrinterHeight.Text) < 230); } else { bHorizontalCheck = PrinterHelper.getPrinterWidth(Printer.Text) > 290; bVerticalCheck = (PrinterHelper.getPrinterHeight(Printer.Text) > 70 && PrinterHelper.getPrinterHeight(Printer.Text) < 130) || (PrinterHelper.getPrinterHeight(Printer.Text) > 170 && PrinterHelper.getPrinterHeight(Printer.Text) < 230); } if (!bHorizontalCheck || !bVerticalCheck) { if (MessageBox.Show("The selected printer does not have a valid page size. Do you want to continue?", "Printer Configuration Error", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { CancelClose = true; } } } if (CancelClose == false) { this.Hide(); } }
/// <summary> /// Crea un documento dependiendo del fileformat que se requiera /// </summary> /// <param name="enumFileFormat">enumerdo con el formato para crear el documento</param> /// <history> /// [emoguel] 02/09/2016 created /// </history> private void CreateFile(EnumFileFormat enumFileFormat) { Workbook wb = null; Microsoft.Office.Interop.Excel.Application excel = null; string defaultPrinter = ""; bool blnChagePrinter = false; try { if (_excelFile.Exists) { #region Printer defaultPrinter = PrinterHelper.GetDefaultPrinter(); if (!string.IsNullOrWhiteSpace(defaultPrinter) && defaultPrinter.Contains("pdf", StringComparison.OrdinalIgnoreCase)) //Ver si hay impresora predeterminada y que no sea pdf { var lstPrinters = PrinterHelper.getAllPrinters().Where(printer => !printer.Contains("pdf", StringComparison.OrdinalIgnoreCase)).ToList(); //Obtener la lista de impresoras que no sean pdf //Verificar si hay una impresora xps string xpsPrinter = lstPrinters.FirstOrDefault(printer => printer.Contains("xps", StringComparison.OrdinalIgnoreCase)); //Buscar impresora XPS if (!string.IsNullOrWhiteSpace(xpsPrinter)) //Verficar si existe una impresora XPS { PrinterHelper.SetDefaultPrinter(xpsPrinter); //Predefinir la impresora XPS blnChagePrinter = true; } else { PrinterHelper.SetDefaultPrinter(lstPrinters[0]);//Predefinir la primera impresora blnChagePrinter = true; } } #endregion //Obtenemos la orientacion seleccionada XlPageOrientation pageOrientation = (XlPageOrientation)cmbOrientation.SelectedValue; //Obtenemos el tamaño de papel seleccionado XlPaperSize paperSize = (XlPaperSize)cmbPageSize.SelectedValue; //Obtenemos el margen seleccionado Margin margin = cmbMargin.SelectedValue as Margin; //Obtenemos la escala seleccionada EnumScale enumScale = (EnumScale)cmbScale.SelectedValue; excel = new Microsoft.Office.Interop.Excel.Application(); excel.Visible = false; excel.ScreenUpdating = false; excel.DisplayAlerts = false; wb = excel.Workbooks.Open(_excelFile.FullName, 0, false, Missing.Value, Missing.Value, Missing.Value, true, XlPlatform.xlWindows, Missing.Value, false, false, Missing.Value, false, true, false);//Cargamos el excel _Worksheet ws = ((_Worksheet)wb.ActiveSheet); #region Page Configuration ws.PageSetup.PaperSize = paperSize; //asignamos el tamaño de hoja ws.PageSetup.Orientation = pageOrientation; //asignamos orientación de la pagina ws.PageSetup.LeftMargin = excel.CentimetersToPoints(margin.left); //asignamos Margen Izquierdo ws.PageSetup.RightMargin = excel.CentimetersToPoints(margin.right); //asignamos Margen Derecho ws.PageSetup.TopMargin = excel.CentimetersToPoints(margin.top); //asignamos Margen de arriba ws.PageSetup.BottomMargin = excel.CentimetersToPoints(margin.bottom); //asignamos Margen de abajo ws.PageSetup.Zoom = false; #endregion #region Scale //Asignamos la escala seleccionada switch (enumScale) { case EnumScale.Noscaling: { ws.PageSetup.FitToPagesTall = false; ws.PageSetup.FitToPagesWide = false; break; } case EnumScale.FitSheetOnOnePage: { ws.PageSetup.FitToPagesTall = 1; ws.PageSetup.FitToPagesWide = 1; break; } case EnumScale.FitAllColumnsOnOnePage: { ws.PageSetup.FitToPagesWide = 1; ws.PageSetup.FitToPagesTall = false; break; } case EnumScale.FitAllRowsOnOnePage: { ws.PageSetup.FitToPagesTall = 1; ws.PageSetup.FitToPagesWide = false; break; } } #endregion ws.PageSetup.Order = XlOrder.xlOverThenDown;//Poner el orden de la paginas #region Export switch (enumFileFormat) { case EnumFileFormat.Pdf: { SaveFileDialog dialog = new SaveFileDialog();//Cargamos el saveFileDialog dialog.FileName = Uid; dialog.Filter = "PDF files(*.pdf) | *.pdf;"; if (dialog.ShowDialog() == true) { wb.ExportAsFixedFormat(XlFixedFormatType.xlTypePDF, dialog.FileName, XlFixedFormatQuality.xlQualityStandard, false, true, Missing.Value, Missing.Value, false, Missing.Value);//Guardamos como PDF if (File.Exists(dialog.FileName)) { UIHelper.ShowMessage("Document sufesfully saved."); Process.Start(dialog.FileName); } else { UIHelper.ShowMessage("Document not saved."); } } break; } case EnumFileFormat.Xps: { wb.ExportAsFixedFormat(XlFixedFormatType.xlTypeXPS, $"{_fullPathAndName}.xps", XlFixedFormatQuality.xlQualityStandard, false, true, Missing.Value, Missing.Value, false, Missing.Value);//Guardamos como XPS break; } } #endregion } } catch (Exception ex) { UIHelper.ShowMessage(ex); } finally { if (wb != null) { wb.Close(); } if (excel != null) { excel.Quit(); } if (blnChagePrinter) { PrinterHelper.SetDefaultPrinter(defaultPrinter); } } }
//[Obsolete] //private void Print_AbsenceY_Click(object sender, EventArgs e) //{ // //graf som visar månadsvis frånvaro? 1 serie per eventyp + total frånvaro //} /// <summary> /// Calls to print a PDF of the calendar for the specified month & year /// </summary> private void Print_AbsenceC_Click(object sender, EventArgs e) { DateTime date = new DateTime(YearInput_AbsenceC.SelectedIndex + 2020, MonthInput_AbsenceC.SelectedIndex + 1, 1); PrinterHelper.Print_Calendar(calForm, date); }
private void button1_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtPath.Text)) { MessageBox.Show("路径不能为空"); return; } if (!File.Exists(txtPath.Text)) { MessageBox.Show("文件不存在"); return; } string printerName = cBoxPrint.SelectedItem.ToString(); if (radioButton1.Checked) { string str = PrinterHelper.SendFileToPrinter(printerName, txtPath.Text) ? "成功" : "失败"; if (!string.IsNullOrEmpty(str)) { MessageBox.Show(str); } else { MessageBox.Show("发送成功"); } } else { //纸张样式 string selectedPaper = cBoxPaperSize.SelectedItem.ToString(); string paperSize = ""; int paperH = 0, paperW = 0; string[] tmps = selectedPaper.TrimStart('[').TrimEnd(']').Split(','); paperSize = tmps[0]; string[] wh = tmps[1].Split('*'); //PrinterUnitConvert.Convert() paperW = (int)(Helper.MMToInch(Convert.ToInt32(wh[0])) * 100); paperH = (int)(Helper.MMToInch(Convert.ToInt32(wh[1])) * 100); PaperSize paper = new PaperSize(paperSize, paperW, paperH); //纵横向 bool isVertical = rBtnVertical.Checked; //份数 int copies = (int)numericUpDownCount.Value; string errorStr = PrinterHelper.UsePDFRender4NetToPrintPdf(txtPath.Text, printerName, paper, isVertical, copies); if (!string.IsNullOrEmpty(errorStr)) { MessageBox.Show(errorStr); } else { MessageBox.Show("发送成功"); } } }
public bool IsRepairRequired() { var printerHelper = new PrinterHelper(); return(!printerHelper.GetPDFCreatorPrinters().Any()); }
/// <summary> /// 订单资料 /// </summary> /// <param name="order"></param> /// <param name="act"></param> /// <returns></returns> public ActionResult Info(DishOrder order, string act = "", int psy_id = 0, string printer = null, string orderMark = null) { if (order.id <= 0) { _result.code = 0; _result.msg = "未找到有效的订单标识"; return(Json(_result, JsonRequestBehavior.AllowGet)); } if (string.IsNullOrWhiteSpace(act)) { EditModel <DishOrder> model = new EditModel <DishOrder>(); model.DataModel = DishOrderBLL.SingleModel.GetModel(order.id) ?? new DishOrder(); if (model.DataModel.id > 0) { model.DataModel.carts = DishShoppingCartBLL.SingleModel.GetCartsByOrderId(model.DataModel.id) ?? new List <DishShoppingCart>(); } model.aId = model.appId = order.aId; model.storeId = order.storeId; ViewBag.dishTransporters = DishTransporterBLL.SingleModel.GetTransportersByparams(model.aId, model.storeId, true) ?? new List <DishTransporter>(); return(View(model)); } else { bool isSuccess = false; DishOrder dbOrder = DishOrderBLL.SingleModel.GetModel(order.id); if (dbOrder == null) { _result.code = 0; _result.msg = "未找到相关订单"; return(Json(_result, JsonRequestBehavior.AllowGet)); } if (act == "changeTable") { DishTable table = DishTableBLL.SingleModel.GetModel(order.order_table_id_zhen); if (table == null) { _result.code = 0; _result.msg = "未找到相关桌台"; return(Json(_result, JsonRequestBehavior.AllowGet)); } dbOrder.order_table_id_zhen = table.id; dbOrder.order_table_id = table.table_name; isSuccess = DishOrderBLL.SingleModel.Update(dbOrder, "order_table_id,order_table_id_zhen"); _result.code = isSuccess ? 1 : 0; _result.msg = isSuccess ? "操作成功" : "操作失败"; return(Json(_result, JsonRequestBehavior.AllowGet)); } else if (act == "queren") { dbOrder.peisong_status = (int)DishEnums.DeliveryState.待取货; isSuccess = DishOrderBLL.SingleModel.Update(dbOrder, "peisong_status"); _result.code = isSuccess ? 1 : 0; _result.msg = isSuccess ? "操作成功" : "操作失败"; return(Json(_result, JsonRequestBehavior.AllowGet)); } else if (act == "quxiao") { dbOrder.peisong_status = (int)DishEnums.DeliveryState.已取消; isSuccess = DishOrderBLL.SingleModel.Update(dbOrder, "peisong_status"); _result.code = isSuccess ? 1 : 0; _result.msg = isSuccess ? "操作成功" : "操作失败"; return(Json(_result, JsonRequestBehavior.AllowGet)); } else if (act == "wancheng") { dbOrder.peisong_status = (int)DishEnums.DeliveryState.已完成; isSuccess = DishOrderBLL.SingleModel.Update(dbOrder, "peisong_status"); _result.code = isSuccess ? 1 : 0; _result.msg = isSuccess ? "操作成功" : "操作失败"; return(Json(_result, JsonRequestBehavior.AllowGet)); } else if (act == "peisong") { if (psy_id <= 0) { _result.code = 0; _result.msg = "配送员标识错误"; return(Json(_result, JsonRequestBehavior.AllowGet)); } DishTransporter transporter = DishTransporterBLL.SingleModel.GetModel(psy_id); if (transporter == null) { _result.code = 0; _result.msg = "未找到配送员资料"; return(Json(_result, JsonRequestBehavior.AllowGet)); } dbOrder.peisong_open = 1; dbOrder.peisong_status = (int)DishEnums.DeliveryState.配送中; dbOrder.peisong_user_name = transporter.dm_name; dbOrder.peisong_user_phone = transporter.dm_mobile; isSuccess = DishOrderBLL.SingleModel.Update(dbOrder, "peisong_open,peisong_status,peisong_user_name,peisong_user_phone"); _result.code = isSuccess ? 1 : 0; _result.msg = isSuccess ? "操作成功" : "操作失败"; return(Json(_result, JsonRequestBehavior.AllowGet)); } else if (act == "print") //打印 { PrinterHelper.DishPrintOrderByPrintType(dbOrder, 0, printer); _result.code = 1; _result.msg = "操作成功"; return(Json(_result, JsonRequestBehavior.AllowGet)); } else if (act == "mark") { DishOrderAttrbute orderAttr = dbOrder.GetAttrbute(); orderAttr.mark = orderMark; dbOrder.attrbute = JsonConvert.SerializeObject(orderAttr); isSuccess = DishOrderBLL.SingleModel.Update(dbOrder, "attrbute"); _result.code = isSuccess ? 1 : 0; _result.msg = isSuccess ? "操作成功" : "操作失败"; return(Json(_result, JsonRequestBehavior.AllowGet)); } } return(Json(_result, JsonRequestBehavior.AllowGet)); }
public Printers() { _printerHelper = new PrinterHelper(); }
private void DoPrinting(object sender, DoWorkEventArgs e) { if (list == null) { return; } var qlist = list.Where(c => c.CheckedIn && c.NumLabels > 0); if (!PrintAll.Text.HasValue()) { qlist = qlist.Where(c => c.WasChecked); } var q = from c in qlist select new LabelInfo { allergies = c.allergies, pid = c.cinfo.pid, mv = c.cinfo.mv, n = c.NumLabels, first = c.preferredname, last = c.last, location = c.location, hour = c.cinfo.hour, org = c.orgname, custody = c.custody, transport = c.transport, requiressecuritylabel = c.RequiresSecurityLabel, securitycode = Program.SecurityCode, dob = (c.dob != null && c.dob.Length > 0 ? DateTime.Parse(c.dob) : DateTime.Now), parents = c.parents }; Util.UnLockFamily(); if (Program.settings.printMode == "Print To Server") { PrintServerLabels(q); return; } if (q.Count() > 0) { if (!Program.settings.useOldDatamaxFormat) { if (!PrinterHelper.doPrinting(q)) { MessageBox.Show("There were no labels to print, please adjust your printer page size. If the page size is correct, please contact support for assistance.", "Printer Page Size Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } else { DoPrinting doprint = new DoPrinting(); int iLabelSize = PrinterHelper.getPageHeight(Program.settings.printer); using (var ms = new MemoryStream()) { if (iLabelSize >= 151 && iLabelSize <= 250) { doprint.PrintLabels2(ms, q); } else { doprint.PrintLabels(ms, q); } doprint.FinishUp(ms); } } } }
private void DoPrinting(object sender, DoWorkEventArgs e) { if (list == null) { return; } var qlist = list.Where(c => c.CheckedIn && c.NumLabels > 0); if (!PrintAll.Text.HasValue()) { qlist = qlist.Where(c => c.WasChecked); } var q = from c in qlist select new LabelInfo { allergies = c.allergies, pid = c.cinfo.pid, mv = c.cinfo.mv, n = c.NumLabels, first = c.preferredname, last = c.last, location = c.location, hour = c.cinfo.hour, org = c.orgname, custody = c.custody, transport = c.transport, requiressecuritylabel = c.RequiresSecurityLabel, securitycode = Program.SecurityCode, dob = (c.dob != null && c.dob.Length > 0 ? DateTime.Parse(c.dob) : DateTime.Now), }; Util.UnLockFamily(); if (Program.PrintMode == "Print To Server") { PrintServerLabels(q); return; } if (Program.UseNewLabels) { PrinterHelper.doPrinting(q); } else { int iLabelSize = PrinterHelper.getPageHeight(Program.Printer); using (var ms = new MemoryStream()) { if (iLabelSize >= 170 && iLabelSize <= 230) { doprint.PrintLabels2(ms, q); } else { doprint.PrintLabels(ms, q); } doprint.FinishUp(ms); } /* * using (var ms = new MemoryStream()) * { * * //if (Program.TwoInchLabel) * //else doprint.PrintLabels(ms, q); * doprint.PrintLabels(ms, q); * doprint.FinishUp(ms); * } */ } }
protected override void DrawCore(GeoCanvas canvas, Collection <SimpleCandidate> labelsInAllLayers) { base.DrawCore(canvas, labelsInAllLayers); var pageBindingBox = GetBoundingBox(); double leftInPoint = PrinterHelper.ConvertLength(left, marginUnit, PrintingUnit.Point); double topInPoint = PrinterHelper.ConvertLength(top, marginUnit, PrintingUnit.Point); double rightInPoint = PrinterHelper.ConvertLength(right, marginUnit, PrintingUnit.Point); double bottomInPoint = PrinterHelper.ConvertLength(bottom, marginUnit, PrintingUnit.Point); PointShape upperLeft = new PointShape(pageBindingBox.UpperLeftPoint.X + leftInPoint, pageBindingBox.UpperLeftPoint.Y - topInPoint); PointShape lowerRight = new PointShape(pageBindingBox.LowerRightPoint.X - rightInPoint, pageBindingBox.LowerRightPoint.Y + bottomInPoint); RectangleShape newBindingBox = new RectangleShape(upperLeft, lowerRight); var columnsCount = columns; var rowsCount = rows; double widthIncrease = newBindingBox.Width / columnsCount; double heightIncrease = newBindingBox.Height / rowsCount; if (useCellSize) { double width = PrinterHelper.ConvertLength(cellWidth, cellUnit, PrintingUnit.Point); double height = PrinterHelper.ConvertLength(cellHeight, cellUnit, PrintingUnit.Point); if (newBindingBox.Width < width || newBindingBox.Height < height) { return; } columnsCount = (int)(newBindingBox.Width / width); rowsCount = (int)(newBindingBox.Height / height); widthIncrease = width; heightIncrease = height; } double horizontalLineX1 = newBindingBox.UpperLeftPoint.X; double horizontalLineX2 = newBindingBox.UpperRightPoint.X; for (int i = 0; i <= rowsCount; i++) { LineShape horizontalLine = new LineShape(); var horizontalLineFirstPoint = new Vertex(horizontalLineX1, newBindingBox.UpperLeftPoint.Y - (i) * heightIncrease); var horizontalLineSecondPoint = new Vertex(horizontalLineX2, newBindingBox.UpperRightPoint.Y - (i) * heightIncrease); horizontalLine.Vertices.Add(horizontalLineFirstPoint); horizontalLine.Vertices.Add(horizontalLineSecondPoint); canvas.DrawLine(horizontalLine, drawingPen, DrawingLevel.LabelLevel); } LineShape lastHorizontalLine = new LineShape(); var lastHorizontalLineFirstPoint = new Vertex(horizontalLineX1, newBindingBox.LowerLeftPoint.Y); var lastHorizontalLineSecondPoint = new Vertex(horizontalLineX2, newBindingBox.LowerRightPoint.Y); lastHorizontalLine.Vertices.Add(lastHorizontalLineFirstPoint); lastHorizontalLine.Vertices.Add(lastHorizontalLineSecondPoint); canvas.DrawLine(lastHorizontalLine, drawingPen, DrawingLevel.LabelLevel); double verticalLineY1 = newBindingBox.UpperLeftPoint.Y; double verticalLineY2 = newBindingBox.LowerRightPoint.Y; for (int i = 0; i <= columnsCount; i++) { LineShape verticalLine = new LineShape(); var verticalLineX = newBindingBox.UpperLeftPoint.X + (i) * widthIncrease; var verticalLineFirstPoint = new Vertex(verticalLineX, verticalLineY1); var verticalLineSecondPoint = new Vertex(verticalLineX, verticalLineY2); verticalLine.Vertices.Add(verticalLineFirstPoint); verticalLine.Vertices.Add(verticalLineSecondPoint); canvas.DrawLine(verticalLine, drawingPen, DrawingLevel.LabelLevel); } LineShape lastVerticalLine = new LineShape(); var lastVerticalLineFirstPoint = new Vertex(newBindingBox.UpperRightPoint.X, verticalLineY1); var lastVerticalLineLineSecondPoint = new Vertex(newBindingBox.UpperRightPoint.X, verticalLineY2); lastVerticalLine.Vertices.Add(lastVerticalLineFirstPoint); lastVerticalLine.Vertices.Add(lastVerticalLineLineSecondPoint); canvas.DrawLine(lastVerticalLine, drawingPen, DrawingLevel.LabelLevel); }
public InvoiceSaveReturn OnInsert(eStoreDbContext db, SaveOrderDTO sales, string userName, int StoreId = 1) { Customer cust = db.Customers.Where(c => c.MobileNo == sales.MobileNo).FirstOrDefault(); if (cust == null) { string[] names = sales.Name.Split(" "); string FName = names[0]; string LName = ""; for (int i = 1; i < names.Length; i++) { LName += names[i] + " "; } cust = new Customer { City = sales.Address, Age = 30, FirstName = FName, Gender = Gender.Male, LastName = LName, MobileNo = sales.MobileNo, NoOfBills = 0, TotalAmount = 0, CreatedDate = DateTime.Now.Date }; db.Customers.Add(cust); } string InvNo = GenerateInvoiceNo(db, StoreId, true); List <RegularSaleItem> itemList = new List <RegularSaleItem>(); List <Stock> stockList = new List <Stock>(); foreach (var item in sales.SaleItems) { RegularSaleItem sItem = new RegularSaleItem { BarCode = item.BarCode, MRP = item.Price, Qty = item.Quantity, Discount = 0, SalesmanId = item.Salesman, Units = item.Units, InvoiceNo = InvNo, BasicAmount = item.Amount, TaxAmount = 0, ProductItemId = -1, BillAmount = 0, SaleTaxTypeId = 1, //TODO: default tax id needed }; ProductItem pItem = db.ProductItems.Where(c => c.Barcode == item.BarCode).FirstOrDefault(); Stock stock = db.Stocks.Where(c => c.ProductItemId == pItem.ProductItemId && c.StoreId == StoreId).FirstOrDefault(); sItem.ProductItemId = pItem.ProductItemId; decimal amt = (decimal)item.Quantity * item.Price; sItem.BasicAmount = (amt * 100) / (100 + pItem.TaxRate); sItem.TaxAmount = (sItem.BasicAmount * pItem.TaxRate) / 100; sItem.BillAmount = sItem.BasicAmount + sItem.TaxAmount; //SaleTax Id var taxid = db.SaleTaxTypes.Where(c => c.CompositeRate == pItem.TaxRate).Select(c => c.SaleTaxTypeId).FirstOrDefault(); if (taxid <= 0) { taxid = 1; //TODO: Handle it for creating new saletax id } sItem.SaleTaxTypeId = taxid; itemList.Add(sItem); stock.SaleQty += item.Quantity; stock.Quantity -= item.Quantity; stockList.Add(stock); } var totalBillamt = itemList.Sum(c => c.BillAmount); var totaltaxamt = itemList.Sum(c => c.TaxAmount); var totalDiscount = itemList.Sum(c => c.Discount); var totalQty = itemList.Sum(c => c.Qty); var totalitem = itemList.Count; decimal roundoffamt = Math.Round(totalBillamt) - totalBillamt; PaymentDetail pd = new PaymentDetail { CardAmount = sales.PaymentInfo.CardAmount, CashAmount = sales.PaymentInfo.CashAmount, InvoiceNo = InvNo, IsManualBill = true, MixAmount = 0, PayMode = SalePayMode.Cash }; if (sales.PaymentInfo.CardAmount > 0) { if (sales.PaymentInfo.CashAmount > 0) { pd.PayMode = SalePayMode.Mix; } else { pd.PayMode = SalePayMode.Card; } CardDetail cd = new CardDetail { CardCode = CardType.Visa,//TODO: default Amount = sales.PaymentInfo.CardAmount, AuthCode = (int)Int64.Parse(sales.PaymentInfo.AuthCode), InvoiceNo = InvNo, LastDigit = (int)Int64.Parse(sales.PaymentInfo.CardNo), CardType = CardMode.DebitCard//TODO: default }; if (sales.PaymentInfo.CardType.Contains("Debit") || sales.PaymentInfo.CardType.Contains("debit") || sales.PaymentInfo.CardType.Contains("DEBIT")) { cd.CardType = CardMode.DebitCard; } else if (sales.PaymentInfo.CardType.Contains("Credit") || sales.PaymentInfo.CardType.Contains("credit") || sales.PaymentInfo.CardType.Contains("CREDIT")) { cd.CardType = CardMode.CreditCard; } if (sales.PaymentInfo.CardType.Contains("visa") || sales.PaymentInfo.CardType.Contains("Visa") || sales.PaymentInfo.CardType.Contains("VISA")) { cd.CardCode = CardType.Visa; } else if (sales.PaymentInfo.CardType.Contains("MasterCard") || sales.PaymentInfo.CardType.Contains("mastercard") || sales.PaymentInfo.CardType.Contains("MASTERCARD")) { cd.CardCode = CardType.MasterCard; } else if (sales.PaymentInfo.CardType.Contains("Rupay") || sales.PaymentInfo.CardType.Contains("rupay") || sales.PaymentInfo.CardType.Contains("RUPAY")) { cd.CardCode = CardType.Rupay; } else if (sales.PaymentInfo.CardType.Contains("MASTRO") || sales.PaymentInfo.CardType.Contains("mastro") || sales.PaymentInfo.CardType.Contains("Mastro")) { cd.CardCode = CardType.Rupay; } pd.CardDetail = cd; } RegularInvoice Invoice = new RegularInvoice { Customer = cust, InvoiceNo = InvNo, OnDate = sales.OnDate, IsManualBill = true, StoreId = StoreId, SaleItems = itemList, CustomerId = cust.CustomerId, TotalBillAmount = totalBillamt + roundoffamt, TotalDiscountAmount = totalDiscount, TotalItems = totalitem, TotalQty = totalQty, TotalTaxAmount = totaltaxamt, RoundOffAmount = roundoffamt, PaymentDetail = pd, UserId = userName }; db.RegularInvoices.Add(Invoice); db.Stocks.UpdateRange(stockList); InvoiceSaveReturn returnData = new InvoiceSaveReturn { NoOfRecord = db.SaveChanges(), FileName = "NotSaved" }; if (returnData.NoOfRecord > 0) { ReceiptHeader header = PrinterHelper.GetReceiptHeader(db, StoreId); ReceiptDetails details = PrinterHelper.GetReceiptDetails(Invoice.InvoiceNo, Invoice.OnDate, DateTime.Now.ToShortTimeString(), sales.Name); ReceiptItemTotal itemtotal = PrinterHelper.GetReceiptItemTotal(Invoice); List <ReceiptItemDetails> itemDetailList = PrinterHelper.GetInvoiceDetails(db, itemList); returnData.FileName = "/" + InvoicePrinter.PrintManaulInvoice(header, itemtotal, details, itemDetailList, false); } return(returnData); }
private void onPrinterChanged(object sender, EventArgs e) { LabelPrinterSize.Text = "Label Size: " + PrinterHelper.getPrinterWidth(Printer.Text) + " X " + PrinterHelper.getPrinterHeight(Printer.Text); if (Printer.Text.Contains("Datamax")) { UseOldDatamaxFormat.Enabled = true; } else { UseOldDatamaxFormat.Enabled = false; UseOldDatamaxFormat.Checked = false; } }
private void cBoxPrint_SelectedIndexChanged(object sender, EventArgs e) { string state = PrinterHelper.GetPrinterStatus(cBoxPrint.SelectedItem.ToString()); MessageBox.Show(state); }
private void onLabelListChanged(object sender, EventArgs e) { string[] sLabelPieces = LabelList.Text.Split(new char[] { '~' }); LabelFormat.Text = PrinterHelper.fetchLabelFormat(sLabelPieces[0], int.Parse(sLabelPieces[1])).Replace("~", "~\r\n"); }
/// <summary> /// Calls to print a PDF of the EventsList /// </summary> private void Print_event_Click(object sender, EventArgs e) { PrinterHelper.Print_ListView(EventsList_events, $"Händelser_{new EventDate(DateTime.Today).ToString()}"); }