Exemplo n.º 1
0
        public bool changeCashierInfo()
        {
            try
            {
                SqlConn conn       = new SqlConn();
                Cashier cashierOld = conn.selectCashier("cashiers", "cashier_id='" + cashier.cashierId + "'");
                if (cashierOld != null)
                {
                    if (cardInfoString != null)
                    {
                        var     matches = Regex.Matches(cardInfoString, @"([0-9])+");
                        string  cardId  = matches[1].ToString();
                        License license = Server.checkLicenseFile();

                        if (license.licenseCompanyCode.ToString() == matches[0].ToString())
                        {
                            if (Card.licenseCheck(cardInfoString))
                            {
                                List <Pair> parameters = new List <Pair>();
                                if (conn.selectCard("cards", "card_id='" + cardId + "'") == null)
                                {
                                    cashier.cashierCardId = Card.registerCashierCard(cardInfoString, cashier.cashierName.ToString()).cardId;
                                    parameters.Add(new Pair {
                                        key = "FIO", value = cashier.cashierName
                                    });
                                    parameters.Add(new Pair {
                                        key = "card_id", value = cashier.cashierCardId
                                    });
                                    if (conn.update("cashiers", "cashier_id='" + cashier.cashierId + "'", parameters))
                                    {
                                        return(true);
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        List <Pair> parameters = new List <Pair>();
                        if (conn.selectCard("cards", "card_id='" + cashier.cashierCardId + "'") != null)
                        {
                            parameters.Add(new Pair {
                                key = "FIO", value = cashier.cashierName
                            });
                            if (conn.update("cashiers", "cashier_id='" + cashier.cashierId + "'", parameters))
                            {
                                return(true);
                            }
                        }
                    }
                }
                return(false);
            }
            catch
            {
                return(false);
            }
        }
Exemplo n.º 2
0
 public CashierInfo(
     Cashier cashier,
     string cardInfoString,
     Admin admin
     )
 {
     this.cashier        = cashier;
     this.cardInfoString = cardInfoString;
     this.admin          = admin;
 }
Exemplo n.º 3
0
 public LoginInfoResponce(
     Cashier cashier,
     CashierRegister cashierRegister,
     WorkShift workShift,
     bool isWokrShiftStarts
     )
 {
     this.cashier           = cashier;
     this.cashierRegister   = cashierRegister;
     this.workShift         = workShift;
     this.isWokrShiftStarts = isWokrShiftStarts;
 }
Exemplo n.º 4
0
        public WorkShiftReport GetXReport(string cardInfo, string ip, int companyCode)
        {
            try
            {
                WorkShiftReport workShiftReport = new WorkShiftReport();
                loginInfoResponce = new LoginInfoResponce();
                MatchCollection matches = Regex.Matches(cardInfo, @"([0-9])+");
                var             cardId  = matches[1].ToString();
                if (matches.Count > 3)
                {
                    if (Card.licenseCheck(cardInfo))
                    {
                        SqlConn conn        = new SqlConn();
                        Card    currentCard = conn.select("cards", "card_id='" + cardId + "'");
                        if (currentCard != null)
                        {
                            Cashier cashier = conn.selectCashier("cashiers", "card_id='" + currentCard.cardId + "'");
                            if (cashier != null)
                            {
                                CashierRegister cashierRegister = conn.selectCashierRegister("cashierregister", "ip='" + ip + "'");
                                if (cashierRegister.id != null)
                                {
                                    SqlConn sqlConn = new SqlConn();

                                    workShiftReport.workShift = sqlConn.selectWorkShift("work_shifts", "cashier_mashine_id='" + cashierRegister.cashierRegisterId + "' AND is_closed='" + false + "'");
                                    if (workShiftReport.workShift != null && workShiftReport.workShift.id > 0)
                                    {
                                        workShiftReport.workShiftInfos = sqlConn.selectWorkShiftInfos("work_shifts_info", "shift_id='" + workShiftReport.workShift.id + "'");
                                        if (workShiftReport.workShiftInfos.Count > 0 && workShiftReport.workShiftInfos.FindAll(x => x.workShiftId == workShiftReport.workShift.id).Count > 0)
                                        {
                                            return(workShiftReport);
                                        }
                                    }
                                    sqlConn.close();
                                }
                            }
                        }
                    }
                }
                return(null);
            }

            catch (Exception exc)
            {
                Console.WriteLine(exc.ToString());
                logger.Error(exc.ToString());
                return(null);
            }
        }
Exemplo n.º 5
0
 public static bool formClosing(LoginInfo loginInfo, int companyCode)
 {
     if (Card.cashierCheck(loginInfo.cardInfo, loginInfo.IP))
     {
         SqlConn         conn            = new SqlConn();
         CashierRegister cashierRegister = conn.selectCashierRegister("cashierregister", "ip='" + loginInfo.IP + "'");
         if (cashierRegister != null)
         {
             MatchCollection matches     = Regex.Matches(loginInfo.cardInfo, @"([0-9])+");
             var             cardLoginId = matches[1].ToString();
             if (matches.Count > 3)
             {
                 Card currentCard = conn.select("cards", "card_id='" + cardLoginId + "'");
                 if (currentCard != null)
                 {
                     Cashier cashier = conn.selectCashier("cashiers", "card_id='" + currentCard.cardId + "'");
                     if (cashier != null)
                     {
                         List <Pair> parameters = new List <Pair>();
                         parameters.Add(new Pair {
                             key = "cashierregister_id", value = cashierRegister.cashierRegisterId
                         });
                         parameters.Add(new Pair {
                             key = "ip", value = loginInfo.IP
                         });
                         parameters.Add(new Pair {
                             key = "cashier_id", value = cashier.cashierCardId
                         });
                         parameters.Add(new Pair {
                             key = "cashier_name", value = cashier.cashierName
                         });
                         parameters.Add(new Pair {
                             key = "event", value = "exit"
                         });
                         parameters.Add(new Pair {
                             key = "time", value = DateTime.Now
                         });
                         return(conn.insert("cashierregister_event", parameters));
                     }
                 }
             }
         }
     }
     return(false);
 }
Exemplo n.º 6
0
        public WorkShift WithdrawaCash(string cardInfo, string ip, int companyCode)
        {
            try
            {
                WorkShiftReport workShiftReport = new WorkShiftReport();
                loginInfoResponce = new LoginInfoResponce();
                MatchCollection matches = Regex.Matches(cardInfo, @"([0-9])+");
                var             cardId  = matches[1].ToString();
                if (matches.Count > 3)
                {
                    if (Card.licenseCheck(cardInfo))
                    {
                        SqlConn conn        = new SqlConn();
                        Card    currentCard = conn.select("cards", "card_id='" + cardId + "'");
                        if (currentCard != null)
                        {
                            Cashier cashier = conn.selectCashier("cashiers", "card_id='" + currentCard.cardId + "'");
                            if (cashier != null)
                            {
                                CashierRegister cashierRegister = conn.selectCashierRegister("cashierregister", "ip='" + ip + "'");
                                if (cashierRegister.id != null)
                                {
                                    SqlConn sqlConn = new SqlConn();

                                    workShiftReport.workShift = sqlConn.selectWorkShift("work_shifts", "cashier_mashine_id='" + cashierRegister.cashierRegisterId + "' AND is_closed='" + false + "'");
                                    if (workShiftReport.workShift != null && workShiftReport.workShift.id > 0)
                                    {
                                        workShiftReport.workShiftInfos = sqlConn.selectWorkShiftInfos("work_shifts_info", "shift_id='" + workShiftReport.workShift.id + "'");
                                        if (workShiftReport.workShiftInfos.Count > 0 && workShiftReport.workShiftInfos.FindAll(x => x.workShiftId == workShiftReport.workShift.id).Count > 0)
                                        {
                                            List <Pair> parameters = new List <Pair>();
                                            parameters.Add(new Pair("cash_on_hand", 0));
                                            parameters.Add(new Pair("withdrawal", workShiftReport.workShift.cashOnHand + workShiftReport.workShift.withdrawal));
                                            parameters.Add(new Pair("withdrawal_count", ++workShiftReport.workShift.withdrawalCount));

                                            if (sqlConn.update("work_shifts", "id='" + workShiftReport.workShift.id + "' AND cashier_mashine_id='" + cashierRegister.cashierRegisterId + "' AND is_closed='" + false + "'", parameters))
                                            {
                                                WorkShiftInfo workShiftInfo = workShiftReport.workShiftInfos.Find(x => x.cashierId == (int)cashier.cashierId);
                                                parameters = new List <Pair>();
                                                parameters.Add(new Pair("withdrawal", workShiftInfo.withdrawal + workShiftReport.workShift.cashOnHand));
                                                parameters.Add(new Pair("withdrawal_count", ++workShiftInfo.withdrawalCount));
                                                if (sqlConn.update("work_shifts_info", "shift_id='" + workShiftReport.workShift.id + "' AND cashier_id='" + cashier.cashierId + "'", parameters))
                                                {
                                                    parameters = new List <Pair>();
                                                    parameters.Add(new Pair("shift_id", workShiftReport.workShift.id));
                                                    parameters.Add(new Pair("operation", 3));
                                                    parameters.Add(new Pair("date", DateTime.Now));
                                                    parameters.Add(new Pair("cashier_mashine_id", workShiftReport.workShift.cashierMashineId));
                                                    parameters.Add(new Pair("cashier_id", cashier.cashierId));
                                                    parameters.Add(new Pair("cashier_name", cashier.cashierName));
                                                    parameters.Add(new Pair("withdrawal", workShiftReport.workShift.withdrawal + workShiftReport.workShift.cashOnHand));
                                                    parameters.Add(new Pair("contributions", workShiftReport.workShift.contributions));
                                                    parameters.Add(new Pair("revenue", workShiftReport.workShift.revenue));
                                                    parameters.Add(new Pair("cash_on_hand", 0));
                                                    parameters.Add(new Pair("nonnullable_amount", workShiftReport.workShift.nonNullableAmount));
                                                    if (conn.insert("work_shift_transactions", parameters))
                                                    {
                                                        return(sqlConn.selectWorkShift("work_shifts", "cashier_mashine_id='" + cashierRegister.cashierRegisterId + "' AND is_closed='" + false + "'"));
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    sqlConn.close();
                                }
                            }
                        }
                    }
                }
                return(null);
            }

            catch (Exception exc)
            {
                Console.WriteLine(exc.ToString());
                logger.Error(exc.ToString());
                return(null);
            }
        }
Exemplo n.º 7
0
        public LoginInfoResponce ContinueWorkShift(string cardInfo, string ip, int companyCode)
        {
            try
            {
                loginInfoResponce = new LoginInfoResponce();
                MatchCollection matches = Regex.Matches(cardInfo, @"([0-9])+");
                var             cardId  = matches[1].ToString();
                if (matches.Count > 3)
                {
                    if (Card.licenseCheck(cardInfo))
                    {
                        SqlConn conn        = new SqlConn();
                        Card    currentCard = conn.select("cards", "card_id='" + cardId + "'");
                        if (currentCard != null)
                        {
                            Cashier cashier = conn.selectCashier("cashiers", "card_id='" + currentCard.cardId + "'");
                            if (cashier != null)
                            {
                                CashierRegister cashierRegister = conn.selectCashierRegister("cashierregister", "ip='" + ip + "'");
                                if (cashierRegister.id != null)
                                {
                                    this.loginInfoResponce.cashier         = cashier;
                                    this.loginInfoResponce.cashierRegister = cashierRegister;
                                    List <WorkShift>   workShifts         = new List <WorkShift>();
                                    WorkShiftCountInfo workShiftCountInfo = new WorkShiftCountInfo();
                                    workShifts = conn.selectWorkShifts("work_shifts", "cashier_mashine_id='" + cashierRegister.cashierRegisterId + "'");
                                    if (workShifts.Count > 0)
                                    {
                                        foreach (WorkShift workShift in workShifts)
                                        {
                                            workShiftCountInfo.nonNullableAmount += workShift.revenue;
                                            if (workShift.isClosed)
                                            {
                                                workShiftCountInfo.closedWorkShift++;
                                            }
                                            else if (workShift.isClosed != true && workShift.cashierMashineId == (int)cashierRegister.cashierRegisterId)
                                            {
                                                workShiftCountInfo.notClosedWorkShift++;
                                            }
                                        }
                                    }
                                    if (workShiftCountInfo.notClosedWorkShift == 1)
                                    {
                                        loginInfoResponce.workShift = conn.selectWorkShift("work_shifts", "cashier_mashine_id='" + cashierRegister.cashierRegisterId + "' AND is_closed='" + false + "'");
                                        if (loginInfoResponce.workShift != null && loginInfoResponce.workShift.id > 0 && loginInfoResponce.workShift.isClosed != true)
                                        {
                                            List <Pair> parameters = new List <Pair>();
                                            parameters = new List <Pair>();
                                            parameters.Add(new Pair("shift_id", loginInfoResponce.workShift.id));
                                            parameters.Add(new Pair("operation", 7));
                                            parameters.Add(new Pair("date", DateTime.Now));
                                            parameters.Add(new Pair("cashier_mashine_id", loginInfoResponce.workShift.cashierMashineId));
                                            parameters.Add(new Pair("cashier_id", cashier.cashierId));
                                            parameters.Add(new Pair("cashier_name", cashier.cashierName));
                                            parameters.Add(new Pair("withdrawal", loginInfoResponce.workShift.withdrawal));
                                            parameters.Add(new Pair("contributions", loginInfoResponce.workShift.contributions));
                                            parameters.Add(new Pair("revenue", loginInfoResponce.workShift.revenue));
                                            parameters.Add(new Pair("cash_on_hand", loginInfoResponce.workShift.cashOnHand));
                                            parameters.Add(new Pair("nonnullable_amount", loginInfoResponce.workShift.nonNullableAmount));
                                            if (conn.insert("work_shift_transactions", parameters))
                                            {
                                                List <WorkShiftInfo> workShiftInfos = conn.selectWorkShiftInfos("work_shifts_info", "shift_id='" + loginInfoResponce.workShift.id + "'");
                                                if (workShiftInfos.FindAll(x => x.cashierId == (int)loginInfoResponce.cashier.cashierId).ToList().Count == 0)
                                                {
                                                    List <Pair> pairs = new List <Pair>();
                                                    pairs.Add(new Pair("shift_id", loginInfoResponce.workShift.id));
                                                    pairs.Add(new Pair("cashier_mashine_id", loginInfoResponce.cashierRegister.cashierRegisterId));
                                                    pairs.Add(new Pair("cashier_id", loginInfoResponce.cashier.cashierId));
                                                    pairs.Add(new Pair("cashier_name", loginInfoResponce.cashier.cashierName));
                                                    pairs.Add(new Pair("cash", 0));
                                                    pairs.Add(new Pair("cash_count", 0));
                                                    pairs.Add(new Pair("cashless_payment", 0));
                                                    pairs.Add(new Pair("cashless_payment_count", 0));
                                                    pairs.Add(new Pair("credit_card", 0));
                                                    pairs.Add(new Pair("credit_card_count", 0));
                                                    pairs.Add(new Pair("contributions", 0));
                                                    pairs.Add(new Pair("contributions_count", 0));
                                                    pairs.Add(new Pair("refund", 0));
                                                    pairs.Add(new Pair("refund_count", 0));
                                                    pairs.Add(new Pair("withdrawal", 0));
                                                    pairs.Add(new Pair("withdrawal_count", 0));
                                                    pairs.Add(new Pair("revenue", 0));
                                                    if (conn.insert("work_shifts_info", pairs))
                                                    {
                                                        //WorkShift workShift = conn.selectWorkShift("work_shifts", "cashier_mashine_id='" + cashierRegister.cashierRegisterId + "' AND is_closed='" + false + "'");

                                                        conn.close();
                                                        return(this.loginInfoResponce);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    throw new Exception("Неверный IP адрес кассы :" + ip);
                                }
                            }
                            else
                            {
                                throw new Exception("Неверная карта кассира :" + cardInfo + " полученная из IP :" + ip);
                            }
                        }
                        else
                        {
                            throw new Exception("Неверная карта кассира :" + cardInfo + " полученная из IP :" + ip);
                        }
                    }
                }
                return(null);
            }
            catch (Exception exc)
            {
                Console.WriteLine(exc.ToString());
                logger.Error(exc.ToString());
                return(null);
            }
        }
Exemplo n.º 8
0
        public LoginInfoResponce GetCashierInfo(string cardInfo, string ip, int companyCode)
        {
            try
            {
                MatchCollection matches = Regex.Matches(cardInfo, @"([0-9])+");
                var             cardId  = matches[1].ToString();
                if (matches.Count > 3)
                {
                    if (Card.licenseCheck(cardInfo))
                    {
                        SqlConn conn        = new SqlConn();
                        Card    currentCard = conn.select("cards", "card_id='" + cardId + "'");
                        if (currentCard != null)
                        {
                            Cashier cashier = conn.selectCashier("cashiers", "card_id='" + currentCard.cardId + "'");
                            if (cashier != null)
                            {
                                CashierRegister cashierRegister = conn.selectCashierRegister("cashierregister", "ip='" + ip + "'");
                                if (cashierRegister.id != null)
                                {
                                    List <Pair> parameters = new List <Pair>();
                                    parameters.Add(new Pair {
                                        key = "cashierregister_id", value = cashierRegister.cashierRegisterId
                                    });
                                    parameters.Add(new Pair {
                                        key = "ip", value = cashierRegister.cashierRegisterIP
                                    });
                                    parameters.Add(new Pair {
                                        key = "cashier_id", value = cashier.cashierCardId
                                    });
                                    parameters.Add(new Pair {
                                        key = "cashier_name", value = cashier.cashierName
                                    });
                                    parameters.Add(new Pair {
                                        key = "event", value = "enter"
                                    });
                                    parameters.Add(new Pair {
                                        key = "time", value = DateTime.Now
                                    });
                                    if (conn.insert("cashierregister_event", parameters))
                                    {
                                        WorkShift workShift = conn.selectWorkShift("work_shifts", "cashier_mashine_id='" + cashierRegister.cashierRegisterId + "' AND is_closed='" + false + "'");
                                        if (workShift == null)
                                        {
                                        }
                                        else
                                        {
                                        }
                                        this.loginInfoResponce = new LoginInfoResponce(cashier, cashierRegister, null, false);

                                        return(this.loginInfoResponce);
                                    }
                                }
                                else
                                {
                                    throw new Exception("Неверный IP адрес кассы :" + ip);
                                }
                            }
                            else
                            {
                                throw new Exception("Неверная карта кассира :" + cardInfo + " полученная из IP :" + ip);
                            }
                        }
                        else
                        {
                            throw new Exception("Неверная карта кассира :" + cardInfo + " полученная из IP :" + ip);
                        }
                    }
                }
                return(null);
            }
            catch (Exception exc)
            {
                Console.WriteLine(exc.ToString());
                logger.Error(exc.ToString());
                return(null);
            }
        }
Exemplo n.º 9
0
 public LoginInfoResponce CheckWorkShiftInfo(string cardInfo, string ip, int companyCode)
 {
     try
     {
         loginInfoResponce = new LoginInfoResponce();
         MatchCollection matches = Regex.Matches(cardInfo, @"([0-9])+");
         var             cardId  = matches[1].ToString();
         if (matches.Count > 3)
         {
             if (Card.licenseCheck(cardInfo))
             {
                 SqlConn conn        = new SqlConn();
                 Card    currentCard = conn.select("cards", "card_id='" + cardId + "'");
                 if (currentCard != null)
                 {
                     Cashier cashier = conn.selectCashier("cashiers", "card_id='" + currentCard.cardId + "'");
                     if (cashier != null)
                     {
                         CashierRegister cashierRegister = conn.selectCashierRegister("cashierregister", "ip='" + ip + "'");
                         if (cashierRegister.id != null)
                         {
                             this.loginInfoResponce.cashier         = cashier;
                             this.loginInfoResponce.cashierRegister = cashierRegister;
                             WorkShift workShift = conn.selectWorkShift("work_shifts", "cashier_mashine_id='" + cashierRegister.cashierRegisterId + "' AND is_closed='" + false + "'");
                             if (workShift.id > 0 && workShift.isClosed == false)
                             {
                                 this.loginInfoResponce.workShift         = workShift;
                                 this.loginInfoResponce.isWokrShiftStarts = true;
                             }
                             else if (workShift.id > 0 && workShift.isClosed == true)
                             {
                                 this.loginInfoResponce.workShift         = workShift;
                                 this.loginInfoResponce.isWokrShiftStarts = false;
                             }
                             else
                             {
                                 this.loginInfoResponce.workShift         = null;
                                 this.loginInfoResponce.isWokrShiftStarts = false;
                             }
                             return(this.loginInfoResponce);
                         }
                         else
                         {
                             throw new Exception("Неверный IP адрес кассы :" + ip);
                         }
                     }
                     else
                     {
                         throw new Exception("Неверная карта кассира :" + cardInfo + " полученная из IP :" + ip);
                     }
                 }
                 else
                 {
                     throw new Exception("Неверная карта кассира :" + cardInfo + " полученная из IP :" + ip);
                 }
             }
         }
         return(null);
     }
     catch (Exception exc)
     {
         Console.WriteLine(exc.ToString());
         logger.Error(exc.ToString());
         return(null);
     }
 }