public bool ChangeCardPrice() { if (admin.check()) { SqlConn sqlConn = new SqlConn(); List <Pair> pairs = new List <Pair>(); pairs.Add(new Pair("state_message", cardStatus.status_message)); sqlConn.update("card_state", "state_id='" + 17 + "'", pairs); sqlConn.close(); return(true); } return(false); }
public CardDataReport(DateTime fromDate, DateTime toDate, int cardId) { CardReport cardReport = new CardReport(); cardReport.GetOneCardReport(fromDate, toDate, cardId); SqlConn conn = new SqlConn(); List <Client> clients = conn.selectClient("client_info", "card_id='" + cardId + "'"); CardPrice cardPrice = conn.selectCardPrice("cards_price", "card_id='" + cardId + "'"); conn.close(); this.cardReport = cardReport; this.clients = clients; this.cardPrice = cardPrice; }
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); } }
public WorkShiftReport GetZReport() { try { //WorkShiftReport workShiftReport = new WorkShiftReport(); SqlConn sqlConn = new SqlConn(); if (this.workShift != null && this.workShift.id > 0) { //workShiftReport.workShiftInfos = sqlConn.selectWorkShiftInfos("work_shifts_info", "shift_id='" + workShiftReport.workShift.id + "'"); if (this.workShiftInfos.Count > 0 && this.workShiftInfos.FindAll(x => x.workShiftId == this.workShift.id).Count > 0) { List <Pair> parameters = new List <Pair>(); parameters.Add(new Pair("end_time", DateTime.Now)); parameters.Add(new Pair("is_closed", true)); if (sqlConn.update("work_shifts", "id='" + workShift.id + "'", parameters)) { parameters = new List <Pair>(); parameters.Add(new Pair("shift_id", this.workShift.id)); parameters.Add(new Pair("operation", 2)); parameters.Add(new Pair("date", DateTime.Now)); parameters.Add(new Pair("cashier_mashine_id", this.workShift.cashierMashineId)); parameters.Add(new Pair("cashier_id", 0)); parameters.Add(new Pair("cashier_name", "Смена закрыта администраторм :" + admin.FIO)); parameters.Add(new Pair("withdrawal", this.workShift.withdrawal)); parameters.Add(new Pair("contributions", this.workShift.contributions)); parameters.Add(new Pair("revenue", this.workShift.revenue)); parameters.Add(new Pair("cash_on_hand", this.workShift.cashOnHand)); parameters.Add(new Pair("nonnullable_amount", this.workShift.nonNullableAmount)); if (sqlConn.insert("work_shift_transactions", parameters)) { return(this); } } } sqlConn.close(); } return(null); } catch { return(null); } }
public static void closeAllConnection() { DataTable dt = GlobalClass.connPool; if (dt == null) { return; } for (int i = 0; i < dt.Rows.Count; i++) { DBConn conn = dt.Rows[i]["engine"] as DBConn; SqlConn sconn = (SqlConn)conn; if (sconn.isOpen()) { sconn.close(); } } }
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); } }
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); } }