Exemplo n.º 1
0
        private void directPayment(int moneyType, bool returnSale)
        {
            ComboBoxItem selectedItem      = (ComboBoxItem)section.SelectedItem;
            string       department_string = selectedItem.Tag.ToString();
            int          department        = int.Parse(department_string);

            decimal price = DocPack.manualParseDecimal(priceForDirectPayment.Text);
            decimal summ  = DocPack.manualParseDecimal(moneyForDirectPayment.Text);

            string sendingSMSorEMAIL = directPaymentSending.Text;

            string printing = stringForPrinting.Text;
            bool   vat      = vatDirectPayment.IsChecked ?? true;

            string[] result = Cashbox.DirectPayment(
                moneyPrice: price, moneySumm: summ, forPrinting: printing, sending: sendingSMSorEMAIL,
                department: department, moneyType: moneyType, returnSale: returnSale, VAT: vat
                ).Split(':');

            if (result[0] == "OK")
            {
                CleanCheck();
                MessageBoxes.ChangeMessage(result[1]);
            }
            else
            {
                ShowError(moneyPlace, "Ошибка кассы: " + result[1]);
            }
        }
Exemplo n.º 2
0
        private void AddedNonPricedService(TextBox field, string service)
        {
            decimal summ = DocPack.manualParseDecimal(field.Text);

            if (summ > 0)
            {
                ManualDocPack.AddService(service + "=" + summ.ToString());
            }
        }
Exemplo n.º 3
0
        public bool CashOutcome(string summ)
        {
            PrepareDriver();

            atolDriver.setParam(Constants.LIBFPTR_PARAM_SUM, (uint)DocPack.manualParseDecimal(summ));
            atolDriver.cashOutcome();

            Log.AddWithCode("выплата денег (" + summ + ")");

            return(atolDriver.printText() < 0 ? false : true);
        }
Exemplo n.º 4
0
        public bool CashOutcome(string summ)
        {
            PrepareDriver();

            Driver.Summ1 = DocPack.manualParseDecimal(summ);
            Driver.CashOutcome();

            Log.AddWithCode("выплата денег (" + summ + ")");

            return(Driver.ResultCode == 0 ? true : false);
        }
Exemplo n.º 5
0
        private void printMoneyDirectPayment_Click(object sender, RoutedEventArgs e)
        {
            decimal summ = DocPack.manualParseDecimal(moneyForDirectPayment.Text);

            if (CheckMoneyFail(summ))
            {
                return;
            }

            directPayment(moneyType: 1, returnSale: false);
        }
Exemplo n.º 6
0
        static public void ShowReceiptContent(DocPack doc)
        {
            string receipt = String.Empty;

            foreach (Service service in doc.Services)
            {
                decimal sum = service.Price * service.Quantity;
                receipt += service.Name + "\n" + service.Price + " x " + service.Quantity + " = " + sum + "\n\n";
            }

            receipt += "\nИТОГО: " + doc.Total.ToString() + "\n";

            MessageBoxResult msg = MessageBox.Show(
                receipt, "Чек", MessageBoxButton.OK, MessageBoxImage.Information
                );
        }
Exemplo n.º 7
0
        private void printCheckMoney_Click(object sender, RoutedEventArgs e)
        {
            decimal money = DocPack.manualParseDecimal(moneyForCheck.Text);

            string sending = printSending.Text;

            if (CheckMoneyFail(money) || CheckAnotherDateFail(returnDate.Text))
            {
                return;
            }

            string[] result = Cashbox.PrintDocPack(
                Cashbox.manDocPackForPrinting, MoneyType: 1, MoneySumm: money, sendingAddress: sending
                ).Split(':');

            CheckError(result, checkPlace);
        }
Exemplo n.º 8
0
        private void printRCheckMoney_Click(object sender, RoutedEventArgs e)
        {
            decimal money = DocPack.manualParseDecimal(moneyForRCheck.Text);

            if (CheckMoneyFail(money))
            {
                return;
            }

            string[] result = Cashbox.PrintDocPack(
                Cashbox.manDocPackForPrinting, MoneyType: 1, MoneySumm: money
                ).Split(':');

            CheckError(result, receptionPlace);

            if (result[0] == "OK")
            {
                CleanCheck();
            }
        }
Exemplo n.º 9
0
        public static void AddDocPack(DocPack docForLog)
        {
            XmlSerializer DocPackLog = new XmlSerializer(typeof(DocPack));

            try
            {
                LogDirectory();

                string logFileName = UPDATE_LOGS_DIR + "\\interceptor-doc.log";

                using (StreamWriter sw = new StreamWriter(logFileName, true))
                {
                    WriteLine(sw);
                    WriteLine(sw, date: true);
                    WriteLine(sw);
                    DocPackLog.Serialize(sw, docForLog);
                    WriteLine(sw);
                }
            }
            finally
            {
                // nothing to do here
            }
        }
Exemplo n.º 10
0
        public string PrintDocPack(DocPack doc, int MoneyType = -1,
                                   bool returnSale            = false, decimal?MoneySumm = null, string sendingAddress = "")
        {
            currentDrvPassword = doc.CashierPass;
            currentDocPack     = doc.AgrNumber;

            if (cancelOpenReceipt)
            {
                cancelOpenReceipt = false;

                if (!atolDriver.getParamBool(Constants.LIBFPTR_PARAM_DOCUMENT_CLOSED))
                {
                    atolDriver.cancelReceipt();
                    Log.AddWithCode("поздняя отмена документа");
                }
            }

            if (MoneyType != -1)
            {
                doc.MoneyType = MoneyType;
            }

            PrepareDriver();

            double SELL_OR_RETURN = (returnSale ? Constants.LIBFPTR_RT_SELL_RETURN : Constants.LIBFPTR_RT_SELL);

            atolDriver.setParam(Constants.LIBFPTR_PARAM_RECEIPT_TYPE, SELL_OR_RETURN);

            atolDriver.openReceipt();

            Log.AddWithCode("открытие чека");

            string sendingCheck = String.Empty;

            if (!String.IsNullOrEmpty(sendingAddress))
            {
                sendingCheck = sendingAddress;
            }
            else if (!String.IsNullOrEmpty(doc.Mobile))
            {
                sendingCheck = doc.Mobile;
            }
            else if (!String.IsNullOrEmpty(doc.Email))
            {
                sendingCheck = doc.Email;
            }

            if (!String.IsNullOrEmpty(sendingCheck))
            {
                Log.Add("отправка СМС/email на адрес: " + sendingCheck);
                atolDriver.setParam(1008, sendingCheck);
            }

            PrintLine("Кассир: " + CRM.cashier, line: true);

            if (doc.Region)
            {
                PrintLine("Договор:" + doc.AgrNumber);
                PrintLine("BankID:" + doc.BankID, line: true);
            }

            foreach (Service service in doc.Services)
            {
                PrepareDriver();

                double VAT = (service.VAT == 1 ? Constants.LIBFPTR_TAX_VAT20 : Constants.LIBFPTR_TAX_NO);
                atolDriver.setParam(Constants.LIBFPTR_PARAM_TAX_TYPE, VAT);

                atolDriver.setParam(Constants.LIBFPTR_PARAM_DEPARTMENT, service.Department);
                atolDriver.setParam(Constants.LIBFPTR_PARAM_COMMODITY_NAME, service.Name);
                atolDriver.setParam(Constants.LIBFPTR_PARAM_PRICE, (double)service.Price);
                atolDriver.setParam(Constants.LIBFPTR_PARAM_QUANTITY, service.Quantity);
                atolDriver.setParam(Constants.LIBFPTR_PARAM_COMMODITY_PIECE, 1);
                atolDriver.registration();

                PrintLine(line: true);
            }

            PrepareDriver();

            atolDriver.setParam(Constants.LIBFPTR_PARAM_PAYMENT_SUM, (double)(MoneySumm ?? doc.Money));

            if (doc.MoneyType == 1)
            {
                Log.Add("тип оплаты: наличными");

                atolDriver.setParam(Constants.LIBFPTR_PARAM_PAYMENT_TYPE, Constants.LIBFPTR_PT_CASH);
            }
            else
            {
                Log.Add("тип оплаты: безнал");

                atolDriver.setParam(Constants.LIBFPTR_PARAM_PAYMENT_TYPE, Constants.LIBFPTR_PT_ELECTRONICALLY);
            }
            atolDriver.payment();

            atolDriver.setParam(Constants.LIBFPTR_PARAM_DATA_TYPE, Constants.LIBFPTR_DT_RECEIPT_STATE);
            atolDriver.queryData();

            double change = atolDriver.getParamDouble(Constants.LIBFPTR_PARAM_CHANGE);

            atolDriver.closeReceipt();

            Log.AddWithCode("распечатка чека");

            while (atolDriver.checkDocumentClosed() < 0)
            {
                Log.AddWithCode("проверка статуса чека");
                return("ERR2:Не удалось проверить - " + atolDriver.errorDescription());
            }

            if (!atolDriver.getParamBool(Constants.LIBFPTR_PARAM_DOCUMENT_CLOSED))
            {
                Log.Add("документ не закрылся");
                atolDriver.cancelReceipt();
                Log.AddWithCode("отмена чека");

                if (atolDriver.errorCode() != 0)
                {
                    cancelOpenReceipt = true;
                }

                return("ERR2:Документ не закрылся - " + atolDriver.errorDescription());
            }

            string fdForRegion = String.Empty;

            if (doc.Region)
            {
                atolDriver.setParam(Constants.LIBFPTR_PARAM_FN_DATA_TYPE, Constants.LIBFPTR_FNDT_LAST_RECEIPT);
                atolDriver.fnQueryData();
                fdForRegion = ":" + atolDriver.getParamInt(Constants.LIBFPTR_PARAM_DOCUMENT_NUMBER).ToString();
            }

            if (!atolDriver.getParamBool(Constants.LIBFPTR_PARAM_DOCUMENT_PRINTED))
            {
                while (atolDriver.continuePrint() < 0)
                {
                    Log.AddWithCode("чек не удалось допечатать");

                    int errCode = (doc.Region ? 5 : 2);

                    return("ERR" + errCode.ToString() + ":Не удалось допечатать - " + atolDriver.errorDescription() + fdForRegion);
                }
            }

            if (!MainWindow.TEST_VERSION && !doc.Region)
            {
                RepeatPrint(null, null);
            }

            return("OK:" + change.ToString() + fdForRegion);
        }
Exemplo n.º 11
0
        public string PrintDocPack(DocPack doc, int MoneyType = -1,
                                   bool returnSale            = false, decimal?MoneySumm = null, string sendingAddress = "")
        {
            currentDrvPassword = doc.CashierPass;
            currentDocPack     = doc.AgrNumber;

            if (MoneyType != -1)
            {
                doc.MoneyType = MoneyType;
            }

            if (doc.Services.Count > 0 && doc.Services[0].ReturnShipping == 1)
            {
                returnSale = true;
            }

            PrepareDriver(currentDrvPassword);
            Driver.CheckType = (returnSale ? 2 : 0);

            Driver.OpenCheck();

            string sendingCheck = String.Empty;

            if (!String.IsNullOrEmpty(sendingAddress))
            {
                sendingCheck = sendingAddress;
            }
            else if (!String.IsNullOrEmpty(doc.Mobile))
            {
                sendingCheck = doc.Mobile;
            }
            else if (!String.IsNullOrEmpty(doc.Email))
            {
                sendingCheck = doc.Email;
            }

            if (!String.IsNullOrEmpty(sendingCheck))
            {
                Driver.CustomerEmail = sendingCheck;
                Driver.FNSendCustomerEmail();
            }

            PrintLine("Кассир: " + CRM.cashier, line: true);

            if (doc.Region)
            {
                PrintLine("Договор: " + doc.AgrNumber);
                PrintLine("BankID : " + doc.BankID, line: true);
            }


            foreach (Service service in doc.Services)
            {
                Driver.Password = currentDrvPassword;
                Driver.Timeout  = timeout;

                Driver.Quantity          = service.Quantity;
                Driver.Price             = service.Price;
                Driver.StringForPrinting = service.Name;

                Driver.Department = service.Department;

                Driver.Tax1 = service.VAT;
                Driver.Tax2 = 0;
                Driver.Tax3 = 0;
                Driver.Tax4 = 0;

                if (returnSale)
                {
                    Driver.ReturnSale();
                }
                else
                {
                    Driver.Sale();
                }

                PrintLine(line: true);
            }

            PrepareDriver(currentDrvPassword);

            Driver.StringForPrinting = String.Empty;

            if (doc.MoneyType == 1)
            {
                Log.Add("тип оплаты: наличными");

                Driver.Summ1 = MoneySumm ?? doc.Money;
                Driver.Summ2 = 0;
            }
            else
            {
                Log.Add("тип оплаты: безнал (реальный: " + doc.MoneyType.ToString() + ")");

                Driver.Summ2 = MoneySumm ?? doc.Money;
                Driver.Summ1 = 0;
            }

            Driver.CloseCheck();

            int    checkClosingResult    = Driver.ResultCode;
            string checkClosingErrorText = Driver.ResultCodeDescription;

            Log.AddWithCode("распечатка чека");

            if (checkClosingResult != 0)
            {
                PrepareDriver(currentDrvPassword);

                Driver.CancelCheck();

                Log.AddWithCode("отмена чека");
            }
            else if (!MainWindow.TEST_VERSION && !doc.Region)
            {
                repeatPrintingTimer.Enabled = true;
                repeatPrintingTimer.Start();
            }

            if (checkClosingResult == 0)
            {
                return("OK:" + Driver.Change);
            }
            else
            {
                CRM.SendError(checkClosingErrorText, doc.AgrNumber);

                return("ERR2:" + checkClosingErrorText);
            }
        }
Exemplo n.º 12
0
        public static string PrintReceipt(string appDataString, DocPack doc)
        {
            string[] appData = appDataString.Split('|');

            decimal[] receptionServices = { 0, 0, 0, 0, 0 };

            if (appData[0] != "OK")
            {
                Log.AddWeb("Ошибка вернувшихся данных записи");
                return("Ошибка вернувшихся данных записи");
            }

            int receiptIndex = int.Parse(appData[5]) + 1;

            if (!Directory.Exists(RECEIPT_DIR))
            {
                Directory.CreateDirectory(RECEIPT_DIR);
            }

            string fileName = RECEIPT_DIR + "\\" + appData[2] + "_D_" + receiptIndex.ToString() + ".pdf";

            document = new Document();
            FileStream fs     = new FileStream(fileName, FileMode.Create, FileAccess.Write);
            PdfWriter  writer = PdfWriter.GetInstance(document, fs);

            document.Open();

            cb = writer.DirectContent;

            BaseFont bf = BaseFont.CreateFont("FONT.TTF", Encoding.GetEncoding(1251).BodyName, BaseFont.NOT_EMBEDDED);

            cb.SetColorFill(BaseColor.BLACK);
            cb.SetFontAndSize(bf, 10);

            string actNum = AppNumber(appData[2]) + "/ДОП" + receiptIndex.ToString();

            for (int i = 0; i < 2; i++)
            {
                if (i > 0)
                {
                    AddText();
                    AddText();
                    AddText(
                        "- - - - - - - - - - - - - - - - - - - - - - - -" +
                        " линия отрыва " +
                        "- - - - - - - - - - - - - - - - - - - - - - -" +
                        " линия отрыва " +
                        "- - - - - - - - - - - - - - - - - - - - - - -"
                        );
                    AddText();
                    AddText();

                    CURRENT_ROW = 0;
                }

                AddTitle("Акт N " + actNum);
                AddTitle("выполненных работ на дополнительные услуги");

                AddText("г.Москва");
                AddText(DateTime.Now.ToString("dd MMMM yyyy"), x: 500, y: CurrentY(), noNewLine: true);

                AddText();

                AddText("Заявитель: " + appData[1] + " (номер записи " + AppNumber(appData[2]) + ")");
                AddText("Исполнитель: ");

                AddText("Оказаны следующие виды работ:");

                AddRow("", "", "", "", "Цена", "Сумма", header: true, aligment: 1);
                AddRow("    " + "п/п", "Наименование работы(услуги)", "Ед.изм.", "Кол-во", "(с учетом", "(с учетом", withBox: false, header: true, aligment: 1);
                AddRow("", "", "", "", "НДС 20%), руб", "НДС 20%), руб", withBox: false, header: true, aligment: 1);

                foreach (Service service in doc.Services)
                {
                    decimal total = service.Price * service.Quantity;

                    AddRow("N", service.Name, "шт", service.Quantity.ToString(),
                           service.Price.ToString() + ".00", total.ToString() + ".00");
                }

                AddText();
                AddText("ИТОГО : " + MainWindow.Cashbox.manDocPackSumm + " руб 00 коп", x: 450, y: CurrentY(), noNewLine: true);

                AddText("Услуги оказаны в полном объеме и в срок.");
                AddText("Услуги оплачены Заказчиком в сумме: " + appData[3].ToLower());
                AddText("в т.ч. НДС 20% " + appData[4].ToLower());
                AddText("Стороны друг к другу претензий не имеют.");

                AddText();
                AddText();
                AddText("Подписи сторон:");

                AddText();
                AddText(
                    "Исполнитель: _______________ / __________________ /"
                    + "       " +
                    "заказчик: _______________ / " + appData[1] + " /"
                    );

                AddText();
                AddText("(ФИО)", x: 175, y: CurrentY(), noNewLine: true);
                AddText("(ФИО)", x: 415, y: CurrentY(), noNewLine: true);
                AddText("М.П.");
            }


            document.Close();
            fs.Close();
            writer.Close();

            System.Diagnostics.Process.Start(fileName);

            CURRENT_LINE = 0;
            CURRENT_ROW  = 0;

            Log.Add("Сформирован акт " + fileName);

            foreach (Service service in doc.Services)
            {
                decimal total = service.Price * service.Quantity;

                if (service.ReceptionID > 0)
                {
                    receptionServices[service.ReceptionID] += total;
                }
            }

            CRM.SendFile(
                pathToFile: fileName,
                appID: appData[6],
                actNum: actNum,
                xerox: receptionServices[1].ToString(),
                form: receptionServices[2].ToString(),
                print: receptionServices[3].ToString(),
                photo: receptionServices[4].ToString()
                );

            return(String.Empty);
        }
Exemplo n.º 13
0
        public static string ResponsePrepare(string request, bool empty, string clientIP)
        {
            string err = String.Empty;

            if (empty)
            {
                Log.Add("пустой запрос с " + clientIP);
                CRM.SendError("Пустой запрос с " + clientIP);

                return("403");
            }
            else if (!CheckRequest.CheckValidRequest(request))
            {
                Log.Add("невалидный запрос " + clientIP);
                CRM.SendError("Невалидный запрос с " + clientIP);

                return("404");
            }

            if (!CheckRequest.CheckLoginInRequest(request, out err))
            {
                Log.Add("конфликт логинов: " + err);
                CRM.SendError("Конфликт логинов: " + err);

                return("ERR3:Кассовая программа запущена пользователем " + CRM.currentLogin);
            }

            if (CheckRequest.CheckConnection(request))
            {
                Log.Add("бип-тест подключения к кассе");

                string testResult = Diagnostics.MakeBeepTest();

                return(testResult);
            }

            if (!CheckRequest.CheckXml(request))
            {
                Log.Add("CRC ошибочна, возвращаем ошибку данных");
                CRM.SendError("CRC ошибка");

                return("ERR1:Ошибка переданных данных");
            }
            else
            {
                Log.Add("CRC запроса корректна, логин соответствует");

                DocPack docPack = new DocPack();

                docPack.DocPackFromXML(request);

                if (!String.IsNullOrWhiteSpace(docPack.AgrNumber))
                {
                    Log.Add("номер договора: " + docPack.AgrNumber);
                }

                MainWindow.Cashbox.manDocPackForPrinting = docPack;

                if (docPack.RequestOnly == 1)
                {
                    MainWindow.Cashbox.manDocPackSumm = docPack.Total;

                    ShowTotal(docPack.Total.ToString());

                    return("OK:Callback запрос получен");
                }
                else
                {
                    return(MainWindow.Cashbox.PrintDocPack(docPack));
                }
            }
        }