예제 #1
0
        static internal void ZeroPlastNum()
        {
            FiskInfo Fi = ReadFiskInfo();

            Fi.CardTransID = 0;
            WriteFiskInfo(Fi);
        }
예제 #2
0
        static internal void InkreasePlastNum()
        {
            FiskInfo Fi = ReadFiskInfo();

            Fi.CardTransID++;
            WriteFiskInfo(Fi);
        }
예제 #3
0
        static internal void WriteFiskInfo(FiskInfo Fi)
        {
            try
            {
                XmlWriter XWriter = new XmlTextWriter(FileName, System.Text.Encoding.UTF8);

                //CardMooverInfoSerializer.CardMooverInfoSerializer.CardMooverInfoSerializer.CardMooverInfoSerializer.XmlSerializer XS = new XmlSerializer(typeof(CardMooverInfo));
                XmlSerializer XS = new XmlSerializer(typeof(FiskInfo));
                //FiskInfo CDI = new FiskInfo();
                //CDI.FiskNum = CurentNum;И

                XS.Serialize(XWriter, Fi);
                XWriter.Close();
            }
            catch
            { }
        }
예제 #4
0
        static public void SverkaWithQ()
        {
            QSverkaForm F1 = new QSverkaForm();

            F1.ShowDialog();
            if (!F1.IsGood)
            {
                return;
            }
            else
            {
                if (Sverka())
                {
                    PDiscountCard.CloseCheck.ZeroPlastNum();
                    FiskInfo fi = PDiscountCard.CloseCheck.ReadFiskInfo();
                    fi.NeedSverka = false;
                    PDiscountCard.CloseCheck.WriteFiskInfo(fi);
                }
            }
        }
예제 #5
0
        static internal FiskInfo ReadFiskInfo()
        {
            if (!File.Exists(FileName))
            {
                return(new FiskInfo
                {
                    ZIsPrinting = false,
                    BoundRate = 6,
                    FiskNum = "0",
                    PortNum = 1
                });
            }
            XmlReader XR = new XmlTextReader(FileName);

            try
            {
                //ToLog("[ReadVisitsFromFile] Читаю из файла " + Fi.FullName + "информацию о карте");

                XmlSerializer XS = new XmlSerializer(typeof(FiskInfo));
                //XmlSerializer XS = new XmlSerializer(typeof(CardMooverInfo));
                FiskInfo CMI = (FiskInfo)XS.Deserialize(XR);
                XR.Close();
                return
                    (CMI);
            }
            catch
            {
                XR.Close();
                return(new FiskInfo
                {
                    ZIsPrinting = false,
                    BoundRate = 6,
                    FiskNum = "0",
                    PortNum = 1
                });
            }
        }
예제 #6
0
        internal static void ApplyCardPayment(int ManagerId, int EmployeeId, int QueueId, int TableId, int CheckId, int TenderId, int PaymentId)
        {
            if ((TenderId == 20) && (EmployeeId != iniFile.RemoteCloseEmployee))
            {
                if (MainClass.ComApplyPayment)
                {
                    Utils.ToLog("MainClass.ComApplyPayment return");
                    MainClass.ComApplyPayment = false;
                    return;
                }
                if ((!iniFile.TRPOSXEnables) && (!iniFile.ArcusEnabled))
                {
                    return;
                }


                Utils.ToLog("Создаю форму вопроса безналичной оплаты");

                FTermonalSelect M3 = new FTermonalSelect();
                M3.ShowDialog();
                if (M3.Cancel)
                {
                    M3.Dispose();
                    return;
                }
                M3.Dispose();

                if (MainClass.IsWiFi == 2)
                {
                    return;
                }


                if (MainClass.PlasticTransactionInProcess)
                {
                    MF2 MesFrm = new MF2("Предыдущая транзакция еще не завершена.");
                    MesFrm.button1.Visible = false;
                    MesFrm.button3.Visible = false;
                    MesFrm.button2.Text    = "Ок";
                    MesFrm.ShowDialog();
                }
                else
                {
                    MainClass.PlasticTransactionInProcess = true;
                    // string Resp = "";
                    // string Rcp = "";
                    // string RespMes = "";
                    FiskInfo fi = PDiscountCard.CloseCheck.ReadFiskInfo();
                    bool     AllChecksOnTable = false;

                    {
                        //  ToShtrih.GetPrinterStatus();
                        //Check Ch = AlohaTSClass.GetCheckById(CheckId);

                        Utils.ToLog("Безналичная оплата. Читаю параметры чека № " + CheckId + " Попытка 1", 2);
                        Check Ch = AlohaTSClass.GetCheckById(CheckId);
                        if (Ch == null)
                        {
                            Thread.Sleep(500);
                            Utils.ToLog("Безналичная оплата. Читаю параметры чека № " + CheckId + " Попытка 2", 2);
                            AlohaTSClass.InitAlohaCom();
                            Ch = AlohaTSClass.GetCheckById(CheckId);
                            if (Ch == null)
                            {
                                Thread.Sleep(500);
                                Utils.ToLog("Безналичная оплата. Читаю параметры чека № " + CheckId + " Попытка 3", 2);
                                AlohaTSClass.InitAlohaCom();
                                Ch = AlohaTSClass.GetCheckById(CheckId);
                                if (Ch == null)
                                {
                                    Thread.Sleep(500);
                                    Utils.ToLog("Безналичная оплата. Читаю параметры чека № " + CheckId + " Попытка 4", 2);
                                    AlohaTSClass.InitAlohaCom();
                                    Ch = AlohaTSClass.GetCheckById(CheckId);
                                }
                            }
                        }
                        if (Ch == null)
                        {
                            AlohaTSClass.ShowMessage("Не удалось прочитать параметры чека ");
                            Utils.ToLog("Безналичная оплата. Не удалось прочитать параметры чека № " + CheckId, 2);
                            MainClass.PlasticTransactionInProcess = false;
                            return;
                        }

                        if (Ch.ChecksOnTable.Count > 1)
                        {
                            FTwoChecks FT = new FTwoChecks();
                            FT.Init(Ch.ChecksOnTable);
                            FT.ShowDialog();
                            if (FT.Cancel)
                            {
                                FT.Dispose();
                                MainClass.PlasticTransactionInProcess = false;
                                return;
                            }

                            if (FT.Result == 1)
                            {
                                AllChecksOnTable = true;
                            }
                            FT.Dispose();
                        }


                        int LastTr = fi.CardTransID;


                        try
                        {
                            if (iniFile.ArcusEnabled)
                            {
                                Utils.ToCardLog("Arcus. Инициалазирую оплату ");
                                ArcusAlohaIntegrator.RunOper(Ch, LastTr, AllChecksOnTable, fi, PaymentId);
                            }
                            else
                            {
                                Utils.ToCardLog("TrPosX. Инициалазирую оплату ");
                                TrPosXAlohaIntegrator.RunOper(Ch, LastTr, AllChecksOnTable, fi, PaymentId);
                            }
                        }
                        catch (Exception e)
                        {
                            Utils.ToCardLog("[Error]. Инициалазации оплаты " + e.Message);
                        }
                    }
                }
            }
        }
예제 #7
0
        internal static void EOD()
        {
            try
            {
                Utils.ToLog("Закрытие дня");

                //RunExport();

                try
                {
                    if ((iniFile.FRSEnabled) && (iniFile.FRSMaster))
                    {
                        FRSClientApp.FRSClient.ZReport(AlohainiFile.BDate);
                    }

                    if (iniFile.TRPOSXEnables)
                    {
                        if (!TrPosXAlohaIntegrator.Sverka())
                        {
                            FiskInfo fi = PDiscountCard.CloseCheck.ReadFiskInfo();
                            fi.NeedSverka = true;
                            PDiscountCard.CloseCheck.WriteFiskInfo(fi);
                        }
                        else
                        {
                            PDiscountCard.CloseCheck.ZeroPlastNum();
                            FiskInfo fi = PDiscountCard.CloseCheck.ReadFiskInfo();
                            fi.NeedSverka = false;
                            PDiscountCard.CloseCheck.WriteFiskInfo(fi);
                        }
                    }
                    if (iniFile.ArcusEnabled)
                    {
                        if (!ArcusAlohaIntegrator.Sverka())
                        {
                            FiskInfo fi = PDiscountCard.CloseCheck.ReadFiskInfo();
                            fi.NeedSverka = true;
                            PDiscountCard.CloseCheck.WriteFiskInfo(fi);
                        }
                        else
                        {
                            PDiscountCard.CloseCheck.ZeroPlastNum();
                            FiskInfo fi = PDiscountCard.CloseCheck.ReadFiskInfo();
                            fi.NeedSverka = false;
                            PDiscountCard.CloseCheck.WriteFiskInfo(fi);
                        }
                    }

                    /*
                     * if (iniFile.InPasEnabled)
                     * {
                     *  DualConnector.DualConnectorMain.Sverka();
                     * }
                     * */
                    if (CreditCardAlohaIntegration.CreditCardConnectorEnabled)
                    {
                        CreditCardAlohaIntegration.RunSverka();
                    }
                }
                catch (Exception ee)
                {
                    Utils.ToLog(ee.Message);
                }



                do
                {
                    Thread.CurrentThread.Join(3000);
                }while (MainClass.FiskalPrinterIsPrinting);

                string Status = "";

                if (!iniFile.FRSEnabled)
                {
                    Utils.ToLog("!iniFile.FRSEnabled");
                    if (iniFile.FiskalDriverNonShtrih)
                    {
                        Utils.ToLog("iniFile.FiskalDriverNonShtrih");
                        FiskalDrivers.FiskalDriver.PrintZReport();
                        Hamster.HamsterWorker.MoveHamster();
                    }
                    else
                    {
                        if (!Shtrih2.ClosedSmenaInternal(out Status))
                        {
                            //Shtrih2.ZReport();
                            ZReport();
                        }
                        else
                        {
                            Utils.ToLog("Принтер с закрытой сменой. Status :" + Status);
                        }
                    }

                    /*
                     * if (iniFile.FiskalDriverNonShtrihAlohaReport)
                     * {
                     *
                     * }
                     * */
                }

                /*
                 * else
                 * {
                 * if (!Shtrih2.ClosedSmenaInternal(out Status))
                 * {
                 *
                 *  RunFiskalChanger();
                 * }
                 * else
                 * {
                 *  Utils.ToLog("Принтер с закрытой сменой. Status :" + Status);
                 * }
                 * }
                 */
                Shtrih2.ExitFiskalThread();
            }
            catch (Exception e)
            {
                Utils.ToLog(e.Message);
            }
        }
예제 #8
0
        internal static bool RunOper(Check Ch, int LastTr, bool AllChecks, FiskInfo mfi, int PaymentId)
        {
            string  inStr = "";
            decimal Sum   = 0;

            if (AllChecks)
            {
                foreach (Check Ch2 in Ch.ChecksOnTable)
                {
                    if (Ch2.AlohaCheckNum != Ch.AlohaCheckNum)
                    {
                        AlohaTSClass.ApplyCardPayment(Ch2.AlohaCheckNum, Ch2.Summ);
                        AlohaTSClass.SetPaymentAttr(Ch2.AlohaCheckNum, LastTr);
                    }
                    Sum += Ch2.Summ;
                }
            }
            else
            {
                Sum = Ch.Summ;
            }
            Utils.ToCardLog("Arcus Транзакция старт " + inStr);
            try
            {
                if (TrPosXMessageForm != null)
                {
                    TrPosXMessageForm.Close();
                }
            }
            catch (Exception e)
            {
                Utils.ToCardLog("[Error] При попытке закрыть старое окно. " + e.Message);
                try
                {
                    TrPosXMessageForm.Dispose();
                }
                catch
                {}
            }

            TrPosXMessageForm = new FTrposxRunComplited();
            //Button1State = 0;
            TrPosXMessageForm.button2.Text    = "Свернуть";
            TrPosXMessageForm.button1.Visible = false;
            TrPosXMessageForm.button2.Visible = true;
            TrPosXMessageForm.button3.Visible = false;
            TrPosXMessageForm.Init("Операция на терминале пластиковых карт.", "");
            TrPosXMessageForm.button1.Click += new EventHandler(button1_Click);
            TrPosXMessageForm.button2.Click += new EventHandler(button2_Click);

            //TrPosXClass.RunOperationAsinc(inStr);
            if (!Ch.Vozvr)
            {
                ArcusClass.RunPaymentAsinc(Sum);
            }
            else
            {
                ArcusClass.RunVozvrAsinc(Sum);
            }

            TrPosXMessageForm.TopMost = true;
            TrPosXMessageForm.Show();

            return(true);
        }
예제 #9
0
        internal static bool RunOper(Check Ch, int LastTr, bool AllChecks, FiskInfo mfi, int PaymentId)
        {
            if (TrPosXClass.OperInProcess)
            {
                return(false);
            }

            _PaymentId = PaymentId;
            KKmNum     = MainClass.IsWiFi;
            //ToShtrih.Disconnect();
            string  inStr = "";
            decimal Sum   = 0;

            if (AllChecks)
            {
                foreach (Check Ch2 in Ch.ChecksOnTable)
                {
                    if (Ch2.AlohaCheckNum != Ch.AlohaCheckNum)
                    {
                        AlohaTSClass.ApplyCardPayment(Ch2.AlohaCheckNum, Ch2.Summ);
                        AlohaTSClass.SetPaymentAttr(Ch2.AlohaCheckNum, LastTr);
                    }
                    Sum += Ch2.Summ;
                }
            }
            else
            {
                Sum = Ch.Summ;
            }


            if (!Ch.Vozvr)
            {
                string TrNumStr = LastTr.ToString().PadLeft(10, "0"[0]);
                inStr = "MessageID=PUR" + Environment.NewLine +
                        //   inStr = "MessageID=SRV" + Environment.NewLine +
                        "ECRReceiptNumber=" + TrNumStr + Environment.NewLine +
                        "ECRNumber=" + KKmNum + Environment.NewLine +
                        "TransactionAmount=" + (Sum * 100).ToString("0") + Environment.NewLine;
            }
            else
            {
                VF = new VoidFrm(Sum);
                VF.ShowDialog();
                if (VF.Cancel)
                {
                    return(false);
                }
                string chNum = VF.ChNum.ToString().PadLeft(10, "0"[0]);

                inStr = "MessageID=VOI" + Environment.NewLine +
                        "ECRReceiptNumber=" + chNum + Environment.NewLine +
                        "ECRNumber=" + KKmNum + Environment.NewLine;
            }



            Utils.ToCardLog("Транзакция старт " + inStr);



            // TrPosXClass.RunOperationAsincComplited += new TrPosXClass.RunOperationAsincDelegate(TrPosXClass_RunOperationAsincComplited);
            if (TrPosXMessageForm != null)
            {
                TrPosXMessageForm.Close();
            }
            TrPosXMessageForm = new FTrposxRunComplited();
            Button1State      = 0;
            TrPosXMessageForm.button2.Text    = "Свернуть";
            TrPosXMessageForm.button1.Visible = false;
            TrPosXMessageForm.button2.Visible = true;
            TrPosXMessageForm.button3.Visible = false;
            TrPosXMessageForm.Init("Операция на терминале пластиковых карт.", "");
            TrPosXMessageForm.button1.Click += new EventHandler(button1_Click);
            TrPosXMessageForm.button2.Click += new EventHandler(button2_Click);

            TrPosXClass.RunOperationAsinc(inStr);
            TrPosXMessageForm.TopMost = true;
            TrPosXMessageForm.Show();

            return(true);
        }
예제 #10
0
        static internal bool GetCheckColor(Check Ch)
        {
            FiskInfo Fi = ReadFiskInfo();

            if (!Fi.IsMod)
            {
                return(true);
            }

            if (Ch.Vozvr)
            {
                return(true);
            }

            /*
             * if (Ch.Tender!=   TenderType.Cash)
             * {
             *  return true;
             * }
             */
            if (Ch.HasNonCashPayment())
            {
                return(true);
            }

            if ((Ch.TableNumber >= 200) && (Ch.TableNumber <= 240))
            {
                return(true);// FoodFox
            }


            //Shtrih.RegisterNumber = 241;
            // Shtrih.GetCashReg();


            decimal CurentShtrihCash = 5000;

            if (!iniFile.FiskalDriverNonShtrih)
            {
                try
                {
                    Utils.ToLog("CurentShtrihCash S");
                    CurentShtrihCash = Shtrih2.GetCashReg(241);
                    Utils.ToLog("CurentShtrihCash E");
                }
                catch (Exception e)
                {
                    Utils.ToCardLog("[Error] CurentShtrihCash " + e.Message);
                }
            }


            if (CurentShtrihCash < 5000)
            {
                return(true);
            }
            foreach (Dish D in Ch.Dishez)
            {
                if (AlohaTSClass.DishIsTort(D.BarCode))
                {
                    return(true);
                }
            }

            /*
             * if (Ch.CompId != 0)
             * {
             *  return true;
             * }
             */
            if ((Ch.CompId == 8) || (Ch.CompId == 53))
            {
                return(true);
            }


            try
            {
                if (AlohaTSClass.GetVip(Ch.AlohaCheckNum))
                {
                    Utils.ToCardLog("VIP");
                    return(true);
                }
            }
            catch
            {
            }

            try
            {
                int    P     = 0;
                int    V     = 0;
                string DCard = AlohaTSClass.GetDiscountAttr((int)Ch.AlohaCheckNum, out P, out V);
                if (DCard.Length > 4)
                {
                    if (DCard.Substring(0, 3).ToUpper() == "ZAV")
                    {
                        try
                        {
                            string n   = DCard.Substring(3);
                            int    num = Convert.ToInt32(n);
                            if (SuperCardsZAV.Contains(num))
                            {
                                Utils.ToCardLog("card");
                                return(true);
                            }
                        }
                        catch
                        {
                        }
                    }
                }
            }
            catch
            { }

            if (VerifyCheckPercent())
            {
                Utils.ToLog("Hamster");
                return(true);
            }

            /*
             * if (RegWorker.GetRegModType() == 3) //Азарика
             * {
             *  Utils.ToCardLog("ModType3");
             *  if ((DateTime.Now.Hour >= 8) && (DateTime.Now.Hour < 22))
             *
             *  //&& (DateTime.Now.DayOfWeek != DayOfWeek.Saturday) && (DateTime.Now.DayOfWeek != DayOfWeek.Sunday))
             *  {
             *      int P = 0;
             *      int V = 0;
             *      string DCard = AlohaTSClass.GetDiscountAttr((int)Ch.AlohaCheckNum, out P, out V);
             *      if (DCard.Length > 4)
             *      {
             *          if ((DCard.Substring(0, 3).ToUpper() == "ZAV") || (DCard.Substring(0, 3).ToUpper() == "VIP"))
             *          {
             *              return false;
             *          }
             *          else if (Ch.CompId == 2)
             *          {
             *              return false;
             *          }
             *          else
             *          {
             *              return true;
             *          }
             *
             *      }
             *      else if (Ch.CompId == 2)
             *      {
             *          return false;
             *      }
             *      else
             *      {
             *          return true;
             *      }
             *  }
             * }
             *
             */


            if (RegWorker.GetRegModType() == 2)
            {
                if ((DateTime.Now.Hour >= 8) && (DateTime.Now.Hour < 22))

                //&& (DateTime.Now.DayOfWeek != DayOfWeek.Saturday) && (DateTime.Now.DayOfWeek != DayOfWeek.Sunday))
                {
                    Utils.ToCardLog("ModType2");
                    int    P     = 0;
                    int    V     = 0;
                    string DCard = AlohaTSClass.GetDiscountAttr((int)Ch.AlohaCheckNum, out P, out V);
                    if (DCard.Length > 4)
                    {
                        if ((DCard.Substring(0, 3).ToUpper() == "ZAV") || (DCard.Substring(0, 3).ToUpper() == "VIP"))
                        {
                            return(false);
                        }
                        else if (Ch.CompId == 2)
                        {
                            return(false);
                        }
                        else
                        {
                            return(true);
                        }
                    }
                    else if (Ch.CompId == 2)
                    {
                        return(false);
                    }
                    else if (Ch.Summ > 2500)
                    {
                        return(false);
                    }
                    else
                    {
                        return(true);
                    }
                }
            }
            //else
            {
                if ((Ch.CompId == 6) || (Ch.CompId == 54)) //с собой
                {
                    return(false);
                }

                DateTime dt2 = DateTime.Now;
                //  dt2 = AlohaTime(Ch.OpenTimeStr);
                if (dt2 > DateTime.Now)
                {
                    dt2.AddDays(-1);
                }


                if ((Ch.CheckTimeLong < Fi.MaxLong) && (Ch.CheckTimeLong > Fi.MinLong))
                {
                    if ((Ch.Summ < Fi.BigSum) && (Ch.Summ > Fi.LowSum))
                    {
                        //if (Ch.CompId == 0)
                        {
                            Random R = new Random();
                            if (R.Next(1, 100) > Fi.HiPercent)
                            {
                                return(true);
                            }
                        }
                    }
                }
            }

            return(false);
        }