Exemple #1
0
        public override void FiscalReport(FiscalReportType reportType, bool full, params object[] reportParams)
        {
            ExecuteDriverCommand(delegate()
            {
                POSCommand Cmd = null;
                _errorCode     = (short)GeneralError.Success;
                switch (reportType)
                {
                case FiscalReportType.ByDates:
                    DateTime firstDate = (DateTime)reportParams[0];
                    DateTime lastDate  = (DateTime)reportParams[1];

                    Cmd = new POSCommand(303);                // фискальный отчет по датам
                    Cmd.AddNumeric(TaxerPassword, 8);         // пароль
                    Cmd.AddNumeric(firstDate.Day, 2);         // день
                    Cmd.AddNumeric(firstDate.Month, 2);       // месяц
                    Cmd.AddNumeric(firstDate.Year, 4);        // год
                    Cmd.AddNumeric(lastDate.Day, 2);          // день
                    Cmd.AddNumeric(lastDate.Month, 2);        // месяц
                    Cmd.AddNumeric(lastDate.Year, 4);         // год
                    Cmd.AddNumeric(Convert.ToInt32(full), 1); // полный или краткий отчет
                    break;

                case FiscalReportType.ByShifts:
                    Cmd = new POSCommand(304);                 // фискальный отчет по сменам
                    Cmd.AddNumeric(TaxerPassword, 8);          // пароль
                    Cmd.AddNumeric((int)(reportParams[0]), 4); // начальная смена
                    Cmd.AddNumeric((int)(reportParams[1]), 4); // конечная смена
                    Cmd.AddNumeric(Convert.ToInt32(full), 1);  // полный или краткий отчет
                    break;
                }

                _errorCode = Cmd.Execute(Port);
            });
        }
Exemple #2
0
        public override void Fiscalization(int newPassword, long registrationNumber, long taxPayerNumber)
        {
            ExecuteDriverCommand(delegate()
            {
                string sCurrentPasswd;
                _errorCode = (short)GeneralError.Success;
                if (!this.Status.Fiscalized)
                {
                    StringBuilder sBuilder = new StringBuilder(8);
                    sBuilder.Insert(0, " ", 8);
                    sBuilder.Insert(0, this.Info.SerialNo);
                    sCurrentPasswd = sBuilder.ToString(0, 8);
                }
                else
                {
                    sCurrentPasswd = TaxerPassword.ToString("d8");
                }

                POSCommand Cmd = new POSCommand(302);
                Cmd.AddChar(sCurrentPasswd, 8);
                Cmd.AddNumeric((int)registrationNumber, 12);
                Cmd.AddNumeric((int)taxPayerNumber, 12);
                Cmd.AddNumeric(2, 1);
                Cmd.AddNumeric(newPassword, 8);

                _errorCode = Cmd.Execute(Port);
            });
        }
Exemple #3
0
        protected override void OnPayment(uint amount, FiscalPaymentType paymentType)
        {
            ExecuteDriverCommand(delegate()
            {
                _errorCode = (short)GeneralError.Success;

                POSCommand cmd = new POSCommand(214);
                cmd.AddChar(OPERATOR_PASSWD, 4);

                switch (paymentType)
                {
                case FiscalPaymentType.Cash:
                    cmd.AddNumeric(0, 2);
                    break;

                case FiscalPaymentType.Card:
                    cmd.AddNumeric(2, 2);
                    break;

                default:
                    cmd.AddNumeric(3, 2);
                    break;
                }
                cmd.AddNumeric((int)amount, 10);

                byte[] nRsp = new byte[11];
                _errorCode  = cmd.Execute(Port, nRsp);
                if (_errorCode != (short)GeneralError.Success)
                {
                    CancelDocument();
                }
            });
        }
Exemple #4
0
        protected override void OnCloseDocument(bool cutPaper)
        {
            ExecuteDriverCommand(delegate()
            {
                _errorCode = (short)GeneralError.Success;

                switch (m_CurrentDocType)
                {
                case DocumentType.Sale:
                case DocumentType.Refund:
                case DocumentType.PayingIn:
                case DocumentType.PayingOut:
                case DocumentType.Other:
                    POSCommand cmd = new POSCommand(215);         // закрыть документ
                    cmd.AddChar(OPERATOR_PASSWD, 4);              // пароль
                    cmd.AddNumeric(Convert.ToInt32(cutPaper), 1); // обрезать чек
                    _errorCode = cmd.Execute(Port);
                    if (_errorCode != (short)GeneralError.Success)
                    {
                        CancelDocument();
                    }
                    break;

                case DocumentType.XReport:
                case DocumentType.SectionsReport:
                case DocumentType.ZReport:
                    _errorCode = PrintReport(m_CurrentDocType);
                    break;
                }
            });
        }
Exemple #5
0
        protected override void OnRegistration(string commentary, uint quantity, uint amount,
                                               byte section)
        {
            ExecuteDriverCommand(delegate()
            {
                _errorCode = (short)GeneralError.Success;

                POSCommand cmd = new POSCommand(209);
                cmd.AddChar(OPERATOR_PASSWD, 4);  // пароль
                cmd.AddNumeric(section, 3);       // номер отдела
                cmd.AddBChar("");                 // штрих-код
                cmd.AddBChar("");                 // внутренний учетный код
                cmd.AddBChar(commentary);         // название
                cmd.AddNumeric((int)amount, 10);  // цена
                cmd.AddNumeric((int)quantity, 8); // количество
                cmd.AddNumeric(0, 10);            // стоимость тары
                cmd.AddBChar("");                 // размерность

                byte[] nRsp = new byte[5];

                _errorCode = cmd.Execute(Port, nRsp);
                if (_errorCode != (short)GeneralError.Success)
                {
                    CancelDocument();
                }
            });
        }
Exemple #6
0
        protected override void OnPrintString(string source, FontStyle style)
        {
            ExecuteDriverCommand(delegate()
            {
                _errorCode = (short)GeneralError.Success;

                if (m_CurrentDocType == DocumentType.XReport ||
                    m_CurrentDocType == DocumentType.ZReport ||
                    m_CurrentDocType == DocumentType.SectionsReport)
                {
                    return;
                }

                POSCommand cmd = new POSCommand(206);
                cmd.AddChar(OPERATOR_PASSWD, 4); // пароль
                cmd.AddNumeric(0, 1);            // устройство
                cmd.AddBChar(source);            // текст

                _errorCode = cmd.Execute(Port);

                if (_errorCode != (short)GeneralError.Success)
                {
                    CancelDocument();
                }
            });
        }
Exemple #7
0
        // продолжение печати
        private bool ContinuePrint()
        {
            POSCommand Cmd = new POSCommand(405);  // повтор команды

            Cmd.AddChar(OPERATOR_PASSWD, 4);       // пароль
            _errorCode = Cmd.Execute(Port);
            return(_errorCode == (short)GeneralError.Success);
        }
Exemple #8
0
        // отмена документа
        private short CancelDocument()
        {
            POSCommand Cmd = new POSCommand(216);  // Отменить документ

            Cmd.AddChar(OPERATOR_PASSWD, 4);       // пароль

            return(Cmd.Execute(Port));
        }
Exemple #9
0
        protected override void OnPrintBarcode(string barcode, AlignOptions align,
                                               bool readable)
        {
            ExecuteDriverCommand(delegate()
            {
                _errorCode = (short)GeneralError.Success;

                byte[] nPrintBuffer = new byte[256];
                int BufSize         = 0;

                // позиционирование по центру
                nPrintBuffer[BufSize++] = 0x1B;
                nPrintBuffer[BufSize++] = Convert.ToByte('a');
                nPrintBuffer[BufSize++] = 1;

                // высота штрих-кода
                nPrintBuffer[BufSize++] = 0x1D;
                nPrintBuffer[BufSize++] = Convert.ToByte('h');
                nPrintBuffer[BufSize++] = 70;

                // ширина кода
                nPrintBuffer[BufSize++] = 0x1D;
                nPrintBuffer[BufSize++] = Convert.ToByte('w');
                nPrintBuffer[BufSize++] = 2;

                // цифры
                nPrintBuffer[BufSize++] = 0x1D;
                nPrintBuffer[BufSize++] = Convert.ToByte('H');
                if (readable)
                {
                    nPrintBuffer[BufSize++] = 2;
                }
                else
                {
                    nPrintBuffer[BufSize++] = 0;
                }

                // штрих-код
                nPrintBuffer[BufSize++] = 0x1D;
                nPrintBuffer[BufSize++] = Convert.ToByte('k');
                nPrintBuffer[BufSize++] = 0x43;
                nPrintBuffer[BufSize++] = 0x0C;

                POSCommand cmd = new POSCommand(237);
                cmd.AddChar(OPERATOR_PASSWD, 4);                                            // пароль
                cmd.AddNumeric(0, 1);                                                       // устройство
                cmd.AddBChar(Encoding.ASCII.GetString(nPrintBuffer, 0, BufSize) + barcode); // данные

                _errorCode = cmd.Execute(Port);

                if (_errorCode != (short)GeneralError.Success)
                {
                    CancelDocument();
                }
            });
        }
Exemple #10
0
        // установка сообщений
        private bool SetConst()
        {
            POSCommand Cmd = new POSCommand(231);

            Cmd.AddChar(OPERATOR_PASSWD, 4);
            Cmd.AddNumeric(5, 2);
            Cmd.AddBChar("НЕФИСКАЛЬНЫЙ ДОКУМЕНТ");
            _errorCode = Cmd.Execute(Port);
            return(_errorCode == (short)GeneralError.Success);
        }
Exemple #11
0
        protected override void OnOpenDrawer()
        {
            ExecuteDriverCommand(delegate()
            {
                _errorCode = (short)GeneralError.Success;

                POSCommand cmd = new POSCommand(236);
                cmd.AddChar(OPERATOR_PASSWD, 4);
                cmd.AddNumeric(0, 1);
                _errorCode = cmd.Execute(Port);
            });
        }
Exemple #12
0
        protected override void OnOpenDocument(DocumentType docType, string cashierName, string cashierInn, string customerPhoneOrEmail)
        {
            ExecuteDriverCommand(delegate()
            {
                _errorCode = (short)GeneralError.Success;

                if (PrinterStatus.OpenedDocument)
                {
                    _errorCode = CancelDocument();
                }

                m_CurrentDocType = docType;
                POSCommand cmd   = new POSCommand(205);
                cmd.AddChar(OPERATOR_PASSWD, 4);
                switch (docType)
                {
                case DocumentType.Sale:
                    cmd.AddNumeric(0, 2);
                    break;

                case DocumentType.Refund:
                    cmd.AddNumeric(1, 2);
                    break;

                case DocumentType.PayingIn:
                    cmd.AddNumeric(2, 2);
                    break;

                case DocumentType.PayingOut:
                    cmd.AddNumeric(3, 2);
                    break;

                case DocumentType.Other:
                    cmd.AddNumeric(4, 2);
                    break;

                case DocumentType.XReport:
                case DocumentType.ZReport:
                case DocumentType.SectionsReport:
                    //                        m_nErrorCode = PrintReport(docType);
                    return;
                }

                cmd.AddBChar(cashierName);  // имя оператора
                cmd.AddNumeric(13, 2);      // код оператора
                cmd.AddBChar("");           // отдел
                cmd.AddBChar("");           // подотдел

                byte[] nRsp = new byte[5];
                _errorCode  = cmd.Execute(Port, nRsp);
            });
        }
Exemple #13
0
        protected override void OnCash(uint amount)
        {
            ExecuteDriverCommand(delegate()
            {
                _errorCode = (short)GeneralError.Success;

                POSCommand Cmd = new POSCommand(214);   // внести сумму
                Cmd.AddChar(OPERATOR_PASSWD, 4);        // пароль
                Cmd.AddNumeric(0, 2);                   // тип оплаты
                Cmd.AddNumeric((int)amount, 10);        // сумма

                byte[] nRsp = new byte[11];
                _errorCode  = Cmd.Execute(Port, nRsp);
                if (_errorCode != (short)GeneralError.Success)
                {
                    CancelDocument();
                }
            });
        }
Exemple #14
0
        // установка подвала документа
        private bool SetDocumentFooter()
        {
            if (DocumentFooter == null)
            {
                return(true);
            }

            POSCommand Cmd = null;

            // очистка подвала
            Cmd = new POSCommand(233);
            Cmd.AddChar(OPERATOR_PASSWD, 4);
            _errorCode = Cmd.Execute(Port);
            if (_errorCode != (short)GeneralError.Success)
            {
                return(false);
            }

            // установка строк подвала
            for (int i = 0; i < DocumentFooter.Length; i++)
            {
                Cmd = new POSCommand(234);   // установить строку подвала
                Cmd.AddChar(OPERATOR_PASSWD, 4);
                Cmd.AddNumeric(i + 1, 2);
                Cmd.AddNumeric(1, 2);
                if (DocumentFooter[i].Length > MAX_STRING_LEN)
                {
                    Cmd.AddBChar(DocumentFooter[i].Substring(0, MAX_STRING_LEN));
                }
                else
                {
                    Cmd.AddBChar(DocumentFooter[i]);
                }
                _errorCode = Cmd.Execute(Port);

                if (_errorCode != (short)GeneralError.Success)
                {
                    break;
                }
            }

            return(_errorCode == (short)GeneralError.Success);
        }
Exemple #15
0
        // печать отчетов
        private short PrintReport(DocumentType docType)
        {
            POSCommand Cmd = null;

            switch (docType)
            {
            case DocumentType.XReport:
            case DocumentType.SectionsReport:
                Cmd = new POSCommand(218);
                Cmd.AddChar(OPERATOR_PASSWD, 4);
                break;

            case DocumentType.ZReport:
                Cmd = new POSCommand(204);
                Cmd.AddChar(OPERATOR_PASSWD, 4);
                Cmd.AddNumeric(1, 2);
                break;
            }

            return(Cmd.Execute(Port));
        }
Exemple #16
0
        public override void GetLifetime(out DateTime firstDate, out DateTime lastDate, out int firstShift, out int lastShift)
        {
            firstDate  = new DateTime();
            lastDate   = new DateTime();
            firstShift = 0;
            lastShift  = 0;

            DateTime _firstDate  = firstDate;
            DateTime _lastDate   = lastDate;
            int      _firstShift = firstShift;
            int      _lastShift  = lastShift;

            ExecuteDriverCommand(delegate()
            {
                _errorCode = (short)GeneralError.Success;

                POSCommand Cmd = new POSCommand(106);   // получить номер последней закрытой смены
                Cmd.AddChar(OPERATOR_PASSWD, 4);
                byte[] Rsp = new byte[4];
                _errorCode = Cmd.Execute(Port, Rsp);
                if (_errorCode != (short)GeneralError.Success)
                {
                    return;
                }

                _firstShift = 1;
                _lastShift  = Convert.ToInt32(Encoding.ASCII.GetString(Rsp, 0, 4));

                Cmd = new POSCommand(109);              // получить данные о первой закрытой смене
                Cmd.AddChar(OPERATOR_PASSWD, 4);
                Cmd.AddNumeric(_firstShift, 4);

                Rsp        = new byte[24];
                _errorCode = Cmd.Execute(Port, Rsp);
                if (_errorCode != (short)GeneralError.Success)
                {
                    return;
                }

                _firstDate = new DateTime(
                    Convert.ToInt32(Encoding.ASCII.GetString(Rsp, 4 + 4, 4)),
                    Convert.ToInt32(Encoding.ASCII.GetString(Rsp, 4 + 2, 2)),
                    Convert.ToInt32(Encoding.ASCII.GetString(Rsp, 4 + 0, 2))
                    );

                Cmd = new POSCommand(109);              // получить данные о последней закрытой смене
                Cmd.AddChar(OPERATOR_PASSWD, 4);
                Cmd.AddNumeric(_lastShift, 4);

                Rsp        = new byte[24];
                _errorCode = Cmd.Execute(Port, Rsp);
                if (_errorCode != (short)GeneralError.Success)
                {
                    return;
                }

                _lastDate = new DateTime(
                    Convert.ToInt32(Encoding.ASCII.GetString(Rsp, 4 + 4, 4)),
                    Convert.ToInt32(Encoding.ASCII.GetString(Rsp, 4 + 2, 2)),
                    Convert.ToInt32(Encoding.ASCII.GetString(Rsp, 4 + 0, 2)));
            });

            firstDate  = _firstDate;
            lastDate   = _lastDate;
            firstShift = _firstShift;
            lastShift  = _lastShift;
        }