Пример #1
0
        static AccountFunctionalities()
        {
            ConnectionStringSettingsCollection connections = ConfigurationManager.ConnectionStrings;

            // Get the collection elements.
            foreach (ConnectionStringSettings connection in connections)
            {
                if (connection.Name == "KidZonePortalDatabase")
                {
                    SqlConnectionStringBuilder sb = new SqlConnectionStringBuilder(connection.ConnectionString);
                    _databaseSettings = new CommonLibrary.DatabaseSmoObjectsAndSettings(
                        sb.InitialCatalog, sb.DataSource, sb.InitialCatalog,
                        sb.UserID, sb.Password, sb.IntegratedSecurity);
                    break;
                }
            }
        }
Пример #2
0
        private void btnTestGeneratedDataAccess_Click(object sender, EventArgs e)
        {
            string databaseName      = txtDatabaseName.Text;
            string dataSource        = txtDataSource.Text;
            string initialCatalog    = txtInitialCatalog.Text;
            string userId            = txtUserId.Text;
            string password          = txtPassword.Text;
            bool   trustedConnection = chkTrustedConnection.Checked;
            string schema            = txtSchema.Text;

            _databaseSmoObjectsAndSettings = new CommonLibrary.DatabaseSmoObjectsAndSettings(databaseName,
                                                                                             dataSource,
                                                                                             initialCatalog,
                                                                                             userId,
                                                                                             password,
                                                                                             trustedConnection);
            string connectionString = _databaseSmoObjectsAndSettings.ConnectionString;

            //TestSprocGenerator.Data.SprocTable.Input.Dto.GetAllGridTablesAndQuestionsByGridKey inputAll =
            //    new TestSprocGenerator.Data.SprocTable.Input.Dto.GetAllGridTablesAndQuestionsByGridKey();

            //inputAll.GridKey = 3002;

            //TestSprocGenerator.Data.Accessor.CustomSproc customSprocAccessor
            //    = new TestSprocGenerator.Data.Accessor.CustomSproc();


            //DataSet ds = customSprocAccessor.GetAllGridTablesAndQuestionsByGridKey_DataSet(connectionString, inputAll);

            //TestSprocGenerator.Data.SprocTable.Input.Dto.GetGridCellFontOverrides inputFontOver =
            //    new TestSprocGenerator.Data.SprocTable.Input.Dto.GetGridCellFontOverrides();

            //inputFontOver.GridKey = 3002;

            //TestSprocGenerator.SprocTable.Result.List.GetGridCellFontOverrides gridCellOverridesList =
            //    customSprocAccessor.GetGridCellFontOverrides(connectionString, inputFontOver);

            //DataSet ds1 =
            //    customSprocAccessor.GetGridCellFontOverrides_DataSet(connectionString, inputFontOver);

            //TestSprocGenerator.Data.SprocTable.Input.Dto.GetGrids gridInput = new TestSprocGenerator.Data.SprocTable.Input.Dto.GetGrids();
            //gridInput.GridKey = 0;
            //TestSprocGenerator.SprocTable.Result.List.GetGrids gridsReturned =
            //    customSprocAccessor.GetGrids(connectionString, gridInput);
        }
Пример #3
0
        private void btnGenerateBusinessObjects_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Have you compiled your dto and list classes into the current app?  If not, then the business classes will not be generated");
            string databaseName      = txtDatabaseName.Text;
            string dataSource        = txtDataSource.Text;
            string initialCatalog    = txtInitialCatalog.Text;
            string userId            = txtUserId.Text;
            string password          = txtPassword.Text;
            bool   trustedConnection = chkTrustedConnection.Checked;
            string schema            = txtSchema.Text;

            CommonLibrary.DatabaseSmoObjectsAndSettings databaseSettings =
                new CommonLibrary.DatabaseSmoObjectsAndSettings(databaseName, dataSource, initialCatalog,
                                                                userId, password, trustedConnection, schema);
            _databaseSmoObjectsAndSettings = databaseSettings;

            BusinessLayerGeneration businessGeneration = new BusinessLayerGeneration(databaseSettings, this.GetType().Namespace);
            bool overwriteExisting = true;

            //this is just a test method so that we generate for only the test table to start with
            //businessGeneration.TestTableGenerateBusinessLayer(overwriteExisting);
            businessGeneration.GenerateBusinessLayer(overwriteExisting);
            MessageBox.Show("Business Objects Generation Complete");
        }
 public DataAccess(CommonLibrary.DatabaseSmoObjectsAndSettings settings) : base(settings)
 {
 }
Пример #5
0
        private void button1_Click(object sender, EventArgs e)
        {
            string databaseName      = txtDatabaseName.Text;
            string dataSource        = txtDataSource.Text;
            string initialCatalog    = txtInitialCatalog.Text;
            string userId            = txtUserId.Text;
            string password          = txtPassword.Text;
            bool   trustedConnection = chkTrustedConnection.Checked;
            string schema            = txtSchema.Text;

            CommonLibrary.DatabaseSmoObjectsAndSettings databaseSettings =
                new CommonLibrary.DatabaseSmoObjectsAndSettings(databaseName, dataSource, initialCatalog,
                                                                userId, password, trustedConnection, schema);
            _databaseSmoObjectsAndSettings = databaseSettings;

            //Business.SingleTable.Bo.TestTable boTestTable =
            //    new TestSprocGenerator.Business.SingleTable.Bo.TestTable(databaseSettings);

            //Business.SingleTable.Bo.TblFilterDefinitions tblFilterDefinitions =
            //    new TestSprocGenerator.Business.SingleTable.Bo.TblFilterDefinitions(databaseSettings);

            ////do not forget, if you do not have a primary key on a table then you will get errors as
            ////cannot find GetByPrimaryKey etc - needs to be resolved

            ////also, if the autoseed ID column is not specified as part of the primary key, then
            ////the insert sproc will still expect it, so IDs should always be part of the primary key
            ////until this can be resolved.

            //this code generator does not support the use of names in the database
            //that have any spaces in them, remove all spaces from object names
            //in your database or else it cannot create the stored procedure parameters
            //or private and public members properly, you will get errors.

            //boTestTable.TestTableBitValue = true;
            //boTestTable.TestTableCharValue = "c".ToCharArray();
            //boTestTable.TestTableCreatedDate = DateTime.Now;
            //boTestTable.TestTableDateLastModified = DateTime.Now;
            //boTestTable.TestTableDecimalValue = 1.0m;
            //boTestTable.TestTableDescription = "description";
            //boTestTable.TestTableGuid = System.Guid.NewGuid();
            //boTestTable.TestTableMoneyValue = 2.0m;
            //boTestTable.TestTableName = "test table name";
            //boTestTable.TestTableNumericValue = 25.0m;
            //boTestTable.TestTableImageValue = Image.FromFile(@"C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\Sunset.jpg");

            //boTestTable.Insert();

            //boTestTable.TestTableName = "Updated Test Table Name";
            //boTestTable.Update();

            //boTestTable.Delete();

            //boTestTable.TestTableGuid = new Guid("44d64a90-60a3-4202-8b55-043f8d6c911c");
            //boTestTable.TestTableID = 4;
            //boTestTable.GetByPrimaryKey();

            //TestSprocGenerator.Business.SingleTable.Bo.List.TestTable listOfAll =
            //    new TestSprocGenerator.Business.SingleTable.Bo.List.TestTable(_databaseSmoObjectsAndSettings);
            //TestSprocGenerator.Business.SingleTable.Bo.TestTable dummyBo = new TestSprocGenerator.Business.SingleTable.Bo.TestTable();
            //listOfAll.FillByGetAll(dummyBo);

            //TestSprocGenerator.Business.SingleTable.Bo.List.TblFilterDefinitions listOfAll =
            //    new TestSprocGenerator.Business.SingleTable.Bo.List.TblFilterDefinitions(_databaseSmoObjectsAndSettings);
            //TestSprocGenerator.Business.SingleTable.Bo.TblFilterDefinitions dummyBo =
            //    new TestSprocGenerator.Business.SingleTable.Bo.TblFilterDefinitions();
            //listOfAll.FillByGetAll(dummyBo);

            //listOfAll.FillByPrimaryKey(boTestTable);

            //boTestTable = new TestSprocGenerator.Business.SingleTable.Bo.TestTable();

            //boTestTable.TestTableName = "test table";
            //boTestTable.TestTableDescription = "updated";
            //listOfAll.FillByCriteriaFuzzy(boTestTable);

            //boTestTable = new TestSprocGenerator.Business.SingleTable.Bo.TestTable();
            //boTestTable.TestTableGuid = new Guid("6975a402-dd9e-4daf-9f30-06ba65117618");
            //listOfAll.FillByCriteriaExact(boTestTable);
        }
Пример #6
0
        private void btnGetCustomSprocs_Click(object sender, EventArgs e)
        {
            _customSprocs.Clear();
            treeCustomSprocs.Nodes.Clear();

            string databaseName      = txtDatabaseName.Text;
            string dataSource        = txtDataSource.Text;
            string initialCatalog    = txtInitialCatalog.Text;
            string userId            = txtUserId.Text;
            string password          = txtPassword.Text;
            bool   trustedConnection = chkTrustedConnection.Checked;
            string schema            = txtSchema.Text;

            _databaseSmoObjectsAndSettings = new CommonLibrary.DatabaseSmoObjectsAndSettings(databaseName,
                                                                                             dataSource,
                                                                                             initialCatalog,
                                                                                             userId,
                                                                                             password,
                                                                                             trustedConnection);

            _dataLayerGenerator = new DataLayerGenerator(_databaseSmoObjectsAndSettings,
                                                         this.GetType().Namespace);

            SprocDataLayerGenerator.PredicateFunctions predicateFunctions = new SprocDataLayerGenerator.PredicateFunctions();
            List <StoredProcedure> customSprocsNotGenerated = new List <StoredProcedure>();


            CommonLibrary.DatabaseSmoObjectsAndSettings databaseSmoObjectsAndSettings =
                new CommonLibrary.DatabaseSmoObjectsAndSettings(databaseName,
                                                                dataSource,
                                                                initialCatalog,
                                                                userId,
                                                                password,
                                                                trustedConnection,
                                                                schema);

            SprocGenerator sprocGenerator = new SprocGenerator(databaseName,
                                                               dataSource,
                                                               initialCatalog,
                                                               userId,
                                                               password,
                                                               trustedConnection,
                                                               schema);

            _sprocGenerator = sprocGenerator;
            List <StoredProcedure> sprocsGenerated = _sprocGenerator.GetStoredProcedures();

            if (sprocsGenerated != null)
            {
                foreach (StoredProcedure sproc in databaseSmoObjectsAndSettings.Database_Property.StoredProcedures)
                {
                    predicateFunctions.SprocNameHolder = sproc.Name;
                    if (!(sprocsGenerated.FindAll(predicateFunctions.FindSprocGeneratedBySprocName).Count > 0))
                    {
                        customSprocsNotGenerated.Add(sproc);
                    }
                }
            }

            if (customSprocsNotGenerated.Count > 0)
            {
                foreach (StoredProcedure customSproc in customSprocsNotGenerated)
                {
                    if (!customSproc.IsSystemObject)
                    {
                        treeCustomSprocs.Nodes.Add(customSproc.Name);
                        _customSprocs.Add(customSproc);
                    }
                }
            }
            btnGenerateCustomSprocDtos.Enabled = true;
            chkSelectAll.Enabled = true;
        }
Пример #7
0
        private void btnTestDataAccess_Click(object sender, EventArgs e)
        {
            string databaseName      = txtDatabaseName.Text;
            string dataSource        = txtDataSource.Text;
            string initialCatalog    = txtInitialCatalog.Text;
            string userId            = txtUserId.Text;
            string password          = txtPassword.Text;
            bool   trustedConnection = chkTrustedConnection.Checked;
            string schema            = txtSchema.Text;

            _databaseSmoObjectsAndSettings = new CommonLibrary.DatabaseSmoObjectsAndSettings(databaseName,
                                                                                             dataSource,
                                                                                             initialCatalog,
                                                                                             userId,
                                                                                             password,
                                                                                             trustedConnection);


            string connectionString = _databaseSmoObjectsAndSettings.ConnectionString;

            //TestSprocGenerator.Data.SingleTable.Dto.TblGrid dtoGrid = new TestSprocGenerator.Data.SingleTable.Dto.TblGrid();


            //CommonLibrary.Base.Database.BaseDataAccess<TestSprocGenerator.Data.SingleTable.Dto.TblGrid> _baseDataAccess =
            //    new CommonLibrary.Base.Database.BaseDataAccess<TestSprocGenerator.Data.SingleTable.Dto.TblGrid>(_databaseSmoObjectsAndSettings);

            //dtoGrid.GridKey = 2830;
            //dtoGrid.Name = "Enterprise Computing View Setup";
            //dtoGrid.NodeKey = 64;
            //dtoGrid.NoOfRows = 2;
            //dtoGrid.NoOfCols = 10;

            //List<TestSprocGenerator.Data.SingleTable.Dto.TblGrid> listReturned =
            //    _baseDataAccess.Get(dtoGrid, CommonLibrary.Enumerations.GetPermutations.ByExplicitCriteria);

            //dtoGrid = new TestSprocGenerator.Data.SingleTable.Dto.TblGrid();
            //dtoGrid.Name = "ent";

            //listReturned = _baseDataAccess.Get(dtoGrid, CommonLibrary.Enumerations.GetPermutations.ByFuzzyCriteria);

            //dtoGrid = new TestSprocGenerator.Data.SingleTable.Dto.TblGrid();
            //dtoGrid.GridKey = 2830;
            //dtoGrid.Name = "SomeName";
            //listReturned
            //   = _baseDataAccess.Get(dtoGrid, CommonLibrary.Enumerations.GetPermutations.ByPrimaryKey);

            //listReturned =
            //    _baseDataAccess.Get(dtoGrid, CommonLibrary.Enumerations.GetPermutations.AllByColumnMappings);


            //CommonLibrary.Base.Database.BaseDataAccess<TestSprocGenerator.Data.SingleTable.Dto.TestTable> _baseDataAccessTestTable =
            //    new CommonLibrary.Base.Database.BaseDataAccess<TestSprocGenerator.Data.SingleTable.Dto.TestTable>(_databaseSmoObjectsAndSettings);

            //TestSprocGenerator.Data.SingleTable.Dto.TestTable testTable =
            //    new TestSprocGenerator.Data.SingleTable.Dto.TestTable();


            //testTable.TestTableGuid = Guid.NewGuid();
            //testTable.TestTableCharValue = new Char[] { 'C' };
            //testTable.TestTableCreatedDate = DateTime.Now;
            //testTable.TestTableDateLastModified = DateTime.Now;
            //testTable.TestTableImageValue = Image.FromFile(@"C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\Sunset.jpg");
            //testTable.TestTableDecimalValue = 1.0M;
            //testTable.TestTableBitValue = true;
            //testTable.TestTableDescription = "test description";
            //testTable.TestTableMoneyValue = 5.00m;
            //testTable.TestTableName = "Test Table name";
            //testTable.TestTableNumericValue = 4;


            //_baseDataAccessTestTable.Insert(testTable);

            //testTable.TestTableID = 3;
            //testTable.TestTableGuid = new Guid("6975a402-dd9e-4daf-9f30-06ba65117618");
            //testTable.TestTableDescription = "Updated Description";

            //_baseDataAccessTestTable.Update(testTable);

            //testTable.TestTableGuid = Guid.NewGuid();
            //testTable.TestTableCharValue = new Char[] { 'C' };
            //testTable.TestTableCreatedDate = DateTime.Now;
            //testTable.TestTableDateLastModified = DateTime.Now;
            //testTable.TestTableImageValue = Image.FromFile(@"C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\Sunset.jpg");
            //testTable.TestTableDecimalValue = 1.0M;
            //testTable.TestTableBitValue = true;
            //testTable.TestTableDescription = "this one should be deleted";
            //testTable.TestTableMoneyValue = 5.00m;
            //testTable.TestTableName = "Test Table name";
            //testTable.TestTableNumericValue = 4;

            //_baseDataAccessTestTable.Insert(testTable);

            //_baseDataAccessTestTable.Delete(testTable);
        }