Exemple #1
0
        public static void ShowAllWaybills()
        {
            waybillRepository = new WaybillRepository();
            var allWaybills = waybillRepository.GetAll();

            if (allWaybills.Count > 0)
            {
                Console.WriteLine("\t- Накладные -\n");
                int i = 1;
                itemRepository = new ItemRepository();
                var allItems = itemRepository.GetAll();

                foreach (var waybill in allWaybills)
                {
                    Console.Write($"\n{i}.\tТовар: {allItems.Where(item => item.Id.Equals(waybill.ItemId)).FirstOrDefault().Name}");
                    Console.Write($" (Всего на складе: {allItems.Where(item => item.Id.Equals(waybill.ItemId)).FirstOrDefault().Quantity})");
                    Console.WriteLine($"\n\tКоличество: {waybill.Quantity}");
                    Console.WriteLine($"\tСтатус: {waybill.Status}");
                    if (waybill.Status == "На складе")
                    {
                        storekeeperRepository = new StorekeeperRepository();
                        var allStorekeepers = storekeeperRepository.GetAll();
                        var storekeeper     = allStorekeepers.Where(s => s.Id.Equals(waybill.StorekeeperId)).ToList();
                        Console.WriteLine($"\tКладовщик: {storekeeper.FirstOrDefault().FullName}");
                    }
                    i++;
                }
            }
        }
        public void CreateAdd()
        {
            var patient  = new Patient("Ivan", "Ivanov", "KI55000", "+375152996");
            var patient1 = new Patient("Petr", "Sergeev", "KH1234311", "+375291545");

            var doctor = new Doctor("Platon", "Sidorov", "Therapist");

            var car = new MedicalCar("Mercedes Benz Sprinter 412", "12.05.2009", "VBGTF48483D6");

            var call  = new Call(new DateTime(2015, 3, 15));
            var call1 = new Call(new DateTime(2015, 3, 16));

            var waybill = new Waybill(new DateTime(2015, 3, 16));

            doctor.Patients.Add(patient);
            doctor.Patients.Add(patient1);
            doctor.Car.Add(car);

            car.Doctors.Add(doctor);
            car.Waybills.Add(waybill);

            call.Patient.Add(patient);
            call.Waybill = waybill;

            call1.Patient.Add(patient1);
            call1.Waybill = waybill;

            waybill.Car = car;
            waybill.Calls.Add(call);
            waybill.Calls.Add(call1);

            patient.Call   = call;
            patient.Doctor = doctor;

            patient1.Call   = call1;
            patient1.Doctor = doctor;

            using (var context = new DataContext())
            {
                context.Database.CreateIfNotExists();

                // context.Database.Delete();
                BaseRepository <Call>       calls       = new CallRepository(context);
                BaseRepository <Doctor>     doctors     = new DoctorRepository(context);
                BaseRepository <MedicalCar> medicalCars = new MedicalCarRepository(context);
                BaseRepository <Patient>    patients    = new PatientRepository(context);
                BaseRepository <Waybill>    waybills    = new WaybillRepository(context);

                patients.Add(patient1);
                patients.Save();
            }
        }
Exemple #3
0
        public static void Change()
        {
            while (true)
            {
                Console.Clear();
                ItemsList.UpdateItemsQuantities();
                WaybillsList.ShowAllWaybills();
                Console.Write("\n\nВведите порядковый номер накладной: ");
                waybillNumberString = Console.ReadLine();
                waybillNumberString = waybillNumberString.ExtractOnlyDigits();
                if (waybillNumberString.IsDigits() == true)
                {
                    Int32.TryParse(waybillNumberString, out waybillNumber);
                    waybillRepository = new WaybillRepository();
                    waybillsQuantity  = waybillRepository.Count();
                    if (waybillNumber > 0 && waybillNumber <= waybillsQuantity)
                    {
                        if (WaybillsList.IsFree(waybillNumber) == true)
                        {
                            Console.Clear();
                            StorekeepersList.ShowAllStorekeepers();
                            Console.Write("\n\nВведите порядковый номер кладовщика: ");
                            storekeeperNumberString = Console.ReadLine();
                            storekeeperNumberString = waybillNumberString.ExtractOnlyDigits();
                            if (storekeeperNumberString.IsDigits() == true)
                            {
                                Int32.TryParse(storekeeperNumberString, out storekeeperNumber);
                                storekeeperRepository = new StorekeeperRepository();
                                storekeepersQuantity  = storekeeperRepository.Count();
                                if (storekeeperNumber > 0 && storekeeperNumber <= storekeepersQuantity)
                                {
                                    WaybillsList.ChangeStatucAndAddStorekeeper(storekeeperNumber);
                                    ItemsList.UpdateItemsQuantities();
                                }
                            }
                        }
                        else
                        {
                        }

                        Console.Clear();
                    }
                }
            }
        }
Exemple #4
0
        public static void UpdateItemsQuantities()
        {
            itemRepository = new ItemRepository();
            var allItems = itemRepository.GetAll();

            waybillRepository = new WaybillRepository();
            var allWaybills = waybillRepository.GetAll();

            foreach (var item in allItems)
            {
                var waybillsByItem       = allWaybills.Where(w => w.ItemId.Equals(item.Id)).ToList();
                var waybillsByItemStatus = waybillsByItem.Where(w => w.Status.Equals("На складе")).ToList();
                var itemsQuantity        = waybillsByItemStatus.Sum(w => w.Quantity);

                Item newItem = new Item {
                    Id = item.Id, Quantity = itemsQuantity
                };
                itemRepository.Update(newItem);
            }
        }
Exemple #5
0
        private static void FillAllTables()
        {
            StorekeeperRepository storekeeperRepository = new StorekeeperRepository();

            storekeeperRepository.Add(firstStorekeeper);
            storekeeperRepository.Add(secondStorekeeper);

            ItemRepository itemRepository = new ItemRepository();

            itemRepository.Add(firstItem);
            itemRepository.Add(secondItem);
            itemRepository.Add(thirdItem);
            itemRepository.Add(fourthItem);

            WaybillRepository waybillRepository = new WaybillRepository();

            waybillRepository.Add(firstWaybill);
            waybillRepository.Add(secondWaybill);
            waybillRepository.Add(thirdWaybill);
            waybillRepository.Add(fourthWaybill);
            waybillRepository.Add(fifthWaybill);
        }
Exemple #6
0
        public static void ChangeStatucAndAddStorekeeper(int storekeeperNumber)
        {
            storekeeperRepository = new StorekeeperRepository();
            var allStorekeepers = storekeeperRepository.GetAll();
            var storekeeper     = allStorekeepers.Skip(storekeeperNumber - 1).Take(1).ToList();

            //waybillRepository = new WaybillRepository();
            //var allWaybills = waybillRepository.GetAll();
            //var itemId = allWaybills.Where(w => w.Id.Equals(waybillId)).FirstOrDefault().ItemId;
            //var itemsQuantityTemp = allWaybills.Where(w => w.ItemId.Equals(itemId)).ToList();
            //var itemsQuantityTemp2 = itemsQuantityTemp.Where(w => w.Status.Equals("На складе")).Sum(w => w.Quantity);
            //var itemsQuantity = allWaybills.Where(w => w.Id.Equals(waybillId)).FirstOrDefault().Quantity + itemsQuantityTemp2;

            Waybill waybill = new Waybill
            {
                Id            = waybillId,
                StorekeeperId = storekeeper.FirstOrDefault().Id,
                Status        = "На складе",
                //Quantity = itemsQuantity
            };

            waybillRepository = new WaybillRepository();
            waybillRepository.Update(waybill);
        }