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(); } }
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(); } }
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; }
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(); } }
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(); } }
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(); } }
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(); } }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }