Exemplo n.º 1
0
        static void PrintXML(string xml)
        {
            CheckPackage checkPackage = DeserializeXMLFileToObject <CheckPackage>(GenerateStreamFromString(xml));

            if (checkPackage == null)
            {
                FR.Start();
                if (xml.Trim().StartsWith("#PrintXReport"))
                {
                    FR.PrintXReport();
                    FR.Stop();
                    return;
                }
                else if (xml.Trim().StartsWith("#PrintZReport"))
                {
                    FR.PrintZReport();
                    FR.Stop();
                    return;
                }
                else
                {
                    //FR.PrintString("Error XML parse!");
                    FR.PrintString(xml);
                    FR.Feed(6);
                    FR.PartialCut();
                    FR.Stop();
                    return;
                }
            }
            else
            {
                //Log("checkPackage.Positions.Count = " + checkPackage.Positions.Count.ToString());
                ProcessCheck(checkPackage);
            }
        }
Exemplo n.º 2
0
        static void PrintFiscalString(FiscalString fs)
        {
            Log("FiscalString");
            string Name = fs.Name;

            Log("Name=" + Name);

            double Price    = fs.Price;
            double Quantity = fs.Quantity;
            double Amount   = fs.Amount;

            int Tax = AtolGetTaxByString(fs.Tax);

            if (Tax == -1)
            {
                Log("Tax = " + fs.Tax);
                FR.Abort();
                return;
            }

            int Department = Convert.ToInt32(fs.Department);

            int    DiscountType = 0;
            double DiscontValue = 0;

            Log("Registration: Name=" + Name + " Price=" + Price + " Quantity=" + Quantity + " Tax=" + Tax);
            FR.Registration(Name, Price, Quantity, Tax, Department, DiscountType, DiscontValue);
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            List <String> Lines = new List <String>();

            if (args.Length == 0)
            {
                string line;
                do
                {
                    line = Console.ReadLine();
                    if (line != null)
                    {
                        line = Encode(line, 866, 1251);
                        Log(line);
                        Lines.Add(Encode(line, 65001, 1251));
                    }
                } while (line != null);
            }
            else
            {
                string filename = args[0];
                try
                {
                    string line = File.ReadAllText(filename, Encoding.GetEncoding(1251));
                    Lines.Add(Encode(line, 65001, 1251));
                }
                catch (Exception e)
                {
                    Log("The file could not be read: " + filename);
                    Log(e.Message);
                }
            }

            FR.Init();

            //string path = "" + AppDomain.CurrentDomain.BaseDirectory + "testCheck.xml";
            //string testXML = File.ReadAllText(path, Encoding.GetEncoding(1251));
            //Console.WriteLine(testXML);
            //PrintXML(testXML);
            //Console.ReadLine();

            PrintXML(ListToString(Lines));
        }
Exemplo n.º 4
0
        static void ProcessCheck(CheckPackage checkPackage)
        {
            int Result;

            if (checkPackage.Positions.Items.Length == 0)
            {
                Log("Positions = 0");
                return;
            }

            Log("ProcessCheck");
            Log("Positions = " + checkPackage.Positions.Items.Length);

            FR.Start();

            Log("SetMode ");
            Result = FR.SetMode(1, "30");
            Log("Result = " + Result);

            if (Result == -3822)
            {
                FR.PrintString("Смена превысила 24 часа!");
                FR.PrintString("Для продолжения снимите Z-Отчет.");
                FR.Feed(6);
                FR.PartialCut();
                FR.Stop();
                return;
            }

            int CheckMode = 1;
            int CheckType = Convert.ToInt32(checkPackage.Parameters.PaymentType);

            Log("OpenCheck CheckMode=" + CheckMode + " CheckType=" + CheckType);
            Result = FR.OpenCheck(CheckMode, CheckType);
            Log("Result = " + Result);

            // Применяемая система налогооблажения в чеке:
            long TaxVariant = AtolGetTaxVariantByLong(checkPackage.Parameters.TaxVariant);

            FR.WriteAttribute(1055, TaxVariant.ToString());

            // Позиции чека
            for (int i = 0; i < checkPackage.Positions.Items.Length; i++)
            {
                if (checkPackage.Positions.ItemsElementName[i] == ItemsChoiceType.FiscalString)
                {
                    PrintFiscalString((FiscalString)checkPackage.Positions.Items[i]);
                }
                else if (checkPackage.Positions.ItemsElementName[i] == ItemsChoiceType.TextString)
                {
                    PrintTextString((TextString)checkPackage.Positions.Items[i]);
                }
                else if (checkPackage.Positions.ItemsElementName[i] == ItemsChoiceType.BarcodeString)
                {
                    PrintBarcodeString((BarcodeString)checkPackage.Positions.Items[i]);
                }
                else
                {
                    Log("Unknown position " + checkPackage.Positions.Items[i].ToString());
                }
            }

            // Оплата
            Log("Payment");
            double Cash          = checkPackage.Payments.Cash;
            double CashLessType1 = checkPackage.Payments.CashLessType1;
            double CashLessType2 = checkPackage.Payments.CashLessType2;
            double CashLessType3 = checkPackage.Payments.CashLessType3;

            Log("Cash = " + Cash.ToString() + " CashLessType1 = " + CashLessType1.ToString() + " CashLessType2 = " + CashLessType2.ToString() + " CashLessType3 = " + CashLessType3.ToString());

            double Remainder = 0;
            double Change    = 0;

            FR.Payment(Cash, 0, ref Remainder, ref Change);
            FR.Payment(CashLessType1, 1, ref Remainder, ref Change);
            FR.Payment(CashLessType2, 2, ref Remainder, ref Change);
            FR.Payment(CashLessType3, 3, ref Remainder, ref Change);

            Log("CloseCheck");
            Result = FR.CloseCheck();
            Log("Result = " + Result);

            string ResultDescription = FR.ResultDescription();

            if (Result != 0)
            {
                Log("Error: " + Result.ToString() + " - " + ResultDescription);
                FR.PrintString("Error: " + Result.ToString() + " - " + ResultDescription);
                Log("Abort");
                FR.Abort();
            }

            Log("Stop");
            FR.Stop();
        }
Exemplo n.º 5
0
 static void PrintTextString(TextString ts)
 {
     FR.PrintString(ts.Text);
 }