public bool SaveTerminalData(CheckCashupStruct cc) { try { _dbConnection.Open(); string ssql = @"UPDATE Terminals SET LastCashup='" + cc.LastCashupReceived + "', LastBatch='" + cc.LastBatch + "' WHERE TerminalID='" + cc.FkTerminalId + "'"; _sc = new SqlCommand(ssql, _dbConnection); _sc.ExecuteNonQuery(); } catch (Exception ex) { throw new Exception("DatabaseInteraction - SaveVenusTrace - " + ex.Message); } finally { if (_dbConnection != null) { _dbConnection.Close(); } } return(true); }
ExecuteCheckCashupsStoredProcedure() { List <CheckCashupStruct> ccList = new List <CheckCashupStruct>(); CheckCashupStruct cc = new CheckCashupStruct(); const string storedProcedureName = "spCheckCashupDates"; try { _dbConnection.Open(); _sc = new SqlCommand(storedProcedureName, _dbConnection) { CommandType = System.Data.CommandType.StoredProcedure }; //sc.Parameters.Add(new SqlParameter("@DateTimeFrom", DateTime.Today.Date)); //sc.Parameters.Add(new SqlParameter("@DateTimeTo", DateTime.Today.Date.AddDays(1))); _sdr = _sc.ExecuteReader(); while (_sdr.Read()) { cc.FkTerminalId = Convert.ToInt32(_sdr["TerminalsID"]); cc.TerminalCode = Convert.ToString(_sdr["TerminalCode"]); cc.Location = Convert.ToString(_sdr["Location"]); cc.LastCashupReceived = Convert.ToDateTime(_sdr["LastCashup"]); cc.LastBatch = Convert.ToInt32(_sdr["LastBatch"]); cc.CashupAmount = Convert.ToInt32(_sdr["CashupAmount"]); try { cc.TransactionAmount = Convert.ToInt32(_sdr["TransactionAmount"]); } catch { cc.TransactionAmount = 0; } cc.DidCashup = cc.LastCashupReceived.Date >= DateTime.Today.Date.AddDays(-1); ccList.Add(cc); } } catch (Exception ex) { throw new Exception("DatabaseInteraction - ExecuteVenusStoredProcedure - " + ex.Message); } finally { if (_dbConnection != null) { _dbConnection.Close(); } } return(ccList); }