Beispiel #1
0
        /// <summary>
        /// Add MaintenanceChecks
        /// </summary>
        /// <param name="description"></param>
        /// <param name="status"></param>

        /// <returns></returns>


        public int AddMaintenanceChecks(string description, bool status)
        {
            int recordId = -1;

            // insert
            using (var db = new EasyMaintainDBContext())
            {
                try
                {
                    var maintenanceChecks = db.Set <MaintenanceChecks>();
                    maintenanceChecks.Add(new MaintenanceChecks {
                        Description = description, status = status
                    });

                    db.SaveChanges();

                    recordId = Int32.Parse(db.Set <MaintenanceChecks>().LastOrDefault().Description);
                }
                catch (SqlException ex)
                {
                    throw ex;
                }
            }

            return(recordId);
        }
Beispiel #2
0
        /// <summary>
        /// Update Component Work
        /// </summary>
        /// <param name="aircraftModleId"></param>
        /// <param name="aircraftModelname"></param>
        /// <param name="description"></param>
        /// <param name="additionalData"></param>
        /// <param name="categoryID"></param>
        /// <param name="engineTypeId"></param>
        /// <param name="manufacturerId"></param>
        /// <param name="imagepath"></param>
        /// <returns></returns>
        public bool UpdateComponentWork(int workID, string component, string serialNumber, string flightNumber, string description, string createdDate, string location)
        {
            bool result = false;

            // update
            using (var db = new EasyMaintainDBContext())
            {
                try
                {
                    var componentWork = db.ComponentWorks.SingleOrDefault(s => s.WorkID == workID);

                    if (componentWork != null)
                    {
                        componentWork.Component    = component;
                        componentWork.SerialNumber = serialNumber;
                        componentWork.FlightNumber = flightNumber;
                        componentWork.Description  = description;
                        componentWork.CreatedDate  = createdDate;
                        componentWork.Location     = location;
                    }
                    db.SaveChanges();
                    result = true;
                }
                catch (SqlException ex)
                {
                    throw ex;
                }
            }

            return(result);
        }
Beispiel #3
0
        public int AddCrew(string name, string designation)
        {
            int recordId = -1;

            // insert
            using (var db = new EasyMaintainDBContext())
            {
                try
                {
                    var crew = db.Set <Crew>();
                    crew.Add(new Crew {
                        Name = name, Designation = designation
                    });

                    db.SaveChanges();

                    recordId = Int32.Parse(db.Set <Crew>().LastOrDefault().Name);
                }
                catch (SqlException ex)
                {
                    throw ex;
                }
            }

            return(recordId);
        }
Beispiel #4
0
        /// <summary>
        /// Update Spare Part
        /// </summary>
        /// <param name="sparePartId"></param>
        /// <param name="sparePartName"></param>
        /// <param name="description"></param>
        /// <param name="additionalData"></param>
        /// <param name="categoryID"></param>
        /// <param name="imagepath"></param>
        /// <returns></returns>
        public bool UpdateSparePart(int sparePartId, string sparePartName, string description, string additionalData, int categoryID, string imagepath)
        {
            bool result = false;

            // update
            using (var db = new EasyMaintainDBContext())
            {
                try
                {
                    var sparePart = db.SpareParts.SingleOrDefault(s => s.SparePartID == sparePartId);

                    if (sparePart != null)
                    {
                        sparePart.SparePartName  = sparePartName;
                        sparePart.CategoryID     = categoryID;
                        sparePart.ImagePath      = imagepath;
                        sparePart.Description    = description;
                        sparePart.AdditionalData = additionalData;
                    }
                    db.SaveChanges();
                    result = true;
                }
                catch (SqlException ex)
                {
                    throw ex;
                }
            }

            return(result);
        }
Beispiel #5
0
        /// <summary>
        /// Update Category
        /// </summary>
        /// <param name="categoryId"></param>
        /// <param name="categoryName"></param>
        /// <param name="additionalData"></param>
        /// <returns></returns>
        public bool UpdateCategory(int categoryId, string categoryName, string additionalData)
        {
            bool result = false;

            // update
            using (var db = new EasyMaintainDBContext())
            {
                try
                {
                    var category = db.Categories.SingleOrDefault(s => s.CategoryID == categoryId);

                    if (category != null)
                    {
                        category.CategoryName   = categoryName;
                        category.AdditionalData = additionalData;
                    }
                    db.SaveChanges();
                    result = true;
                }
                catch (SqlException ex)
                {
                    throw ex;
                }
            }
            return(result);
        }
Beispiel #6
0
        /// <summary>
        /// Add Category
        /// </summary>
        /// <param name="categoryName"></param>
        /// <param name="additionalData"></param>
        /// <returns></returns>
        public int AddCategory(string categoryName, string additionalData)
        {
            int recordId = -1;

            // insert
            using (var db = new EasyMaintainDBContext())
            {
                try
                {
                    var category = db.Set <Category>();
                    category.Add(new Category {
                        CategoryName = categoryName, AdditionalData = additionalData
                    });

                    db.SaveChanges();

                    recordId = db.Set <Category>().LastOrDefault().CategoryID;
                }
                catch (SqlException ex)
                {
                    throw ex;
                }
            }

            return(recordId);
        }
Beispiel #7
0
        /// <summary>
        /// Update Engine Type
        /// </summary>
        /// <param name="engineTypeId"></param>
        /// <param name="engineTypeName"></param>
        /// <param name="additionalData"></param>
        /// <returns></returns>
        public bool UpdateMaintenance(string workID, string FlightModel, string additionalData)
        {
            bool result = false;

            // update
            using (var db = new EasyMaintainDBContext())
            {
                try
                {
                    var engineType = db.Maintenances.SingleOrDefault(s => s.WorkID.Equals(workID));

                    if (engineType != null)
                    {
                        engineType.FlightModel = FlightModel;
                        engineType.Description = additionalData;
                    }
                    db.SaveChanges();
                    result = true;
                }
                catch (SqlException ex)
                {
                    throw ex;
                }
            }

            return(result);
        }
Beispiel #8
0
        /// <summary>
        /// Update Maintenance Checks
        /// </summary>
        /// <param name="Description"></param>
        /// <param name="status"></param>

        /// <returns></returns>

        public bool UpdateMaintenanceChecks(string description, bool status)
        {
            bool result = false;

            // update
            using (var db = new EasyMaintainDBContext())
            {
                try
                {
                    var maintenanceCheck = db.MaintenanceChecks.SingleOrDefault(s => s.Description.Equals(description));

                    if (maintenanceCheck != null)
                    {
                        maintenanceCheck.Description = description;
                        maintenanceCheck.status      = status;
                    }
                    db.SaveChanges();
                    result = true;
                }
                catch (SqlException ex)
                {
                    throw ex;
                }
            }

            return(result);
        }
Beispiel #9
0
        /// <summary>
        /// Update Manufacturer
        /// </summary>
        /// <param name="manufacturerId"></param>
        /// <param name="manufacturerName"></param>
        /// <param name="description"></param>
        /// <param name="additionalData"></param>
        /// <returns></returns>
        public bool UpdateManufacturer(int manufacturerId, string manufacturerName, string description, string additionalData)
        {
            bool result = false;

            // update
            using (var db = new EasyMaintainDBContext())
            {
                try
                {
                    var manufacturer = db.Manufactureres.SingleOrDefault(s => s.ManufacturerID.Equals(manufacturerId));

                    if (manufacturer != null)
                    {
                        manufacturer.ManufacturerName = manufacturerName;
                        manufacturer.Description      = description;
                        manufacturer.AdditionalData   = additionalData;
                    }
                    db.SaveChanges();
                    result = true;
                }
                catch (SqlException ex)
                {
                    throw ex;
                }
            }

            return(result);
        }
Beispiel #10
0
        /// <summary>
        /// Update Manufacturer
        /// </summary>
        /// <param name="DeliveryDetailsId"></param>
        /// <param name="DeliveryDate"></param>
        /// <param name="DeliveryMethod"></param>
        /// <param name="PersonInCharge"></param>
        /// <param name="AddressLine1"></param>
        /// <param name="AddressLine2"></param>
        /// <param name="City"></param>
        /// <param name="State"></param>
        /// <param name="AddtionalNotes"></param>
        /// <returns></returns>
        public bool UpdateDeliveryDetails(string deliveryDetailsId, string deliveryDate, string deliveryMethod, string personInCharge, string addressLine1, string addressLine2, string city, string state, string addtionalNotes)
        {
            bool result = false;

            // update
            using (var db = new EasyMaintainDBContext())
            {
                try
                {
                    var delivery = db.Deliveries.SingleOrDefault(s => s.DeliveryDetailsId.Equals(deliveryDetailsId));

                    if (delivery != null)
                    {
                        delivery.DeliveryDetailsId = Int32.Parse(deliveryDetailsId);
                        delivery.DeliveryDate      = deliveryDate;
                        delivery.DeliveryMethod    = deliveryMethod;
                        delivery.PersonInCharge    = personInCharge;
                        delivery.AddressLine1      = addressLine1;
                        delivery.AddressLine2      = addressLine2;
                        delivery.City           = city;
                        delivery.State          = state;
                        delivery.AddtionalNotes = addtionalNotes;
                    }
                    db.SaveChanges();
                    result = true;
                }
                catch (SqlException ex)
                {
                    throw ex;
                }
            }

            return(result);
        }
Beispiel #11
0
        /// <summary>
        /// Add Spare Part
        /// </summary>
        /// <param name="sparePartName"></param>
        /// <param name="description"></param>
        /// <param name="additionalData"></param>
        /// <param name="categoryID"></param>
        /// <param name="imagepath"></param>
        /// <returns></returns>
        public int AddSparePart(string sparePartName, string description, string additionalData, int categoryID, string imagepath)
        {
            int recordId = -1;

            // insert
            using (var db = new EasyMaintainDBContext())
            {
                try
                {
                    var sparePart = db.Set <SparePart>();
                    sparePart.Add(new SparePart {
                        SparePartName = sparePartName, CategoryID = categoryID, ImagePath = imagepath, Description = description, AdditionalData = additionalData
                    });

                    db.SaveChanges();

                    recordId = db.Set <SparePart>().LastOrDefault().SparePartID;
                }
                catch (SqlException ex)
                {
                    throw ex;
                }
            }

            return(recordId);
        }
Beispiel #12
0
        //---- Update Data

        /// <summary>
        /// Update Supplier
        /// </summary>
        /// <param name="supplierId"></param>
        /// <param name="supplierName"></param>
        /// <param name="emailAddress"></param>
        /// <param name="address"></param>
        /// <param name="contact"></param>
        /// <param name="description"></param>
        /// <param name="additionalData"></param>
        /// <returns></returns>
        public bool UpdateSupplier(int supplierId, string supplierName, string emailAddress, string address, string contact, string description, string additionalData)
        {
            bool result = false;

            // update
            using (var db = new EasyMaintainDBContext())
            {
                try
                {
                    var supplier = db.Suppliers.SingleOrDefault(s => s.SupplierID == supplierId);

                    if (supplier != null)
                    {
                        supplier.SupplierName   = supplierName;
                        supplier.EmailAddress   = emailAddress;
                        supplier.Address        = address;
                        supplier.ContactDetails = contact;
                        supplier.Description    = description;
                        supplier.AdditionalData = additionalData;
                    }
                    db.SaveChanges();
                    result = true;
                }
                catch (SqlException ex)
                {
                    throw ex;
                }
            }

            return(result);
        }
Beispiel #13
0
        /// <summary>
        /// Add Engine Type
        /// </summary>
        /// <param name="engineTypeName"></param>
        /// <param name="additionalData"></param>
        /// <returns></returns>
        public int AddMaintenance(int workID, string flightModel, string flightNumber, string description, string startDate, string completionDate, string location)
        {
            int recordId = -1;

            // insert
            using (var db = new EasyMaintainDBContext())
            {
                try
                {
                    var maintenance = db.Set <Maintenance>();
                    int record      = maintenance.Add(new Maintenance {
                        WorkID = workID, FlightModel = flightModel, FlightNumber = flightNumber, Description = description, StartDate = startDate, CompletionDate = completionDate, Location = location
                    }).WorkID;

                    db.SaveChanges();

                    //recordId = db.Set<EngineType>().LastOrDefault().WorkID;
                }
                catch (SqlException ex)
                {
                    throw ex;
                }
            }

            return(recordId);
        }
Beispiel #14
0
        /// <summary>
        /// Add Aircraft Model
        /// </summary>
        /// <param name="aircraftModelname"></param>
        /// <param name="description"></param>
        /// <param name="additionalData"></param>
        /// <param name="categoryID"></param>
        /// <param name="engineTypeId"></param>
        /// <param name="manufacturerId"></param>
        /// <param name="imagepath"></param>
        /// <returns></returns>
        public int AddAircraftModel(string aircraftModelname, string description, string additionalData, int categoryID, int engineTypeId, string flightNumber, string imagepath)
        {
            int recordId = -1;

            // insert
            using (var db = new EasyMaintainDBContext())
            {
                try
                {
                    var aircraftModel = db.Set <AircraftModel>();
                    aircraftModel.Add(new AircraftModel {
                        ModelName = aircraftModelname, CategoryID = categoryID, EngineTypeID = engineTypeId, FlightNumber = flightNumber, ImagePath = imagepath, Description = description, AdditionalData = additionalData
                    });

                    db.SaveChanges();

                    recordId = db.Set <AircraftModel>().LastOrDefault().AircraftModelID;
                }
                catch (SqlException ex)
                {
                    throw ex;
                }
            }

            return(recordId);
        }
Beispiel #15
0
        /// <summary>
        /// Update Manufacturer
        /// </summary>
        /// <param name="Name"></param>
        /// <param name="Designation"></param>
        /// <returns></returns>

        public bool UpdateCrew(string name, string designation)
        {
            bool result = false;

            // update
            using (var db = new EasyMaintainDBContext())
            {
                try
                {
                    var crew = db.Crews.SingleOrDefault(s => s.Name.Equals(name));

                    if (crew != null)
                    {
                        crew.Name        = name;
                        crew.Designation = designation;
                    }
                    db.SaveChanges();
                    result = true;
                }
                catch (SqlException ex)
                {
                    throw ex;
                }
            }

            return(result);
        }
Beispiel #16
0
        /// <summary>
        /// Add Component Work
        /// </summary>
        /// <param name="WorkID"></param>
        /// <param name="Component"></param>
        /// <param name="SerialNumber"></param>
        /// <param name="FlightNumber"></param>
        /// <param name="Description"></param>
        /// <param name="Deliverydetails"></param>
        /// <param name="CreatedDate"></param>
        /// <param name="Location"></param>
        /// <returns></returns>
        public int AddComponentWork(int workID, string component, string serialNumber, string flightNumber, string description, /*DeliveryDetails deliveryDetails*/ string createdDate, string location)
        {
            int recordId = -1;

            // insert
            using (var db = new EasyMaintainDBContext())
            {
                try
                {
                    var componentwork = db.Set <ComponentWork>();
                    componentwork.Add(new ComponentWork {
                        WorkID = workID, Component = component, SerialNumber = serialNumber, FlightNumber = flightNumber, Description = description, CreatedDate = createdDate, Location = location
                    });

                    db.SaveChanges();

                    recordId = (db.Set <ComponentWork>().LastOrDefault().WorkID);
                }
                catch (SqlException ex)
                {
                    throw ex;
                }
            }

            return(recordId);
        }
Beispiel #17
0
        /// <summary>
        /// Update Aircraft Model
        /// </summary>
        /// <param name="aircraftModleId"></param>
        /// <param name="aircraftModelname"></param>
        /// <param name="description"></param>
        /// <param name="additionalData"></param>
        /// <param name="categoryID"></param>
        /// <param name="engineTypeId"></param>
        /// <param name="manufacturerId"></param>
        /// <param name="imagepath"></param>
        /// <returns></returns>
        public bool UpdateAircraftModel(int aircraftModleId, string aircraftModelname, string description, string additionalData, int categoryID, int engineTypeId, int manufacturerId, string imagepath)
        {
            bool result = false;

            // update
            using (var db = new EasyMaintainDBContext())
            {
                try
                {
                    var aircraftModel = db.AircraftModels.SingleOrDefault(s => s.AircraftModelID == aircraftModleId);

                    if (aircraftModel != null)
                    {
                        aircraftModel.ModelName       = aircraftModelname;
                        aircraftModel.CategoryID      = categoryID;
                        aircraftModel.EngineTypeID    = engineTypeId;
                        aircraftModel.AircraftModelID = manufacturerId;
                        aircraftModel.ImagePath       = imagepath;
                        aircraftModel.Description     = description;
                        aircraftModel.AdditionalData  = additionalData;
                    }
                    db.SaveChanges();
                    result = true;
                }
                catch (SqlException ex)
                {
                    throw ex;
                }
            }

            return(result);
        }
Beispiel #18
0
        /// <summary>
        /// Add Manufacturer
        /// </summary>
        /// <param name="manufacturerName"></param>
        /// <param name="description"></param>
        /// <param name="additionalData"></param>
        /// <returns></returns>
        public int AddManufacturer(string manufacturerName, string description, string additionalData)
        {
            int recordId = -1;

            // insert
            using (var db = new EasyMaintainDBContext())
            {
                try
                {
                    var manufacturer = db.Set <Manufacturer>();
                    manufacturer.Add(new Manufacturer {
                        ManufacturerName = manufacturerName, Description = description, AdditionalData = additionalData
                    });

                    db.SaveChanges();

                    recordId = Int32.Parse(db.Set <Manufacturer>().LastOrDefault().ManufacturerID);
                }
                catch (SqlException ex)
                {
                    throw ex;
                }
            }

            return(recordId);
        }
Beispiel #19
0
        /// <summary>
        /// Get Inventory Data
        /// </summary>
        /// <returns></returns>
        //public List<Inventory> GetInventoryData()
        //{
        //    List<Inventory> inventory = new List<Inventory>();

        //    using (var db = new EasyMaintainDBContext())
        //    {
        //        //var query = from b in db.Inventories
        //        //            orderby b.InventoryID
        //        //            select b;

        //        //foreach (var item in query)
        //        //{
        //        //    inventory.Add(item as Inventory);
        //        //}
        //    }

        //    return inventory;
        //}


        //--- Insert Data

        /// <summary>
        /// Add Supplier
        /// </summary>
        /// <param name="supplierName"></param>
        /// <param name="emailAddress"></param>
        /// <param name="address"></param>
        /// <param name="contact"></param>
        /// <param name="description"></param>
        /// <param name="additionalData"></param>
        /// <returns></returns>
        public int AddSupplier(string supplierName, string emailAddress, string address, string contact, string description, string additionalData)
        {
            int recordId = -1;

            // insert
            using (var db = new EasyMaintainDBContext())
            {
                try
                {
                    var supplier = db.Set <Supplier>();
                    supplier.Add(new Supplier {
                        SupplierName = supplierName, EmailAddress = emailAddress, Address = address, ContactDetails = contact, Description = description, AdditionalData = additionalData
                    });

                    db.SaveChanges();

                    recordId = db.Set <Supplier>().LastOrDefault().SupplierID;
                }
                catch (SqlException ex)
                {
                    throw ex;
                }
            }

            return(recordId);
        }
Beispiel #20
0
 /// <summary>
 /// Delete delivery details
 /// </summary>
 /// <param name="Name"></param>
 public void DeleteDeliveryDetails(String id)
 {
     // Delete
     using (var db = new EasyMaintainDBContext())
     {
         var delivery = db.Deliveries.SingleOrDefault(s => s.DeliveryDetailsId.Equals(id));
         db.Deliveries.Attach(delivery);
         db.Deliveries.Remove(delivery);
         db.SaveChanges();
     }
 }
Beispiel #21
0
 /// <summary>
 /// Delete Engine Type
 /// </summary>
 /// <param name="engineTypeId"></param>
 public void DeleteMaintenance(string workID)
 {
     // Delete
     using (var db = new EasyMaintainDBContext())
     {
         var engineType = db.Maintenances.SingleOrDefault(s => s.WorkID.Equals(workID));
         db.Maintenances.Attach(engineType);
         db.Maintenances.Remove(engineType);
         db.SaveChanges();
     }
 }
Beispiel #22
0
        //--- Delete Data

        /// <summary>
        /// Delete Supplier
        /// </summary>
        /// <param name="supplierId"></param>
        public void DeleteSupplier(int supplierId)
        {
            // Delete
            using (var db = new EasyMaintainDBContext())
            {
                var supplier = db.Suppliers.SingleOrDefault(s => s.SupplierID == supplierId);
                db.Suppliers.Attach(supplier);
                db.Suppliers.Remove(supplier);
                db.SaveChanges();
            }
        }
Beispiel #23
0
 /// <summary>
 /// Delete Spare Part
 /// </summary>
 /// <param name="sparePartId"></param>
 public void DeleteSparePart(int sparePartId)
 {
     // Delete
     using (var db = new EasyMaintainDBContext())
     {
         var sparePart = db.SpareParts.SingleOrDefault(s => s.SparePartID == sparePartId);
         db.SpareParts.Attach(sparePart);
         db.SpareParts.Remove(sparePart);
         db.SaveChanges();
     }
 }
Beispiel #24
0
 /// <summary>
 /// Delete Aircraft Model
 /// </summary>
 /// <param name="aircraftModleId"></param>
 public void DeleteAircraftModel(int aircraftModleId)
 {
     // Delete
     using (var db = new EasyMaintainDBContext())
     {
         var aircraftModel = db.AircraftModels.SingleOrDefault(s => s.AircraftModelID == aircraftModleId);
         db.AircraftModels.Attach(aircraftModel);
         db.AircraftModels.Remove(aircraftModel);
         db.SaveChanges();
     }
 }
Beispiel #25
0
 /// <summary>
 /// Delete Component Work
 /// </summary>
 /// <param name="WorkID"></param>
 public void DeleteComponentWork(int workId)
 {
     // Delete
     using (var db = new EasyMaintainDBContext())
     {
         var component = db.ComponentWorks.SingleOrDefault(s => s.WorkID.Equals(workId));
         db.ComponentWorks.Attach(component);
         db.ComponentWorks.Remove(component);
         db.SaveChanges();
     }
 }
Beispiel #26
0
 /// <summary>
 /// Delete Category
 /// </summary>
 /// <param name="categoryId"></param>
 public void DeleteCategory(int categoryId)
 {
     // Delete
     using (var db = new EasyMaintainDBContext())
     {
         var category = db.Categories.SingleOrDefault(s => s.CategoryID == categoryId);
         db.Categories.Attach(category);
         db.Categories.Remove(category);
         db.SaveChanges();
     }
 }
Beispiel #27
0
 /// <summary>
 /// Delete Manufacturer
 /// </summary>
 /// <param name="manufacturerId"></param>
 public void DeleteManufacturer(int manufacturerId)
 {
     // Delete
     using (var db = new EasyMaintainDBContext())
     {
         var manufacturer = db.Manufactureres.SingleOrDefault(s => s.ManufacturerID.Equals(manufacturerId));
         db.Manufactureres.Attach(manufacturer);
         db.Manufactureres.Remove(manufacturer);
         db.SaveChanges();
     }
 }
Beispiel #28
0
 /// <summary>
 /// Delete Manufacturer
 /// </summary>
 /// <param name="Name"></param>
 public void DeleteCrew(String name)
 {
     // Delete
     using (var db = new EasyMaintainDBContext())
     {
         var crew = db.Crews.SingleOrDefault(s => s.Name.Equals(name));
         db.Crews.Attach(crew);
         db.Crews.Remove(crew);
         db.SaveChanges();
     }
 }
Beispiel #29
0
        /// <summary>
        /// Add Manufacturer
        /// </summary>
        /// <param name="DeliveryDetailsId"></param>
        /// <param name="DeliveryDate"></param>
        /// <param name="DeliveryMethod"></param>
        /// <param name="PersonInCharge"></param>
        /// <param name="AddressLine1"></param>
        /// <param name="AddressLine2"></param>
        /// <param name="City"></param>
        /// <param name="State"></param>
        /// <param name="AddtionalNotes"></param>
        /// <returns></returns>
        public int AddDeliveryDetails(string deliveryDetailsId, string deliveryDate, string deliveryMethod, string personInCharge, string addressLine1, string addressLine2, string city, string state, string addtionalNotes)
        {
            // insert
            using (var db = new EasyMaintainDBContext())
            {
                var delivery = db.Set <DeliveryDetails>();
                try
                {
                    delivery.Add(new DeliveryDetails {
                        DeliveryDetailsId = Int32.Parse(deliveryDetailsId), DeliveryDate = deliveryDate, DeliveryMethod = deliveryMethod, PersonInCharge = personInCharge, AddressLine1 = addressLine1, AddressLine2 = addressLine2, City = city, State = state, AddtionalNotes = addtionalNotes
                    });

                    db.SaveChanges();
                }
                catch (SqlException ex)
                {
                    throw ex;
                }

                return(1);
            }
        }