示例#1
0
文件: Program.cs 项目: skhan92/FDM
        static void Main(string[] args)
        {
            //Base class - most senior class
            UserController userController = new UserController();

            userController.Login("Bart Simpson", "EatMyShorts");

            //Inherits from UserController, so gets all it's methods
            AdminController adminController = new AdminController();

            adminController.Login("Homer Simpson", "Doh");
            adminController.SetPermissions("Maggie Simpson");

            //Inherits from AdminController, so gets all it's methods and the UserController Methods
            SuperAdminController superAdminController = new SuperAdminController();

            superAdminController.Login("Marge Simpson", "hmmm...");
            superAdminController.SetPermissions("Lisa Simpson");

            //Admin inherits name and id from User
            Admin admin = new Admin();

            admin.id       = 123;
            admin.name     = "batman";
            admin.password = "******";

            //Buyer inherits name and id from user
            Buyer buyer = new Buyer();

            buyer.id   = 456;
            buyer.name = "joker";

            //Can't instantantiate because this is an abstract class
            //User user = new User();

            //MSDBConnection inherited its method from DatabaseConnection Interface
            MicrosoftDatabaseConnection dbCon = new MicrosoftDatabaseConnection();

            dbCon.OpenConnectionToDatabase("Address");

            //Even though these are abstract and interaces we can still construct any object that inherits from them
            User user = new Admin();
            DatabaseConnection dbConnection = new OracleDatabaseConnection();

            Console.ReadLine();
        }
示例#2
0
 public override DbConnection CreateConnection() => OracleDatabaseConnection.CreateConnection(this.As <TestingDb>().ConnectionString);
示例#3
0
        public List <ProjectBomMode> CallOracleTest(string model, string color)
        {
            var list    = new List <ProjectBomMode>();
            var newList = new List <ProjectBomMode>();

            try
            {
                var employeeQuery = @"SELECT
     substr(iasy.segment1,1,20) Assembly,( iasy.SEGMENT1||'.'||iasy.SEGMENT2||'.'||iasy.SEGMENT3)  ITEM_CODE,iasy.DESCRIPTION,
                 substr(icmp.segment1,1,20) Component,
                 substr(comp.component_quantity,1,8) Quantity,
                  ( icmp.SEGMENT1||'.'||icmp.SEGMENT2||'.'||icmp.SEGMENT3)  SPARE_ITEM_CODE,icmp.DESCRIPTION SPARE_DESCRIPTION
FROM
                 apps.mtl_system_items_B iasy,
                 apps.bom_bill_of_materials bom,
                 apps.bom_inventory_components comp,
                 apps.mtl_system_items_B icmp
WHERE
           
                 iasy.organization_id = 646 AND
                 iasy.inventory_item_id = bom.assembly_item_id AND
                 iasy.organization_id = bom.organization_id AND
                 bom.bill_sequence_id = comp.bill_sequence_id AND
                 comp.component_item_id = icmp.inventory_item_id AND
                 icmp.organization_id = 646 AND
                
                 LOWER(icmp.DESCRIPTION) LIKE '%" + model + "%'";
                var connection    = OracleDatabaseConnection.GetOldConnection();
                OracleDataReader oracleDataReader = null;
                var oracleCommand = new OracleCommand(employeeQuery, connection)
                {
                    CommandType = CommandType.Text
                };

                connection.Open();
                oracleDataReader = oracleCommand.ExecuteReader();

                if (oracleDataReader.HasRows)
                {
                    while (oracleDataReader.Read())
                    {
                        var projectBom = new ProjectBomMode
                        {
                            ITEM_CODE         = oracleDataReader["ITEM_CODE"].ToString(),
                            DESCRIPTION       = oracleDataReader["DESCRIPTION"].ToString(),
                            Quantity          = oracleDataReader["Quantity"].ToString(),
                            SPARE_ITEM_CODE   = oracleDataReader["SPARE_ITEM_CODE"].ToString(),
                            SPARE_DESCRIPTION = oracleDataReader["SPARE_DESCRIPTION"].ToString()
                        };
                        list.Add(projectBom);
                    }
                }


                newList = list.Where(a => a.DESCRIPTION.Contains(color)).ToList();

                oracleDataReader.Dispose();
                connection.Close();
                //connection.Dispose();
            }
            catch (Exception)
            {
                throw;
            }



            return(newList);
        }