Exemple #1
0
        public static List <Dock> getDocks()
        {
            DataTable   dt    = MarinaDBConnnection.getRows("SELECT ID, Name, WaterService, ElectricalService FROM Dock");
            List <Dock> docks = new List <Dock>();

            foreach (DataRow dr in dt.Rows)
            {
                int         id                = (int)dr["ID"];
                string      name              = dr["Name"].ToString();
                bool        waterService      = (bool)dr["WaterService"];
                bool        electricalService = (bool)dr["ElectricalService"];
                List <Slip> slips             = getAvailableSlips(id);

                Dock dock = new Dock(id, name, waterService, electricalService, slips);
                docks.Add(dock);
            }
            return(docks);
        }
Exemple #2
0
        private static List <Slip> getAvailableSlips(int dockID)
        {
            string sql = "SELECT s.ID, s.Width, s.Length ";

            sql += "FROM Slip as s ";
            sql += "left Join Lease as l on l.SlipID = s.ID ";
            sql += "WHERE l.SlipID is NULL AND s.DockID = " + dockID.ToString();
            DataTable   dt    = MarinaDBConnnection.getRows(sql);
            List <Slip> slips = new List <Slip>();

            foreach (DataRow dr in dt.Rows)
            {
                int id     = (int)dr["ID"];
                int width  = (int)dr["Width"];
                int length = (int)dr["Length"];

                Slip slip = new Slip(id, width, length);
                slips.Add(slip);
            }
            return(slips);
        }