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 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); } }