예제 #1
0
 private void checkIsGraphed_Click(object sender, EventArgs e)
 {
     if (Security.IsAuthorized(Permissions.Schedules))
     {
         PhoneGraph phoneGraph = PhoneGraphs.GetForEmployeeNumAndDate(PedCur.EmployeeNum, DateTime.Today); //check for override
         if (phoneGraph == null)                                                                           //no existing entry so exit
         {
             return;
         }
         if (checkIsGraphed.Checked == phoneGraph.IsGraphed)               //default matches existing entry so exit
         {
             return;
         }
         //we have an existing entry so ask if they want to get rid of it
         if (!MsgBox.Show(this, MsgBoxButtons.YesNo, "Phone Graph override exists to the contrary of new setting for this employee. Do you want to delete the override and use the default?"))
         {
             return;
         }
         //get rid of the existing
         PhoneGraphs.Delete(phoneGraph.PhoneGraphNum);
         FillGrid();
         return;
     }
     //Put the checkbox back the way it was before user clicked on it.
     if (checkIsGraphed.Checked)
     {
         checkIsGraphed.Checked = false;
     }
     else
     {
         checkIsGraphed.Checked = true;
     }
 }
예제 #2
0
        private void gridGraph_CellClick(object sender, ODGridClickEventArgs e)
        {
            //only allow clicking on the 'Desired Graph Status' column
            if (e.Col != 3 || gridGraph.Rows[e.Row].Tag == null || !(gridGraph.Rows[e.Row].Tag is PhoneEmpDefault))
            {
                return;
            }
            PhoneEmpDefault phoneEmpDefault = (PhoneEmpDefault)gridGraph.Rows[e.Row].Tag;
            bool            uiGraphStatus   = gridGraph.Rows[e.Row].Cells[e.Col].Text.ToLower() == "x";
            bool            dbGraphStatus   = PhoneEmpDefaults.GetGraphedStatusForEmployeeDate(phoneEmpDefault.EmployeeNum, DateEdit);

            if (uiGraphStatus != dbGraphStatus)
            {
                MessageBox.Show(Lan.g(this, "Graph status has changed unexpectedly for employee: ") + phoneEmpDefault.EmpName + Lan.g(this, ". Exit and reopen this form, and try again."));
                return;
            }
            //flip the bit in the db and reload the grid
            PhoneGraph pg = new PhoneGraph();

            pg.EmployeeNum = phoneEmpDefault.EmployeeNum;
            pg.DateEntry   = DateEdit;
            pg.IsGraphed   = !uiGraphStatus;         //flip the bit
            PhoneGraphs.InsertOrUpdate(pg);          //update the db
            FillGrid();
        }
예제 #3
0
        private void FillGrid()
        {
            //get PhoneGraphs for this employee num and fill the grid
            List <PhoneGraph> phoneGraphs = PhoneGraphs.GetAllForEmployeeNum(PedCur.EmployeeNum);

            gridGraph.BeginUpdate();
            gridGraph.Columns.Clear();
            ODGridColumn col = new ODGridColumn(Lan.g("TablePhoneGraph", "Date"), 70);

            col.TextAlign = HorizontalAlignment.Center;
            gridGraph.Columns.Add(col);
            col           = new ODGridColumn(Lan.g("TablePhoneGraph", "IsGraphed"), 60);
            col.TextAlign = HorizontalAlignment.Center;
            gridGraph.Columns.Add(col);
            gridGraph.Rows.Clear();
            ODGridRow row;

            for (int i = 0; i < phoneGraphs.Count; i++)
            {
                if (phoneGraphs[i].DateEntry < DateTime.Today)               //do not show past date entries
                {
                    continue;
                }
                row = new ODGridRow();
                row.Cells.Add(phoneGraphs[i].DateEntry.ToShortDateString());
                row.Cells.Add(phoneGraphs[i].IsGraphed?"X":"");
                row.Tag = phoneGraphs[i];
                gridGraph.Rows.Add(row);
            }
            gridGraph.EndUpdate();
        }
예제 #4
0
 private void FormGraphEmployeeTime_Load(object sender, EventArgs e)
 {
     butEdit.Visible = Security.IsAuthorized(Permissions.Schedules);
     ListPED         = PhoneEmpDefaults.Refresh();
     DateShowing     = AppointmentL.DateSelected.Date;
     //fill in the missing PhoneGraph entries for today
     PhoneGraphs.AddMissingEntriesForToday(ListPED);
     FillData();
 }
예제 #5
0
 private void butDelete_Click(object sender, System.EventArgs e)
 {
     if (PhoneGraphCur.IsNew)
     {
         DialogResult = DialogResult.Cancel;
         return;
     }
     PhoneGraphs.Delete(PhoneGraphCur.PhoneGraphNum);
     DialogResult = DialogResult.OK;
 }
예제 #6
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            if (textDateEntry.Text == "" || textDateEntry.errorProvider1.GetError(textDateEntry) != "")
            {
                MsgBox.Show(this, "Please fix data entry errors first.");
                return;
            }
            //user brought in an existing entry and may have modified it so get rid of it and recreate it in its entirety
            //EG...
            //user brought in 9/27/13 Checked: TRUE...
            //then changed date to 9/28/13 Checked: FALSE...
            //user has expectation that the 9/27 entry will be gone and new 9/28 entry will be created
            if (!PhoneGraphCur.IsNew)
            {
                PhoneGraphs.Delete(PhoneGraphCur.PhoneGraphNum);
            }
            PhoneGraph pg = new PhoneGraph();

            pg.EmployeeNum = EmployeeNum;
            pg.DateEntry   = PIn.Date(textDateEntry.Text);
            pg.IsGraphed   = checkIsGraphed.Checked;
            PhoneGraphs.InsertOrUpdate(pg);
            DialogResult = DialogResult.OK;
        }
예제 #7
0
        private void FillGrid()
        {
            //get PhoneGraph entries for this date
            ListPhoneGraphsForDate = PhoneGraphs.GetAllForDate(DateEdit);
            //get current employee defaults
            ListPhoneEmpDefaults = PhoneEmpDefaults.Refresh();
            ListPhoneEmpDefaults.Sort(new PhoneEmpDefaults.PhoneEmpDefaultComparer(PhoneEmpDefaults.PhoneEmpDefaultComparer.SortBy.name));
            //get schedules
            ListSchedulesForDate = Schedules.GetDayList(DateEdit);
            long selectedEmployeeNum = -1;

            if (gridGraph.Rows.Count >= 1 &&
                gridGraph.GetSelectedIndex() >= 0 &&
                gridGraph.Rows[gridGraph.GetSelectedIndex()].Tag != null &&
                gridGraph.Rows[gridGraph.GetSelectedIndex()].Tag is PhoneEmpDefault)
            {
                selectedEmployeeNum = ((PhoneEmpDefault)gridGraph.Rows[gridGraph.GetSelectedIndex()].Tag).EmployeeNum;
            }
            gridGraph.BeginUpdate();
            gridGraph.Columns.Clear();
            ODGridColumn col = new ODGridColumn(Lan.g("TablePhoneGraphDate", "Employee"), 80);

            gridGraph.Columns.Add(col);             //column 0 (name - not clickable)
            col           = new ODGridColumn(Lan.g("TablePhoneGraphDate", "Schedule"), 130);
            col.TextAlign = HorizontalAlignment.Center;
            gridGraph.Columns.Add(col);             //column 1 (schedule - clickable)
            col           = new ODGridColumn(Lan.g("TablePhoneGraphDate", "Graph Default"), 90);
            col.TextAlign = HorizontalAlignment.Center;
            gridGraph.Columns.Add(col);             //column 2 (default - not clickable)
            col           = new ODGridColumn(Lan.g("TablePhoneGraphDate", "Set Graph Status"), 110);
            col.TextAlign = HorizontalAlignment.Center;
            gridGraph.Columns.Add(col);             //column 3 (set graph status - clickable)
            col           = new ODGridColumn(Lan.g("TablePhoneGraphDate", "Is Overridden?"), 80);
            col.TextAlign = HorizontalAlignment.Center;
            gridGraph.Columns.Add(col);             //column 4 (is value an overridde of default? - not clickable)
            gridGraph.Rows.Clear();
            int selectedRow = -1;

            //loop through all employee defaults and create 1 row per employee
            for (int iPED = 0; iPED < ListPhoneEmpDefaults.Count; iPED++)
            {
                PhoneEmpDefault phoneEmpDefault = ListPhoneEmpDefaults[iPED];
                Employee        employee        = Employees.GetEmp(phoneEmpDefault.EmployeeNum);
                if (employee == null || employee.IsHidden)               //only deal with current employees
                {
                    continue;
                }
                List <Schedule> scheduleForEmployee = Schedules.GetForEmployee(ListSchedulesForDate, phoneEmpDefault.EmployeeNum);
                bool            isGraphed           = phoneEmpDefault.IsGraphed; //set default
                bool            hasOverride         = false;
                for (int iPG = 0; iPG < ListPhoneGraphsForDate.Count; iPG++)     //we have a default, now loop through all known exceptions and find a match
                {
                    PhoneGraph phoneGraph = ListPhoneGraphsForDate[iPG];
                    if (phoneEmpDefault.EmployeeNum == ListPhoneGraphsForDate[iPG].EmployeeNum)                   //found a match so no op necessary for this employee
                    {
                        isGraphed   = phoneGraph.IsGraphed;
                        hasOverride = true;
                        break;
                    }
                }
                ODGridRow row;
                row = new ODGridRow();
                row.Cells.Add(phoneEmpDefault.EmpName);                                                           //column 0 (name - not clickable)
                row.Cells.Add(Schedules.GetCommaDelimStringForScheds(scheduleForEmployee).Replace(", ", "\r\n")); //column 1 (shift times - not clickable)
                row.Cells.Add(phoneEmpDefault.IsGraphed?"X":"");                                                  //column 2 (default - not clickable)
                row.Cells.Add(isGraphed?"X":"");                                                                  //column 3 (set graph status - clickable)
                row.Cells.Add(hasOverride && isGraphed != phoneEmpDefault.IsGraphed?"X":"");                      //column 4 (is overridden to IsGraphed? - not clickable)
                row.Tag = phoneEmpDefault;                                                                        //store the employee for click events
                int rowIndex = gridGraph.Rows.Add(row);
                if (selectedEmployeeNum == phoneEmpDefault.EmployeeNum)
                {
                    selectedRow = rowIndex;
                }
            }
            gridGraph.EndUpdate();
            if (selectedRow >= 0)
            {
                gridGraph.SetSelected(selectedRow, true);
            }
        }
예제 #8
0
        private void FillData()
        {
            DictEmployeesPerBucket = new Dictionary <int, List <Employee> >();
            labelDate.Text         = DateShowing.ToString("dddd, MMMM d");
            butEdit.Enabled        = DateShowing.Date >= DateTime.Today;  //do not allow editing of past dates
            listCalls = new List <PointF>();
            if (DateShowing.DayOfWeek == DayOfWeek.Friday)
            {
                listCalls.Add(new PointF(5f, 0));
                listCalls.Add(new PointF(5.5f, 50));               //5-6am
                listCalls.Add(new PointF(6.5f, 133));
                listCalls.Add(new PointF(7.5f, 210));
                listCalls.Add(new PointF(8.5f, 332));
                listCalls.Add(new PointF(9f, 360));               //-
                listCalls.Add(new PointF(9.5f, 370));             //was 380
                listCalls.Add(new PointF(10f, 360));              //-
                listCalls.Add(new PointF(10.5f, 352));            //was 348
                listCalls.Add(new PointF(11.5f, 352));
                listCalls.Add(new PointF(12.5f, 340));            //was 313
                listCalls.Add(new PointF(13.5f, 325));            //was 363
                listCalls.Add(new PointF(14.5f, 277));
                listCalls.Add(new PointF(15.5f, 185));
                listCalls.Add(new PointF(16.5f, 141));
                listCalls.Add(new PointF(17f, 50));
                listCalls.Add(new PointF(17.0f, 0));
            }
            else
            {
                listCalls.Add(new PointF(5f, 0));
                listCalls.Add(new PointF(5.5f, 284));               //5-6am
                listCalls.Add(new PointF(6.5f, 767));
                listCalls.Add(new PointF(7.5f, 1246));
                listCalls.Add(new PointF(8.5f, 1753));
                listCalls.Add(new PointF(9f, 1920));               //-
                listCalls.Add(new PointF(9.5f, 2000));             //was 2029
                listCalls.Add(new PointF(10f, 1950));              //-
                listCalls.Add(new PointF(10.5f, 1875));            //1846
                listCalls.Add(new PointF(11.5f, 1890));            //1899
                listCalls.Add(new PointF(12.5f, 1820));
                listCalls.Add(new PointF(13.5f, 1807));
                listCalls.Add(new PointF(14.5f, 1565));
                listCalls.Add(new PointF(15.5f, 1178));
                listCalls.Add(new PointF(16.5f, 733));
                listCalls.Add(new PointF(17.5f, 226));
                listCalls.Add(new PointF(17.5f, 0));
            }
            buckets    = new float[56];       //Number of total bucket. 4 buckets per hour * 14 hours = 56 buckets.
            ListScheds = Schedules.GetDayList(DateShowing);
            //PhoneGraph exceptions will take precedence over employee default
            List <PhoneGraph> listPhoneGraphs = PhoneGraphs.GetAllForDate(DateShowing);
            TimeSpan          time1;
            TimeSpan          time2;
            TimeSpan          delta;

            for (int i = 0; i < ListScheds.Count; i++)
            {
                if (ListScheds[i].SchedType != ScheduleType.Employee)
                {
                    continue;
                }
                //get this employee
                Employee employee = Employees.GetEmp(ListScheds[i].EmployeeNum);
                if (employee == null)               //employees will NEVER be deleted. even after they cease to work here. but just in case.
                {
                    continue;
                }
                bool hasPhoneGraphEntry = false;
                bool isGraphed          = false;
                //PhoneGraph entries will take priority over the default employee graph state
                for (int iPG = 0; iPG < listPhoneGraphs.Count; iPG++)
                {
                    if (listPhoneGraphs[iPG].EmployeeNum == employee.EmployeeNum)
                    {
                        isGraphed          = listPhoneGraphs[iPG].IsGraphed;
                        hasPhoneGraphEntry = true;
                        break;
                    }
                }
                if (!hasPhoneGraphEntry)                 //no phone graph entry found (likely for a future date which does not have entries created yet OR past date where current employee didn't work here yet)
                {
                    if (DateShowing <= DateTime.Today)   //no phone graph entry and we are on a past OR current date. if it's not already created then don't graph this employee for this date
                    {
                        continue;
                    }
                    //we are on a future date AND we don't have a PhoneGraph entry explicitly set so use the default for this employee
                    PhoneEmpDefault ped = PhoneEmpDefaults.GetEmpDefaultFromList(ListScheds[i].EmployeeNum, ListPED);
                    if (ped == null)                   //we will default to PhoneEmpDefault.IsGraphed so make sure the deafult exists
                    {
                        continue;
                    }
                    //no entry in PhoneGraph for the employee on this date so use the default
                    isGraphed = ped.IsGraphed;
                }
                if (!isGraphed)                 //only care about employees that are being graphed
                {
                    continue;
                }
                for (int b = 0; b < buckets.Length; b++)
                {
                    //minutes field multiplier is a function of buckets per hour. answers the question, "how many minutes long is each bucket?"
                    time1 = new TimeSpan(5, 0, 0) + new TimeSpan(0, b * 15, 0);
                    time2 = new TimeSpan(5, 15, 0) + new TimeSpan(0, b * 15, 0);
                    //situation 1: this bucket is completely within the start and stop times.
                    if (ListScheds[i].StartTime <= time1 && ListScheds[i].StopTime >= time2)
                    {
                        AddEmployeeToBucket(b, employee);
                    }
                    //situation 2: the start time is after this bucket
                    else if (ListScheds[i].StartTime >= time2)
                    {
                        continue;
                    }
                    //situation 3: the stop time is before this bucket
                    else if (ListScheds[i].StopTime <= time1)
                    {
                        continue;
                    }
                    //situation 4: start time falls within this bucket
                    if (ListScheds[i].StartTime > time1)
                    {
                        delta = ListScheds[i].StartTime - time1;
                        //7.5 minutes is half of one bucket.
                        if (delta.TotalMinutes > 7.5)                          //has to work more than 15 minutes to be considered *in* this bucket
                        {
                            AddEmployeeToBucket(b, employee);
                        }
                    }
                    //situation 5: stop time falls within this bucket
                    if (ListScheds[i].StopTime < time2)
                    {
                        delta = time2 - ListScheds[i].StopTime;
                        if (delta.TotalMinutes > 7.5)                          //has to work more than 15 minutes to be considered *in* this bucket
                        {
                            AddEmployeeToBucket(b, employee);
                        }
                    }
                }
                //break;//just show one sched for debugging.
            }
            //missed calls
            //missedCalls=new int[28];
            //List<DateTime> callTimes=PhoneAsterisks.GetMissedCalls(dateShowing);
            //for(int i=0;i<callTimes.Count;i++) {
            //  for(int b=0;b<missedCalls.Length;b++) {
            //    time1=new TimeSpan(5,0,0) + new TimeSpan(0,b*30,0);
            //    time2=new TimeSpan(5,30,0) + new TimeSpan(0,b*30,0);
            //    if(callTimes[i].TimeOfDay >= time1 && callTimes[i].TimeOfDay < time2) {
            //      missedCalls[b]++;
            //    }
            //  }
            //}
            //Minutes Behind
            minutesBehind = PhoneMetrics.AverageMinutesBehind(DateShowing);
            this.Invalidate();
        }