예제 #1
0
 public static void ChangeTransport(
     long transportID,
     string model,
     string registrationNumber,
     string VIN,
     string transportType,
     string transportCategory,
     long?transportMakingYear,
     string ecologyClass,
     float?maxWeight,
     float?weight,
     string engineType,
     float?engineVolume)
 {
     using (var db = new trafficEntities())
     {
         var Query = from t in db.Transport
                     where t.transportID == transportID
                     select t;
         Transport updTransport = Query.First();
         //updTransport.transportID = transportID; Unnecessary
         updTransport.model = model;
         updTransport.registrationNumber = registrationNumber;
         updTransport.VIN                 = VIN;
         updTransport.transportType       = transportType;
         updTransport.transportMakingYear = transportMakingYear;
         updTransport.ecologyClass        = ecologyClass;
         updTransport.maxWeight           = maxWeight;
         updTransport.weight              = weight;
         updTransport.engineType          = engineType;
         updTransport.engineVolume        = engineVolume;
         db.SaveChanges();
     }
 }
예제 #2
0
        public static void AddTransport(
            long transportID,
            string model,
            string registrationNumber,
            string VIN,
            string transportType,
            string transportCategory,
            long?transportMakingYear,
            string ecologyClass,
            float?maxWeight,
            float?weight,
            string engineType,
            float?engineVolume)
        {
            var transport = new Transport {
                transportID   = transportID, model = model, registrationNumber = registrationNumber, VIN = VIN,
                transportType = transportType, transportMakingYear = transportMakingYear, ecologyClass = ecologyClass,
                maxWeight     = maxWeight, weight = weight, engineType = engineType, engineVolume = engineVolume
            };

            using (var db = new trafficEntities())
            {
                db.Transport.Add(transport);
                db.SaveChanges();
            }
        }
예제 #3
0
        public InternationalCardClass(long registrationID, long transportID,
                                      DateTime dateFrom, DateTime dateUntil, long organizationID)
        {
            TransportID = transportID;
            Transport    tr  = new Transport();
            Organization org = new Organization();

            using (var db = new trafficEntities())
            {
                //finding transport TODO - swap on methods
                var query = from t in db.Transport
                            where t.transportID == TransportID
                            select t;
                foreach (var t in query)
                {
                    tr = t;
                }

                //finding organization TODO - swap on methods
                var queryOrg = from o in db.Organization
                               where o.organizationID == organizationID
                               select o;
                foreach (var o in queryOrg)
                {
                    org = o;
                }
            }
            RegistrationID = registrationID;
            DateFrom       = dateFrom;
            DateUntil      = dateUntil;
            Model          = tr.model;
            RegNumber      = tr.registrationNumber;
            OrgName        = org.ShortTitle;
        }
예제 #4
0
 public static void DeleteByID(long transportID)
 {
     using (var db = new trafficEntities())
     {
         var Query = from t in db.Transport
                     where t.transportID == transportID
                     select t;
         Transport DelTransport = Query.First();
         db.Transport.Remove(DelTransport);
         db.SaveChanges();
     }
 }
예제 #5
0
        public static void AddTypeCost(string TypeCostName, bool Service, bool Repair)
        {
            var TypeCost = new TypeCost {
                typeCostName = TypeCostName, service = Service, repair = Repair
            };

            using (var db = new trafficEntities())
            {
                db.TypeCost.Add(TypeCost);
                db.SaveChanges();
            }
        }
예제 #6
0
        public static void AddMaintenance(long transportID, DateTime dateFrom, DateTime dateUntil, long typeCostID, decimal cost)
        {
            var Maintenance = new Maintenance {
                transportID = transportID, dateFrom = dateFrom, dateUntil = dateUntil, typeCostID = typeCostID, cost = (decimal)cost
            };

            using (var db = new trafficEntities())
            {
                db.Maintenance.Add(Maintenance);
                db.SaveChanges();
            }
        }
예제 #7
0
        public static void AddOrganization(long OrganizationID, long AddressID, string FullTitle,
                                           string ShortTitle, string RegNumber, string INN,
                                           string KPP, string UNP)
        {
            var organization = new Organization {
                addressID = AddressID, organizationID = OrganizationID, FullTitle = FullTitle, ShortTitle = ShortTitle, RegistrationNumber = RegNumber, INN = INN, KPP = KPP, UNP = UNP
            };

            using (var db = new trafficEntities())
            {
                db.Organization.Add(organization);
                db.SaveChanges();
            }
        }
예제 #8
0
        public static List <Organization> ReadAllOrganizations()
        {
            List <Organization> AllOrganizations = new List <Organization>();

            using (var db = new trafficEntities())
            {
                var query = from o in db.Organization
                            orderby o.organizationID
                            select o;
                foreach (var org in query)
                {
                    AllOrganizations.Add(org);
                }
            }
            return(AllOrganizations);
        }
예제 #9
0
        public static List <Transport> ReadAllTransports()
        {
            List <Transport> AllTransports = new List <Transport>();

            using (var db = new trafficEntities())
            {
                var query = from t in db.Transport
                            orderby t.transportID
                            select t;
                foreach (var tr in query)
                {
                    AllTransports.Add(tr);
                }
            }
            return(AllTransports);
        }
예제 #10
0
        public static List <TypeCost> ReadAllTypeCosts()
        {
            List <TypeCost> AllTypeCosts = new List <TypeCost>();

            using (var db = new trafficEntities())
            {
                var query = from tc in db.TypeCost
                            orderby tc.typeCostID
                            select tc;
                foreach (var tc in query)
                {
                    AllTypeCosts.Add(tc);
                }
            }
            return(AllTypeCosts);
        }
예제 #11
0
        public static List <Maintenance> ReadAllMaintenances()
        {
            List <Maintenance> AllMaintenances = new List <Maintenance>();

            using (var db = new trafficEntities())
            {
                var query = from m in db.Maintenance
                            orderby m.typeCostID
                            select m;
                foreach (var m in query)
                {
                    AllMaintenances.Add(m);
                }
            }
            return(AllMaintenances);
        }
예제 #12
0
        public static Organization SearchByID(long organizationID)
        {
            Organization org = new Organization();

            using (var db = new trafficEntities())
            {
                //finding organization
                var queryOrg = from o in db.Organization
                               where o.organizationID == organizationID
                               select o;
                foreach (var o in queryOrg)
                {
                    org = o;
                }
            }
            return(org);
        }
예제 #13
0
        public static Transport SearchByID(long _transportID)
        {
            Transport tr = new Transport();

            using (var db = new trafficEntities())
            {
                //finding transport
                var query = from t in db.Transport
                            where t.transportID == _transportID
                            select t;
                foreach (var t in query)
                {
                    tr = t;
                }
            }
            return(tr);
        }
예제 #14
0
        public static TypeCost SearchByID(long TypeCostID)
        {
            TypeCost TC = new TypeCost();

            using (var db = new trafficEntities())
            {
                //finding TypeCost
                var queryTypeCost = from tc in db.TypeCost
                                    where tc.typeCostID == TypeCostID
                                    select tc;
                foreach (var tc in queryTypeCost)
                {
                    TC = tc;
                }
            }
            return(TC);
        }
예제 #15
0
        public static Maintenance SearchByID(long MaintenanceID)
        {
            Maintenance Maintenance = new Maintenance();

            using (var db = new trafficEntities())
            {
                //finding Maintenance
                var queryMaintenance = from m in db.Maintenance
                                       where m.maintenanceID == MaintenanceID
                                       select m;
                foreach (var m in queryMaintenance)
                {
                    Maintenance = m;
                }
            }
            return(Maintenance);
        }
예제 #16
0
        public static InternationalCardClass SearchByTransportID(long transportID)
        {
            InternationalCardClass returnParam = new InternationalCardClass();

            returnParam.TransportID = transportID;
            Transport         tr  = new Transport();
            Organization      org = new Organization();
            InternationalCard IC  = new InternationalCard();

            using (var db = new trafficEntities())
            {
                //finding transport TODO - swap on methods
                var query = from t in db.Transport
                            where t.transportID == returnParam.TransportID
                            select t;
                foreach (var t in query)
                {
                    tr = t;
                }
                //finding IC TODO - swap on methods
                var queryIC = from i in db.InternationalCard
                              where i.transportID == returnParam.TransportID
                              select i;
                foreach (var i in queryIC)
                {
                    IC = i;
                }
                //finding organization TODO - swap on methods
                var queryOrg = from o in db.Organization
                               where o.organizationID == IC.organizationID
                               select o;
                foreach (var o in queryOrg)
                {
                    org = o;
                }
            }
            returnParam.RegistrationID = IC.registrationID;
            returnParam.DateFrom       = IC.dateFromApproval;
            returnParam.DateUntil      = IC.dateUntil;
            returnParam.Model          = tr.model;
            returnParam.RegNumber      = tr.registrationNumber;
            returnParam.OrgName        = org.ShortTitle;
            return(returnParam);
        }