public Item Map(SafeDataReader reader) { var item = (Item)Activator.CreateInstance(typeof(Item), true); using (BypassPropertyChecks(item)) { item.ItemId = reader.GetString("ItemId"); item.OriginalItemId = reader.GetString("ItemId"); item.ProductId = reader.GetString("ProductId"); item.ListPrice = reader.IsDBNull("ListPrice") ? (System.Decimal?)null : reader.GetDecimal("ListPrice"); item.UnitCost = reader.IsDBNull("UnitCost") ? (System.Decimal?)null : reader.GetDecimal("UnitCost"); item.Supplier = reader.IsDBNull("Supplier") ? (System.Int32?)null : reader.GetInt32("Supplier"); item.Status = reader.GetString("Status"); item.Name = reader.GetString("Name"); item.Image = reader.GetString("Image"); } MarkOld(item); return item; }
public Cart Map(SafeDataReader reader) { var item = (Cart)Activator.CreateInstance(typeof(Cart), true); using (BypassPropertyChecks(item)) { item.CartId = reader.GetInt32("CartId"); item.UniqueID = reader.GetInt32("UniqueID"); item.ItemId = reader.GetString("ItemId"); item.Name = reader.GetString("Name"); item.Type = reader.GetString("Type"); item.Price = reader.GetDecimal("Price"); item.CategoryId = reader.GetString("CategoryId"); item.ProductId = reader.GetString("ProductId"); item.IsShoppingCart = reader.GetBoolean("IsShoppingCart"); item.Quantity = reader.GetInt32("Quantity"); } MarkOld(item); MarkAsChild(item); return item; }
public Order Map(SafeDataReader reader) { var item = (Order)Activator.CreateInstance(typeof(Order), true); using (BypassPropertyChecks(item)) { item.OrderId = reader.GetInt32("OrderId"); item.UserId = reader.GetString("UserId"); item.OrderDate = reader.GetDateTime("OrderDate"); item.ShipAddr1 = reader.GetString("ShipAddr1"); item.ShipAddr2 = reader.GetString("ShipAddr2"); item.ShipCity = reader.GetString("ShipCity"); item.ShipState = reader.GetString("ShipState"); item.ShipZip = reader.GetString("ShipZip"); item.ShipCountry = reader.GetString("ShipCountry"); item.BillAddr1 = reader.GetString("BillAddr1"); item.BillAddr2 = reader.GetString("BillAddr2"); item.BillCity = reader.GetString("BillCity"); item.BillState = reader.GetString("BillState"); item.BillZip = reader.GetString("BillZip"); item.BillCountry = reader.GetString("BillCountry"); item.Courier = reader.GetString("Courier"); item.TotalPrice = reader.GetDecimal("TotalPrice"); item.BillToFirstName = reader.GetString("BillToFirstName"); item.BillToLastName = reader.GetString("BillToLastName"); item.ShipToFirstName = reader.GetString("ShipToFirstName"); item.ShipToLastName = reader.GetString("ShipToLastName"); item.AuthorizationNumber = reader.GetInt32("AuthorizationNumber"); item.Locale = reader.GetString("Locale"); } MarkOld(item); return item; }
private void BindAttackData() { using (SqlConnection cn = new SqlConnection( Database.AphelionTriggerConnection )) { cn.Open(); using (SqlCommand cm = cn.CreateCommand()) { cm.CommandText = "GetAttackData"; cm.CommandType = CommandType.StoredProcedure; cm.Parameters.AddWithValue( "@AttackerHouseID", _attackerHouseId ); cm.Parameters.AddWithValue( "@DefenderHouseID", _defenderHouseId ); using (SafeDataReader dr = new SafeDataReader( cm.ExecuteReader() )) { while (dr.Read()) { _attackerHouse = new House( dr.GetInt32( "ID" ), dr.GetInt32( "UserID" ), dr.GetInt32( "FactionID" ), dr.GetString( "Faction" ), dr.GetString( "FactionDisplay" ), dr.GetString( "Name" ), dr.GetInt32( "Intelligence" ), dr.GetInt32( "Power" ), dr.GetInt32( "Protection" ), dr.GetInt32( "Affluence" ), dr.GetInt32( "Speed" ), dr.GetInt32( "Contingency" ), dr.GetInt32( "LevelID" ), (double)dr.GetDecimal( "Ambition" ), dr.GetInt32( "Turns" ), dr.GetInt32( "Credits" ), dr.GetInt32( "MilitiaCount" ), dr.GetInt32( "MilitaryCount" ), dr.GetInt32( "MercenaryCount" ), dr.GetInt32( "AgentCount" ), dr.GetInt32( "Rank" ), dr.GetInt32( "LastRank" ), dr.GetInt32( "Points" ), dr.GetInt32( "Experience" ), dr.GetInt32( "Attack" ), dr.GetInt32( "Defense" ), dr.GetInt32( "Capture" ), dr.GetInt32( "Plunder" ), dr.GetInt32( "Stun" ), dr.GetInt32( "GuildID" ), dr.GetString( "Guild" ), dr.GetString( "SmallFactionIconPath" ), dr.GetInt32( "VotedFactionLeaderHouseID" ), dr.GetInt32( "FactionLeaderHouseID" ), dr.GetInt32( "FactionVotingPower" ) ); } if (dr.NextResult()) { while (dr.Read()) { if (dr.GetInt32( "Count" ) > 0) { _attackerForces.Add( new Unit( dr.GetInt32( "ID" ), dr.GetInt32( "FactionID" ), dr.GetInt32( "UnitClassID" ), dr.GetString( "Name" ), dr.GetString( "Description" ), dr.GetString( "Faction" ), dr.GetString( "UnitClass" ), dr.GetInt32( "Cost" ), dr.GetInt32( "Attack" ), dr.GetInt32( "Defense" ), dr.GetInt32( "Plunder" ), dr.GetInt32( "Capture" ), dr.GetInt32( "Stun" ), dr.GetInt32( "Experience" ), dr.GetDecimal( "RepopulationRate" ), dr.GetDecimal( "DepopulationRate" ), dr.GetInt32( "Count" ), dr.GetInt32( "AttackTech" ), dr.GetInt32( "DefenseTech" ), dr.GetInt32( "CaptureTech" ), dr.GetInt32( "PlunderTech" ), dr.GetInt32( "StunTech" ), dr.GetInt32( "ExperienceTech" ), dr.GetDecimal( "RepopulationRateTech" ), dr.GetDecimal( "DepopulationRateTech" ) ) ); } } } else { throw new DataPortalException( "Attacker House has no forces to attack with.", this ); } if (dr.NextResult()) { while (dr.Read()) { _attackerTechnologies.Add( new Technology( dr.GetInt32( "ID" ), dr.GetInt32( "FactionID" ), dr.GetInt32( "HouseID" ), dr.GetInt32( "GuildID" ), dr.GetInt32( "TechnologyTypeID" ), dr.GetInt32( "UnitID" ), dr.GetInt32( "UnitClassID" ), dr.GetString( "Name" ), dr.GetString( "Faction" ), dr.GetString( "House" ), dr.GetString( "Guild" ), dr.GetString( "Description" ), dr.GetString( "TechnologyType" ), dr.GetString( "Unit" ), dr.GetString( "UnitClass" ), dr.GetInt32( "Attack" ), dr.GetInt32( "Defense" ), dr.GetInt32( "Plunder" ), dr.GetInt32( "Capture" ), dr.GetInt32( "Stun" ), dr.GetInt32( "Experience" ), dr.GetDecimal( "RepopulationRate" ), dr.GetDecimal( "DepopulationRate" ), dr.GetInt32( "ResearchCost" ), dr.GetInt32( "ResearchTime" ), dr.GetInt32( "ResearchTurns" ), dr.GetInt32( "TimeSpent" ), dr.GetInt32( "TurnsSpent" ), dr.GetInt32( "CreditsSpent" ), dr.GetInt32( "ResearchStateID" ), dr.GetString( "ResearchState" ), dr.GetSmartDate( "ResearchStartedDate" ) ) ); } } if (dr.NextResult()) { while (dr.Read()) { _defenderHouse = new House( dr.GetInt32( "ID" ), dr.GetInt32( "UserID" ), dr.GetInt32( "FactionID" ), dr.GetString( "Faction" ), dr.GetString( "FactionDisplay" ), dr.GetString( "Name" ), dr.GetInt32( "Intelligence" ), dr.GetInt32( "Power" ), dr.GetInt32( "Protection" ), dr.GetInt32( "Affluence" ), dr.GetInt32( "Speed" ), dr.GetInt32( "Contingency" ), dr.GetInt32( "LevelID" ), (double)dr.GetDecimal( "Ambition" ), dr.GetInt32( "Turns" ), dr.GetInt32( "Credits" ), dr.GetInt32( "MilitiaCount" ), dr.GetInt32( "MilitaryCount" ), dr.GetInt32( "MercenaryCount" ), dr.GetInt32( "AgentCount" ), dr.GetInt32( "Rank" ), dr.GetInt32( "LastRank" ), dr.GetInt32( "Points" ), dr.GetInt32( "Experience" ), dr.GetInt32( "Attack" ), dr.GetInt32( "Defense" ), dr.GetInt32( "Capture" ), dr.GetInt32( "Plunder" ), dr.GetInt32( "Stun" ), dr.GetInt32( "GuildID" ), dr.GetString( "Guild" ), dr.GetString( "SmallFactionIconPath" ), dr.GetInt32( "VotedFactionLeaderHouseID" ), dr.GetInt32( "FactionLeaderHouseID" ), dr.GetInt32( "FactionVotingPower" ) ); } } else { throw new DataPortalException( "Defender House not found.", this ); } if (dr.NextResult()) { while (dr.Read()) { if (dr.GetInt32( "Count" ) > 0) { _defenderForces.Add( new Unit( dr.GetInt32( "ID" ), dr.GetInt32( "FactionID" ), dr.GetInt32( "UnitClassID" ), dr.GetString( "Name" ), dr.GetString( "Description" ), dr.GetString( "Faction" ), dr.GetString( "UnitClass" ), dr.GetInt32( "Cost" ), dr.GetInt32( "Attack" ), dr.GetInt32( "Defense" ), dr.GetInt32( "Plunder" ), dr.GetInt32( "Capture" ), dr.GetInt32( "Stun" ), dr.GetInt32( "Experience" ), dr.GetDecimal( "RepopulationRate" ), dr.GetDecimal( "DepopulationRate" ), dr.GetInt32( "Count" ), dr.GetInt32( "AttackTech" ), dr.GetInt32( "DefenseTech" ), dr.GetInt32( "CaptureTech" ), dr.GetInt32( "StunTech" ), dr.GetInt32( "PlunderTech" ), dr.GetInt32( "ExperienceTech" ), dr.GetDecimal( "RepopulationRateTech" ), dr.GetDecimal( "DepopulationRateTech" ) ) ); } } } if (dr.NextResult()) { while (dr.Read()) { _defenderTechnologies.Add( new Technology( dr.GetInt32( "ID" ), dr.GetInt32( "FactionID" ), dr.GetInt32( "HouseID" ), dr.GetInt32( "GuildID" ), dr.GetInt32( "TechnologyTypeID" ), dr.GetInt32( "UnitID" ), dr.GetInt32( "UnitClassID" ), dr.GetString( "Name" ), dr.GetString( "Faction" ), dr.GetString( "House" ), dr.GetString( "Guild" ), dr.GetString( "Description" ), dr.GetString( "TechnologyType" ), dr.GetString( "Unit" ), dr.GetString( "UnitClass" ), dr.GetInt32( "Attack" ), dr.GetInt32( "Defense" ), dr.GetInt32( "Plunder" ), dr.GetInt32( "Capture" ), dr.GetInt32( "Stun" ), dr.GetInt32( "Experience" ), dr.GetDecimal( "RepopulationRate" ), dr.GetDecimal( "DepopulationRate" ), dr.GetInt32( "ResearchCost" ), dr.GetInt32( "ResearchTime" ), dr.GetInt32( "ResearchTurns" ), dr.GetInt32( "TimeSpent" ), dr.GetInt32( "TurnsSpent" ), dr.GetInt32( "CreditsSpent" ), dr.GetInt32( "ResearchStateID" ), dr.GetString( "ResearchState" ), dr.GetSmartDate( "ResearchStartedDate" ) ) ); } } } } } }
public LineItem Map(SafeDataReader reader) { var item = (LineItem)Activator.CreateInstance(typeof(LineItem), true); using (BypassPropertyChecks(item)) { item.OrderId = reader.GetInt32("OrderId"); item.OriginalOrderId = reader.GetInt32("OrderId"); item.LineNum = reader.GetInt32("LineNum"); item.OriginalLineNum = reader.GetInt32("LineNum"); item.ItemId = reader.GetString("ItemId"); item.Quantity = reader.GetInt32("Quantity"); item.UnitPrice = reader.GetDecimal("UnitPrice"); } MarkOld(item); return item; }
public override List<AccountDTO> GetAccounts() { if (myData.GetConnection(out _myAccessConn)) return null; try { using (var myAccessCommand = new OleDbCommand(MMSQLGetAccounts, _myAccessConn)) { _myAccessConn.Open(); using (var dr = new SafeDataReader(myAccessCommand.ExecuteReader())) using (dr) while (dr.Read()) { var myaccountDTO = new AccountDTO { AccountID = dr.GetInt32(dr.GetOrdinal("CustomerID")), Line1 = dr.GetString(dr.GetOrdinal("Line1")), Line2 = dr.GetString(dr.GetOrdinal("Line2")), Line3 = dr.GetString(dr.GetOrdinal("Line3")), Line4 = dr.GetString(dr.GetOrdinal("Line4")), Line5 = dr.GetString(dr.GetOrdinal("Line5")), Balance = dr.GetDecimal(dr.GetOrdinal("Balance")), }; myaccountDTOs.Add(myaccountDTO); } } LoadStorageUnits(); MergeStorageUnits(); LoadContactItems(); MergeContactItems(); return myaccountDTOs; } catch (Exception ex) { Console.WriteLine("Error: Failed to retrieve the required data from the DataBase.\n{0}", ex.Message); return null; } finally { _myAccessConn.Close(); } }
private void LoadStorageUnits() { try { using (var myAccessCommand = new OleDbCommand(MMSQLGetStorageUnits, _myAccessConn)) { // _myAccessConn.Open(); using (var dr = new SafeDataReader(myAccessCommand.ExecuteReader())) using (dr) while (dr.Read()) { var myStorageUnitDTO = new StorageUnitDTO { AccountID = dr.GetInt32(dr.GetOrdinal(("CustomerID"))), FacilityName = dr.GetString(dr.GetOrdinal("FacilityName")), BuildingNumber = dr.GetString(dr.GetOrdinal("BldgNumber")), UnitNumber = dr.GetString(dr.GetOrdinal("UnitNumber")), UnitRate = dr.GetDecimal(dr.GetOrdinal("UnitRate")), UnitStatus = dr.GetString(dr.GetOrdinal("UnitStatus")), UnitSize = dr.GetString(dr.GetOrdinal("UnitSize")) }; mystorageUnitDTOs.Add(myStorageUnitDTO); } } } catch (Exception ex) { Console.WriteLine("Error: Failed to retrieve the required data from the DataBase.\n{0}", ex.Message); } }
public override List<TransactionDTO> GetTransactions(int accountID) { _accountIDParm = accountID; var myParm = _accountIDParm.ToString(CultureInfo.InvariantCulture); var getAccountTransactions = MMSQLGetTransactionsByID + myParm; if (myData.GetConnection(out _myAccessConn)) return null; try { using (var myAccessCommand = new OleDbCommand(getAccountTransactions, _myAccessConn)) { _myAccessConn.Open(); using (var dr = new SafeDataReader(myAccessCommand.ExecuteReader())) using (dr) while (dr.Read()) { var myTransactionDTO = new TransactionDTO { TransactionID = dr.GetInt32(dr.GetOrdinal("TransactionID")), AccountID = dr.GetInt32(dr.GetOrdinal("CustomerID")), TransactionDate = dr.GetSmartDate(dr.GetOrdinal("TransDate")), Amount = dr.GetDecimal(dr.GetOrdinal("Amount")), Description = dr.GetString(dr.GetOrdinal("Description")), TransactionCode = dr.GetString(dr.GetOrdinal("TranCode")), UnitID = dr.GetInt32(dr.GetOrdinal("UnitID")), RentalDate = dr.GetSmartDate(dr.GetOrdinal("RentalDate")) }; mytransactionDTOs.Add(myTransactionDTO); } } return mytransactionDTOs; } catch (Exception ex) { Console.WriteLine("Error: Failed to retrieve the required data from the DataBase.\n{0}", ex.Message); return null; } finally { _myAccessConn.Close(); } }
private PaymentInfoDto Fetch(SafeDataReader dr) { var paymentInfo = new PaymentInfoDto(); paymentInfo.Id = dr.GetInt32("tran_id"); paymentInfo.BatchNum = dr.GetInt32("batch_num"); paymentInfo.PayDate = dr.GetSmartDate("pay_date"); paymentInfo.JobNum = dr.GetInt32("job_num"); paymentInfo.ThankYou1 = dr.GetString("thank_you_1"); paymentInfo.StudyTopic = dr.GetString("study_topic"); paymentInfo.ThankYou2 = dr.GetString("thank_you_2"); paymentInfo.MarketingResearchMessage = dr.GetString("marketing_research_message"); paymentInfo.CheckDate = dr.GetSmartDate("check_date"); paymentInfo.CheckNum = dr.GetString("check_num"); paymentInfo.Amount = dr.GetDecimal("tran_amount"); paymentInfo.PersonId = dr.GetString("person_id"); paymentInfo.Prefix = dr.GetString("name_prefix"); paymentInfo.FirstName = dr.GetString("first_name"); paymentInfo.MiddleName = dr.GetString("middle_name"); paymentInfo.LastName = dr.GetString("last_name"); paymentInfo.NameSuffix = dr.GetString("name_suffix"); paymentInfo.Title = dr.GetString("title"); paymentInfo.Company = dr.GetString("company"); paymentInfo.Address1 = dr.GetString("address_1"); paymentInfo.Address2 = dr.GetString("address_2"); paymentInfo.Municipality = dr.GetString("municipality"); paymentInfo.Region = dr.GetString("region"); paymentInfo.PostalCode = dr.GetString("postal_code"); paymentInfo.Country = dr.GetString("country"); paymentInfo.Email = dr.GetString("email"); paymentInfo.PhoneNumber = dr.GetString("phone_number"); paymentInfo.Completed = dr.GetBoolean("print_flag"); return paymentInfo; }