示例#1
0
        private void FormSiteLinkEdit_Load(object sender, EventArgs e)
        {
            Site site = Sites.GetFirstOrDefault(x => x.SiteNum == _siteLink.SiteNum);

            if (_siteLink.SiteNum < 1 || site == null)
            {
                MsgBox.Show(this, "Invalid SiteNum set for the passed in siteLink.");
                DialogResult = DialogResult.Abort;
                Close();
                return;
            }
            textSite.Text = site.Description;
            //Octets
            if (!string.IsNullOrEmpty(_siteLink.OctetStart))
            {
                string[] arrayOctets = _siteLink.OctetStart.Split('.');
                if (arrayOctets.Length > 0)
                {
                    textOctet1.Text = arrayOctets[0];
                }
                if (arrayOctets.Length > 1)
                {
                    textOctet2.Text = arrayOctets[1];
                }
                if (arrayOctets.Length > 2)
                {
                    textOctet3.Text = arrayOctets[2];
                }
            }
            //Triage
            comboTriageCoordinator.Items.Clear();
            foreach (Employee employee in Employees.GetDeepCopy(true))
            {
                int index = comboTriageCoordinator.Items.Add(new ODBoxItem <Employee>(Employees.GetNameFL(employee), employee));
                if (_siteLink.EmployeeNum == employee.EmployeeNum)
                {
                    comboTriageCoordinator.SelectedIndex = index;
                }
            }
            //Colors
            panelSiteColor.BackColor  = _siteLink.SiteColor;
            panelForeColor.BackColor  = _siteLink.ForeColor;
            panelInnerColor.BackColor = _siteLink.InnerColor;
            panelOuterColor.BackColor = _siteLink.OuterColor;
            labelOpsCountPreview.SetColors(panelForeColor.BackColor, panelOuterColor.BackColor, panelInnerColor.BackColor);
            FillGridConnections();
        }
示例#2
0
        private void FillEmployees()
        {
            List <Employee> employees = Employees.GetDeepCopy(true);

            employees.Sort(new Employees.EmployeeComparer(Employees.EmployeeComparer.SortBy.ext));
            gridEmployees.BeginUpdate();
            gridEmployees.Columns.Clear();
            ODGridColumn col = new ODGridColumn("Ext. - Name", 0);

            col.TextAlign = HorizontalAlignment.Left;
            gridEmployees.Columns.Add(col);
            gridEmployees.Rows.Clear();
            ODGridRow row;

            for (int i = 0; i < employees.Count; i++)
            {
                row = new ODGridRow();
                row.Cells.Add(employees[i].PhoneExt + " - " + employees[i].FName + " " + employees[i].LName);
                row.Tag = employees[i];
                //row.ColorBackG=gridEmployees.Rows.Count%2==0?Color.LightGray:Color.White;
                gridEmployees.Rows.Add(row);
            }
            gridEmployees.EndUpdate();
        }
示例#3
0
        private void FillGrid()
        {
            Employees.RefreshCache();
            _listEmployees = Employees.GetDeepCopy();
            gridMain.BeginUpdate();
            gridMain.Columns.Clear();
            ODGridColumn col = new ODGridColumn(Lan.g("FormEmployeeSelect", "FName"), 75);

            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("FormEmployeeSelect", "LName"), 75);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("FormEmployeeSelect", "MiddleI"), 50);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("FormEmployeeSelect", "Hidden"), 50, HorizontalAlignment.Center);
            gridMain.Columns.Add(col);
            gridMain.Rows.Clear();
            ODGridRow row;

            for (int i = 0; i < _listEmployees.Count; i++)
            {
                row = new ODGridRow();
                row.Cells.Add(_listEmployees[i].FName);
                row.Cells.Add(_listEmployees[i].LName);
                row.Cells.Add(_listEmployees[i].MiddleI);
                if (_listEmployees[i].IsHidden)
                {
                    row.Cells.Add("X");
                }
                else
                {
                    row.Cells.Add("");
                }
                gridMain.Rows.Add(row);
            }
            gridMain.EndUpdate();
        }
示例#4
0
        private void FillGridMain()
        {
            gridMain.BeginUpdate();
            gridMain.ListGridColumns.Clear();
            gridMain.ListGridColumns.Add(new GridColumn(Lan.g(this, "LName"), 100));
            gridMain.ListGridColumns.Add(new GridColumn(Lan.g(this, "FName"), 100));
            gridMain.ListGridColumns.Add(new GridColumn(_monthT2.ToString("MMMM yyyy"), 100, HorizontalAlignment.Right, GridSortingStrategy.AmountParse));
            gridMain.ListGridColumns.Add(new GridColumn(_monthT1.ToString("MMMM yyyy"), 100, HorizontalAlignment.Right, GridSortingStrategy.AmountParse));
            if (!checkIgnore.Checked)
            {
                gridMain.ListGridColumns.Add(new GridColumn(_monthT0.ToString("MMMM yyyy"), 100, HorizontalAlignment.Right, GridSortingStrategy.AmountParse));
            }
            gridMain.ListGridColumns.Add(new GridColumn(Lan.g(this, "Letter"), 100));
            gridMain.ListGridRows.Clear();
            List <Employee>   listEmpsAll        = Employees.GetDeepCopy(true).OrderBy(x => x.LName).ThenBy(x => x.FName).ToList();
            List <ClockEvent> listClockEventsAll = ClockEvents.GetAllForPeriod(_monthT2, _monthT2.AddMonths(3)); //get all three months of clock events

            listClockEventsAll.RemoveAll(x => x.ClockStatus == TimeClockStatus.Break);                           //remove breaks, they have already been acounted for on the clock events.
            listClockEventsAll.RemoveAll(x => x.TimeDisplayed2 <= x.TimeDisplayed1);                             //Remove all mal-formed entries with stop time before start time. (also if user has not clocked out.)
            listClockEventsAll.RemoveAll(x => x.TimeDisplayed1.Date != x.TimeDisplayed2.Date);                   //No one works over midnight at ODHQ. If they do, they know to split clock events @ midnight
            List <TimeAdjust> listTimeAdjustAll = TimeAdjusts.GetAllForPeriod(_monthT2, _monthT2.AddMonths(3));

            foreach (Employee empCur in listEmpsAll)
            {
                //Construct each row, then filter out if neccesary.
                GridRow row = new GridRow();
                //Name
                row.Cells.Add(empCur.LName);
                row.Cells.Add(empCur.FName);
                //Month T-2 (current month -2 months)
                TimeSpan ts2 = TimeSpan.FromTicks(listClockEventsAll
                                                  .FindAll(x => x.EmployeeNum == empCur.EmployeeNum &&
                                                           x.TimeDisplayed1.Year == _monthT2.Year &&
                                                           x.TimeDisplayed1.Month == _monthT2.Month)
                                                  .Select(x => (x.TimeDisplayed2 - x.TimeDisplayed1) + (x.AdjustIsOverridden ? x.Adjust : x.AdjustAuto))
                                                  .Sum(x => x.Ticks));
                ts2.Add(TimeSpan.FromTicks(listTimeAdjustAll.FindAll(x => x.EmployeeNum == empCur.EmployeeNum &&
                                                                     x.TimeEntry.Year == _monthT2.Year &&
                                                                     x.TimeEntry.Month == _monthT2.Month)
                                           .Sum(x => x.RegHours.Ticks)));
                row.Cells.Add(new GridCell(string.Format("{0:0.00}", Math.Round(ts2.TotalHours, 2, MidpointRounding.AwayFromZero)))
                {
                    ColorBackG = (ts2.TotalHours < 125 ? lightRed : Color.Empty)
                });
                //Month T-1
                TimeSpan ts1 = TimeSpan.FromTicks(listClockEventsAll
                                                  .FindAll(x => x.EmployeeNum == empCur.EmployeeNum &&
                                                           x.TimeDisplayed1.Year == _monthT1.Year &&
                                                           x.TimeDisplayed1.Month == _monthT1.Month)
                                                  .Select(x => (x.TimeDisplayed2 - x.TimeDisplayed1) + (x.AdjustIsOverridden ? x.Adjust : x.AdjustAuto))
                                                  .Sum(x => x.Ticks));
                ts1.Add(TimeSpan.FromTicks(listTimeAdjustAll.FindAll(x => x.EmployeeNum == empCur.EmployeeNum &&
                                                                     x.TimeEntry.Year == _monthT1.Year &&
                                                                     x.TimeEntry.Month == _monthT1.Month)
                                           .Select(x => x.RegHours)
                                           .Sum(x => x.Ticks)));
                row.Cells.Add(new GridCell(string.Format("{0:0.00}", Math.Round(ts1.TotalHours, 2, MidpointRounding.AwayFromZero)))
                {
                    ColorBackG = (ts1.TotalHours < 125 ? lightRed : Color.Empty)
                });
                //Month T-0
                TimeSpan ts0 = TimeSpan.FromTicks(listClockEventsAll
                                                  .FindAll(x => x.EmployeeNum == empCur.EmployeeNum &&
                                                           x.TimeDisplayed1.Year == _monthT0.Year &&
                                                           x.TimeDisplayed1.Month == _monthT0.Month)
                                                  .Select(x => (x.TimeDisplayed2 - x.TimeDisplayed1) + (x.AdjustIsOverridden ? x.Adjust : x.AdjustAuto))
                                                  .Sum(x => x.Ticks));
                ts0.Add(TimeSpan.FromTicks(listTimeAdjustAll.FindAll(x => x.EmployeeNum == empCur.EmployeeNum &&
                                                                     x.TimeEntry.Year == _monthT0.Year &&
                                                                     x.TimeEntry.Month == _monthT0.Month)
                                           .Select(x => x.RegHours)
                                           .Sum(x => x.Ticks)));
                if (!checkIgnore.Checked)
                {
                    row.Cells.Add(new GridCell(string.Format("{0:0.00}", Math.Round(ts0.TotalHours, 2, MidpointRounding.AwayFromZero)))
                    {
                        ColorBackG = (ts0.TotalHours < 125 ? lightRed : Color.Empty)
                    });
                }
                //filter out rows that should not be displaying. Rows should not display only when the most recent month was less than 125 hours, regardless of status of previous months
                if (!checkShowAll.Checked)
                {
                    //Show all is not checked, therefore we must filter out rows with more than 125 hours on the most recent pay period.
                    if (!checkIgnore.Checked && ts0.TotalHours > 125)
                    {
                        //Not ignoring "current month" so check T0 for >125 hours
                        continue;
                    }
                    else if (checkIgnore.Checked && ts1.TotalHours > 125)
                    {
                        //Ignore current month (because it is probably only partially complete), check the previous months for >125 hours.
                        continue;
                    }
                }
                string letterNumber = "";
                if ((checkIgnore.Checked?ts2:ts0).TotalHours < 125 && ts1.TotalHours < 125)
                {
                    //the last two visible month were less than 125 hours. AKA "Send the Second letter"
                    letterNumber = "Second";
                }
                else if ((checkIgnore.Checked?ts1:ts0).TotalHours < 125)
                {
                    //the last visible month was less than 125 hours. AKA "Send the First letter"
                    letterNumber = "First";
                }
                row.Cells.Add(letterNumber);
                gridMain.ListGridRows.Add(row);
            }
            gridMain.EndUpdate();
        }
示例#5
0
        private void FormUserEdit_Load(object sender, System.EventArgs e)
        {
            checkIsHidden.Checked = UserCur.IsHidden;
            if (UserCur.UserNum != 0)
            {
                textUserNum.Text = UserCur.UserNum.ToString();
            }
            textUserName.Text   = UserCur.UserName;
            textDomainUser.Text = UserCur.DomainUser;
            if (!PrefC.GetBool(PrefName.DomainLoginEnabled))
            {
                labelDomainUser.Visible   = false;
                textDomainUser.Visible    = false;
                butPickDomainUser.Visible = false;
            }
            checkRequireReset.Checked = UserCur.IsPasswordResetRequired;
            _listUserGroups           = UserGroups.GetList();
            _isFillingList            = true;
            for (int i = 0; i < _listUserGroups.Count; i++)
            {
                listUserGroup.Items.Add(new ODBoxItem <UserGroup>(_listUserGroups[i].Description, _listUserGroups[i]));
                if (!_isFromAddUser && UserCur.IsInUserGroup(_listUserGroups[i].UserGroupNum))
                {
                    listUserGroup.SetSelected(i, true);
                }
                if (_isFromAddUser && _listUserGroups[i].UserGroupNum == PrefC.GetLong(PrefName.DefaultUserGroup))
                {
                    listUserGroup.SetSelected(i, true);
                }
            }
            if (listUserGroup.SelectedIndex == -1)          //never allowed to delete last group, so this won't fail
            {
                listUserGroup.SelectedIndex = 0;
            }
            _isFillingList = false;
            securityTreeUser.FillTreePermissionsInitial();
            RefreshUserTree();
            listEmployee.Items.Clear();
            listEmployee.Items.Add(Lan.g(this, "none"));
            listEmployee.SelectedIndex = 0;
            _listEmployees             = Employees.GetDeepCopy(true);
            for (int i = 0; i < _listEmployees.Count; i++)
            {
                listEmployee.Items.Add(Employees.GetNameFL(_listEmployees[i]));
                if (UserCur.EmployeeNum == _listEmployees[i].EmployeeNum)
                {
                    listEmployee.SelectedIndex = i + 1;
                }
            }
            listProv.Items.Clear();
            listProv.Items.Add(Lan.g(this, "none"));
            listProv.SelectedIndex = 0;
            _listProviders         = Providers.GetDeepCopy(true);
            for (int i = 0; i < _listProviders.Count; i++)
            {
                listProv.Items.Add(_listProviders[i].GetLongDesc());
                if (UserCur.ProvNum == _listProviders[i].ProvNum)
                {
                    listProv.SelectedIndex = i + 1;
                }
            }
            _listClinics           = Clinics.GetDeepCopy(true);
            _listUserAlertTypesOld = AlertSubs.GetAllForUser(UserCur.UserNum);
            List <long> listSubscribedClinics;
            bool        isAllClinicsSubscribed = false;

            if (_listUserAlertTypesOld.Select(x => x.ClinicNum).Contains(-1))             //User subscribed to all clinics
            {
                isAllClinicsSubscribed = true;
                listSubscribedClinics  = _listClinics.Select(x => x.ClinicNum).Distinct().ToList();
            }
            else
            {
                listSubscribedClinics = _listUserAlertTypesOld.Select(x => x.ClinicNum).Distinct().ToList();
            }
            List <long> listAlertCatNums = _listUserAlertTypesOld.Select(x => x.AlertCategoryNum).Distinct().ToList();

            listAlertSubMulti.Items.Clear();
            _listAlertCategories = AlertCategories.GetDeepCopy();
            List <long> listUserAlertCatNums = _listUserAlertTypesOld.Select(x => x.AlertCategoryNum).ToList();

            foreach (AlertCategory cat in _listAlertCategories)
            {
                int index = listAlertSubMulti.Items.Add(Lan.g(this, cat.Description));
                listAlertSubMulti.SetSelected(index, listUserAlertCatNums.Contains(cat.AlertCategoryNum));
            }
            if (!PrefC.HasClinicsEnabled)
            {
                tabClinics.Enabled = false;              //Disables all controls in the clinics tab.  Tab is still selectable.
                listAlertSubsClinicsMulti.Visible = false;
                labelAlertClinic.Visible          = false;
            }
            else
            {
                listClinic.Items.Clear();
                listClinic.Items.Add(Lan.g(this, "All"));
                listAlertSubsClinicsMulti.Items.Add(Lan.g(this, "All"));
                listAlertSubsClinicsMulti.Items.Add(Lan.g(this, "Headquarters"));
                if (UserCur.ClinicNum == 0)               //Unrestricted
                {
                    listClinic.SetSelected(0, true);
                    checkClinicIsRestricted.Enabled = false; //We don't really need this checkbox any more but it's probably better for users to keep it....
                }
                if (isAllClinicsSubscribed)                  //They are subscribed to all clinics
                {
                    listAlertSubsClinicsMulti.SetSelected(0, true);
                }
                else if (listSubscribedClinics.Contains(0))                 //They are subscribed to Headquarters
                {
                    listAlertSubsClinicsMulti.SetSelected(1, true);
                }
                List <UserClinic> listUserClinics = UserClinics.GetForUser(UserCur.UserNum);
                for (int i = 0; i < _listClinics.Count; i++)
                {
                    listClinic.Items.Add(_listClinics[i].Abbr);
                    listClinicMulti.Items.Add(_listClinics[i].Abbr);
                    listAlertSubsClinicsMulti.Items.Add(_listClinics[i].Abbr);
                    if (UserCur.ClinicNum == _listClinics[i].ClinicNum)
                    {
                        listClinic.SetSelected(i + 1, true);
                    }
                    if (UserCur.ClinicNum != 0 && listUserClinics.Exists(x => x.ClinicNum == _listClinics[i].ClinicNum))
                    {
                        listClinicMulti.SetSelected(i, true);                       //No "All" option, don't select i+1
                    }
                    if (!isAllClinicsSubscribed && _listUserAlertTypesOld.Exists(x => x.ClinicNum == _listClinics[i].ClinicNum))
                    {
                        listAlertSubsClinicsMulti.SetSelected(i + 2, true);                     //All+HQ
                    }
                }
                checkClinicIsRestricted.Checked = UserCur.ClinicIsRestricted;
            }
            if (string.IsNullOrEmpty(UserCur.PasswordHash))
            {
                butPassword.Text = Lan.g(this, "Create Password");
            }
            if (!PrefC.IsODHQ)
            {
                butJobRoles.Visible = false;
            }
            if (IsNew)
            {
                butUnlock.Visible = false;
            }
            _listDoseSpotUserPrefOld = UserOdPrefs.GetByUserAndFkeyAndFkeyType(UserCur.UserNum,
                                                                               Programs.GetCur(ProgramName.eRx).ProgramNum, UserOdFkeyType.Program,
                                                                               Clinics.GetForUserod(Security.CurUser, true).Select(x => x.ClinicNum)
                                                                               .Union(new List <long>()
            {
                0
            })                                                //Always include 0 clinic, this is the default, NOT a headquarters only value.
                                                                               .Distinct()
                                                                               .ToList());
            _listDoseSpotUserPrefNew = _listDoseSpotUserPrefOld.Select(x => x.Clone()).ToList();
            _doseSpotUserPrefDefault = _listDoseSpotUserPrefNew.Find(x => x.ClinicNum == 0);
            if (_doseSpotUserPrefDefault == null)
            {
                _doseSpotUserPrefDefault = DoseSpot.GetDoseSpotUserIdFromPref(UserCur.UserNum, 0);
                _listDoseSpotUserPrefNew.Add(_doseSpotUserPrefDefault);
            }
            textDoseSpotUserID.Text = _doseSpotUserPrefDefault.ValueString;
            if (_isFromAddUser && !Security.IsAuthorized(Permissions.SecurityAdmin, true))
            {
                butPassword.Visible       = false;
                checkRequireReset.Checked = true;
                checkRequireReset.Enabled = false;
                butUnlock.Visible         = false;
                butJobRoles.Visible       = false;
            }
            if (!PrefC.HasClinicsEnabled)
            {
                butDoseSpotAdditional.Visible = false;
            }
        }