예제 #1
0
        /// <summary>
        /// Return a table containing all suppliers
        /// </summary>
        /// <returns></returns>
        public DataTable EnumerateSuppliers()
        {
            if (isDebugEnabled)
            {
                logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " in");
            }

            DataTable supplierTable = new DataTable(TableNames.ALERTS);

            if (compactDatabaseType)
            {
                try
                {
                    using (SqlCeConnection conn = DatabaseConnection.CreateOpenCEConnection())
                    {
                        string commandText =
                            "SELECT _SUPPLIERID, _NAME ,_ADDRESS1 ,_ADDRESS2 ,_CITY, _STATE ,_ZIP ,_TELEPHONE " +
                            ",_CONTACT_NAME ,_CONTACT_EMAIL, _WWW ,_FAX ,_NOTES " +
                            "FROM SUPPLIERS " +
                            "ORDER BY _SUPPLIERID";

                        using (SqlCeCommand command = new SqlCeCommand(commandText, conn))
                        {
                            new SqlCeDataAdapter(command).Fill(supplierTable);
                        }
                    }
                }
                catch (SqlCeException ex)
                {
                    Utility.DisplayErrorMessage("A database error has occurred in AuditWizard." + Environment.NewLine + Environment.NewLine +
                                                "Please see the log file for further details.");
                    logger.Error("Exception in " + System.Reflection.MethodBase.GetCurrentMethod().Name, ex);
                }
                catch (Exception ex)
                {
                    Utility.DisplayErrorMessage("A database error has occurred in AuditWizard." + Environment.NewLine + Environment.NewLine +
                                                "Please see the log file for further details.");

                    logger.Error("Exception in " + System.Reflection.MethodBase.GetCurrentMethod().Name, ex);
                }
            }
            else
            {
                AuditWizardDataAccess lAuditWizardDataAccess = new AuditWizardDataAccess();
                supplierTable = lAuditWizardDataAccess.EnumerateSuppliers();
            }

            if (isDebugEnabled)
            {
                logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " out");
            }
            return(supplierTable);
        }