コード例 #1
0
ファイル: ElzabDriver.cs プロジェクト: MakoLab/fractus
 public ReceiptLine(ReceiptLine rLine)
 {
     this.name     = rLine.name;
     this.vatRate  = rLine.vatRate;
     this.quantity = rLine.quantity;
     this.coma     = rLine.coma;
     this.measure  = rLine.measure;
     this.price    = rLine.price;
     this.value    = rLine.value;
 }
コード例 #2
0
ファイル: ElzabDriver.cs プロジェクト: MakoLab/fractus
        /// <summary>
        /// Prints the bill.
        /// </summary>
        /// <param name="bill">The xml representation of bill.</param>
        ///
        ///
        public void PrintBill(XmlDocument bill)
        {
            ProcessBill(bill);

            StringBuilder errorMessage = null;

            lock (MakoPrintFiscal.SerialPortSyncRoot)
            {
                //inicjalizacja portu
                if ((errorMessage = ElzabLibWrapper.LibCommunicationInit(portName, 9600, 5)) != null)
                {
                    HandleError(errorMessage.ToString());
                }

                // ustawienie numeru kasy i kasjera
                SetCashierCode();


                //rozpoczecie paragonu
                if ((errorMessage = ElzabLibWrapper.LibReceiptBegin()) != null)
                {
                    HandleError(errorMessage.ToString());
                }

                //linie paragonu
                for (int i = 0; i < receitLines.Count; i++)
                {
                    ReceiptLine rLine = (ReceiptLine)receitLines[i];
                    if ((errorMessage = ElzabLibWrapper.LibReceiptItem(rLine.name, rLine.vatRate, rLine.quantity, rLine.coma, rLine.measure, rLine.price, rLine.value)) != null)
                    {
                        HandleError(errorMessage.ToString());
                    }
                }


                // wydrukowanie numeru systemowego
                if ((errorMessage = ElzabLibWrapper.LibAdditionalLine(12, billNr)) != null)
                {
                    HandleError(errorMessage.ToString());
                }

                //zakonczenie paragonu
                if ((errorMessage = ElzabLibWrapper.LibReceiptEnd(0)) != null)
                {
                    HandleError(errorMessage.ToString());
                }


                //zamkniecie portu
                if ((errorMessage = ElzabLibWrapper.LibCommunicationEnd()) != null)
                {
                    HandleError(errorMessage.ToString());
                }
            }
        }
コード例 #3
0
ファイル: ElzabDriver.cs プロジェクト: MakoLab/fractus
        public override bool Equals(Object obj)
        {
            //Check for null and compare run-time types.
            if (obj == null || GetType() != obj.GetType())
            {
                return(false);
            }
            ReceiptLine rt = (ReceiptLine)obj;

            return((name == rt.name) && (vatRate == rt.vatRate) && (quantity == rt.quantity) && (coma == rt.coma) && (measure == rt.measure) && (price == rt.price) && (value == rt.value));
        }
コード例 #4
0
ファイル: ElzabDriver.cs プロジェクト: MakoLab/fractus
        public void ProcessBill(XmlDocument bill)
        {
            XmlNode cashierNode = bill.DocumentElement.SelectSingleNode("cashier");

            if (cashierNode != null)
            {
                cashier = cashierNode.InnerText.PadLeft(2, '0').Substring(0, 2);;
            }
            else
            {
                throw new FiscalPrinterException(FiscalExceptionId.MissingCashierError);
            }

            XmlNode cashNode = bill.DocumentElement.SelectSingleNode("cash");

            if (cashNode != null)
            {
                cash = cashNode.InnerText.PadLeft(2, '0').Substring(0, 2);;
            }
            else
            {
                cash = "01";
            }


            XmlNode billNrNode = bill.DocumentElement.SelectSingleNode("number");

            if (billNrNode != null)
            {
                billNr = billNrNode.InnerText;
            }
            else
            {
                throw new FiscalPrinterException(FiscalExceptionId.MissingBillNumberError);
            }


            XmlNode grossValueNode = bill.DocumentElement.SelectSingleNode("grossValue");

            if (grossValueNode != null)
            {
                grossValue = grossValueNode.InnerText;
            }
            else
            {
                throw new FiscalPrinterException(FiscalExceptionId.PrinterPrecisionError);
            }

            foreach (XmlNode line in bill.DocumentElement.SelectNodes("lines/line"))
            {
                ReceiptLine rLine = new ReceiptLine();

                string quantity = (line.SelectSingleNode("quantity").InnerText).Replace(".", ",");

                Double q = Math.Round(Double.Parse(quantity), 4, MidpointRounding.ToEven);

                if ((Double.Parse(quantity) - q) != 0)
                {
                    throw new FiscalPrinterException(FiscalExceptionId.PrinterPrecisionError);
                }
                else
                {
                    int coma = checkComaPosition(q.ToString());
                    rLine.quantity = (int)(Math.Round(q * Math.Pow(10, coma), MidpointRounding.AwayFromZero));
                    rLine.coma     = coma;
                }

                string name = line.SelectSingleNode("name").InnerText;
                rLine.name = name;

                string vatRate = line.SelectSingleNode("vatRateType").InnerText;
                rLine.vatRate = Char.ConvertToUtf32(vatRate, 0);


                String price = (line.SelectSingleNode("grossPrice").InnerText).Replace(".", ",");
                rLine.price = (int)(Math.Round(Double.Parse(price) * 100.0, MidpointRounding.AwayFromZero));

                String value = (line.SelectSingleNode("grossValue").InnerText).Replace(".", ",");
                rLine.value = (int)(Math.Round(Double.Parse(value) * 100, MidpointRounding.AwayFromZero));

                String measure = line.SelectSingleNode("unit").InnerText;
                rLine.measure = measure;

                receitLines.Add(rLine);
            }
        }