///<summary>Syncs any changes made by the user to the list of Program Properties that indicates this Program Link's button should be hidden
        ///per clinic.  Only syncs changes made to ProgramProperties for clinics the user has access to.</summary>
        private void SyncHiddenProgramProperties()
        {
            //Get the users total list of unrestricted clinics, then acquire their list of ProgramProperties so we can tell which PL buttons
            //should be hidden based upon the ProgramProperty PropertyDesc indicator.
            List <Clinic> listUserClinics = Clinics.GetForUserod(Security.CurUser, doIncludeHQ: true, hqClinicName: Lan.g(this, "HQ"));
            //Get the cached list of button hiding ProgramProperties for clinics this user has access to, i.e. the "Old" list.
            List <ProgramProperty> listHiddenForUserOld = ProgramProperties.GetForProgram(_progNumCur)
                                                          .Where(x => x.PropertyDesc == ProgramProperties.PropertyDescs.ClinicHideButton &&
                                                                 x.ClinicNum.In(listUserClinics.Select(y => y.ClinicNum))).ToList();

            //Compares the old list of ProgramProperties to the new one, if a clinic exists in the old list but not the new list then it was deleted by the
            //user and we remove it from the db.
            foreach (ProgramProperty propOld in listHiddenForUserOld)
            {
                if (!propOld.ProgramPropertyNum.In(_listProgramPropertiesHiddenClinics.Select(x => x.ProgramPropertyNum))) //Clinic was Removed from List
                {
                    ProgramProperties.Delete(propOld);                                                                     //Remove from ProgramProperty
                }
            }
            //Compares the new list of ProgramProperties to the old one, if a clinic exists in the new list but not the old one then it was added by the
            //user and we should add it to the db.
            foreach (ProgramProperty propNew in _listProgramPropertiesHiddenClinics)
            {
                if (!propNew.ProgramPropertyNum.In(listHiddenForUserOld.Select(x => x.ProgramPropertyNum))) //Clinic was Added to List
                {
                    ProgramProperties.Insert(propNew);                                                      //Insert ProgramProperty
                }
            }
        }
Ejemplo n.º 2
0
        private void UpsertProgramPropertiesForClinics()
        {
            List <ProgramProperty> listLocationIDsFromDb = ProgramProperties.GetForProgram(_progCur.ProgramNum).FindAll(x => x.PropertyDesc == Podium.PropertyDescs.LocationID);
            List <ProgramProperty> listLocationIDsCur    = _dictLocationIDs.Values.ToList();

            foreach (ProgramProperty ppCur in listLocationIDsCur)
            {
                if (listLocationIDsFromDb.Exists(x => x.ProgramPropertyNum == ppCur.ProgramPropertyNum))
                {
                    UpdateProgramProperty(listLocationIDsFromDb[listLocationIDsFromDb.FindIndex(x => x.ProgramPropertyNum == ppCur.ProgramPropertyNum)], ppCur.PropertyValue);                   //ppCur.PropertyValue will match textLocationID.Text
                }
                else
                {
                    ProgramProperties.Insert(ppCur);                    //Program property for that clinicnum didn't exist, so insert it into the db.
                    _hasProgramPropertyChanged = true;
                }
            }
        }
        private void butOK_Click(object sender, EventArgs e)
        {
            if (comboClinics.SelectedIndex == -1)
            {
                MsgBox.Show(this, "Please select a clinic.");
                return;
            }
            _clinicErxCur.ClinicNum = comboClinics.GetSelected <Clinic>().ClinicNum;
            Program         progErx    = Programs.GetCur(ProgramName.eRx);
            ProgramProperty ppClinicID = _listClinicIDs.FirstOrDefault(x => x.ClinicNum == _clinicErxCur.ClinicNum);

            if (ppClinicID == null)
            {
                ppClinicID               = new ProgramProperty();
                ppClinicID.ProgramNum    = progErx.ProgramNum;
                ppClinicID.ClinicNum     = _clinicErxCur.ClinicNum;
                ppClinicID.PropertyDesc  = Erx.PropertyDescs.ClinicID;
                ppClinicID.PropertyValue = _clinicErxCur.ClinicId;
                ProgramProperties.Insert(ppClinicID);
            }
            else
            {
                ppClinicID.PropertyValue = _clinicErxCur.ClinicId;
                ProgramProperties.Update(ppClinicID);
            }
            ProgramProperty ppClinicKey = _listClinicKeys.FirstOrDefault(x => x.ClinicNum == _clinicErxCur.ClinicNum);

            if (ppClinicKey == null)
            {
                ppClinicKey               = new ProgramProperty();
                ppClinicKey.ProgramNum    = progErx.ProgramNum;
                ppClinicKey.ClinicNum     = _clinicErxCur.ClinicNum;
                ppClinicKey.PropertyDesc  = Erx.PropertyDescs.ClinicKey;
                ppClinicKey.PropertyValue = _clinicErxCur.ClinicKey;
                ProgramProperties.Insert(ppClinicKey);
            }
            else
            {
                ppClinicKey.PropertyValue = _clinicErxCur.ClinicKey;
                ProgramProperties.Update(ppClinicKey);
            }
            DataValid.SetInvalid(InvalidType.Programs);
            DialogResult = DialogResult.OK;
        }