示例#1
0
        /// <summary>
        /// Initialize instance of account editor.
        /// </summary>
        /// <param name="parent"></param>
        public Account(MainForm parent)
        {
            //  Initialize properties and other objects
            _ApplicationForm = parent;
            dataTable = new iCampaign.TACS.Data.AccountsDs.AccountsDataTable();
            tableAdapter = new iCampaign.TACS.Data.AccountsDsTableAdapters.AccountsTableAdapter();
            tableAdapter.Connection = new System.Data.SqlClient.SqlConnection(TacsSession.ConnectionString);

            //  Initialize form components
            InitializeComponent();
            InitializeDocument();
        }
示例#2
0
        /// <summary>
        /// Get an account profile registered in TACS.NET database.
        /// </summary>
        /// <param name="acctId">long: Account id.</param>
        /// <param name="credentials">iCamapaign.TACS.Client.Credentials: object.</param>
        /// <returns>System.Collections.Generic.List T:iCampaign.TACS.AccountProfile</returns>
        internal AccountProfile GetAccountProfile(long acctId, Credentials credentials)
        {
            AccountProfile profile = null;

            //  Check to see if user has sufficient access
            if (!credentials.SuperAdministrator)
            {
                throw new System.Exception(TacsSession.MSG_INSUFPRIV);
            }

            //  Check for valid session token
            if (!TacsSession.IsTokenValid(credentials.Username, credentials.SessionToken))
            {
                throw new System.Exception(TacsSession.MSG_INVALSESS);
            }

            //  Retrieve the list of account profiles from the database
            Data.AccountsDs.AccountsDataTable dataTable = new AccountsDs.AccountsDataTable();
            Data.AccountsDsTableAdapters.AccountsTableAdapter tableAdapter =
                new iCampaign.TACS.Data.AccountsDsTableAdapters.AccountsTableAdapter();
            tableAdapter.Connection = new SqlConnection(TacsSession.ConnectionString);
            try
            {
                tableAdapter.Connection.Open();
                tableAdapter.FillByAcctId(dataTable, acctId);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                tableAdapter.Connection.Close();
            }

            //  Transfer data from data table to list collection
            Data.AccountsDs.AccountsRow row = dataTable[0];
            profile.Account = row.AcctName;
            profile.AccountId = row.AcctId;
            profile.Address1 = row.Address1;
            profile.Address2 = row.Address2;
            profile.City = row.City;
            profile.Contact = row.Contact;
            profile.CreatedOn = row.CreatedOn;
            profile.Email = row.Email;
            profile.ExpireOn = row.ExpireOn;
            profile.Phone = row.Phone;
            profile.State = row.State;
            profile.ZipCode = row.ZipCode;
            return profile;
        }
示例#3
0
        /// <summary>
        /// Retrieves a data table containing accounts in the TACS.NET database.
        /// </summary>
        /// <returns>iCampaign.TACS.Data.AccountsDs.AccountsDataTable</returns>
        internal iCampaign.TACS.Data.AccountsDs.AccountsDataTable GetAccounts()
        {
            //  Instantiate the database objects
            AccountsDs.AccountsDataTable dataTable = new AccountsDs.AccountsDataTable();
            iCampaign.TACS.Data.AccountsDsTableAdapters.AccountsTableAdapter tableAdapter =
                new iCampaign.TACS.Data.AccountsDsTableAdapters.AccountsTableAdapter();
            tableAdapter.Connection = new SqlConnection(TacsSession.ConnectionString);

            //  Try to get the data from the database server
            try
            {
                tableAdapter.Connection.Open();
                tableAdapter.Fill(dataTable);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                tableAdapter.Connection.Close();
            }

            return dataTable;
        }
示例#4
0
        /// <summary>
        /// Get a list of accounts registered in TACS.NET database.
        /// </summary>
        /// <param name="credentials">iCampaign.TACS.Client.Credentials: object.</param>
        /// <returns>System.Collections.Generic.List T:string</returns>
        internal List<string> GetAccounts(Credentials credentials)
        {
            List<string> resultList = new List<string>();

            //  Check to see if user has sufficient access
            if (!credentials.SuperAdministrator)
            {
                throw new System.Exception(TacsSession.MSG_INSUFPRIV);
            }

            //  Check for valid session token
            if (!TacsSession.IsTokenValid(credentials.Username, credentials.SessionToken))
            {
                throw new System.Exception(TacsSession.MSG_INVALSESS);
            }

            //  Get the list of accounts from the database
            Data.AccountsDs.AccountsDataTable dataTable = new AccountsDs.AccountsDataTable();
            Data.AccountsDsTableAdapters.AccountsTableAdapter tableAdapter =
                new iCampaign.TACS.Data.AccountsDsTableAdapters.AccountsTableAdapter();
            tableAdapter.Connection = new SqlConnection(TacsSession.ConnectionString);
            try
            {
                tableAdapter.Connection.Open();
                tableAdapter.Fill(dataTable);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                tableAdapter.Connection.Close();
            }

            //  Copy the data table to a list collection
            foreach (Data.AccountsDs.AccountsRow row in dataTable)
            {
                resultList.Add(row.AcctName);
            }
            return resultList;
        }