Esempio n. 1
0
        public void Delete(Hospital_Entity_Framework.Management management)
        {
            var delete = _db.Managements.Single(v => v.Id == management.Id);

            _db.Managements.Remove(delete);
            _db.SaveChanges();
        }
Esempio n. 2
0
        private void DeleteForm(Hospital_Entity_Framework.Account acc)
        {
            var getManagement = _db.Managements.FirstOrDefault(v => v.AccountId == acc.Id);

            if (getManagement != null)
            {
                if (getManagement.Forms != null)
                {
                    foreach (var item in getManagement.Forms.ToList())
                    {
                        if (item.Id == 6)
                        {
                            continue;
                        }
                        var getItem = _db.Forms.First(v => v.Id == item.Id);
                        getManagement.Forms.Remove(getItem);
                    }
                }
            }
            else
            {
                var insert = new Hospital_Entity_Framework.Management()
                {
                    AccountId = acc.Id
                };
                _db.Managements.Add(insert);
            }
            _db.SaveChanges();
        }
Esempio n. 3
0
        private void Insert(int accId)
        {
            var insert = new Hospital_Entity_Framework.Management()
            {
                AccountId = accId
            };

            _db.Managements.Add(insert);
            _db.SaveChanges();
        }
Esempio n. 4
0
        public TabPage TabConsultation(Hospital_Entity_Framework.Account acc, CategorySelection categorySelection)
        {
            var tab = new TabPage()
            {
                AutoScroll = true, Text = @"Consultation", Name = @"Consultation"
            };
            var flpn = new FlowLayoutPanel()
            {
                Dock = DockStyle.Fill, AutoScroll = true
            };

            flpn.Controls.Clear();
            _categorySelection = null;
            _categorySelection = categorySelection;
            _account           = acc;

            var chkMedicalForm = _db.TempManagements.Where(v => v.WorkerId == acc.WorkerId)
                                 .Any(v => v.Forms == "Medical's Form");

            if (chkMedicalForm)
            {
                var getTemp     = _db.TempManagements.Where(v => v.Forms == "Medical's Form").Where(v => v.Services == "Consultation");
                var getCategory = _db.ConsultationCategories;
                foreach (var itemCategory in getCategory)
                {
                    if (getTemp.Any(v => v.Categorys == itemCategory.Id.ToString()))
                    {
                        var dic = new Dictionary <int, string> {
                            { acc.WorkerId, "Consultation" }
                        };
                        var btn = new Button
                        {
                            Size      = new Size(180, 90),
                            Text      = itemCategory.Name,
                            Name      = itemCategory.Id.ToString(),
                            BackColor = Color.LimeGreen,
                            Font      = new Font("November", 12),
                            Tag       = dic
                        };

                        flpn.Controls.Add(btn);
                        btn.Click += RemoveCategory_Click;
                    }
                    else
                    {
                        var dic = new Dictionary <int, string> {
                            { acc.WorkerId, "Consultation" }
                        };
                        var btn = new Button
                        {
                            Location  = new Point(3, 3),
                            Size      = new Size(180, 90),
                            Text      = itemCategory.Name,
                            Name      = itemCategory.Id.ToString(),
                            BackColor = Color.Khaki,
                            Font      = new Font("November", 12),
                            Tag       = dic
                        };

                        flpn.Controls.Add(btn);
                        btn.Click += TakeCategory_Click;
                    }
                }
            }
            else
            {
                var getManagement = _db.Managements.Any(v => v.AccountId == acc.Id);
                if (getManagement)
                {
                    var getCategoryforManagement = _db.Managements.First(v => v.AccountId == acc.Id);
                    if (getCategoryforManagement.ConsultationCategories != null)
                    {
                        foreach (var item in getCategoryforManagement.ConsultationCategories.ToList())
                        {
                            var insertTemp = new TempManagement()
                            {
                                WorkerId = acc.WorkerId, Forms = "Medical's Form", Services = "Consultation", Categorys = item.Id.ToString()
                            };
                            _db.TempManagements.Add(insertTemp);
                        }
                    }
                    if (getCategoryforManagement.LaboratoryCategories != null)
                    {
                        foreach (var item in getCategoryforManagement.LaboratoryCategories.ToList())
                        {
                            var insertTemp = new TempManagement()
                            {
                                WorkerId = acc.WorkerId, Forms = "Medical's Form", Services = "Laboratory", Categorys = item.Id.ToString()
                            };
                            _db.TempManagements.Add(insertTemp);
                        }
                    }
                    if (getCategoryforManagement.MedicalImagingCategories != null)
                    {
                        foreach (var item in getCategoryforManagement.MedicalImagingCategories.ToList())
                        {
                            var insertTemp = new TempManagement()
                            {
                                WorkerId = acc.WorkerId, Forms = "Medical's Form", Services = "MedicalImaging", Categorys = item.Id.ToString()
                            };
                            _db.TempManagements.Add(insertTemp);
                        }
                    }
                    if (getCategoryforManagement.PrescriptionCategories != null)
                    {
                        foreach (var item in getCategoryforManagement.PrescriptionCategories.ToList())
                        {
                            var insertTemp = new TempManagement()
                            {
                                WorkerId = acc.WorkerId, Forms = "Medical's Form", Services = "Prescription", Categorys = item.Id.ToString()
                            };
                            _db.TempManagements.Add(insertTemp);
                        }
                    }
                    if (getCategoryforManagement.VariousDocumentCategories != null)
                    {
                        foreach (var item in getCategoryforManagement.VariousDocumentCategories.ToList())
                        {
                            var insertTemp = new TempManagement()
                            {
                                WorkerId = acc.WorkerId, Forms = "Medical's Form", Services = "VariousDocument", Categorys = item.Id.ToString()
                            };
                            _db.TempManagements.Add(insertTemp);
                        }
                    }
                    _db.SaveChanges();

                    var getTemp     = _db.TempManagements.Where(v => v.Forms == "Medical's Form").Where(v => v.Services == "Consultation");
                    var getCategory = _db.ConsultationCategories;
                    foreach (var itemCategory in getCategory)
                    {
                        if (getTemp.Any(v => v.Categorys == itemCategory.Id.ToString()))
                        {
                            var dic = new Dictionary <int, string> {
                                { acc.WorkerId, "Consultation" }
                            };
                            var btn = new Button
                            {
                                Size      = new Size(180, 90),
                                Text      = itemCategory.Name,
                                Name      = itemCategory.Id.ToString(),
                                BackColor = Color.LimeGreen,
                                Font      = new Font("November", 12),
                                Tag       = dic
                            };

                            flpn.Controls.Add(btn);
                            btn.Click += RemoveCategory_Click;
                        }
                        else
                        {
                            var dic = new Dictionary <int, string> {
                                { acc.WorkerId, "Consultation" }
                            };
                            var btn = new Button
                            {
                                Location  = new Point(3, 3),
                                Size      = new Size(180, 90),
                                Text      = itemCategory.Name,
                                Name      = itemCategory.Id.ToString(),
                                BackColor = Color.Khaki,
                                Font      = new Font("November", 12),
                                Tag       = dic
                            };

                            flpn.Controls.Add(btn);
                            btn.Click += TakeCategory_Click;
                        }
                    }
                }
                else
                {
                    var create = new Hospital_Entity_Framework.Management()
                    {
                        AccountId = acc.Id
                    };
                    _db.Managements.Add(create);
                    _db.SaveChanges();

                    var getTemp     = _db.TempManagements.Where(v => v.Forms == "Medical's Form").Where(v => v.Services == "Consultation");
                    var getCategory = _db.ConsultationCategories;
                    foreach (var itemCategory in getCategory)
                    {
                        if (getTemp.Any(v => v.Categorys == itemCategory.Id.ToString()))
                        {
                            var dic = new Dictionary <int, string> {
                                { acc.WorkerId, "Consultation" }
                            };
                            var btn = new Button
                            {
                                Size      = new Size(180, 90),
                                Text      = itemCategory.Name,
                                Name      = itemCategory.Id.ToString(),
                                BackColor = Color.LimeGreen,
                                Font      = new Font("November", 12),
                                Tag       = dic
                            };

                            flpn.Controls.Add(btn);
                            btn.Click += RemoveCategory_Click;
                        }
                        else
                        {
                            var dic = new Dictionary <int, string> {
                                { acc.WorkerId, "Consultation" }
                            };
                            var btn = new Button
                            {
                                Location  = new Point(3, 3),
                                Size      = new Size(180, 90),
                                Text      = itemCategory.Name,
                                Name      = itemCategory.Id.ToString(),
                                BackColor = Color.Khaki,
                                Font      = new Font("November", 12),
                                Tag       = dic
                            };

                            flpn.Controls.Add(btn);
                            btn.Click += TakeCategory_Click;
                        }
                    }
                }
            }


            tab.Controls.Add(flpn);

            return(tab);
        }