Ejemplo n.º 1
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        internal static List <ClockEvent> TableToList(DataTable table)
        {
            List <ClockEvent> retVal = new List <ClockEvent>();
            ClockEvent        clockEvent;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                clockEvent = new ClockEvent();
                clockEvent.ClockEventNum      = PIn.Long(table.Rows[i]["ClockEventNum"].ToString());
                clockEvent.EmployeeNum        = PIn.Long(table.Rows[i]["EmployeeNum"].ToString());
                clockEvent.TimeEntered1       = PIn.DateT(table.Rows[i]["TimeEntered1"].ToString());
                clockEvent.TimeDisplayed1     = PIn.DateT(table.Rows[i]["TimeDisplayed1"].ToString());
                clockEvent.ClockStatus        = (TimeClockStatus)PIn.Int(table.Rows[i]["ClockStatus"].ToString());
                clockEvent.Note               = PIn.String(table.Rows[i]["Note"].ToString());
                clockEvent.TimeEntered2       = PIn.DateT(table.Rows[i]["TimeEntered2"].ToString());
                clockEvent.TimeDisplayed2     = PIn.DateT(table.Rows[i]["TimeDisplayed2"].ToString());
                clockEvent.OTimeHours         = PIn.TSpan(table.Rows[i]["OTimeHours"].ToString());
                clockEvent.OTimeAuto          = PIn.TSpan(table.Rows[i]["OTimeAuto"].ToString());
                clockEvent.Adjust             = PIn.TSpan(table.Rows[i]["Adjust"].ToString());
                clockEvent.AdjustAuto         = PIn.TSpan(table.Rows[i]["AdjustAuto"].ToString());
                clockEvent.AdjustIsOverridden = PIn.Bool(table.Rows[i]["AdjustIsOverridden"].ToString());
                retVal.Add(clockEvent);
            }
            return(retVal);
        }
Ejemplo n.º 2
0
        private ClockEvent getTestObj()
        {
            var clid    = 123456;
            var cid     = 9696;
            var cname   = "Test Company";
            var eid     = Guid.NewGuid();
            var ename   = "John Doe";
            var cevent  = DateTime.Now;
            var sid     = Guid.NewGuid();;
            var sname   = "Matt Bastage";
            var tc      = DateTime.Now;
            var tcevent = ClockEventTypes.LunchEnd;

            var obj = new ClockEvent
            {
                ClockId        = clid,
                CompanyId      = cid,
                CompanyName    = cname,
                EmployeeId     = eid,
                EmployeeName   = ename,
                Event          = cevent,
                SupervisorId   = sid,
                SupervisorName = sname,
                TimeCard       = tc,
                Type           = tcevent,
            };

            return(obj);
        }
Ejemplo n.º 3
0
 ///<summary>Inserts one ClockEvent into the database.  Provides option to use the existing priKey.</summary>
 internal static long Insert(ClockEvent clockEvent,bool useExistingPK)
 {
     if(!useExistingPK && PrefC.RandomKeys) {
         clockEvent.ClockEventNum=ReplicationServers.GetKey("clockevent","ClockEventNum");
     }
     string command="INSERT INTO clockevent (";
     if(useExistingPK || PrefC.RandomKeys) {
         command+="ClockEventNum,";
     }
     command+="EmployeeNum,TimeEntered1,TimeDisplayed1,ClockStatus,Note,TimeEntered2,TimeDisplayed2,OTimeHours,OTimeAuto,Adjust,AdjustAuto,AdjustIsOverridden) VALUES(";
     if(useExistingPK || PrefC.RandomKeys) {
         command+=POut.Long(clockEvent.ClockEventNum)+",";
     }
     command+=
              POut.Long  (clockEvent.EmployeeNum)+","
         +    DbHelper.Now()+","
         +    DbHelper.Now()+","
         +    POut.Int   ((int)clockEvent.ClockStatus)+","
         +"'"+POut.String(clockEvent.Note)+"',"
         +    POut.DateT (clockEvent.TimeEntered2)+","
         +    POut.DateT (clockEvent.TimeDisplayed2)+","
         +"'"+POut.TSpan (clockEvent.OTimeHours)+"',"
         +"'"+POut.TSpan (clockEvent.OTimeAuto)+"',"
         +"'"+POut.TSpan (clockEvent.Adjust)+"',"
         +"'"+POut.TSpan (clockEvent.AdjustAuto)+"',"
         +    POut.Bool  (clockEvent.AdjustIsOverridden)+")";
     if(useExistingPK || PrefC.RandomKeys) {
         Db.NonQ(command);
     }
     else {
         clockEvent.ClockEventNum=Db.NonQ(command,true);
     }
     return clockEvent.ClockEventNum;
 }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            var      clockevent = new ClockEvent();
            DateTime alarmTime = new DateTime();
            int      year, month, day, hour, minute, second;

            Console.WriteLine("Please enter the accurate alarm time of your clock");
            Console.WriteLine("Enter year, month, day, hour ,minute and second IN TURN and seperate them with the ENTER key");
            try
            {
                year      = int.Parse(Console.ReadLine());
                month     = int.Parse(Console.ReadLine());
                day       = int.Parse(Console.ReadLine());
                hour      = int.Parse(Console.ReadLine());
                minute    = int.Parse(Console.ReadLine());
                second    = int.Parse(Console.ReadLine());
                alarmTime = new DateTime(year, month, day, hour, minute, second);
                Console.WriteLine($"You have set the alarm time as {alarmTime}");
            }
            catch (ArgumentOutOfRangeException)
            {
                Console.WriteLine("Error:the time you enter is out of range");
            }
            catch (FormatException)
            {
                Console.WriteLine("Error:the format of time you enter is wrong");
            }
            finally
            {
                clockevent.ShowTime(alarmTime);
            }
        }
Ejemplo n.º 5
0
 ///<summary>Inserts one ClockEvent into the database.  Returns the new priKey.</summary>
 internal static long Insert(ClockEvent clockEvent)
 {
     if(DataConnection.DBtype==DatabaseType.Oracle) {
         clockEvent.ClockEventNum=DbHelper.GetNextOracleKey("clockevent","ClockEventNum");
         int loopcount=0;
         while(loopcount<100){
             try {
                 return Insert(clockEvent,true);
             }
             catch(Oracle.DataAccess.Client.OracleException ex){
                 if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
                     clockEvent.ClockEventNum++;
                     loopcount++;
                 }
                 else{
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else {
         return Insert(clockEvent,false);
     }
 }
        public async Task <IActionResult> Edit(int id, ClockEvent clockEvent)
        {
            if (id != clockEvent.Id)
            {
                return(NotFound());
            }

            clockEvent.Teacher = _teacherRepository.FindByUsername(clockEvent.Teacher.UserName);

            if (ModelState.IsValid)
            {
                try
                {
                    await _clockEventRepository.UpdateClockEvent(clockEvent);

                    return(BuildEditClockView(clockEvent, "Event updated successfully!"));
                }
                catch (Exception)
                {
                    return(BuildEditClockView(clockEvent, "There was a problem!"));
                }
            }

            return(BuildEditClockView(clockEvent, "There was a problem!"));
        }
Ejemplo n.º 7
0
        ///<summary></summary>
        public static void Insert(ClockEvent ce)
        {
            if (PrefB.RandomKeys)
            {
                ce.ClockEventNum = MiscData.GetKey("clockevent", "ClockEventNum");
            }
            string command = "INSERT INTO clockevent (";

            if (PrefB.RandomKeys)
            {
                command += "ClockEventNum,";
            }
            command += "EmployeeNum,TimeEntered,TimeDisplayed,ClockIn"
                       + ",ClockStatus,Note) VALUES(";
            if (PrefB.RandomKeys)
            {
                command += "'" + POut.PInt(ce.ClockEventNum) + "', ";
            }
            command +=
                "'" + POut.PInt(ce.EmployeeNum) + "', "
                + POut.PDateT(ce.TimeEntered) + ", "
                + POut.PDateT(ce.TimeDisplayed) + ", "
                + "'" + POut.PBool(ce.ClockIn) + "', "
                + "'" + POut.PInt((int)ce.ClockStatus) + "', "
                + "'" + POut.PString(ce.Note) + "')";
            if (PrefB.RandomKeys)
            {
                General.NonQ(command);
            }
            else
            {
                ce.ClockEventNum = General.NonQ(command, true);
            }
        }
Ejemplo n.º 8
0
 ///<summary>Inserts one ClockEvent into the database.  Returns the new priKey.</summary>
 internal static long Insert(ClockEvent clockEvent)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         clockEvent.ClockEventNum = DbHelper.GetNextOracleKey("clockevent", "ClockEventNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(clockEvent, true));
             }
             catch (Oracle.DataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     clockEvent.ClockEventNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(clockEvent, false));
     }
 }
Ejemplo n.º 9
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <ClockEvent> TableToList(DataTable table)
        {
            List <ClockEvent> retVal = new List <ClockEvent>();
            ClockEvent        clockEvent;

            foreach (DataRow row in table.Rows)
            {
                clockEvent = new ClockEvent();
                clockEvent.ClockEventNum      = PIn.Long(row["ClockEventNum"].ToString());
                clockEvent.EmployeeNum        = PIn.Long(row["EmployeeNum"].ToString());
                clockEvent.TimeEntered1       = PIn.DateT(row["TimeEntered1"].ToString());
                clockEvent.TimeDisplayed1     = PIn.DateT(row["TimeDisplayed1"].ToString());
                clockEvent.ClockStatus        = (OpenDentBusiness.TimeClockStatus)PIn.Int(row["ClockStatus"].ToString());
                clockEvent.Note               = PIn.String(row["Note"].ToString());
                clockEvent.TimeEntered2       = PIn.DateT(row["TimeEntered2"].ToString());
                clockEvent.TimeDisplayed2     = PIn.DateT(row["TimeDisplayed2"].ToString());
                clockEvent.OTimeHours         = PIn.TSpan(row["OTimeHours"].ToString());
                clockEvent.OTimeAuto          = PIn.TSpan(row["OTimeAuto"].ToString());
                clockEvent.Adjust             = PIn.TSpan(row["Adjust"].ToString());
                clockEvent.AdjustAuto         = PIn.TSpan(row["AdjustAuto"].ToString());
                clockEvent.AdjustIsOverridden = PIn.Bool(row["AdjustIsOverridden"].ToString());
                clockEvent.Rate2Hours         = PIn.TSpan(row["Rate2Hours"].ToString());
                clockEvent.Rate2Auto          = PIn.TSpan(row["Rate2Auto"].ToString());
                clockEvent.ClinicNum          = PIn.Long(row["ClinicNum"].ToString());
                retVal.Add(clockEvent);
            }
            return(retVal);
        }
Ejemplo n.º 10
0
        ///<summary>Updates one ClockEvent in the database.</summary>
        public static void Update(ClockEvent clockEvent)
        {
            string command = "UPDATE clockevent SET "
                             + "EmployeeNum       =  " + POut.Long(clockEvent.EmployeeNum) + ", "
                             //TimeEntered1 not allowed to change
                             + "TimeDisplayed1    =  " + POut.DateT(clockEvent.TimeDisplayed1) + ", "
                             + "ClockStatus       =  " + POut.Int((int)clockEvent.ClockStatus) + ", "
                             + "Note              =  " + DbHelper.ParamChar + "paramNote, "
                             + "TimeEntered2      =  " + POut.DateT(clockEvent.TimeEntered2) + ", "
                             + "TimeDisplayed2    =  " + POut.DateT(clockEvent.TimeDisplayed2) + ", "
                             + "OTimeHours        = '" + POut.TSpan(clockEvent.OTimeHours) + "', "
                             + "OTimeAuto         = '" + POut.TSpan(clockEvent.OTimeAuto) + "', "
                             + "Adjust            = '" + POut.TSpan(clockEvent.Adjust) + "', "
                             + "AdjustAuto        = '" + POut.TSpan(clockEvent.AdjustAuto) + "', "
                             + "AdjustIsOverridden=  " + POut.Bool(clockEvent.AdjustIsOverridden) + ", "
                             + "Rate2Hours        = '" + POut.TSpan(clockEvent.Rate2Hours) + "', "
                             + "Rate2Auto         = '" + POut.TSpan(clockEvent.Rate2Auto) + "', "
                             + "ClinicNum         =  " + POut.Long(clockEvent.ClinicNum) + " "
                             + "WHERE ClockEventNum = " + POut.Long(clockEvent.ClockEventNum);

            if (clockEvent.Note == null)
            {
                clockEvent.Note = "";
            }
            OdSqlParameter paramNote = new OdSqlParameter("paramNote", OdDbType.Text, POut.StringParam(clockEvent.Note));

            Db.NonQ(command, paramNote);
        }
Ejemplo n.º 11
0
 ///<summary></summary>
 public FormClockEventEdit(ClockEvent clockEventCur)
 {
     //
     // Required for Windows Form Designer support
     //
     InitializeComponent();
     Lan.F(this);
     ClockEventCur = clockEventCur.Copy();
 }
 /// <summary>
 /// Builds and return the view to edit a clock event.
 /// </summary>
 private ViewResult BuildEditClockView(ClockEvent clockEvent, string message)
 {
     return(View("EditClockEvent", new ClockEventViewModel
     {
         Id = clockEvent.Id,
         Teacher = clockEvent.Teacher,
         EventDateTime = clockEvent.EventDateTime,
         ClockIn = clockEvent.ClockIn,
         Message = message
     }));
 }
Ejemplo n.º 13
0
        ///<summary></summary>
        public static void Update(ClockEvent ce)
        {
            string command = "UPDATE clockevent SET "
                             + "EmployeeNum = '" + POut.PInt(ce.EmployeeNum) + "' "
                             + ",TimeEntered = " + POut.PDateT(ce.TimeEntered) + " "
                             + ",TimeDisplayed = " + POut.PDateT(ce.TimeDisplayed) + " "
                             + ",ClockIn = '" + POut.PBool(ce.ClockIn) + "' "
                             + ",ClockStatus = '" + POut.PInt((int)ce.ClockStatus) + "' "
                             + ",Note = '" + POut.PString(ce.Note) + "' "
                             + "WHERE ClockEventNum = '" + POut.PInt(ce.ClockEventNum) + "'";

            General.NonQ(command);
        }
Ejemplo n.º 14
0
        public static long InsertBreak(long emp, DateTime start, int minutes)
        {
            ClockEvent ce = new ClockEvent();

            ce.ClockStatus    = TimeClockStatus.Break;
            ce.EmployeeNum    = emp;
            ce.TimeDisplayed1 = start;
            ce.TimeEntered1   = start;
            ce.TimeDisplayed2 = start.AddMinutes(minutes);
            ce.TimeEntered2   = start.AddMinutes(minutes);
            ce.ClockEventNum  = ClockEvents.Insert(ce);
            ClockEvents.Update(ce);            //Updates TimeDisplayed1 because it defaults to now().
            return(ce.ClockEventNum);
        }
Ejemplo n.º 15
0
        ///<summary>Inserts one ClockEvent into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(ClockEvent clockEvent, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO clockevent (";

            if (!useExistingPK && isRandomKeys)
            {
                clockEvent.ClockEventNum = ReplicationServers.GetKeyNoCache("clockevent", "ClockEventNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "ClockEventNum,";
            }
            command += "EmployeeNum,TimeEntered1,TimeDisplayed1,ClockStatus,Note,TimeEntered2,TimeDisplayed2,OTimeHours,OTimeAuto,Adjust,AdjustAuto,AdjustIsOverridden,Rate2Hours,Rate2Auto,ClinicNum) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(clockEvent.ClockEventNum) + ",";
            }
            command +=
                POut.Long(clockEvent.EmployeeNum) + ","
                + DbHelper.Now() + ","
                + DbHelper.Now() + ","
                + POut.Int((int)clockEvent.ClockStatus) + ","
                + DbHelper.ParamChar + "paramNote,"
                + POut.DateT(clockEvent.TimeEntered2) + ","
                + POut.DateT(clockEvent.TimeDisplayed2) + ","
                + "'" + POut.TSpan(clockEvent.OTimeHours) + "',"
                + "'" + POut.TSpan(clockEvent.OTimeAuto) + "',"
                + "'" + POut.TSpan(clockEvent.Adjust) + "',"
                + "'" + POut.TSpan(clockEvent.AdjustAuto) + "',"
                + POut.Bool(clockEvent.AdjustIsOverridden) + ","
                + "'" + POut.TSpan(clockEvent.Rate2Hours) + "',"
                + "'" + POut.TSpan(clockEvent.Rate2Auto) + "',"
                + POut.Long(clockEvent.ClinicNum) + ")";
            if (clockEvent.Note == null)
            {
                clockEvent.Note = "";
            }
            OdSqlParameter paramNote = new OdSqlParameter("paramNote", OdDbType.Text, POut.StringParam(clockEvent.Note));

            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command, paramNote);
            }
            else
            {
                clockEvent.ClockEventNum = Db.NonQ(command, true, "ClockEventNum", "clockEvent", paramNote);
            }
            return(clockEvent.ClockEventNum);
        }
Ejemplo n.º 16
0
        public static long InsertWorkPeriod(long emp, DateTime start, DateTime stop)
        {
            ClockEvent ce = new ClockEvent();

            ce.ClockStatus    = TimeClockStatus.Home;
            ce.EmployeeNum    = emp;
            ce.TimeDisplayed1 = start;
            ce.TimeEntered1   = start;
            ce.TimeDisplayed2 = stop;
            ce.TimeEntered2   = stop;
            ce.ClockEventNum  = ClockEvents.Insert(ce);
            ClockEvents.Update(ce);            //Updates TimeDisplayed1 because it defaults to now().
            return(ce.ClockEventNum);
        }
Ejemplo n.º 17
0
 ///<summary>Inserts one ClockEvent into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(ClockEvent clockEvent)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(clockEvent, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             clockEvent.ClockEventNum = DbHelper.GetNextOracleKey("clockevent", "ClockEventNum");                  //Cacheless method
         }
         return(InsertNoCache(clockEvent, true));
     }
 }
Ejemplo n.º 18
0
        public static long InsertWorkPeriod(long emp, DateTime start, DateTime stop, long clinicNum = 0, double adjustHours = 0)
        {
            ClockEvent ce = new ClockEvent();

            ce.ClockStatus    = TimeClockStatus.Home;
            ce.EmployeeNum    = emp;
            ce.TimeDisplayed1 = start;
            ce.TimeEntered1   = start;
            ce.TimeDisplayed2 = stop;
            ce.TimeEntered2   = stop;
            ce.ClinicNum      = clinicNum;
            ce.AdjustAuto     = TimeSpan.FromHours(-adjustHours);
            ce.ClockEventNum  = ClockEvents.Insert(ce);
            ClockEvents.Update(ce);            //Updates TimeDisplayed1 because it defaults to now().
            return(ce.ClockEventNum);
        }
Ejemplo n.º 19
0
        public void TimeCardRules_CalculateWeeklyOvertime_CalculationWithManualOvertime()
        {
            string    suffix    = "67";
            DateTime  startDate = DateTime.Parse("2016-03-14");
            Employee  emp       = EmployeeT.CreateEmployee(suffix);
            PayPeriod payP1     = PayPeriodT.CreateTwoWeekPayPeriodIfNotExists(startDate);

            PayPeriods.RefreshCache();
            Prefs.UpdateInt(PrefName.TimeCardOvertimeFirstDayOfWeek, 0);
            TimeCardRules.RefreshCache();
            //Each of these are 11 hour days. Should have 4 hours of OT with clinic 3 in the second pay period and 11 hours for clinic 4.
            //Week 1 - 40.13 (Note: These appear as they should after CalculateDaily is run.)
            long clockEvent1 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(0).AddHours(6), startDate.AddDays(0).AddHours(6 + 8.06), 0);    //Mon
            long clockEvent2 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(1).AddHours(6), startDate.AddDays(1).AddHours(6 + 8), 0);       //Tue
            long clockEvent3 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(2).AddHours(6), startDate.AddDays(2).AddHours(6 + 8.08), 0);    //Wed
            long clockEvent4 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(3).AddHours(6), startDate.AddDays(3).AddHours(6 + 8), 0, 0.02); //Thurs
            long clockEvent5 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(4).AddHours(6), startDate.AddDays(4).AddHours(6 + 8.01), 0);    //Fri
            //SATURDAY - 4.1 HRS OF OVERTIME
            ClockEvent ce = new ClockEvent();

            ce.ClinicNum      = 0;
            ce.ClockStatus    = TimeClockStatus.Home;
            ce.EmployeeNum    = emp.EmployeeNum;
            ce.OTimeHours     = TimeSpan.FromHours(4.1);
            ce.TimeDisplayed1 = new DateTime(startDate.Year, startDate.Month, startDate.AddDays(5).Day, 6, 54, 0);
            ce.TimeDisplayed2 = new DateTime(startDate.Year, startDate.Month, startDate.AddDays(5).Day, 11, 0, 0);
            ce.TimeEntered1   = ce.TimeDisplayed1;
            ce.TimeEntered2   = ce.TimeDisplayed2;
            ce.ClockEventNum  = ClockEvents.Insert(ce);
            ClockEvents.Update(ce);
            //Week 2 - 41.06
            long clockEvent6  = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(7).AddHours(6), startDate.AddDays(7).AddHours(6 + 8.02), 0);   //Mon
            long clockEvent7  = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(8).AddHours(6), startDate.AddDays(8).AddHours(6 + 8), 0);      //Tue
            long clockEvent8  = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(9).AddHours(6), startDate.AddDays(9).AddHours(6 + 8), 0);      //Wed
            long clockEvent9  = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(10).AddHours(6), startDate.AddDays(10).AddHours(6 + 9.04), 0); //Thurs
            long clockEvent10 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(11).AddHours(6), startDate.AddDays(11).AddHours(6 + 8), 0);    //Fri

            TimeCardRules.CalculateWeeklyOvertime(emp, payP1.DateStart, payP1.DateStop);
            //Validate
            List <TimeAdjust> listAdjusts = TimeAdjusts.GetValidList(emp.EmployeeNum, startDate, startDate.AddDays(28)).OrderBy(x => x.OTimeHours).ToList();

            Assert.AreEqual(2, listAdjusts.Count);
            Assert.AreEqual(TimeSpan.FromHours(-0.13), listAdjusts[0].RegHours);
            Assert.AreEqual(TimeSpan.FromHours(0.13), listAdjusts[0].OTimeHours);
            Assert.AreEqual(TimeSpan.FromHours(-1.06), listAdjusts[1].RegHours);
            Assert.AreEqual(TimeSpan.FromHours(1.06), listAdjusts[1].OTimeHours);
        }
Ejemplo n.º 20
0
        ///<summary>Updates one ClockEvent in the database.</summary>
        internal static void Update(ClockEvent clockEvent)
        {
            string command = "UPDATE clockevent SET "
                             + "EmployeeNum       =  " + POut.Long(clockEvent.EmployeeNum) + ", "
                             //TimeEntered1 not allowed to change
                             + "TimeDisplayed1    =  " + POut.DateT(clockEvent.TimeDisplayed1) + ", "
                             + "ClockStatus       =  " + POut.Int((int)clockEvent.ClockStatus) + ", "
                             + "Note              = '" + POut.String(clockEvent.Note) + "', "
                             + "TimeEntered2      =  " + POut.DateT(clockEvent.TimeEntered2) + ", "
                             + "TimeDisplayed2    =  " + POut.DateT(clockEvent.TimeDisplayed2) + ", "
                             + "OTimeHours        = '" + POut.TSpan(clockEvent.OTimeHours) + "', "
                             + "OTimeAuto         = '" + POut.TSpan(clockEvent.OTimeAuto) + "', "
                             + "Adjust            = '" + POut.TSpan(clockEvent.Adjust) + "', "
                             + "AdjustAuto        = '" + POut.TSpan(clockEvent.AdjustAuto) + "', "
                             + "AdjustIsOverridden=  " + POut.Bool(clockEvent.AdjustIsOverridden) + " "
                             + "WHERE ClockEventNum = " + POut.Long(clockEvent.ClockEventNum);

            Db.NonQ(command);
        }
Ejemplo n.º 21
0
        ///<summary>Inserts one ClockEvent into the database.  Provides option to use the existing priKey.</summary>
        public static long Insert(ClockEvent clockEvent, bool useExistingPK)
        {
            if (!useExistingPK && PrefC.RandomKeys)
            {
                clockEvent.ClockEventNum = ReplicationServers.GetKey("clockevent", "ClockEventNum");
            }
            string command = "INSERT INTO clockevent (";

            if (useExistingPK || PrefC.RandomKeys)
            {
                command += "ClockEventNum,";
            }
            command += "EmployeeNum,TimeEntered1,TimeDisplayed1,ClockStatus,Note,TimeEntered2,TimeDisplayed2,OTimeHours,OTimeAuto,Adjust,AdjustAuto,AdjustIsOverridden,Rate2Hours,Rate2Auto) VALUES(";
            if (useExistingPK || PrefC.RandomKeys)
            {
                command += POut.Long(clockEvent.ClockEventNum) + ",";
            }
            command +=
                POut.Long(clockEvent.EmployeeNum) + ","
                + DbHelper.Now() + ","
                + DbHelper.Now() + ","
                + POut.Int((int)clockEvent.ClockStatus) + ","
                + "'" + POut.String(clockEvent.Note) + "',"
                + POut.DateT(clockEvent.TimeEntered2) + ","
                + POut.DateT(clockEvent.TimeDisplayed2) + ","
                + "'" + POut.TSpan(clockEvent.OTimeHours) + "',"
                + "'" + POut.TSpan(clockEvent.OTimeAuto) + "',"
                + "'" + POut.TSpan(clockEvent.Adjust) + "',"
                + "'" + POut.TSpan(clockEvent.AdjustAuto) + "',"
                + POut.Bool(clockEvent.AdjustIsOverridden) + ","
                + "'" + POut.TSpan(clockEvent.Rate2Hours) + "',"
                + "'" + POut.TSpan(clockEvent.Rate2Auto) + "')";
            if (useExistingPK || PrefC.RandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                clockEvent.ClockEventNum = Db.NonQ(command, true);
            }
            return(clockEvent.ClockEventNum);
        }
Ejemplo n.º 22
0
        public virtual void Init(AnimalInfo info)
        {
            Info = info;

            SpawnTime      = MainClock.NowTime;
            LifespanLeft   = Info.Availability.Lifespan;
            LifetimeFactor = 1;

            GFXObject =
                Instantiate(info.FishGFX, transform);
            GFXObject.name = "GFX";

            LifespanSpeedUpEvent = new ClockEvent(
                SavedTime.NoTime,
                EventRepetitionType.Every_DayPhase,
                false,
                CheckCurrentPhase);

            LifespanSpeedUpEvent.InjectClockEvent();
        }
Ejemplo n.º 23
0
 private void gridMain_CellDoubleClick(object sender, ODGridClickEventArgs e)
 {
     timer1.Enabled = false;
     if (gridMain.Rows[e.Row].Tag.GetType() == typeof(TimeAdjust))
     {
         if (!Security.IsAuthorized(Permissions.TimecardsEditAll))
         {
             timer1.Enabled = true;
             return;
         }
         TimeAdjust         adjust = (TimeAdjust)gridMain.Rows[e.Row].Tag;
         FormTimeAdjustEdit FormT  = new FormTimeAdjustEdit(adjust);
         FormT.ShowDialog();
     }
     else
     {
         ClockEvent         ce      = (ClockEvent)gridMain.Rows[e.Row].Tag;
         FormClockEventEdit FormCEE = new FormClockEventEdit(ce);
         FormCEE.ShowDialog();
     }
     FillMain(true);
     timer1.Enabled = true;
 }
Ejemplo n.º 24
0
        ///<summary>isBreaks is ignored if getAll is true.</summary>
        public static ClockEvent[] Refresh(int empNum, DateTime fromDate, DateTime toDate, bool getAll, bool isBreaks)
        {
            string command =
                "SELECT * from clockevent WHERE"
                + " EmployeeNum = '" + POut.PInt(empNum) + "'"
                + " AND TimeDisplayed >= " + POut.PDate(fromDate)
                //adding a day takes it to midnight of the specified toDate
                + " AND TimeDisplayed <= " + POut.PDate(toDate.AddDays(1));

            if (!getAll)
            {
                if (isBreaks)
                {
                    command += " AND ClockStatus = '2'";
                }
                else
                {
                    command += " AND (ClockStatus = '0' OR ClockStatus = '1')";
                }
            }
            command += " ORDER BY TimeDisplayed";
            DataTable table = General.GetTable(command);

            ClockEvent[] List = new ClockEvent[table.Rows.Count];
            for (int i = 0; i < List.Length; i++)
            {
                List[i] = new ClockEvent();
                List[i].ClockEventNum = PIn.PInt(table.Rows[i][0].ToString());
                List[i].EmployeeNum   = PIn.PInt(table.Rows[i][1].ToString());
                List[i].TimeEntered   = PIn.PDateT(table.Rows[i][2].ToString());
                List[i].TimeDisplayed = PIn.PDateT(table.Rows[i][3].ToString());
                List[i].ClockIn       = PIn.PBool(table.Rows[i][4].ToString());
                List[i].ClockStatus   = (TimeClockStatus)PIn.PInt(table.Rows[i][5].ToString());
                List[i].Note          = PIn.PString(table.Rows[i][6].ToString());
            }
            return(List);
        }
Ejemplo n.º 25
0
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<ClockEvent> TableToList(DataTable table){
			List<ClockEvent> retVal=new List<ClockEvent>();
			ClockEvent clockEvent;
			for(int i=0;i<table.Rows.Count;i++) {
				clockEvent=new ClockEvent();
				clockEvent.ClockEventNum     = PIn.Long  (table.Rows[i]["ClockEventNum"].ToString());
				clockEvent.EmployeeNum       = PIn.Long  (table.Rows[i]["EmployeeNum"].ToString());
				clockEvent.TimeEntered1      = PIn.DateT (table.Rows[i]["TimeEntered1"].ToString());
				clockEvent.TimeDisplayed1    = PIn.DateT (table.Rows[i]["TimeDisplayed1"].ToString());
				clockEvent.ClockStatus       = (TimeClockStatus)PIn.Int(table.Rows[i]["ClockStatus"].ToString());
				clockEvent.Note              = PIn.String(table.Rows[i]["Note"].ToString());
				clockEvent.TimeEntered2      = PIn.DateT (table.Rows[i]["TimeEntered2"].ToString());
				clockEvent.TimeDisplayed2    = PIn.DateT (table.Rows[i]["TimeDisplayed2"].ToString());
				clockEvent.OTimeHours        = PIn.TSpan (table.Rows[i]["OTimeHours"].ToString());
				clockEvent.OTimeAuto         = PIn.TSpan (table.Rows[i]["OTimeAuto"].ToString());
				clockEvent.Adjust            = PIn.TSpan (table.Rows[i]["Adjust"].ToString());
				clockEvent.AdjustAuto        = PIn.TSpan (table.Rows[i]["AdjustAuto"].ToString());
				clockEvent.AdjustIsOverridden= PIn.Bool  (table.Rows[i]["AdjustIsOverridden"].ToString());
				clockEvent.Rate2Hours        = PIn.TSpan (table.Rows[i]["Rate2Hours"].ToString());
				clockEvent.Rate2Auto         = PIn.TSpan (table.Rows[i]["Rate2Auto"].ToString());
				retVal.Add(clockEvent);
			}
			return retVal;
		}
Ejemplo n.º 26
0
		///<summary>Updates one ClockEvent in the database.  Uses an old object to compare to, and only alters changed fields.  This prevents collisions and concurrency problems in heavily used tables.</summary>
		public static void Update(ClockEvent clockEvent,ClockEvent oldClockEvent){
			string command="";
			if(clockEvent.EmployeeNum != oldClockEvent.EmployeeNum) {
				if(command!=""){ command+=",";}
				command+="EmployeeNum = "+POut.Long(clockEvent.EmployeeNum)+"";
			}
			//TimeEntered1 not allowed to change
			if(clockEvent.TimeDisplayed1 != oldClockEvent.TimeDisplayed1) {
				if(command!=""){ command+=",";}
				command+="TimeDisplayed1 = "+POut.DateT(clockEvent.TimeDisplayed1)+"";
			}
			if(clockEvent.ClockStatus != oldClockEvent.ClockStatus) {
				if(command!=""){ command+=",";}
				command+="ClockStatus = "+POut.Int   ((int)clockEvent.ClockStatus)+"";
			}
			if(clockEvent.Note != oldClockEvent.Note) {
				if(command!=""){ command+=",";}
				command+="Note = '"+POut.String(clockEvent.Note)+"'";
			}
			if(clockEvent.TimeEntered2 != oldClockEvent.TimeEntered2) {
				if(command!=""){ command+=",";}
				command+="TimeEntered2 = "+POut.DateT(clockEvent.TimeEntered2)+"";
			}
			if(clockEvent.TimeDisplayed2 != oldClockEvent.TimeDisplayed2) {
				if(command!=""){ command+=",";}
				command+="TimeDisplayed2 = "+POut.DateT(clockEvent.TimeDisplayed2)+"";
			}
			if(clockEvent.OTimeHours != oldClockEvent.OTimeHours) {
				if(command!=""){ command+=",";}
				command+="OTimeHours = '"+POut.TSpan (clockEvent.OTimeHours)+"'";
			}
			if(clockEvent.OTimeAuto != oldClockEvent.OTimeAuto) {
				if(command!=""){ command+=",";}
				command+="OTimeAuto = '"+POut.TSpan (clockEvent.OTimeAuto)+"'";
			}
			if(clockEvent.Adjust != oldClockEvent.Adjust) {
				if(command!=""){ command+=",";}
				command+="Adjust = '"+POut.TSpan (clockEvent.Adjust)+"'";
			}
			if(clockEvent.AdjustAuto != oldClockEvent.AdjustAuto) {
				if(command!=""){ command+=",";}
				command+="AdjustAuto = '"+POut.TSpan (clockEvent.AdjustAuto)+"'";
			}
			if(clockEvent.AdjustIsOverridden != oldClockEvent.AdjustIsOverridden) {
				if(command!=""){ command+=",";}
				command+="AdjustIsOverridden = "+POut.Bool(clockEvent.AdjustIsOverridden)+"";
			}
			if(clockEvent.Rate2Hours != oldClockEvent.Rate2Hours) {
				if(command!=""){ command+=",";}
				command+="Rate2Hours = '"+POut.TSpan (clockEvent.Rate2Hours)+"'";
			}
			if(clockEvent.Rate2Auto != oldClockEvent.Rate2Auto) {
				if(command!=""){ command+=",";}
				command+="Rate2Auto = '"+POut.TSpan (clockEvent.Rate2Auto)+"'";
			}
			if(command==""){
				return;
			}
			command="UPDATE clockevent SET "+command
				+" WHERE ClockEventNum = "+POut.Long(clockEvent.ClockEventNum);
			Db.NonQ(command);
		}
Ejemplo n.º 27
0
		///<summary>Updates one ClockEvent in the database.</summary>
		public static void Update(ClockEvent clockEvent){
			string command="UPDATE clockevent SET "
				+"EmployeeNum       =  "+POut.Long  (clockEvent.EmployeeNum)+", "
				//TimeEntered1 not allowed to change
				+"TimeDisplayed1    =  "+POut.DateT (clockEvent.TimeDisplayed1)+", "
				+"ClockStatus       =  "+POut.Int   ((int)clockEvent.ClockStatus)+", "
				+"Note              = '"+POut.String(clockEvent.Note)+"', "
				+"TimeEntered2      =  "+POut.DateT (clockEvent.TimeEntered2)+", "
				+"TimeDisplayed2    =  "+POut.DateT (clockEvent.TimeDisplayed2)+", "
				+"OTimeHours        = '"+POut.TSpan (clockEvent.OTimeHours)+"', "
				+"OTimeAuto         = '"+POut.TSpan (clockEvent.OTimeAuto)+"', "
				+"Adjust            = '"+POut.TSpan (clockEvent.Adjust)+"', "
				+"AdjustAuto        = '"+POut.TSpan (clockEvent.AdjustAuto)+"', "
				+"AdjustIsOverridden=  "+POut.Bool  (clockEvent.AdjustIsOverridden)+", "
				+"Rate2Hours        = '"+POut.TSpan (clockEvent.Rate2Hours)+"', "
				+"Rate2Auto         = '"+POut.TSpan (clockEvent.Rate2Auto)+"' "
				+"WHERE ClockEventNum = "+POut.Long(clockEvent.ClockEventNum);
			Db.NonQ(command);
		}
Ejemplo n.º 28
0
        ///<summary>Updates one ClockEvent in the database.  Uses an old object to compare to, and only alters changed fields.  This prevents collisions and concurrency problems in heavily used tables.  Returns true if an update occurred.</summary>
        public static bool Update(ClockEvent clockEvent, ClockEvent oldClockEvent)
        {
            string command = "";

            if (clockEvent.EmployeeNum != oldClockEvent.EmployeeNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "EmployeeNum = " + POut.Long(clockEvent.EmployeeNum) + "";
            }
            //TimeEntered1 not allowed to change
            if (clockEvent.TimeDisplayed1 != oldClockEvent.TimeDisplayed1)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "TimeDisplayed1 = " + POut.DateT(clockEvent.TimeDisplayed1) + "";
            }
            if (clockEvent.ClockStatus != oldClockEvent.ClockStatus)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ClockStatus = " + POut.Int((int)clockEvent.ClockStatus) + "";
            }
            if (clockEvent.Note != oldClockEvent.Note)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Note = " + DbHelper.ParamChar + "paramNote";
            }
            if (clockEvent.TimeEntered2 != oldClockEvent.TimeEntered2)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "TimeEntered2 = " + POut.DateT(clockEvent.TimeEntered2) + "";
            }
            if (clockEvent.TimeDisplayed2 != oldClockEvent.TimeDisplayed2)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "TimeDisplayed2 = " + POut.DateT(clockEvent.TimeDisplayed2) + "";
            }
            if (clockEvent.OTimeHours != oldClockEvent.OTimeHours)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "OTimeHours = '" + POut.TSpan(clockEvent.OTimeHours) + "'";
            }
            if (clockEvent.OTimeAuto != oldClockEvent.OTimeAuto)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "OTimeAuto = '" + POut.TSpan(clockEvent.OTimeAuto) + "'";
            }
            if (clockEvent.Adjust != oldClockEvent.Adjust)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Adjust = '" + POut.TSpan(clockEvent.Adjust) + "'";
            }
            if (clockEvent.AdjustAuto != oldClockEvent.AdjustAuto)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "AdjustAuto = '" + POut.TSpan(clockEvent.AdjustAuto) + "'";
            }
            if (clockEvent.AdjustIsOverridden != oldClockEvent.AdjustIsOverridden)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "AdjustIsOverridden = " + POut.Bool(clockEvent.AdjustIsOverridden) + "";
            }
            if (clockEvent.Rate2Hours != oldClockEvent.Rate2Hours)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Rate2Hours = '" + POut.TSpan(clockEvent.Rate2Hours) + "'";
            }
            if (clockEvent.Rate2Auto != oldClockEvent.Rate2Auto)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Rate2Auto = '" + POut.TSpan(clockEvent.Rate2Auto) + "'";
            }
            if (clockEvent.ClinicNum != oldClockEvent.ClinicNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ClinicNum = " + POut.Long(clockEvent.ClinicNum) + "";
            }
            if (command == "")
            {
                return(false);
            }
            if (clockEvent.Note == null)
            {
                clockEvent.Note = "";
            }
            OdSqlParameter paramNote = new OdSqlParameter("paramNote", OdDbType.Text, POut.StringParam(clockEvent.Note));

            command = "UPDATE clockevent SET " + command
                      + " WHERE ClockEventNum = " + POut.Long(clockEvent.ClockEventNum);
            Db.NonQ(command, paramNote);
            return(true);
        }
Ejemplo n.º 29
0
 ///<summary>Returns true if Update(ClockEvent,ClockEvent) would make changes to the database.
 ///Does not make any changes to the database and can be called before remoting role is checked.</summary>
 public static bool UpdateComparison(ClockEvent clockEvent, ClockEvent oldClockEvent)
 {
     if (clockEvent.EmployeeNum != oldClockEvent.EmployeeNum)
     {
         return(true);
     }
     //TimeEntered1 not allowed to change
     if (clockEvent.TimeDisplayed1 != oldClockEvent.TimeDisplayed1)
     {
         return(true);
     }
     if (clockEvent.ClockStatus != oldClockEvent.ClockStatus)
     {
         return(true);
     }
     if (clockEvent.Note != oldClockEvent.Note)
     {
         return(true);
     }
     if (clockEvent.TimeEntered2 != oldClockEvent.TimeEntered2)
     {
         return(true);
     }
     if (clockEvent.TimeDisplayed2 != oldClockEvent.TimeDisplayed2)
     {
         return(true);
     }
     if (clockEvent.OTimeHours != oldClockEvent.OTimeHours)
     {
         return(true);
     }
     if (clockEvent.OTimeAuto != oldClockEvent.OTimeAuto)
     {
         return(true);
     }
     if (clockEvent.Adjust != oldClockEvent.Adjust)
     {
         return(true);
     }
     if (clockEvent.AdjustAuto != oldClockEvent.AdjustAuto)
     {
         return(true);
     }
     if (clockEvent.AdjustIsOverridden != oldClockEvent.AdjustIsOverridden)
     {
         return(true);
     }
     if (clockEvent.Rate2Hours != oldClockEvent.Rate2Hours)
     {
         return(true);
     }
     if (clockEvent.Rate2Auto != oldClockEvent.Rate2Auto)
     {
         return(true);
     }
     if (clockEvent.ClinicNum != oldClockEvent.ClinicNum)
     {
         return(true);
     }
     return(false);
 }
Ejemplo n.º 30
0
        public async Task CreateClockEvent(ClockEvent clockEvent)
        {
            await _context.ClockEvents.AddAsync(clockEvent);

            await _context.SaveChangesAsync();
        }
Ejemplo n.º 31
0
        ///<summary>Updates one ClockEvent in the database.  Uses an old object to compare to, and only alters changed fields.  This prevents collisions and concurrency problems in heavily used tables.</summary>
        internal static void Update(ClockEvent clockEvent, ClockEvent oldClockEvent)
        {
            string command = "";

            if (clockEvent.EmployeeNum != oldClockEvent.EmployeeNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "EmployeeNum = " + POut.Long(clockEvent.EmployeeNum) + "";
            }
            //TimeEntered1 not allowed to change
            if (clockEvent.TimeDisplayed1 != oldClockEvent.TimeDisplayed1)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "TimeDisplayed1 = " + POut.DateT(clockEvent.TimeDisplayed1) + "";
            }
            if (clockEvent.ClockStatus != oldClockEvent.ClockStatus)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ClockStatus = " + POut.Int((int)clockEvent.ClockStatus) + "";
            }
            if (clockEvent.Note != oldClockEvent.Note)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Note = '" + POut.String(clockEvent.Note) + "'";
            }
            if (clockEvent.TimeEntered2 != oldClockEvent.TimeEntered2)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "TimeEntered2 = " + POut.DateT(clockEvent.TimeEntered2) + "";
            }
            if (clockEvent.TimeDisplayed2 != oldClockEvent.TimeDisplayed2)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "TimeDisplayed2 = " + POut.DateT(clockEvent.TimeDisplayed2) + "";
            }
            if (clockEvent.OTimeHours != oldClockEvent.OTimeHours)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "OTimeHours = '" + POut.TSpan(clockEvent.OTimeHours) + "'";
            }
            if (clockEvent.OTimeAuto != oldClockEvent.OTimeAuto)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "OTimeAuto = '" + POut.TSpan(clockEvent.OTimeAuto) + "'";
            }
            if (clockEvent.Adjust != oldClockEvent.Adjust)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Adjust = '" + POut.TSpan(clockEvent.Adjust) + "'";
            }
            if (clockEvent.AdjustAuto != oldClockEvent.AdjustAuto)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "AdjustAuto = '" + POut.TSpan(clockEvent.AdjustAuto) + "'";
            }
            if (clockEvent.AdjustIsOverridden != oldClockEvent.AdjustIsOverridden)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "AdjustIsOverridden = " + POut.Bool(clockEvent.AdjustIsOverridden) + "";
            }
            if (command == "")
            {
                return;
            }
            command = "UPDATE clockevent SET " + command
                      + " WHERE ClockEventNum = " + POut.Long(clockEvent.ClockEventNum);
            Db.NonQ(command);
        }
Ejemplo n.º 32
0
 public async Task UpdateClockEvent(ClockEvent clockEvent)
 {
     _context.ClockEvents.Update(clockEvent);
     await _context.SaveChangesAsync();
 }
Ejemplo n.º 33
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");
            }
        }
Ejemplo n.º 34
0
 private void OnClockEvent(string category)
 {
     ClockEvent?.Invoke(this, null);
 }
Ejemplo n.º 35
0
        ///<summary></summary>
        public static void Delete(ClockEvent ce)
        {
            string command = "DELETE FROM clockevent WHERE ClockEventNum = " + POut.PInt(ce.ClockEventNum);

            General.NonQ(command);
        }