예제 #1
0
        public void SaveFurColor()
        {
            try
            {
                if (FurColorName != null)
                {
                    using (ShelterDatabaseLINQDataContext db = new ShelterDatabaseLINQDataContext())
                    {
                        FurColors furColor = new FurColors
                        {
                            FurColorName = FurColorName,
                            IsDeleted    = null
                        };
                        db.FurColors.InsertOnSubmit(furColor);
                        db.SubmitChanges();

                        ID = furColor.Id;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #2
0
        public void SaveCost()
        {
            try
            {
                using (ShelterDatabaseLINQDataContext db = new ShelterDatabaseLINQDataContext())
                {
                    Costs cost = new Costs
                    {
                        AnimalID    = AnimalID,
                        CostName    = CostName,
                        Description = Description,
                        Price       = Price,
                        Date        = Date
                    };
                    db.Costs.InsertOnSubmit(cost);
                    db.SubmitChanges();

                    ID = cost.Id;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #3
0
        public void SaveAdoption()
        {
            try
            {
                using (ShelterDatabaseLINQDataContext db = new ShelterDatabaseLINQDataContext())
                {
                    Adoptions adoption = new Adoptions
                    {
                        AnimalID     = AnimalID,
                        PersonID     = PersonID,
                        Returned     = false,
                        ReturnDate   = ReturnDate,
                        ReturnReason = ReturnReason,
                        Date         = Date
                    };
                    db.Adoptions.InsertOnSubmit(adoption);
                    db.SubmitChanges();

                    ID = adoption.ID;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #4
0
 public void SaveStay()
 {
     try
     {
         using (ShelterDatabaseLINQDataContext db = new ShelterDatabaseLINQDataContext())
         {
             Stays stay = new Stays
             {
                 AnimalID   = AnimalID,
                 StartDate  = StartDate,
                 FinishDate = FinishDate,
                 Note       = Note,
                 FindDate   = FindDate,
                 FindPlace  = FindPlace,
                 Adopted    = Adopted,
                 Escaped    = Escaped,
                 Died       = Died
             };
             db.Stays.InsertOnSubmit(stay);
             db.SubmitChanges();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
예제 #5
0
        public void SaveBreed()
        {
            try
            {
                if (BreedName != null)
                {
                    using (ShelterDatabaseLINQDataContext db = new ShelterDatabaseLINQDataContext())
                    {
                        Breeds breed = new Breeds
                        {
                            BreedName = BreedName,
                            SpeciesID = SpeciesID,
                            IsDeleted = null
                        };
                        db.Breeds.InsertOnSubmit(breed);
                        db.SubmitChanges();

                        ID = breed.Id;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #6
0
        public void SavePerson()
        {
            try
            {
                using (ShelterDatabaseLINQDataContext db = new ShelterDatabaseLINQDataContext())
                {
                    People person = new People
                    {
                        Title        = Title,
                        FirstName    = FirstName,
                        LastName     = LastName,
                        Phone        = Phone,
                        Mail         = Mail,
                        Note         = Note,
                        AdressCity   = AdressCity,
                        AdressStreet = AdressStreet,
                        AdressZip    = AdressZip,
                        IsOwner      = IsOwner,
                        IsVet        = IsVet,
                        IsWalker     = IsWalker,
                        IsSponsor    = IsSponsor,
                        IsVolunteer  = IsVolunteer
                    };
                    db.People.InsertOnSubmit(person);
                    db.SubmitChanges();

                    ID = person.Id;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #7
0
        public void UpdateStay()
        {
            try
            {
                using (ShelterDatabaseLINQDataContext db = new ShelterDatabaseLINQDataContext())
                {
                    Stays stay = db.Stays.FirstOrDefault(i => i.Id == ID);

                    stay.StartDate  = StartDate;
                    stay.FinishDate = FinishDate;
                    stay.Note       = Note;
                    stay.Adopted    = Adopted;
                    stay.Escaped    = Escaped;
                    stay.Died       = Died;
                    stay.FindDate   = FindDate;
                    stay.FindPlace  = FindPlace;

                    db.SubmitChanges();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #8
0
        public void SaveWalk()
        {
            try
            {
                using (ShelterDatabaseLINQDataContext db = new ShelterDatabaseLINQDataContext())
                {
                    db.DeferredLoadingEnabled = false;

                    Walks walk = new Walks
                    {
                        AnimalID = AnimalID,
                        Date     = Date,
                        PersonID = PersonID,
                        Note     = Note
                    };
                    db.Walks.InsertOnSubmit(walk);
                    db.SubmitChanges();

                    ID = walk.ID;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #9
0
        public void SaveDonation()
        {
            try
            {
                using (ShelterDatabaseLINQDataContext db = new ShelterDatabaseLINQDataContext())
                {
                    Donations donation = new Donations
                    {
                        DonatorID    = DonatorID,
                        DonationName = DonationName,
                        Description  = Description,
                        Amount       = Amount,
                        Date         = Date
                    };
                    db.Donations.InsertOnSubmit(donation);
                    db.SubmitChanges();

                    ID = donation.ID;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #10
0
        public void SaveMedicalRecord()
        {
            try
            {
                using (ShelterDatabaseLINQDataContext db = new ShelterDatabaseLINQDataContext())
                {
                    MedicalRecords medicalRecord = new MedicalRecords
                    {
                        AnimalID    = AnimalID,
                        RecordName  = RecordName,
                        Description = Description,
                        CostID      = CostID,
                        Date        = Date,
                        VetID       = VetID
                    };
                    db.MedicalRecords.InsertOnSubmit(medicalRecord);
                    db.SubmitChanges();

                    ID = medicalRecord.Id;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #11
0
        public void UpdatePerson()
        {
            try
            {
                using (ShelterDatabaseLINQDataContext db = new ShelterDatabaseLINQDataContext())
                {
                    People person = db.People.FirstOrDefault(i => i.Id == ID);

                    person.Title        = Title;
                    person.FirstName    = FirstName;
                    person.LastName     = LastName;
                    person.Phone        = Phone;
                    person.Mail         = Mail;
                    person.Note         = Note;
                    person.AdressCity   = AdressCity;
                    person.AdressStreet = AdressStreet;
                    person.AdressZip    = AdressZip;
                    person.IsOwner      = IsOwner;
                    person.IsSponsor    = IsSponsor;
                    person.IsVet        = IsVet;
                    person.IsWalker     = IsWalker;
                    person.IsVolunteer  = IsVolunteer;

                    db.SubmitChanges();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #12
0
 public static void MarkAsDeleted(int id)
 {
     using (ShelterDatabaseLINQDataContext db = new ShelterDatabaseLINQDataContext())
     {
         var coatType = db.CoatTypes.Single(x => x.Id == id);
         coatType.IsDeleted = DateTime.Now;
         db.SubmitChanges();
     }
 }
예제 #13
0
 public static void MarkAsDeleted(int id)
 {
     try
     {
         using (ShelterDatabaseLINQDataContext db = new ShelterDatabaseLINQDataContext())
         {
             var animal = db.Animals.Single(x => x.ID == id);
             animal.IsDeleted = DateTime.Now;
             db.SubmitChanges();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
예제 #14
0
 public static void MarkAsDeleted(int id)
 {
     try
     {
         using (ShelterDatabaseLINQDataContext db = new ShelterDatabaseLINQDataContext())
         {
             var record = db.MedicalRecords.Single(x => x.Id == id);
             record.IsDeleted = DateTime.Now;
             db.SubmitChanges();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
예제 #15
0
        public void SaveCoatType()
        {
            if (CoatTypeName != null)
            {
                using (ShelterDatabaseLINQDataContext db = new ShelterDatabaseLINQDataContext())
                {
                    CoatTypes coatType = new CoatTypes
                    {
                        CoatTypeName = CoatTypeName,
                        IsDeleted    = null
                    };
                    db.CoatTypes.InsertOnSubmit(coatType);
                    db.SubmitChanges();

                    ID = coatType.Id;
                }
            }
        }
예제 #16
0
        public static void SetLogo(string path)
        {
            try
            {
                using (ShelterDatabaseLINQDataContext db = new ShelterDatabaseLINQDataContext())
                {
                    Shelter shelter = db.Shelter.FirstOrDefault();

                    shelter.LogoPath = path;


                    db.SubmitChanges();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #17
0
        public void SaveAnimal()
        {
            try
            {
                using (ShelterDatabaseLINQDataContext db = new ShelterDatabaseLINQDataContext())
                {
                    Animals animal = new Animals
                    {
                        Name         = Name,
                        ChipNumber   = ChipNumber,
                        Birth        = BirthDate,
                        SexID        = SexID,
                        SpeciesID    = SpeciesID,
                        BreedID      = BreedID,
                        CrossBreedID = CrossBreedID,
                        CoatTypeID   = CoatTypeID,
                        FurColorID   = FurColorID,
                        OwnerID      = OwnerID,
                        NewOwnerID   = NewOwnerID,
                        VetID        = VetID,
                        FeedRation   = FeedRation,
                        Weight       = Weight,
                        Note         = Note,
                        Castration   = Castration,
                        InShelter    = InShelter,
                        IsDead       = IsDead,
                        FolderPath   = FolderPath,
                        ImagePath    = ImagePath,
                    };
                    db.Animals.InsertOnSubmit(animal);
                    db.SubmitChanges();

                    ID = animal.ID;

                    CreateDocumentFolder();
                    UpdateAnimal();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #18
0
        public void UpdateAdoption()
        {
            try
            {
                using (ShelterDatabaseLINQDataContext db = new ShelterDatabaseLINQDataContext())
                {
                    Adoptions adoption = db.Adoptions.FirstOrDefault(i => i.ID == ID);

                    adoption.Returned     = Returned;
                    adoption.ReturnDate   = ReturnDate;
                    adoption.ReturnReason = ReturnReason;

                    db.SubmitChanges();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #19
0
 public void CreateEscape()
 {
     try
     {
         using (ShelterDatabaseLINQDataContext db = new ShelterDatabaseLINQDataContext())
         {
             Escapes escape = new Escapes
             {
                 AnimalID    = AnimalID,
                 Date        = Date,
                 Description = Description,
             };
             db.Escapes.InsertOnSubmit(escape);
             db.SubmitChanges();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
예제 #20
0
        public void UpdateWalk()
        {
            try
            {
                using (ShelterDatabaseLINQDataContext db = new ShelterDatabaseLINQDataContext())
                {
                    Walks walk = db.Walks.FirstOrDefault(i => i.ID == ID);

                    walk.AnimalID = AnimalID;
                    walk.PersonID = PersonID;
                    walk.Note     = Note;
                    walk.Date     = Date;

                    db.SubmitChanges();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #21
0
        public void UpdateIncident()
        {
            try
            {
                using (ShelterDatabaseLINQDataContext db = new ShelterDatabaseLINQDataContext())
                {
                    Incidents incident = db.Incidents.FirstOrDefault(i => i.ID == ID);

                    incident.IncidentDate = Date;
                    incident.Severity     = Severity;
                    incident.Description  = Description;
                    incident.AnimalID     = AnimalID;

                    db.SubmitChanges();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #22
0
        public void UpdateMedicalRecord()
        {
            try
            {
                using (ShelterDatabaseLINQDataContext db = new ShelterDatabaseLINQDataContext())
                {
                    MedicalRecords medicalRecord = db.MedicalRecords.FirstOrDefault(i => i.Id == ID);

                    medicalRecord.RecordName  = RecordName;
                    medicalRecord.VetID       = VetID;
                    medicalRecord.Description = Description;
                    medicalRecord.Date        = Date;

                    db.SubmitChanges();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #23
0
        public void UpdateDonation()
        {
            try
            {
                using (ShelterDatabaseLINQDataContext db = new ShelterDatabaseLINQDataContext())
                {
                    Donations donation = db.Donations.FirstOrDefault(i => i.ID == ID);

                    donation.Amount       = Amount;
                    donation.Date         = Date;
                    donation.DonationName = DonationName;
                    donation.Description  = Description;
                    donation.DonatorID    = DonatorID;

                    db.SubmitChanges();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #24
0
        public void SaveDiaryRecord()
        {
            try
            {
                using (ShelterDatabaseLINQDataContext db = new ShelterDatabaseLINQDataContext())
                {
                    DiaryRecords diaryRecord = new DiaryRecords
                    {
                        Date   = Date,
                        Record = Record
                    };
                    db.DiaryRecords.InsertOnSubmit(diaryRecord);
                    db.SubmitChanges();

                    ID = diaryRecord.Id;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #25
0
        public void UpdateCost()
        {
            try
            {
                using (ShelterDatabaseLINQDataContext db = new ShelterDatabaseLINQDataContext())
                {
                    Costs cost = db.Costs.FirstOrDefault(i => i.Id == ID);

                    cost.Price       = Price;
                    cost.Date        = Date;
                    cost.CostName    = CostName;
                    cost.Description = Description;
                    cost.AnimalID    = AnimalID;

                    db.SubmitChanges();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #26
0
        public void UpdateInfo()
        {
            try
            {
                using (ShelterDatabaseLINQDataContext db = new ShelterDatabaseLINQDataContext())
                {
                    Shelter shelter = db.Shelter.FirstOrDefault();

                    shelter.Name    = Name;
                    shelter.Phone   = Phone;
                    shelter.Phone2  = Phone2;
                    shelter.Mail    = Mail;
                    shelter.Adress  = Adress;
                    shelter.Account = Account;

                    db.SubmitChanges();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #27
0
        public void UpdateAnimal()
        {
            try
            {
                using (ShelterDatabaseLINQDataContext db = new ShelterDatabaseLINQDataContext())
                {
                    Animals animal = db.Animals.FirstOrDefault(i => i.ID == ID);

                    animal.Name         = Name;
                    animal.ChipNumber   = ChipNumber;
                    animal.Birth        = BirthDate;
                    animal.SexID        = SexID;
                    animal.SpeciesID    = SpeciesID;
                    animal.BreedID      = BreedID;
                    animal.CrossBreedID = CrossBreedID;
                    animal.CoatTypeID   = CoatTypeID;
                    animal.FurColorID   = FurColorID;
                    animal.FeedRation   = FeedRation;
                    animal.Weight       = Weight;
                    animal.OwnerID      = OwnerID;
                    animal.NewOwnerID   = NewOwnerID;
                    animal.VetID        = VetID;
                    animal.Note         = Note;
                    animal.Castration   = Castration;
                    animal.InShelter    = InShelter;
                    animal.IsDead       = IsDead;
                    animal.FolderPath   = FolderPath;
                    animal.ImagePath    = ImagePath;

                    db.SubmitChanges();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #28
0
        public static void RestoreDeleted(DateTime since, DateTime to)
        {
            try
            {
                using (ShelterDatabaseLINQDataContext db = new ShelterDatabaseLINQDataContext())
                {
                    var records = (from record in db.CoatTypes
                                   where record.IsDeleted >= since && record.IsDeleted <= to
                                   select record).ToList();

                    foreach (var record in records)
                    {
                        record.IsDeleted = null;
                    }


                    db.SubmitChanges();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #29
0
 public void CreateDeath()
 {
     try
     {
         using (ShelterDatabaseLINQDataContext db = new ShelterDatabaseLINQDataContext())
         {
             Deaths death = new Deaths
             {
                 AnimalID    = AnimalID,
                 Date        = Date,
                 Description = Description,
                 Euthanasia  = Euthanasia,
                 Natural     = Natural,
                 Other       = Other
             };
             db.Deaths.InsertOnSubmit(death);
             db.SubmitChanges();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
예제 #30
0
        public void SaveIncident()
        {
            try
            {
                using (ShelterDatabaseLINQDataContext db = new ShelterDatabaseLINQDataContext())
                {
                    Incidents incident = new Incidents
                    {
                        AnimalID     = AnimalID,
                        Severity     = Severity,
                        Description  = Description,
                        IncidentDate = Date
                    };
                    db.Incidents.InsertOnSubmit(incident);
                    db.SubmitChanges();

                    ID = incident.ID;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }