Пример #1
0
 public VoucherEditDto Fetch(int id)
 {
     var voucherEdit = new VoucherEditDto();
     using (var ctx = ConnectionManager<SqlConnection>.GetManager("CoopCheck"))
     {
         using (var cmd = new SqlCommand("dbo.dsa_GetVoucher", ctx.Connection))
         {
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.AddWithValue("@tran_id", id).DbType = DbType.Int32;
             var dr = new SafeDataReader(cmd.ExecuteReader());
             dr.Read();
             voucherEdit.Id = dr.GetInt32("tran_id");
             voucherEdit.Amount = (Decimal?)dr.GetValue("tran_amount");
             voucherEdit.PersonId = !dr.IsDBNull("person_id") ? dr.GetString("person_id") : null;
             voucherEdit.NamePrefix = !dr.IsDBNull("name_prefix") ? dr.GetString("name_prefix") : null;
             voucherEdit.First = !dr.IsDBNull("first_name") ? dr.GetString("first_name") : null;
             voucherEdit.Middle = !dr.IsDBNull("middle_name") ? dr.GetString("middle_name") : null;
             voucherEdit.Last = !dr.IsDBNull("last_name") ? dr.GetString("last_name") : null;
             voucherEdit.Suffix = !dr.IsDBNull("name_suffix") ? dr.GetString("name_suffix") : null;
             voucherEdit.Title = !dr.IsDBNull("title") ? dr.GetString("title") : null;
             voucherEdit.Company = !dr.IsDBNull("company") ? dr.GetString("company") : null;
             voucherEdit.AddressLine1 = !dr.IsDBNull("address_1") ? dr.GetString("address_1") : null;
             voucherEdit.AddressLine2 = !dr.IsDBNull("address_2") ? dr.GetString("address_2") : null;
             voucherEdit.Municipality = !dr.IsDBNull("municipality") ? dr.GetString("municipality") : null;
             voucherEdit.Region = !dr.IsDBNull("region") ? dr.GetString("region") : null;
             voucherEdit.PostalCode = !dr.IsDBNull("postal_code") ? dr.GetString("postal_code") : null;
             voucherEdit.Country = !dr.IsDBNull("country") ? dr.GetString("country") : null;
             voucherEdit.PhoneNumber = !dr.IsDBNull("phone_number") ? dr.GetString("phone_number") : null;
             voucherEdit.EmailAddress = !dr.IsDBNull("email") ? dr.GetString("email") : null;
             voucherEdit.Updated = !dr.IsDBNull("updated") ? dr.GetSmartDate("updated", true) : null;
         }
     }
     return voucherEdit;
 }
 private BatchEditDto Fetch(IDataReader data)
 {
     var batchEdit = new BatchEditDto();
     using (var dr = new SafeDataReader(data))
     {
         if (dr.Read())
         {
             batchEdit.Num = dr.GetInt32("batch_num");
             batchEdit.Date = !dr.IsDBNull("batch_date") ? dr.GetSmartDate("batch_date", true) : null;
             batchEdit.PayDate = !dr.IsDBNull("pay_date") ? dr.GetSmartDate("pay_date", true) : null;
             batchEdit.Amount = (Decimal?)dr.GetValue("batch_amount");
             batchEdit.JobNum = (int?)dr.GetValue("job_num");
             batchEdit.Description = !dr.IsDBNull("batch_dscr") ? dr.GetString("batch_dscr") : null;
             batchEdit.Updated = !dr.IsDBNull("updated") ? dr.GetSmartDate("updated", true) : null;
             batchEdit.ThankYou1 = !dr.IsDBNull("thank_you_1") ? dr.GetString("thank_you_1") : null;
             batchEdit.StudyTopic = !dr.IsDBNull("study_topic") ? dr.GetString("study_topic") : null;
             batchEdit.ThankYou2 = !dr.IsDBNull("thank_you_2") ? dr.GetString("thank_you_2") : null;
             batchEdit.MarketingResearchMessage = !dr.IsDBNull("marketing_research_message") ? dr.GetString("marketing_research_message") : null;
         }
         FetchChildren(dr);
     }
     return batchEdit;
 }
 private AccountDto Fetch(IDataReader data)
 {
     var account = new AccountDto();
     using (var dr = new SafeDataReader(data))
     {
         if (dr.Read())
         {
             account.Id = dr.GetInt32("account_id");
             account.Name = dr.GetString("account_name");
             account.Description = !dr.IsDBNull("account_dscr") ? dr.GetString("account_dscr") : null;
             account.Number = !dr.IsDBNull("account_number") ? dr.GetString("account_number") : null;
             account.Balance = (Decimal?)dr.GetValue("balance");
             account.LastReconciliationDate = !dr.IsDBNull("last_rec_date") ? dr.GetSmartDate("last_rec_date", true) : null;
             account.LastReconciliationBalance = (Decimal?)dr.GetValue("last_rec_balance");
         }
     }
     return account;
 }
        private VoucherEditDto FetchVoucherEdit(SafeDataReader dr)
        {
            var voucherEdit = new VoucherEditDto();
            // Value properties
            voucherEdit.Id = dr.GetInt32("tran_id");
            voucherEdit.Amount = (Decimal?)dr.GetValue("tran_amount");
            voucherEdit.PersonId = !dr.IsDBNull("person_id") ? dr.GetString("person_id") : null;
            voucherEdit.NamePrefix = !dr.IsDBNull("name_prefix") ? dr.GetString("name_prefix") : null;
            voucherEdit.First = !dr.IsDBNull("first_name") ? dr.GetString("first_name") : null;
            voucherEdit.Middle = !dr.IsDBNull("middle_name") ? dr.GetString("middle_name") : null;
            voucherEdit.Last = !dr.IsDBNull("last_name") ? dr.GetString("last_name") : null;
            voucherEdit.Suffix = !dr.IsDBNull("name_suffix") ? dr.GetString("name_suffix") : null;
            voucherEdit.Title = !dr.IsDBNull("title") ? dr.GetString("title") : null;
            voucherEdit.Company = !dr.IsDBNull("company") ? dr.GetString("company") : null;
            voucherEdit.AddressLine1 = !dr.IsDBNull("address_1") ? dr.GetString("address_1") : null;
            voucherEdit.AddressLine2 = !dr.IsDBNull("address_2") ? dr.GetString("address_2") : null;
            voucherEdit.Municipality = !dr.IsDBNull("municipality") ? dr.GetString("municipality") : null;
            voucherEdit.Region = !dr.IsDBNull("region") ? dr.GetString("region") : null;
            voucherEdit.PostalCode = !dr.IsDBNull("postal_code") ? dr.GetString("postal_code") : null;
            voucherEdit.Country = !dr.IsDBNull("country") ? dr.GetString("country") : null;
            voucherEdit.PhoneNumber = !dr.IsDBNull("phone_number") ? dr.GetString("phone_number") : null;
            voucherEdit.EmailAddress = !dr.IsDBNull("email") ? dr.GetString("email") : null;
            voucherEdit.Updated = !dr.IsDBNull("updated") ? dr.GetSmartDate("updated", true) : null;

            return voucherEdit;
        }
Пример #5
0
        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 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();
            }
        }
Пример #7
0
        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;

        }