Exemplo n.º 1
0
        static public Corpus CreateCorpus(int floors, string name)
        {
            Corpus corpus = new Corpus();

            corpus.Cabinet = new List <Cabinet>();
            corpus.Floors  = floors;
            corpus.Name    = name;

            return(corpus);
        }
Exemplo n.º 2
0
        private void comboBoxCorpus_SelectedIndexChanged(object sender, EventArgs e)
        {
            comboBoxCabinet.Items.Clear();
            string corpusName = comboBoxCorpus.Text;

            Corpus corpus = (from c in db.CorpusSet where c.Name == corpusName select c).ToList()[0];

            foreach (Cabinet c in corpus.Cabinet)
            {
                comboBoxCabinet.Items.Add(c.Num);
            }
        }
Exemplo n.º 3
0
        private void ReloadForm(bool RefreshDataGrid = false, bool selectByCab = false)
        {
            if (RefreshDataGrid)
            {
                if (!selectByCab)
                {
                    var cabinetsInfo = (from cabinet in db.CabinetSet select new { Корпус = cabinet.Corpus.Name, Этаж = cabinet.Floor, Номер = cabinet.Num, id = cabinet.Id }).ToList();
                    dataGridView1.Columns.Clear();
                    dataGridView1.Columns.Add("Корпус", "Корпус");
                    dataGridView1.Columns.Add("Этаж", "Этаж");
                    dataGridView1.Columns.Add("Номер", "Номер");
                    dataGridView1.Columns.Add("Id", "Id");
                    dataGridView1.Columns["Id"].Visible = false;

                    foreach (var s in cabinetsInfo)
                    {
                        dataGridView1.Rows.Add(s.Корпус, s.Этаж, s.Номер, s.id);
                    }
                    dataGridView1.RowHeadersVisible = false;
                    dataGridView1.Refresh();
                }
                else
                {
                    Corpus corpus       = (from c in db.CorpusSet where c.Name == comboBoxJobs.Text select c).ToList()[0];
                    var    cabinetsInfo = (from cabinet in corpus.Cabinet select new { Корпус = cabinet.Corpus.Name, Этаж = cabinet.Floor, Номер = cabinet.Num, id = cabinet.Id }).ToList();
                    dataGridView1.Columns.Clear();
                    dataGridView1.Columns.Add("Корпус", "Корпус");
                    dataGridView1.Columns.Add("Этаж", "Этаж");
                    dataGridView1.Columns.Add("Номер", "Номер");
                    dataGridView1.Columns.Add("Id", "Id");
                    dataGridView1.Columns["Id"].Visible = false;

                    foreach (var s in cabinetsInfo)
                    {
                        dataGridView1.Rows.Add(s.Корпус, s.Этаж, s.Номер, s.id);
                    }
                    dataGridView1.RowHeadersVisible = false;
                    dataGridView1.Refresh();
                }
                dataGridView1.Refresh();
            }
            else
            {
                comboBoxJobs.Items.Clear();
                var corpuses = (from c in db.CorpusSet select c).ToList();

                foreach (var c in corpuses)
                {
                    comboBoxJobs.Items.Add(c.Name);
                }
            }
        }
Exemplo n.º 4
0
        static public Cabinet CreateCabinet(string corpusName,
                                            int floor,
                                            int num)
        {
            Cabinet cabinet = new Cabinet();
            Corpus  corpus  = (from c in dbContext.CorpusSet where c.Name == corpusName select c).ToList()[0];

            cabinet.Corpus       = corpus;
            cabinet.Floor        = floor;
            cabinet.Num          = num;
            cabinet.TimeForVisit = new List <TimeForVisit>();

            return(cabinet);
        }
Exemplo n.º 5
0
        private void EditVisit_Load(object sender, EventArgs e)
        {
            var doctorsList = (from d in db.PersonSet where d is Doctor select d).ToArray();


            if (doctorsList.Count() == 0)
            {
                MessageBox.Show("Добавьте врачей");
                this.Close();
            }


            foreach (Person d in doctorsList)
            {
                comboBoxDoctor.Items.Add(d.FullName + "_" + d.BirthDate.Date.ToString());
            }



            var corpusList = (from c in db.CorpusSet select c).ToArray();

            if (corpusList.Count() == 0)
            {
                MessageBox.Show("Добавьте корпусы");
                this.Close();
            }

            foreach (Corpus c in corpusList)
            {
                comboBoxCorpus.Items.Add(c.Name);
            }
            comboBoxCorpus.SelectedIndex = 0;

            string corpusName = comboBoxCorpus.Text;

            Corpus corpus = (from c in db.CorpusSet where c.Name == corpusName select c).ToList()[0];

            if (corpus.Cabinet.Count() == 0)
            {
                MessageBox.Show("Добавьте кабинеты в корпус");
                this.Close();
            }

            comboBoxCabinet.Items.Clear();
            foreach (Cabinet c in corpus.Cabinet)
            {
                comboBoxCabinet.Items.Add(c.Num);
            }
        }
Exemplo n.º 6
0
        static public TimeForVisit EditVisit(TimeForVisit visit,
                                             string docInfo,
                                             string patInfo,
                                             string corpusName,
                                             string cabinetNum,
                                             string date,
                                             string time)
        {
            visit = dbContext.TimeForVisitSet.Find(visit.Id);



            string[] docFIODB = docInfo.Split('_');
            string   docFIO   = docFIODB[0];
            DateTime docDB    = DateTime.Parse(docFIODB[1]);
            Doctor   doctor   = (Doctor)(from pers in dbContext.PersonSet where pers is Doctor && pers.FullName == docFIO && pers.BirthDate == docDB select pers).ToList()[0];


            Patient patient = null;

            if (patInfo != "Нет пациента" && patInfo != "")
            {
                string[] patFIODB = patInfo.Split('_');
                string   patFIO   = patFIODB[0];
                DateTime patDB    = DateTime.Parse(patFIODB[1]);
                patient = (Patient)(from pers in dbContext.PersonSet where pers is Patient && pers.FullName == patFIO && pers.BirthDate == patDB select pers).ToList()[0];
            }


            Corpus  corpus  = (from c in dbContext.CorpusSet where c.Name == corpusName select c).ToArray()[0];
            int     num     = int.Parse(cabinetNum);
            Cabinet cabinet = (from c in corpus.Cabinet where c.Num == num select c).ToArray()[0];


            DateTime dateValue = DateTime.Parse(date);
            DateTime timeValue = DateTime.Parse(time);
            DateTime visitTime = dateValue.Add(timeValue.TimeOfDay);

            visit.Cabinet   = cabinet;
            visit.Doctor    = doctor;
            visit.Patient   = patient;
            visit.VisitTime = visitTime;

            dbContext.Entry(visit).State = System.Data.Entity.EntityState.Modified;
            dbContext.SaveChanges();

            return(visit);
        }
Exemplo n.º 7
0
        private void comboBoxCorpus_SelectedIndexChanged_1(object sender, EventArgs e)
        {
            comboBoxFloor.Items.Clear();

            string corpusName = comboBoxCorpus.Text;

            if (corpusName != "")
            {
                Corpus corpus = (from c in db.CorpusSet where c.Name == corpusName select c).ToList()[0];

                for (int i = 0; i < corpus.Floors; i++)
                {
                    comboBoxFloor.Items.Add(i + 1);
                }
            }
        }
Exemplo n.º 8
0
        private void comboBoxCorpus_SelectedIndexChanged(object sender, EventArgs e)
        {
            comboBoxFloor.Items.Clear();

            string corpusName = comboBoxCorpus.Text;
            Corpus corpus     = (from c in db.CorpusSet where c.Name == corpusName select c).ToList().First();

            if (corpus != null)
            {
                for (int i = 0; i < corpus.Floors; i++)
                {
                    comboBoxFloor.Items.Add(i + 1);
                }
                comboBoxFloor.Enabled = true;
            }
        }
Exemplo n.º 9
0
        static public void RemoveCabinet(string cabinetName)
        {
            string  corpusName = cabinetName.Split(':')[0];
            int     cabinetNum = int.Parse(cabinetName.Split(':')[1]);
            Corpus  corpus     = (from c in dbContext.CorpusSet where c.Name == corpusName select c).ToArray()[0];
            Cabinet cabinet    = (from c in corpus.Cabinet where c.Num == cabinetNum select c).ToArray()[0];

            TimeForVisit[] tfvs = cabinet.TimeForVisit.ToArray();
            foreach (TimeForVisit tfv in tfvs)
            {
                dbContext.TimeForVisitSet.Remove(tfv);
            }

            cabinet.TimeForVisit.Clear();

            dbContext.CabinetSet.Remove(cabinet);
            dbContext.SaveChanges();
        }
Exemplo n.º 10
0
        static public Cabinet EditCabinet(Cabinet cabinet,
                                          string corpusName,
                                          int floor,
                                          int num)
        {
            cabinet = dbContext.CabinetSet.Find(cabinet.Id);

            Corpus corpus = (from c in dbContext.CorpusSet where c.Name == corpusName select c).ToList()[0];

            cabinet.Corpus = corpus;
            cabinet.Floor  = floor;
            cabinet.Num    = num;

            dbContext.Entry(cabinet).State = System.Data.Entity.EntityState.Modified;
            dbContext.SaveChanges();

            return(cabinet);
        }
Exemplo n.º 11
0
        static public string AddCorpus(Corpus corpus)
        {
            //Проверка наличия совпадений по этажу, комнате, корпусу
            var searchResult = (from c in dbContext.CorpusSet
                                where c.Name == corpus.Name
                                select c).ToList();

            if (searchResult.Count != 0)
            {
                return("Такой корпус уже существует");
            }
            else
            {
                ;
            }

            //Добавление в БД
            dbContext.CorpusSet.Add(corpus);
            dbContext.SaveChanges();
            return(null);
        }
Exemplo n.º 12
0
        private void buttonAddJob_Click(object sender, EventArgs e)
        {
            string corpusName = textBoxCorpus.Text;

            if (corpusName != "")
            {
                int floors = (int)numericUpDown1.Value;

                Corpus newCorpus = ControlFunctions.CreateCorpus(floors, corpusName);
                string result    = ControlFunctions.AddCorpus(newCorpus);
                if (result != null)
                {
                    MessageBox.Show(result, "Ошибка");
                }
                else
                {
                    ReloadForm();
                }
            }
            else
            {
                MessageBox.Show("Введите название корпуса");
            }
        }
Exemplo n.º 13
0
        protected override void Seed(ModelMedContainer db)
        {
            Job jobNull = ControlFunctions.CreateJob("Нет должности");

            db.JobSet.Add(jobNull);
            Job jobA = ControlFunctions.CreateJob("Главврач");

            db.JobSet.Add(jobA);
            Job jobB = ControlFunctions.CreateJob("Терапевт");

            db.JobSet.Add(jobB);
            db.SaveChanges();

            Doctor docA = ControlFunctions.CreateDoctor("Александров Александр Иванович", DateTime.Parse("11.11.1990"), "Паспорт РФ", "0000000001", "Главврач", "Home,1", "Enough", "Мужской", "12345", "2");

            db.PersonSet.Add(docA);


            Doctor docB = ControlFunctions.CreateDoctor("Иванов Иван Иванович", DateTime.Parse("11.11.1980"), "Паспорт РФ", "0000000002", "Терапевт", "Home,2", "Enough", "Мужской", "12346", "2");

            db.PersonSet.Add(docB);


            db.SaveChanges();



            Doctor docC = ControlFunctions.CreateDoctor("Иванов Иван Иванович", DateTime.Parse("11.11.1955"), "Паспорт РФ", "0000000003", "Терапевт", "Home,2", "Enough", "Мужской", "123473", "2");

            ControlFunctions.AddPerson(docC);



            Patient patA  = ControlFunctions.CreatePatient("Иванов Иван Иванович", DateTime.Parse("11.12.1980"), "Паспорт РФ", "0000000004", "Home,3", "+1", "Мужской", "12347", "2");
            Corpus  corpA = ControlFunctions.CreateCorpus(3, "Корпус 1");

            db.CorpusSet.Add(corpA);
            db.SaveChanges();
            Cabinet cabA = ControlFunctions.CreateCabinet("Корпус 1", 1, 1);

            db.CabinetSet.Add(cabA);
            db.SaveChanges();

            TimeForVisit timeA = ControlFunctions.CreateTimeForVisit("Иванов Иван Иванович_11.11.1980", "Корпус 1", "1", "11.11.2000", "00:00:00");
            TimeForVisit timeB = ControlFunctions.CreateTimeForVisit("Иванов Иван Иванович_11.11.1980", "Корпус 1", "1", "11.11.2000", "12:13:17");

            db.TimeForVisitSet.Add(timeB);
            db.TimeForVisitSet.Add(timeA);
            patA.TimeForVisit.Add(timeA);
            timeA.Patient = patA;


            Illness illA  = ControlFunctions.CreateIllness("Что-то можно, что-то нельзя.", "Болезнь А");
            Illness illAA = ControlFunctions.CreateIllness("Что-то можно, что-то нельзя.", "Болезнь А");
            Illness illB  = ControlFunctions.CreateIllness("Что-то можно, что-то нельзя.", "Болезнь Б");

            db.IllnessSet.Add(illA);
            illA.MedCard.Add(patA.MedCard);
            patA.MedCard.Illness.Add(illA);

            db.IllnessSet.Add(illB);
            illB.MedCard.Add(patA.MedCard);
            patA.MedCard.Illness.Add(illB);


            db.PersonSet.Add(patA);



            Record recA = ControlFunctions.CreateRecord(DateTime.Now, docB, "111", patA.MedCard);
            Record recB = ControlFunctions.CreateRecord(DateTime.Parse("11.11.2000"), docB, "222", patA.MedCard);
            Record recC = ControlFunctions.CreateRecord(DateTime.Parse("11.11.2010"), docA, "333", patA.MedCard);

            db.RecordSet.Add(recA);
            db.RecordSet.Add(recB);
            db.RecordSet.Add(recC);

            db.JobSet.Add(ControlFunctions.CreateJob("testJob"));
            db.SaveChanges();
        }