Beispiel #1
0
        ///<summary>If already clocked in, this does nothing.  Returns false if not able to clock in due to security, or true if successful.</summary>
        private static bool ClockIn(PhoneTile tile)
        {
            long employeeNum = Security.CurUser.EmployeeNum; //tile.PhoneCur.EmployeeNum;

            if (employeeNum == 0)                            //Can happen if logged in as 'admin' user (employeeNum==0). Otherwise should not happen, means the employee trying to clock doesn't exist in the employee table.
            {
                MsgBox.Show(langThis, "Inavlid OD User: "******"Working";
            Employees.Update(EmpCur);
            return(true);
        }
Beispiel #2
0
        public static void Break(Phone phone)
        {
            //verify that employee is logged in as user
            int  extension   = phone.Extension;
            long employeeNum = phone.EmployeeNum;

            if (!CheckUserCanChangeStatus(phone))
            {
                return;
            }
            try {
                ClockEvents.ClockOut(employeeNum, TimeClockStatus.Break);
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);                //This message will tell user that they are already clocked out.
                return;
            }
            PhoneEmpDefaults.SetAvailable(extension, employeeNum);
            Employee EmpCur = Employees.GetEmp(employeeNum);

            EmpCur.ClockStatus = Lan.g("enumTimeClockStatus", TimeClockStatus.Break.ToString());
            Employees.Update(EmpCur);
            Phones.SetPhoneStatus(ClockStatusEnum.Break, extension);
            PhoneAsterisks.SetQueueForExtension(phone.Extension, AsteriskQueues.None);
        }
        private void menuItemBreak_Click(object sender, EventArgs e)
        {
            //verify that employee is logged in as user
            int  extension   = PhoneList[rowI].Extension;
            long employeeNum = PhoneList[rowI].EmployeeNum;

            if (PrefC.GetBool(PrefName.TimecardSecurityEnabled))
            {
                if (Security.CurUser.EmployeeNum != employeeNum)
                {
                    if (!Security.IsAuthorized(Permissions.TimecardsEditAll))
                    {
                        MsgBox.Show(this, "Not authorized.");
                        return;
                    }
                }
            }
            try{
                ClockEvents.ClockOut(employeeNum, TimeClockStatus.Break);
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);                //This message will tell user that they are already clocked out.
                return;
            }
            PhoneEmpDefaults.SetAvailable(extension, employeeNum);
            Employee EmpCur = Employees.GetEmp(employeeNum);

            EmpCur.ClockStatus = Lan.g("enumTimeClockStatus", TimeClockStatus.Break.ToString());
            Employees.Update(EmpCur);
            Phones.SetPhoneStatus(ClockStatusEnum.Break, extension);
            FillEmps();
        }
Beispiel #4
0
        public static void Break(PhoneTile tile)
        {
            //verify that employee is logged in as user
            int  extension   = tile.PhoneCur.Extension;
            long employeeNum = tile.PhoneCur.EmployeeNum;

            if (Security.CurUser.EmployeeNum != employeeNum)
            {
                if (!Security.IsAuthorized(Permissions.TimecardsEditAll, true))
                {
                    if (!CheckSelectedUserPassword(employeeNum))
                    {
                        return;
                    }
                }
            }
            try {
                ClockEvents.ClockOut(employeeNum, TimeClockStatus.Break);
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);                //This message will tell user that they are already clocked out.
                return;
            }
            PhoneEmpDefaults.SetAvailable(extension, employeeNum);
            Employee EmpCur = Employees.GetEmp(employeeNum);

            EmpCur.ClockStatus = Lan.g("enumTimeClockStatus", TimeClockStatus.Break.ToString());
            Employees.Update(EmpCur);
            Phones.SetPhoneStatus(ClockStatusEnum.Break, extension);
        }
 private void MapAreaRoomControl_MouseUp(object sender,MouseEventArgs e)
 {
     if(!_allowClickOptions || _phoneCur==null) {
         return;//disable click options in setup window.
     }
     if(e==null || e.Button!=MouseButtons.Right) {
         if(e.Button==MouseButtons.Left && !IsFlashing && Status!="OnWay") {
             if(_rectName.Contains(e.Location)) {
                 PhoneUI.EmployeeSettings(_phoneCur);
                 return;
             }
             if(_rectPhone.Contains(e.Location) && _phoneCur.PatNum!=0) {
                 OnGoToChanged();
             }
         }
         return;
     }
     bool allowStatusEdit=ClockEvents.IsClockedIn(EmployeeNum);
     if(EmployeeNum==Security.CurUser.EmployeeNum) {//can always edit yourself
         allowStatusEdit=true;
     }
     if(Status==Phones.ConvertClockStatusToString(ClockStatusEnum.NeedsHelp)) {
         //Always allow any employee to change any other employee from NeedsAssistance to Available
         allowStatusEdit=true;
     }
     string statusOnBehalfOf=EmployeeName;
     bool allowSetSelfAvailable=false;
     if(!ClockEvents.IsClockedIn(EmployeeNum) //No one is clocked in at this extension.
         && !ClockEvents.IsClockedIn(Security.CurUser.EmployeeNum)) //This user is not clocked in either.
     {
         //Vacant extension and this user is not clocked in so allow this user to clock in at this extension.
         statusOnBehalfOf=Security.CurUser.UserName;
         allowSetSelfAvailable=true;
     }
     AddToolstripGroup("menuItemStatusOnBehalf","Status for: "+statusOnBehalfOf);
     AddToolstripGroup("menuItemRingGroupOnBehalf","Queues for ext: "+Extension.ToString());
     AddToolstripGroup("menuItemClockOnBehalf","Clock event for: "+EmployeeName);
     AddToolstripGroup("menuItemCustomer","Customer: "+_phoneCur.CustomerNumber);
     AddToolstripGroup("menuItemEmployee","Employee: "+EmployeeName);
     SetToolstripItemText("menuItemAvailable",allowStatusEdit || allowSetSelfAvailable);
     SetToolstripItemText("menuItemTraining",allowStatusEdit);
     SetToolstripItemText("menuItemTeamAssist",allowStatusEdit);
     SetToolstripItemText("menuItemNeedsHelp",allowStatusEdit);
     SetToolstripItemText("menuItemWrapUp",allowStatusEdit);
     SetToolstripItemText("menuItemOfflineAssist",allowStatusEdit);
     SetToolstripItemText("menuItemUnavailable",allowStatusEdit);
     SetToolstripItemText("menuItemTCResponder",allowStatusEdit);
     SetToolstripItemText("menuItemBackup",allowStatusEdit);
     SetToolstripItemText("menuItemLunch",allowStatusEdit);
     SetToolstripItemText("menuItemHome",allowStatusEdit);
     SetToolstripItemText("menuItemBreak",allowStatusEdit);
     menuItemGoTo.Enabled=true;
     if(_phoneCur.PatNum==0) {//disable go to if not a current patient
         menuItemGoTo.Enabled=false;
     }
     Point p=new Point(Location.X+e.Location.X,Location.Y+e.Location.Y);
     menuStatus.Show(Cursor.Position);
 }
Beispiel #6
0
 private void FormClockEventEdit_Load(object sender, System.EventArgs e)
 {
     if (!Security.IsAuthorized(Permissions.TimecardDeleteEntry, ClockEventCur.TimeEntered1, true))
     {
         butDelete.Enabled = false;
         butClear.Enabled  = false;
         butNow1.Enabled   = false;
         butNow2.Enabled   = false;
     }
     if (ClockEventCur.ClockStatus == TimeClockStatus.Break)
     {
         groupBox1.Text         = Lan.g(this, "Clock Out Date and Time");
         groupBox2.Text         = Lan.g(this, "Clock In Date and Time");
         groupTimeSpans.Visible = false;
     }
     textTimeEntered1.Text   = ClockEventCur.TimeEntered1.ToString();
     textTimeDisplayed1.Text = ClockEventCur.TimeDisplayed1.ToString();
     if (ClockEventCur.TimeEntered2.Year > 1880)
     {
         textTimeEntered2.Text = ClockEventCur.TimeEntered2.ToString();
     }
     if (ClockEventCur.TimeDisplayed2.Year > 1880)
     {
         textTimeDisplayed2.Text = ClockEventCur.TimeDisplayed2.ToString();
     }
     listStatus.Items.Clear();
     for (int i = 0; i < Enum.GetNames(typeof(TimeClockStatus)).Length; i++)
     {
         listStatus.Items.Add(Lan.g("enumTimeClockStatus", Enum.GetNames(typeof(TimeClockStatus))[i]));
     }
     listStatus.SelectedIndex = (int)ClockEventCur.ClockStatus;          //all clockevents have a status
     textAdjustAuto.Text      = ClockEvents.Format(ClockEventCur.AdjustAuto);
     if (ClockEventCur.AdjustIsOverridden)
     {
         if (ClockEventCur.Adjust == TimeSpan.Zero)
         {
             textAdjust.Text = "0";
         }
         else
         {
             textAdjust.Text = ClockEvents.Format(ClockEventCur.Adjust);
         }
     }
     else
     {
         textAdjust.Text = "";
     }
     textOTimeAuto.Text = ClockEvents.Format(ClockEventCur.OTimeAuto);
     if (ClockEventCur.OTimeHours == TimeSpan.FromHours(-1))           //no override
     {
         textOTimeHours.Text = "";
     }
     else
     {
         textOTimeHours.Text = ClockEvents.Format(ClockEventCur.OTimeHours);
     }
     textNote.Text = ClockEventCur.Note;
 }
Beispiel #7
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            try {
                DateTime.Parse(textTimeEntry.Text);
            }
            catch {
                MsgBox.Show(this, "Please enter a valid Date/Time.");
                return;
            }
            try{
                if (textHours.Text.Contains(":"))
                {
                    ClockEvents.ParseHours(textHours.Text);
                }
                else
                {
                    Double.Parse(textHours.Text);
                }
            }
            catch {
                MsgBox.Show(this, "Please enter valid Hours and Minutes.");
                return;
            }
            //end of validation
            TimeAdjustCur.IsAuto    = radioAuto.Checked;
            TimeAdjustCur.TimeEntry = DateTime.Parse(textTimeEntry.Text);
            TimeSpan hoursEntered;

            if (textHours.Text.Contains(":"))
            {
                hoursEntered = ClockEvents.ParseHours(textHours.Text);              //we know this will work because we tested ParseHours above.
            }
            else
            {
                hoursEntered = TimeSpan.FromHours(Double.Parse(textHours.Text));
            }
            if (checkOvertime.Checked)
            {
                TimeAdjustCur.RegHours   = -hoursEntered;
                TimeAdjustCur.OTimeHours = hoursEntered;
            }
            else
            {
                TimeAdjustCur.RegHours   = hoursEntered;
                TimeAdjustCur.OTimeHours = TimeSpan.FromHours(0);
            }
            TimeAdjustCur.Note = textNote.Text;
            if (IsNew)
            {
                TimeAdjusts.Insert(TimeAdjustCur);
            }
            else
            {
                TimeAdjusts.Update(TimeAdjustCur);
            }
            DialogResult = DialogResult.OK;
        }
Beispiel #8
0
 private void butOK_Click(object sender, System.EventArgs e)
 {
     //TimeDisplayed already handled
     ClockEventCur.ClockIn     = radioClockIn.Checked;
     ClockEventCur.ClockStatus = (TimeClockStatus)listStatus.SelectedIndex;
     ClockEventCur.Note        = textNote.Text;
     ClockEvents.Update(ClockEventCur);
     DialogResult = DialogResult.OK;
 }
Beispiel #9
0
 private void butDelete_Click(object sender, System.EventArgs e)
 {
     if (!MsgBox.Show(this, true, "Delete this clock event?"))
     {
         return;
     }
     ClockEvents.Delete(ClockEventCur);
     DialogResult = DialogResult.OK;
 }
Beispiel #10
0
 private void FormVoiceMails_FormClosing(object sender, FormClosingEventArgs e)
 {
     //Change the ClockStatus to Available if the logged on user is clocked in and the same user as the extension.
     if (FormOpenDental.PhoneTile.PhoneCur != null &&
         ClockEvents.IsClockedIn(Security.CurUser.EmployeeNum) &&
         Security.CurUser.EmployeeNum == FormOpenDental.PhoneTile.PhoneCur.EmployeeNum)
     {
         FormOpenDental.S_SetPhoneStatusAvailable();
     }
 }
Beispiel #11
0
 private void butDelete_Click(object sender, System.EventArgs e)
 {
     if (!MsgBox.Show(this, true, "Delete this clock event?"))
     {
         return;
     }
     ClockEvents.Delete(ClockEventCur.ClockEventNum);
     SecurityLogs.MakeLogEntry(Permissions.TimecardDeleteEntry, 0,
                               "Original entry: " + ClockEventCur.TimeEntered1.ToString());
     DialogResult = DialogResult.OK;
 }
Beispiel #12
0
        private void labelStatusAndNote_MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Right)
            {
                return;
            }
            if (_phoneCur == null)
            {
                return;
            }
            //Jason - Allowed to be 0 here.  The Security.UserCur.EmpNum will be used when they go to clock in and that is where the 0 check needs to be.
            //if(phoneCur.EmployeeNum==0) {
            //  return;
            //}
            OnSelectedTileChanged();
            bool allowStatusEdit = ClockEvents.IsClockedIn(PhoneCur.EmployeeNum);

            if (PhoneCur.EmployeeNum == Security.CurUser.EmployeeNum)            //Always allow status edit for yourself
            {
                allowStatusEdit = true;
            }
            if (PhoneCur.ClockStatus == ClockStatusEnum.NeedsHelp)            //Always allow any employee to change any other employee from NeedsAssistance to Available
            {
                allowStatusEdit = true;
            }
            string statusOnBehalfOf      = PhoneCur.EmployeeName;
            bool   allowSetSelfAvailable = false;

            if (!ClockEvents.IsClockedIn(PhoneCur.EmployeeNum) &&         //No one is clocked in at this extension.
                !ClockEvents.IsClockedIn(Security.CurUser.EmployeeNum))                    //This user is not clocked in either.
            {
                //Vacant extension and this user is not clocked in so allow this user to clock in at this extension.
                statusOnBehalfOf      = Security.CurUser.UserName;
                allowSetSelfAvailable = true;
            }
            AddToolstripGroup("menuItemStatusOnBehalf", "Status for: " + statusOnBehalfOf);
            AddToolstripGroup("menuItemRingGroupOnBehalf", "Queues for ext: " + PhoneCur.Extension.ToString());
            AddToolstripGroup("menuItemClockOnBehalf", "Clock event for: " + PhoneCur.EmployeeName);
            SetToolstripItemText("menuItemAvailable", allowStatusEdit || allowSetSelfAvailable);
            SetToolstripItemText("menuItemTraining", allowStatusEdit);
            SetToolstripItemText("menuItemTeamAssist", allowStatusEdit);
            SetToolstripItemText("menuItemNeedsHelp", allowStatusEdit);
            SetToolstripItemText("menuItemWrapUp", allowStatusEdit);
            SetToolstripItemText("menuItemOfflineAssist", allowStatusEdit);
            SetToolstripItemText("menuItemUnavailable", allowStatusEdit);
            SetToolstripItemText("menuItemTCResponder", allowStatusEdit);
            SetToolstripItemText("menuItemBackup", allowStatusEdit);
            SetToolstripItemText("menuItemLunch", allowStatusEdit);
            SetToolstripItemText("menuItemHome", allowStatusEdit);
            SetToolstripItemText("menuItemBreak", allowStatusEdit);
            MenuStatus.Show(labelStatusAndNote, e.Location);
        }
Beispiel #13
0
        private void FormTimeAdjustEdit_Load(object sender, System.EventArgs e)
        {
            if (TimeAdjustCur.IsAuto)
            {
                radioAuto.Checked = true;
            }
            else
            {
                radioManual.Checked = true;
            }
            textTimeEntry.Text = TimeAdjustCur.TimeEntry.ToString();
            if (TimeAdjustCur.OTimeHours.TotalHours == 0)
            {
                if (TimeAdjustCur.PtoDefNum == 0)
                {
                    textHours.Text = ClockEvents.Format(TimeAdjustCur.RegHours);
                }
                else                  //Is PTO
                {
                    textHours.Text = ClockEvents.Format(TimeAdjustCur.PtoHours);
                }
            }
            else
            {
                checkOvertime.Checked = true;
                textHours.Text        = ClockEvents.Format(TimeAdjustCur.OTimeHours);
            }
            textNote.Text = TimeAdjustCur.Note;
            comboPTO.Items.Clear();
            comboPTO.Items.Add(Lan.g(this, "None"));
            comboPTO.SelectedIndex = 0;
            List <Def> listPtoTypes = Defs.GetDefsForCategory(DefCat.TimeCardAdjTypes).OrderBy(x => x.ItemName).ToList();

            foreach (Def def in listPtoTypes)
            {
                if (def.IsHidden && def.DefNum == TimeAdjustCur.PtoDefNum)
                {
                    comboPTO.Items.Add(new ODBoxItem <Def>(def.ItemName + " " + Lan.g(this, "(hidden)"), def));
                }
                else if (!def.IsHidden)
                {
                    comboPTO.Items.Add(new ODBoxItem <Def>(def.ItemName, def));
                }
                if (def.DefNum == TimeAdjustCur.PtoDefNum)
                {
                    comboPTO.SelectedIndex = comboPTO.Items.Count - 1;
                }
            }
        }
Beispiel #14
0
 private void FormTimeCard_Load(object sender, System.EventArgs e)
 {
     Text              = Lan.g(this, "TimeCard for") + " " + EmployeeCur.FName + " " + EmployeeCur.LName;
     TimeDelta         = ClockEvents.GetServerTime() - DateTime.Now;
     SelectedPayPeriod = PayPeriods.GetForDate(DateTime.Today);
     if (IsBreaks)
     {
         textOvertime.Visible  = false;
         labelOvertime.Visible = false;
         butCompute.Visible    = false;
         butAdj.Visible        = false;
     }
     FillPayPeriod();
     FillMain(true);
 }
Beispiel #15
0
        public static void Available(Phone phone)
        {
            long employeeNum = Security.CurUser.EmployeeNum;

            if (Security.CurUser.EmployeeNum != phone.EmployeeNum)            //We are on someone else's tile. So Let's do some checks before we assume we can take over this extension.
            {
                if (phone.ClockStatus == ClockStatusEnum.NeedsHelp)
                {
                    //Allow the specific state where we are changing their status back from NeedsHelp to Available.
                    //This does not require any security permissions as any tech in can perform this action on behalf of any other tech.
                    Phones.SetPhoneStatus(ClockStatusEnum.Available, phone.Extension, phone.EmployeeNum);                  //green
                    return;
                }
                //We are on a tile that is not our own
                //If another employee is occupying this extension then assume we are trying to change that employee's status back to available.
                if (ClockEvents.IsClockedIn(phone.EmployeeNum))                  //This tile is taken by an employee who is clocked in.
                //Transition the employee back to available.
                {
                    ChangeTileStatus(phone, ClockStatusEnum.Available);
                    PhoneAsterisks.SetToDefaultQueue(phone.EmployeeNum);
                    return;
                }
                if (phone.ClockStatus != ClockStatusEnum.None &&
                    phone.ClockStatus != ClockStatusEnum.Home)
                {
                    //Another person is still actively using this extension.
                    MsgBox.Show(langThis, "Cannot take over this extension as it is currently occuppied by someone who is likely on Break or Lunch.");
                    return;
                }
                //If another employee is NOT occupying this extension then assume we are trying clock in at this extension.
                if (ClockEvents.IsClockedIn(employeeNum))                  //We are already clocked in at a different extension.
                {
                    MsgBox.Show(langThis, "You are already clocked in at a different extension.  You must clock out of the current extension you are logged into before moving to another extension.");
                    return;
                }
                //We got this far so fall through and allow user to clock in.
            }
            //We go here so all of our checks passed and we may login at this extension
            if (!ClockIn())              //Clock in on behalf of yourself
            {
                return;
            }
            //Update the Phone tables accordingly.
            PhoneEmpDefaults.SetAvailable(phone.Extension, employeeNum);
            PhoneAsterisks.SetToDefaultQueue(phone.EmployeeNum);
            Phones.SetPhoneStatus(ClockStatusEnum.Available, phone.Extension, employeeNum);          //green
        }
Beispiel #16
0
        public static void BuildMenuStatus(ContextMenuStrip menuStatus, Phone phoneCur)
        {
            //Jason - Allowed to be 0 here.  The Security.UserCur.EmpNum will be used when they go to clock in and that is where the 0 check needs to be.
            //if(phoneCur.EmployeeNum==0) {
            //  return;
            //}
            bool allowStatusEdit = ClockEvents.IsClockedIn(phoneCur.EmployeeNum);

            if (phoneCur.EmployeeNum == Security.CurUser.EmployeeNum)            //Always allow status edit for yourself
            {
                allowStatusEdit = true;
            }
            if (phoneCur.ClockStatus == ClockStatusEnum.NeedsHelp)            //Always allow any employee to change any other employee from NeedsAssistance to Available
            {
                allowStatusEdit = true;
            }
            string statusOnBehalfOf      = phoneCur.EmployeeName;
            bool   allowSetSelfAvailable = false;

            if (!ClockEvents.IsClockedIn(phoneCur.EmployeeNum) &&         //No one is clocked in at this extension.
                !ClockEvents.IsClockedIn(Security.CurUser.EmployeeNum))                    //This user is not clocked in either.
            {
                //Vacant extension and this user is not clocked in so allow this user to clock in at this extension.
                statusOnBehalfOf      = Security.CurUser.UserName;
                allowSetSelfAvailable = true;
            }
            AddToolstripGroup(menuStatus, "menuItemStatusOnBehalf", "Status for: " + statusOnBehalfOf);
            AddToolstripGroup(menuStatus, "menuItemRingGroupOnBehalf", "Queues for ext: " + phoneCur.Extension.ToString());
            AddToolstripGroup(menuStatus, "menuItemClockOnBehalf", "Clock event for: " + phoneCur.EmployeeName);
            SetToolstripItemText(menuStatus, "menuItemAvailable", allowStatusEdit || allowSetSelfAvailable);
            SetToolstripItemText(menuStatus, "menuItemTraining", allowStatusEdit);
            SetToolstripItemText(menuStatus, "menuItemTeamAssist", allowStatusEdit);
            SetToolstripItemText(menuStatus, "menuItemNeedsHelp", allowStatusEdit);
            SetToolstripItemText(menuStatus, "menuItemWrapUp", allowStatusEdit);
            SetToolstripItemText(menuStatus, "menuItemOfflineAssist", allowStatusEdit);
            SetToolstripItemText(menuStatus, "menuItemUnavailable", allowStatusEdit);
            SetToolstripItemText(menuStatus, "menuItemTCResponder", allowStatusEdit);
            SetToolstripItemText(menuStatus, "menuItemBackup", allowStatusEdit);
            SetToolstripItemText(menuStatus, "menuItemLunch", allowStatusEdit);
            SetToolstripItemText(menuStatus, "menuItemHome", allowStatusEdit);
            SetToolstripItemText(menuStatus, "menuItemBreak", allowStatusEdit);
        }
Beispiel #17
0
 ///<summary>Verify...
 ///1) Security.CurUser is clocked in.
 ///2) Target status change employee is clocked in.
 ///3) Secruity.CurUser has TimecardsEditAll permission.</summary>
 private static bool ChangeTileStatus(Phone phoneCur, ClockStatusEnum newClockStatus)
 {
     if (!ClockEvents.IsClockedIn(Security.CurUser.EmployeeNum))              //Employee performing the action must be clocked in.
     {
         MsgBox.Show(langThis, "You must clock in before completing this action.");
         return(false);
     }
     if (!ClockEvents.IsClockedIn(phoneCur.EmployeeNum))              //Employee having action performed must be clocked in.
     {
         MessageBox.Show(Lan.g(langThis, "Target employee must be clocked in before setting this status:") + " " + phoneCur.EmployeeName);
         return(false);
     }
     if (!CheckUserCanChangeStatus(phoneCur))
     {
         return(false);
     }
     PhoneEmpDefaults.SetAvailable(phoneCur.Extension, phoneCur.EmployeeNum);
     Phones.SetPhoneStatus(newClockStatus, phoneCur.Extension);
     return(true);
 }
        ///<summary>If already clocked in, this does nothing.  Returns false if not able to clock in due to security, or true if successful.</summary>
        private bool ClockIn()
        {
            long employeeNum = PhoneList[rowI].EmployeeNum;

            if (employeeNum == 0)
            {
                MsgBox.Show(this, "No employee at that extension.");
                return(false);
            }
            if (ClockEvents.IsClockedIn(employeeNum))
            {
                return(true);
            }
            if (PrefC.GetBool(PrefName.TimecardSecurityEnabled))
            {
                if (Security.CurUser.EmployeeNum != employeeNum)
                {
                    if (!Security.IsAuthorized(Permissions.TimecardsEditAll))
                    {
                        MsgBox.Show(this, "Not authorized.");
                        return(false);
                    }
                }
            }
            try{
                ClockEvents.ClockIn(employeeNum);
            }
            catch (Exception ex) {
                if (ex.Message.Contains("Already clocked in"))
                {
                    return(true);
                }
                return(false);
            }
            Employee EmpCur = Employees.GetEmp(employeeNum);

            EmpCur.ClockStatus = Lan.g(this, "Working");;
            Employees.Update(EmpCur);
            return(true);
        }
Beispiel #19
0
        public static void Home(PhoneTile tile)
        {
            //verify that employee is logged in as user
            int  extension   = tile.PhoneCur.Extension;
            long employeeNum = tile.PhoneCur.EmployeeNum;

            if (!CheckUserCanChangeStatus(tile))
            {
                return;
            }
            try {             //Update the clock event, phone (HQ only), and phone emp default (HQ only).
                ClockEvents.ClockOut(employeeNum, TimeClockStatus.Home);
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);                //This message will tell user that they are already clocked out.
                return;
            }
            Employee EmpCur = Employees.GetEmp(employeeNum);

            EmpCur.ClockStatus = Lan.g("enumTimeClockStatus", TimeClockStatus.Home.ToString());
            Employees.Update(EmpCur);
        }
 private void FormTimeAdjustEdit_Load(object sender, System.EventArgs e)
 {
     if (TimeAdjustCur.IsAuto)
     {
         radioAuto.Checked = true;
     }
     else
     {
         radioManual.Checked = true;
     }
     textTimeEntry.Text = TimeAdjustCur.TimeEntry.ToString();
     if (TimeAdjustCur.OTimeHours.TotalHours == 0)
     {
         textHours.Text = ClockEvents.Format(TimeAdjustCur.RegHours);
     }
     else
     {
         checkOvertime.Checked = true;
         textHours.Text        = ClockEvents.Format(TimeAdjustCur.OTimeHours);
     }
     textNote.Text = TimeAdjustCur.Note;
 }
Beispiel #21
0
        public static void Unavailable(Phone phone)
        {
            if (!ClockEvents.IsClockedIn(Security.CurUser.EmployeeNum))              //Employee performing the action must be clocked in.
            {
                MsgBox.Show("PhoneUI", "You must clock in before completing this action.");
                return;
            }
            if (!ClockEvents.IsClockedIn(phone.EmployeeNum))              //Employee having action performed must be clocked in.
            {
                MessageBox.Show(Lan.g("PhoneUI", "Target employee must be clocked in before setting this status:") + " " + phone.EmployeeName);
                return;
            }
            if (!CheckUserCanChangeStatus(phone))
            {
                return;
            }
            int             extension   = phone.Extension;
            long            employeeNum = phone.EmployeeNum;
            PhoneEmpDefault ped         = PhoneEmpDefaults.GetByExtAndEmp(extension, employeeNum);

            if (ped == null)
            {
                MessageBox.Show("PhoneEmpDefault (employee setting row) not found for Extension " + extension.ToString() + " and EmployeeNum " + employeeNum.ToString());
                return;
            }
            FormPhoneEmpDefaultEdit formPED = new FormPhoneEmpDefaultEdit();

            formPED.PedCur = ped;
            formPED.PedCur.StatusOverride = PhoneEmpStatusOverride.Unavailable;
            if (formPED.ShowDialog() == DialogResult.OK && formPED.PedCur.StatusOverride == PhoneEmpStatusOverride.Unavailable)
            {
                //This phone status update can get skipped from within the editor if the employee is not clocked in.
                //This would be the case when you are setting an employee other than yourself to Unavailable.
                //So we will set it here. This keeps the phone table and phone panel in sync.
                Phones.SetPhoneStatus(ClockStatusEnum.Unavailable, formPED.PedCur.PhoneExt, formPED.PedCur.EmployeeNum);
                PhoneAsterisks.SetQueueForExtension(phone.Extension, AsteriskQueues.None);
            }
        }
Beispiel #22
0
        ///<summary>Makes sure that the pay periods that the user has selected are safe to delete.
        ///A pay period cannot be deleted in bulk if:
        ///a) It is in the past OR
        ///b) There are clockevents tied to it and there are no other pay periods for the date of the clockevent.</summary>
        private bool IsSafeToDelete(List <PayPeriod> listSelectedPayPeriods, out List <PayPeriod> retListToDelete)
        {
            if (listSelectedPayPeriods.Where(x => x.DateStop < DateTimeOD.Today).Count() > 0)
            {
                MsgBox.Show(this, "You may not delete past pay periods from here. Delete them individually by double clicking them instead.");
                retListToDelete = new List <PayPeriod>();
                return(false);
            }
            List <PayPeriod>  listPayPeriodsToDelete = new List <PayPeriod>();
            List <ClockEvent> listClockEventsAll     = ClockEvents.GetAllForPeriod(listSelectedPayPeriods.Min(x => x.DateStart), listSelectedPayPeriods.Max(x => x.DateStop));

            foreach (PayPeriod payPeriod in listSelectedPayPeriods)
            {
                List <ClockEvent> listClockEventsForPeriod = listClockEventsAll.Where(x => x.TimeDisplayed1 >= payPeriod.DateStart && x.TimeDisplayed2 <= payPeriod.DateStop).ToList();
                if (listClockEventsForPeriod.Count == 0)
                {
                    //there are no clock events for this period.
                    listPayPeriodsToDelete.Add(payPeriod);
                    continue;
                }
                //there ARE clock events for this period. now are there other periods that are *not* in the selected list?
                foreach (ClockEvent clockEvent in listClockEventsForPeriod)
                {
                    if (_listPayPeriods.Where(x => x.DateStart <= clockEvent.TimeDisplayed1 && x.DateStop >= clockEvent.TimeDisplayed1 && !listSelectedPayPeriods.Contains(x)).Count() < 1)
                    {
                        //if no, then kick out.
                        MsgBox.Show(this, "You may not delete all pay periods where a clock event exists.");
                        retListToDelete = new List <PayPeriod>();
                        return(false);
                    }
                    //otherwise, the add this pay period to the list to delete and continue
                    listPayPeriodsToDelete.Add(payPeriod);
                }
            }
            retListToDelete = listPayPeriodsToDelete;
            return(true);
        }
Beispiel #23
0
        ///<summary>If already clocked in, this does nothing.  Returns false if not able to clock in due to security, or true if successful.</summary>
        private bool ClockIn()
        {
            long employeeNum = PhoneList[rowI].EmployeeNum;

            if (employeeNum == 0)
            {
                MsgBox.Show(this, "No employee at that extension.");
                return(false);
            }
            if (ClockEvents.IsClockedIn(employeeNum))
            {
                return(true);
            }
            if (PrefC.GetBool(PrefName.TimecardSecurityEnabled))
            {
                if (Security.CurUser.EmployeeNum != employeeNum)
                {
                    if (!Security.IsAuthorized(Permissions.TimecardsEditAll))
                    {
                        MsgBox.Show(this, "Not authorized.");
                        return(false);
                    }
                }
            }
            try{
                ClockEvents.ClockIn(employeeNum);
            }
            catch {
                //This should never happen.  Fail silently.
                return(true);
            }
            Employee EmpCur = Employees.GetEmp(employeeNum);

            EmpCur.ClockStatus = Lan.g(this, "Working");;
            Employees.Update(EmpCur);
            return(true);
        }
Beispiel #24
0
        //Timecard---------------------------------------------------

        public static void Lunch(PhoneTile tile)
        {
            //verify that employee is logged in as user
            int  extension   = tile.PhoneCur.Extension;
            long employeeNum = tile.PhoneCur.EmployeeNum;

            if (!CheckUserCanChangeStatus(tile))
            {
                return;
            }
            try {
                ClockEvents.ClockOut(employeeNum, TimeClockStatus.Lunch);
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);                //This message will tell user that they are already clocked out.
                return;
            }
            PhoneEmpDefaults.SetAvailable(extension, employeeNum);
            Employee EmpCur = Employees.GetEmp(employeeNum);

            EmpCur.ClockStatus = Lan.g("enumTimeClockStatus", TimeClockStatus.Lunch.ToString());
            Employees.Update(EmpCur);
            Phones.SetPhoneStatus(ClockStatusEnum.Lunch, extension);
        }
Beispiel #25
0
        ///<summary>If already clocked in, this does nothing.  Returns false if not able to clock in due to security, or true if successful.</summary>
        private static bool ClockIn(PhoneTile tile)
        {
            long employeeNum = tile.PhoneCur.EmployeeNum;

            if (employeeNum == 0)
            {
                MsgBox.Show(langThis, "No employee at that extension.");
                return(false);
            }
            if (ClockEvents.IsClockedIn(employeeNum))
            {
                return(true);
            }
            if (Security.CurUser.EmployeeNum != employeeNum)
            {
                if (!Security.IsAuthorized(Permissions.TimecardsEditAll, true))
                {
                    if (!CheckSelectedUserPassword(employeeNum))
                    {
                        return(false);
                    }
                }
            }
            try {
                ClockEvents.ClockIn(employeeNum);
            }
            catch {
                //This should never happen.  Fail silently.
                return(true);
            }
            Employee EmpCur = Employees.GetEmp(employeeNum);

            EmpCur.ClockStatus = "Working";
            Employees.Update(EmpCur);
            return(true);
        }
Beispiel #26
0
        ///<summary>fromDB is set to false when it is refreshing every second so that there will be no extra network traffic.</summary>
        private void FillMain(bool fromDB)
        {
            if (fromDB)
            {
                ClockEventList = ClockEvents.Refresh(EmployeeCur.EmployeeNum, PIn.PDate(textDateStart.Text),
                                                     PIn.PDate(textDateStop.Text), false, IsBreaks);
                if (IsBreaks)
                {
                    TimeAdjustList = new TimeAdjust[0];
                }
                else
                {
                    TimeAdjustList = TimeAdjusts.Refresh(EmployeeCur.EmployeeNum, PIn.PDate(textDateStart.Text),
                                                         PIn.PDate(textDateStop.Text));
                }
            }
            mergedAL = new ArrayList();
            for (int i = 0; i < ClockEventList.Length; i++)
            {
                mergedAL.Add(ClockEventList[i]);
            }
            for (int i = 0; i < TimeAdjustList.Length; i++)
            {
                mergedAL.Add(TimeAdjustList[i]);
            }
            IComparer myComparer = new ObjectDateComparer();

            mergedAL.Sort(myComparer);
            gridMain.BeginUpdate();
            gridMain.Columns.Clear();
            ODGridColumn col = new ODGridColumn(Lan.g(this, "Date"), 70);

            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Weekday"), 70);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Altered"), 50, HorizontalAlignment.Right);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Status"), 50);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "In/Out"), 60, HorizontalAlignment.Right);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Time"), 60, HorizontalAlignment.Right);
            gridMain.Columns.Add(col);
            if (IsBreaks)
            {
                col = new ODGridColumn(Lan.g(this, "Minutes"), 50, HorizontalAlignment.Right);
            }
            else
            {
                col = new ODGridColumn(Lan.g(this, "Hours"), 50, HorizontalAlignment.Right);
            }
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Overtime"), 55, HorizontalAlignment.Right);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Daily"), 50, HorizontalAlignment.Right);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Weekly"), 50, HorizontalAlignment.Right);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Note"), 5);
            gridMain.Columns.Add(col);
            gridMain.Rows.Clear();
            ODGridRow row;

            //TimeSpan weeklyTotalPrevious=
            WeeklyTotals = new TimeSpan[mergedAL.Count];
            TimeSpan   alteredSpan = new TimeSpan(0); //used to display altered times
            TimeSpan   pairSpan    = new TimeSpan(0); //used to sum one pair of clockevents
            ClockEvent pairFirst   = null;            //the first of a pair of clockevents
            TimeSpan   daySpan     = new TimeSpan(0); //used for daily totals.
            TimeSpan   weekSpan    = new TimeSpan(0); //used for weekly totals.

            if (mergedAL.Count > 0)
            {
                weekSpan = ClockEvents.GetWeekTotal(EmployeeCur.EmployeeNum, GetDateForRow(0));
            }
            //MessageBox.Show(weekSpan.TotalHours.ToString());
            TimeSpan         periodSpan   = new TimeSpan(0); //used to add up totals for entire page.
            TimeSpan         otspan       = new TimeSpan(0); //overtime for the entire period
            Calendar         cal          = CultureInfo.CurrentCulture.Calendar;
            CalendarWeekRule rule         = CultureInfo.CurrentCulture.DateTimeFormat.CalendarWeekRule;
            DateTime         curDate      = DateTime.MinValue;
            DateTime         previousDate = DateTime.MinValue;
            Type             type;
            ClockEvent       clock;
            TimeAdjust       adjust;

            for (int i = 0; i < mergedAL.Count; i++)
            {
                row          = new ODGridRow();
                type         = mergedAL[i].GetType();
                row.Tag      = mergedAL[i];
                previousDate = curDate;
                //clock event row---------------------------------------------------------------------------------------------
                if (type == typeof(ClockEvent))
                {
                    clock   = (ClockEvent)mergedAL[i];
                    curDate = clock.TimeDisplayed.Date;
                    if (curDate == previousDate)
                    {
                        row.Cells.Add("");
                        row.Cells.Add("");
                    }
                    else
                    {
                        row.Cells.Add(curDate.ToShortDateString());
                        row.Cells.Add(curDate.DayOfWeek.ToString());
                    }
                    //altered--------------------------------------
                    if (clock.TimeEntered != clock.TimeDisplayed)
                    {
                        alteredSpan = clock.TimeDisplayed - clock.TimeEntered;
                        if (IsBreaks)
                        {
                            row.Cells.Add(alteredSpan.TotalMinutes.ToString("n"));
                        }
                        else
                        {
                            row.Cells.Add(alteredSpan.TotalHours.ToString("n"));
                        }
                    }
                    else
                    {
                        row.Cells.Add("");
                    }
                    //status--------------------------------------
                    row.Cells.Add(clock.ClockStatus.ToString());
                    //in/out------------------------------------------
                    if (clock.ClockIn)
                    {
                        row.Cells.Add(Lan.g(this, "In"));
                    }
                    else
                    {
                        row.Cells.Add(Lan.g(this, "Out"));
                    }
                    //time-----------------------------
                    row.Cells.Add(clock.TimeDisplayed.ToShortTimeString());
                    //minutes or hours-------------------------------
                    if (IsBreaks)                     //breaks
                    {
                        if (!clock.ClockIn)           //clocking out
                        {
                            pairFirst = clock.Copy();
                            row.Cells.Add("");
                        }
                        else                         //clocking in
                        {
                            if (pairFirst == null)
                            {
                                row.Cells.Add("");
                            }
                            else
                            {
                                pairSpan = clock.TimeDisplayed - pairFirst.TimeDisplayed;
                                row.Cells.Add(pairSpan.TotalMinutes.ToString("n"));
                                daySpan += pairSpan;
                                //weekSpan+=pairSpan;
                                periodSpan += pairSpan;
                            }
                        }
                    }
                    else                     //regular hours
                    {
                        if (clock.ClockIn)   //clocking in
                        {
                            pairFirst = clock.Copy();
                            row.Cells.Add("");
                        }
                        else                         //clocking out
                        {
                            if (pairFirst == null)
                            {
                                row.Cells.Add("");
                            }
                            else
                            {
                                pairSpan = clock.TimeDisplayed - pairFirst.TimeDisplayed;
                                row.Cells.Add(pairSpan.TotalHours.ToString("n"));
                                daySpan    += pairSpan;
                                weekSpan   += pairSpan;
                                periodSpan += pairSpan;
                            }
                        }
                    }
                    //Overtime------------------------------
                    row.Cells.Add("");
                    //Daily-----------------------------------
                    //if this is the last entry for a given date
                    if (i == mergedAL.Count - 1 ||            //if this is the last row
                        GetDateForRow(i + 1) != curDate)                         //or the next row is a different date
                    {
                        if (IsBreaks)
                        {
                            if (!clock.ClockIn)                            //if they have not clocked back in yet from break
                            //display the timespan of pairSpan using current time as the other number.
                            {
                                pairSpan = DateTime.Now - clock.TimeDisplayed + TimeDelta;
                                row.Cells.Add(pairSpan.TotalMinutes.ToString("n"));
                                daySpan += pairSpan;
                            }
                            else
                            {
                                row.Cells.Add(daySpan.TotalMinutes.ToString("n"));
                            }
                        }
                        else
                        {
                            row.Cells.Add(daySpan.TotalHours.ToString("n"));
                        }
                        daySpan = new TimeSpan(0);
                    }
                    else                     //not the last entry for the day
                    {
                        row.Cells.Add("");
                    }
                    //Weekly-------------------------------------
                    WeeklyTotals[i] = weekSpan;
                    if (IsBreaks)
                    {
                        row.Cells.Add("");
                    }
                    //if this is the last entry for a given week
                    else if (i == mergedAL.Count - 1 ||            //if this is the last row
                             cal.GetWeekOfYear(GetDateForRow(i + 1), rule, DayOfWeek.Sunday)                  //or the next row has a
                             != cal.GetWeekOfYear(clock.TimeDisplayed.Date, rule, DayOfWeek.Sunday))          //different week of year
                    {
                        row.Cells.Add(weekSpan.TotalHours.ToString("n"));
                        weekSpan = new TimeSpan(0);
                    }
                    else
                    {
                        row.Cells.Add("");
                    }
                    //Note-----------------------------------------
                    row.Cells.Add(clock.Note);
                }
                //adjustment row--------------------------------------------------------------------------------------
                else if (type == typeof(TimeAdjust))
                {
                    adjust  = (TimeAdjust)mergedAL[i];
                    curDate = adjust.TimeEntry.Date;
                    if (curDate == previousDate)
                    {
                        row.Cells.Add("");
                        row.Cells.Add("");
                    }
                    else
                    {
                        row.Cells.Add(curDate.ToShortDateString());
                        row.Cells.Add(curDate.DayOfWeek.ToString());
                    }
                    //altered--------------------------------------
                    row.Cells.Add("");                    //2
                    //status--------------------------------------
                    row.Cells.Add(Lan.g(this, "Adjust")); //3
                    row.ColorText = Color.Red;
                    //in/out------------------------------------------
                    row.Cells.Add("");                                   //4
                    //time-----------------------------
                    row.Cells.Add(adjust.TimeEntry.ToShortTimeString()); //5
                    //minutes or hours-------------------------------
                    if (adjust.RegHours.TotalHours == 0)
                    {
                        row.Cells.Add("");                        //6
                    }
                    else
                    {
                        daySpan    += adjust.RegHours;                   //might be negative
                        weekSpan   += adjust.RegHours;
                        periodSpan += adjust.RegHours;
                        row.Cells.Add(adjust.RegHours.TotalHours.ToString("n"));                        //6
                    }
                    //Overtime------------------------------
                    if (adjust.OTimeHours.TotalHours != 0)
                    {
                        otspan += adjust.OTimeHours;
                        row.Cells.Add(adjust.OTimeHours.TotalHours.ToString("n"));                        //7
                    }
                    else
                    {
                        row.Cells.Add("");                        //7
                    }
                    //Daily-----------------------------------
                    //if this is the last entry for a given date
                    if (i == mergedAL.Count - 1 ||            //if this is the last row
                        GetDateForRow(i + 1) != curDate)                         //or the next row is a different date
                    {
                        row.Cells.Add(daySpan.TotalHours.ToString("n"));         //8
                        daySpan = new TimeSpan(0);
                    }
                    else
                    {
                        row.Cells.Add("");
                    }
                    //Weekly-------------------------------------
                    WeeklyTotals[i] = weekSpan;
                    if (IsBreaks)
                    {
                        row.Cells.Add("");
                    }
                    //if this is the last entry for a given week
                    else if (i == mergedAL.Count - 1 ||            //if this is the last row
                             cal.GetWeekOfYear(GetDateForRow(i + 1), rule, DayOfWeek.Sunday)                  //or the next row has a
                             != cal.GetWeekOfYear(adjust.TimeEntry.Date, rule, DayOfWeek.Sunday))             //different week of year
                    {
                        ODGridCell cell = new ODGridCell(weekSpan.TotalHours.ToString("n"));
                        cell.ColorText = Color.Black;
                        row.Cells.Add(cell);
                        weekSpan = new TimeSpan(0);
                    }
                    else
                    {
                        row.Cells.Add("");
                    }
                    //Note-----------------------------------------
                    row.Cells.Add(adjust.Note);
                }
                gridMain.Rows.Add(row);
            }
            gridMain.EndUpdate();
            if (IsBreaks)
            {
                textTotal.Text = "";
            }
            else
            {
                textTotal.Text    = periodSpan.TotalHours.ToString("n");
                textOvertime.Text = otspan.TotalHours.ToString("n");
            }
        }
Beispiel #27
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            //Using a switch statement in case we want special functionality for the other statuses later on.
            switch ((PhoneEmpStatusOverride)listStatusOverride.SelectedIndex)
            {
            case PhoneEmpStatusOverride.None:
                if (_pedOld.StatusOverride == PhoneEmpStatusOverride.Unavailable)
                {
                    MsgBox.Show(this, "Change your status from unavailable by using the small phone panel.");
                    return;
                }
                break;

            case PhoneEmpStatusOverride.OfflineAssist:
                if (_pedOld.StatusOverride == PhoneEmpStatusOverride.Unavailable)
                {
                    MsgBox.Show(this, "Change your status from unavailable by using the small phone panel.");
                    return;
                }
                break;
            }
            if (IsNew)
            {
                if (textEmployeeNum.Text == "")
                {
                    MsgBox.Show(this, "Unique EmployeeNum is required.");
                    return;
                }
                if (textEmpName.Text == "")
                {
                    MsgBox.Show(this, "Employee name is required.");
                    return;
                }
                PedCur.EmployeeNum = PIn.Long(textEmployeeNum.Text);
            }
            //Get the current database state of the phone emp default (before we change it)
            PhoneEmpDefault pedFromDatabase = PhoneEmpDefaults.GetOne(PedCur.EmployeeNum);

            if (pedFromDatabase == null)
            {
                pedFromDatabase = new PhoneEmpDefault();
            }
            else if (pedFromDatabase != null && IsNew)
            {
                MessageBox.Show("Employee Num already in use.\r\nEdit their current phone settings entry instead of creating a duplicate.");
                return;
            }
            int  newExtension    = PIn.Int(textPhoneExt.Text);
            bool extensionChange = pedFromDatabase.PhoneExt != newExtension;

            if (extensionChange)              //Only check when extension has changed and clocked in.
            //We need to prevent changes to phoneempdefault table which involve employees who are currently logged in.
            //Failing to do so would cause subtle race conditions between the phone table and phoneempdefault.
            //Net result would be the phone panel looking wrong.
            {
                if (ClockEvents.IsClockedIn(PedCur.EmployeeNum))                 //Prevent any change if employee being edited is currently clocked in.
                {
                    MsgBox.Show(this, "You must first clock out before making changes");
                    return;
                }
                //Find out if the target extension is already being occuppied by a different employee.
                Phone phoneOccuppied = Phones.GetPhoneForExtensionDB(PIn.Int(textPhoneExt.Text));
                if (phoneOccuppied != null)
                {
                    if (ClockEvents.IsClockedIn(phoneOccuppied.EmployeeNum))                      //Prevent change if employee's new extension is occupied by a different employee who is currently clocked in.
                    {
                        MessageBox.Show(Lan.g(this, "This extension cannot be inherited because it is currently occuppied by an employee who is currently logged in.\r\n\r\nExisting employee: ") + phoneOccuppied.EmployeeName);
                        return;
                    }
                    if (phoneOccuppied.EmployeeNum != PedCur.EmployeeNum)
                    {
                        //We are setting to a new employee so let's clean up the old employee.
                        //This will prevent duplicates in the phone table and subsequently prevent duplicates in the phone panel.
                        Phones.UpdatePhoneToEmpty(phoneOccuppied.EmployeeNum, -1);
                        PhoneEmpDefault pedOccuppied = PhoneEmpDefaults.GetOne(phoneOccuppied.EmployeeNum);
                        if (pedOccuppied != null)                       //prevent duplicate in phoneempdefault
                        {
                            pedOccuppied.PhoneExt = 0;
                            PhoneEmpDefaults.Update(pedOccuppied);
                        }
                    }
                }
                //Get the employee that is normally assigned to this extension (assigned ext set in the employee table).
                long permanentLinkageEmployeeNum = Employees.GetEmpNumAtExtension(pedFromDatabase.PhoneExt);
                if (permanentLinkageEmployeeNum >= 1)                      //Extension is nomrally assigned to an employee.
                {
                    if (PedCur.EmployeeNum != permanentLinkageEmployeeNum) //This is not the normally linked employee so let's revert back to the proper employee.
                    {
                        PhoneEmpDefault pedRevertTo = PhoneEmpDefaults.GetOne(permanentLinkageEmployeeNum);
                        //Make sure the employee we are about to revert is not logged in at yet a different workstation. This would be rare but it's worth checking.
                        if (pedRevertTo != null && !ClockEvents.IsClockedIn(pedRevertTo.EmployeeNum))
                        {
                            //Revert to the permanent extension for this PhoneEmpDefault.
                            pedRevertTo.PhoneExt = pedFromDatabase.PhoneExt;
                            PhoneEmpDefaults.Update(pedRevertTo);
                            //Update phone table to match this change.
                            Phones.SetPhoneStatus(ClockStatusEnum.Home, pedRevertTo.PhoneExt, pedRevertTo.EmployeeNum);
                        }
                    }
                }
            }
            //Ordering of these updates is IMPORTANT!!!
            //Phone Emp Default must be updated first
            PedCur.EmpName        = textEmpName.Text;
            PedCur.IsGraphed      = checkIsGraphed.Checked;
            PedCur.HasColor       = checkHasColor.Checked;
            PedCur.RingGroups     = (AsteriskQueues)listRingGroup.SelectedIndex;
            PedCur.PhoneExt       = PIn.Int(textPhoneExt.Text);
            PedCur.StatusOverride = (PhoneEmpStatusOverride)listStatusOverride.SelectedIndex;
            PedCur.Notes          = textNotes.Text;
            if (comboSite.SelectedIndex > -1)
            {
                PedCur.SiteNum = ((ODBoxItem <Site>)comboSite.SelectedItem).Tag.SiteNum;
            }
            PedCur.IsPrivateScreen  = true;         //we no longer capture screen shots.
            PedCur.IsTriageOperator = checkIsTriageOperator.Checked;
            if (IsNew)
            {
                PhoneEmpDefaults.Insert(PedCur);
                //insert a new Phone record to keep the 2 tables in sync an entry for the new extension in the phone table doesn't already exist.
                if (PedCur.PhoneExt != 0 && Phones.GetPhoneForExtensionDB(PedCur.PhoneExt) == null)
                {
                    Phone phoneNew = new Phone();
                    phoneNew.EmployeeName = PedCur.EmpName;
                    phoneNew.EmployeeNum  = PedCur.EmployeeNum;
                    phoneNew.Extension    = PedCur.PhoneExt;
                    phoneNew.ClockStatus  = ClockStatusEnum.Home;
                    Phones.Insert(phoneNew);
                }
            }
            else
            {
                PhoneEmpDefaults.Update(PedCur);
            }
            //It is now safe to update Phone table as it will draw from the newly updated Phone Emp Default row
            if ((PhoneEmpStatusOverride)listStatusOverride.SelectedIndex == PhoneEmpStatusOverride.Unavailable &&
                ClockEvents.IsClockedIn(PedCur.EmployeeNum))
            {
                //We set ourselves unavailable from this window because we require an explanation.
                //This is the only status that will synch with the phone table, all others should be handled by the small phone panel.
                Phones.SetPhoneStatus(ClockStatusEnum.Unavailable, PedCur.PhoneExt, PedCur.EmployeeNum);
            }
            if (extensionChange)
            {
                //Phone extension has changed so update the phone table as well.
                //We have already guaranteed that this employee is Clocked Out (above) so set to home and update phone table.
                Phones.SetPhoneStatus(ClockStatusEnum.Home, PedCur.PhoneExt, PedCur.EmployeeNum);
            }
            //The user just flagged themselves as a triage operator
            //OR
            //This user used to be a triage operator and they no longer want to be one which will need their ring group set back to their default.
            if ((!_pedOld.IsTriageOperator && checkIsTriageOperator.Checked) ||
                (_pedOld.IsTriageOperator && !checkIsTriageOperator.Checked))
            {
                //Set the queue for this phone emp default to whatever the current ClockStatus is for the phone row associated to this PED.
                PhoneAsterisks.SetQueueForClockStatus(PedCur);
            }
            DialogResult = DialogResult.OK;
        }
Beispiel #28
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();
        }
Beispiel #29
0
        ///<summary>Does not alter the overrides, but only the auto calc boxes.  Triggered by many things on this form.  It's better to have it be triggered too frequently than to miss something.</summary>
        private void FillTimeSpans()
        {
            if (ClockEventCur.ClockStatus == TimeClockStatus.Break)          //TimeSpans not showing
            {
                return;
            }
            if (textTimeEntered2.Text == "" || textTimeDisplayed2.Text == "")
            {
                textTotalTime.Text = "";
                textRegTime.Text   = "";
                return;
            }
            try{
                DateTime.Parse(textTimeDisplayed1.Text); //because this must always be valid
                DateTime.Parse(textTimeDisplayed2.Text); //this must also be filled in order to calculate timespans
            }
            catch {                                      //an invalid date/time.
                //textTotalTime.Text="";
                //textRegTime.Text="";
                return;
            }
            DateTime dt1 = DateTime.Parse(textTimeDisplayed1.Text);
            DateTime dt2 = DateTime.Parse(textTimeDisplayed2.Text);

            if (dt1 > dt2)
            {
                return;
            }
            TimeSpan totalTime = dt2 - dt1;

            textTotalTime.Text = ClockEvents.Format(totalTime);
            TimeSpan overtime = ClockEventCur.OTimeAuto;

            if (textOTimeHours.Text != "")
            {
                try {
                    if (textOTimeHours.Text.Contains(":"))
                    {
                        overtime = TimeSpan.Parse(textOTimeHours.Text);
                    }
                    else
                    {
                        overtime = TimeSpan.FromHours(Double.Parse(textOTimeHours.Text));
                    }
                }
                catch {
                    return;
                }
            }
            TimeSpan adjust = ClockEventCur.AdjustAuto;

            if (textAdjust.Text != "")
            {
                try {
                    if (textAdjust.Text.Contains(":"))
                    {
                        adjust = TimeSpan.Parse(textAdjust.Text);
                    }
                    else
                    {
                        adjust = TimeSpan.FromHours(Double.Parse(textAdjust.Text));
                    }
                }
                catch {
                    return;
                }
            }
            TimeSpan regTime = totalTime - overtime + adjust;      //adjust is typically a negative value

            if (regTime < TimeSpan.Zero)
            {
                textRegTime.Text = "";
                return;
            }
            textRegTime.Text = ClockEvents.Format(regTime);
        }
Beispiel #30
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            DateTime timeDisplayed1 = DateTime.MinValue;

            try{
                timeDisplayed1 = DateTime.Parse(textTimeDisplayed1.Text);              //because this must always be valid
            }
            catch {
                if (ClockEventCur.ClockStatus == TimeClockStatus.Break)
                {
                    MsgBox.Show(this, "Please enter a valid clock-out date and time.");
                }
                else
                {
                    MsgBox.Show(this, "Please enter a valid clock-in date and time.");
                }
                return;
            }
            if (timeDisplayed1.Date > DateTime.Today)
            {
                if (ClockEventCur.ClockStatus == TimeClockStatus.Break)
                {
                    MsgBox.Show(this, "Clock-out date cannot be a future date.");
                }
                else
                {
                    MsgBox.Show(this, "Clock-in date cannot be a future date.");
                }
                return;
            }
            DateTime timeDisplayed2 = DateTime.MinValue;

            if (textTimeDisplayed2.Text != "")          //it can be empty
            {
                try{
                    timeDisplayed2 = DateTime.Parse(textTimeDisplayed2.Text);
                }
                catch {
                    if (ClockEventCur.ClockStatus == TimeClockStatus.Break)
                    {
                        MsgBox.Show(this, "Please enter a valid clock-in date and time.");
                    }
                    else
                    {
                        MsgBox.Show(this, "Please enter a valid clock-out date and time.");
                    }
                    return;
                }
            }
            if (timeDisplayed2.Date > DateTime.Today)
            {
                if (ClockEventCur.ClockStatus == TimeClockStatus.Break)
                {
                    MsgBox.Show(this, "Clock-in date cannot be a future date.");
                }
                else
                {
                    MsgBox.Show(this, "Clock-out date cannot be a future date.");
                }
                return;
            }
            if (textTimeDisplayed2.Text != "" && timeDisplayed1 > timeDisplayed2)
            {
                if (ClockEventCur.ClockStatus == TimeClockStatus.Break)
                {
                    MsgBox.Show(this, "Break end time cannot be earlier than break start time.");
                    return;
                }
                else
                {
                    MsgBox.Show(this, "Clock out time cannot be earlier than clock in time.");
                    return;
                }
            }
            if (textTimeDisplayed2.Text == "" && textTimeEntered2.Text != "")         //user is trying to clear the time manually
            {
                MsgBox.Show(this, "A date and time must be entered in the second box, or use the Clear button.");
                return;
            }
            TimeSpan overtime = TimeSpan.Zero;
            TimeSpan adjust   = TimeSpan.Zero;

            if (ClockEventCur.ClockStatus != TimeClockStatus.Break)
            {
                if (textOTimeHours.Text != "")
                {
                    try {
                        if (textOTimeHours.Text.Contains(":"))
                        {
                            overtime = TimeSpan.Parse(textOTimeHours.Text);
                        }
                        else
                        {
                            overtime = TimeSpan.FromHours(Double.Parse(textOTimeHours.Text));
                        }
                        if (overtime < TimeSpan.Zero)
                        {
                            MsgBox.Show(this, "Overtime must be positive.");
                            return;
                        }
                    }
                    catch {
                        MsgBox.Show(this, "Please enter a valid overtime amount.");
                        return;
                    }
                }
                if (textAdjust.Text != "")
                {
                    try {
                        if (textAdjust.Text.Contains(":"))
                        {
                            adjust = TimeSpan.Parse(textAdjust.Text);
                        }
                        else
                        {
                            adjust = TimeSpan.FromHours(Double.Parse(textAdjust.Text));
                        }
                    }
                    catch {
                        MsgBox.Show(this, "Please enter a valid adjustment amount.");
                        return;
                    }
                }
                if (textRegTime.Text == "")                                                              //Must be invalid calc.
                {
                    if (textTimeEntered2.Text == "")                                                     //They haven't clocked out yet.	Invalid calc is expected.
                    {
                        if (textAdjust.Text.Trim() != "" || textOTimeHours.Text.Trim() != "")            //They're entering in overtime or adjustments.
                        {
                            MsgBox.Show(this, "Cannot enter overtime or adjustments while clocked in."); //To this timespan is implied.
                            return;
                        }
                    }
                    else                      //They have clocked out.
                    {
                        MsgBox.Show(this, "Overtime and adjustments cannot excede the total time.");
                        return;
                    }
                }
            }
            //timeEntered2 is largely taken care of, except for this one situation
            if (textTimeDisplayed2.Text != "" && textTimeEntered2.Text == "")
            {
                ClockEventCur.TimeEntered2 = MiscData.GetNowDateTime();
            }
            ClockEventCur.TimeDisplayed1 = timeDisplayed1;
            ClockEventCur.TimeDisplayed2 = timeDisplayed2;
            ClockEventCur.ClockStatus    = (TimeClockStatus)listStatus.SelectedIndex;
            if (textAdjust.Text == "")           //no override
            {
                ClockEventCur.AdjustIsOverridden = false;
                ClockEventCur.Adjust             = TimeSpan.Zero;
            }
            else
            {
                ClockEventCur.AdjustIsOverridden = true;
                ClockEventCur.Adjust             = adjust;
            }
            if (textOTimeHours.Text == "")           //no override
            {
                ClockEventCur.OTimeHours = TimeSpan.FromHours(-1d);
            }
            else
            {
                ClockEventCur.OTimeHours = overtime;
            }
            //The two auto fields are only set externally.
            ClockEventCur.Note = textNote.Text;
            ClockEvents.Update(ClockEventCur);
            DialogResult = DialogResult.OK;
        }