Exemplo n.º 1
0
 ///<summary>Inserts one TimeAdjust into the database.  Provides option to use the existing priKey.</summary>
 internal static long Insert(TimeAdjust timeAdjust,bool useExistingPK)
 {
     if(!useExistingPK && PrefC.RandomKeys) {
         timeAdjust.TimeAdjustNum=ReplicationServers.GetKey("timeadjust","TimeAdjustNum");
     }
     string command="INSERT INTO timeadjust (";
     if(useExistingPK || PrefC.RandomKeys) {
         command+="TimeAdjustNum,";
     }
     command+="EmployeeNum,TimeEntry,RegHours,OTimeHours,Note,IsAuto) VALUES(";
     if(useExistingPK || PrefC.RandomKeys) {
         command+=POut.Long(timeAdjust.TimeAdjustNum)+",";
     }
     command+=
              POut.Long  (timeAdjust.EmployeeNum)+","
         +    POut.DateT (timeAdjust.TimeEntry)+","
         +"'"+POut.TSpan (timeAdjust.RegHours)+"',"
         +"'"+POut.TSpan (timeAdjust.OTimeHours)+"',"
         +"'"+POut.String(timeAdjust.Note)+"',"
         +    POut.Bool  (timeAdjust.IsAuto)+")";
     if(useExistingPK || PrefC.RandomKeys) {
         Db.NonQ(command);
     }
     else {
         timeAdjust.TimeAdjustNum=Db.NonQ(command,true);
     }
     return timeAdjust.TimeAdjustNum;
 }
Exemplo n.º 2
0
 ///<summary>Inserts one TimeAdjust into the database.  Returns the new priKey.</summary>
 internal static long Insert(TimeAdjust timeAdjust)
 {
     if(DataConnection.DBtype==DatabaseType.Oracle) {
         timeAdjust.TimeAdjustNum=DbHelper.GetNextOracleKey("timeadjust","TimeAdjustNum");
         int loopcount=0;
         while(loopcount<100){
             try {
                 return Insert(timeAdjust,true);
             }
             catch(Oracle.DataAccess.Client.OracleException ex){
                 if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
                     timeAdjust.TimeAdjustNum++;
                     loopcount++;
                 }
                 else{
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else {
         return Insert(timeAdjust,false);
     }
 }
Exemplo n.º 3
0
 ///<summary>Returns true if Update(TimeAdjust,TimeAdjust) 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(TimeAdjust timeAdjust, TimeAdjust oldTimeAdjust)
 {
     if (timeAdjust.EmployeeNum != oldTimeAdjust.EmployeeNum)
     {
         return(true);
     }
     if (timeAdjust.TimeEntry != oldTimeAdjust.TimeEntry)
     {
         return(true);
     }
     if (timeAdjust.RegHours != oldTimeAdjust.RegHours)
     {
         return(true);
     }
     if (timeAdjust.OTimeHours != oldTimeAdjust.OTimeHours)
     {
         return(true);
     }
     if (timeAdjust.Note != oldTimeAdjust.Note)
     {
         return(true);
     }
     if (timeAdjust.IsAuto != oldTimeAdjust.IsAuto)
     {
         return(true);
     }
     if (timeAdjust.ClinicNum != oldTimeAdjust.ClinicNum)
     {
         return(true);
     }
     return(false);
 }
Exemplo n.º 4
0
        public void TimeCardRules_CalculateWeeklyOvertime_OneWeekWorkWeekStartsOnWednesday()
        {
            string    suffix    = "27";
            DateTime  startDate = DateTime.Parse("2001-01-01");
            Employee  emp       = EmployeeT.CreateEmployee(suffix);
            PayPeriod payP1     = PayPeriodT.CreateTwoWeekPayPeriodIfNotExists(startDate);

            PayPeriods.RefreshCache();
            Prefs.UpdateInt(PrefName.TimeCardOvertimeFirstDayOfWeek, 3);
            TimeCardRules.RefreshCache();
            long clockEvent1 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(0).AddHours(6), startDate.AddDays(0).AddHours(17), 0);
            long clockEvent2 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(1).AddHours(6), startDate.AddDays(1).AddHours(17), 0);
            //new work week
            long clockEvent3 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(2).AddHours(6), startDate.AddDays(2).AddHours(17), 0);
            long clockEvent4 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(3).AddHours(6), startDate.AddDays(3).AddHours(17), 0);
            long clockEvent5 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(4).AddHours(6), startDate.AddDays(4).AddHours(17), 0);
            long clockEvent6 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(5).AddHours(6), startDate.AddDays(5).AddHours(17), 0);

            TimeCardRules.CalculateWeeklyOvertime(emp, payP1.DateStart, payP1.DateStop);
            //Validate
            TimeAdjust result = TimeAdjusts.Refresh(emp.EmployeeNum, startDate, startDate.AddDays(28))[0];

            Assert.AreEqual(TimeSpan.FromHours(-4), result.RegHours);
            Assert.AreEqual(TimeSpan.FromHours(4), result.OTimeHours);
        }
Exemplo n.º 5
0
        ///<summary>Updates one TimeAdjust 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(TimeAdjust timeAdjust, TimeAdjust oldTimeAdjust)
        {
            string command = "";

            if (timeAdjust.EmployeeNum != oldTimeAdjust.EmployeeNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "EmployeeNum = " + POut.Long(timeAdjust.EmployeeNum) + "";
            }
            if (timeAdjust.TimeEntry != oldTimeAdjust.TimeEntry)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "TimeEntry = " + POut.DateT(timeAdjust.TimeEntry) + "";
            }
            if (timeAdjust.RegHours != oldTimeAdjust.RegHours)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "RegHours = '" + POut.TSpan(timeAdjust.RegHours) + "'";
            }
            if (timeAdjust.OTimeHours != oldTimeAdjust.OTimeHours)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "OTimeHours = '" + POut.TSpan(timeAdjust.OTimeHours) + "'";
            }
            if (timeAdjust.Note != oldTimeAdjust.Note)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Note = '" + POut.String(timeAdjust.Note) + "'";
            }
            if (timeAdjust.IsAuto != oldTimeAdjust.IsAuto)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "IsAuto = " + POut.Bool(timeAdjust.IsAuto) + "";
            }
            if (command == "")
            {
                return;
            }
            command = "UPDATE timeadjust SET " + command
                      + " WHERE TimeAdjustNum = " + POut.Long(timeAdjust.TimeAdjustNum);
            Db.NonQ(command);
        }
Exemplo n.º 6
0
        private void butAdj_Click(object sender, EventArgs e)
        {
            if (!Security.IsAuthorized(Permissions.TimecardsEditAll))
            {
                return;
            }
            TimeAdjust adjust = new TimeAdjust();

            adjust.EmployeeNum = EmployeeCur.EmployeeNum;
            DateTime dateStop = PIn.PDate(textDateStop.Text);

            if (DateTime.Today <= dateStop && DateTime.Today >= PIn.PDate(textDateStart.Text))
            {
                adjust.TimeEntry = DateTime.Now;
            }
            else
            {
                adjust.TimeEntry = new DateTime(dateStop.Year, dateStop.Month, dateStop.Day,
                                                DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second);
            }
            FormTimeAdjustEdit FormT = new FormTimeAdjustEdit(adjust);

            FormT.IsNew = true;
            FormT.ShowDialog();
            if (FormT.DialogResult == DialogResult.Cancel)
            {
                return;
            }
            FillMain(true);
        }
Exemplo n.º 7
0
        ///<summary>Inserts one TimeAdjust into the database.  Provides option to use the existing priKey.</summary>
        internal static long Insert(TimeAdjust timeAdjust, bool useExistingPK)
        {
            if (!useExistingPK && PrefC.RandomKeys)
            {
                timeAdjust.TimeAdjustNum = ReplicationServers.GetKey("timeadjust", "TimeAdjustNum");
            }
            string command = "INSERT INTO timeadjust (";

            if (useExistingPK || PrefC.RandomKeys)
            {
                command += "TimeAdjustNum,";
            }
            command += "EmployeeNum,TimeEntry,RegHours,OTimeHours,Note,IsAuto) VALUES(";
            if (useExistingPK || PrefC.RandomKeys)
            {
                command += POut.Long(timeAdjust.TimeAdjustNum) + ",";
            }
            command +=
                POut.Long(timeAdjust.EmployeeNum) + ","
                + POut.DateT(timeAdjust.TimeEntry) + ","
                + "'" + POut.TSpan(timeAdjust.RegHours) + "',"
                + "'" + POut.TSpan(timeAdjust.OTimeHours) + "',"
                + "'" + POut.String(timeAdjust.Note) + "',"
                + POut.Bool(timeAdjust.IsAuto) + ")";
            if (useExistingPK || PrefC.RandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                timeAdjust.TimeAdjustNum = Db.NonQ(command, true);
            }
            return(timeAdjust.TimeAdjustNum);
        }
Exemplo n.º 8
0
 ///<summary>Inserts one TimeAdjust into the database.  Returns the new priKey.</summary>
 public static long Insert(TimeAdjust timeAdjust)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         timeAdjust.TimeAdjustNum = DbHelper.GetNextOracleKey("timeadjust", "TimeAdjustNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(timeAdjust, true));
             }
             catch (Oracle.ManagedDataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     timeAdjust.TimeAdjustNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(timeAdjust, false));
     }
 }
Exemplo n.º 9
0
        ///<summary></summary>
        public static TimeAdjust[] Refresh(int empNum, DateTime fromDate, DateTime toDate)
        {
            string command =
                "SELECT * from timeadjust WHERE"
                + " EmployeeNum = '" + POut.PInt(empNum) + "'"
                + " AND TimeEntry >= " + POut.PDate(fromDate)
                //adding a day takes it to midnight of the specified toDate
                + " AND TimeEntry <= " + POut.PDate(toDate.AddDays(1));

            command += " ORDER BY TimeEntry";
            DataTable table = General.GetTable(command);

            TimeAdjust[] List = new TimeAdjust[table.Rows.Count];
            for (int i = 0; i < List.Length; i++)
            {
                List[i] = new TimeAdjust();
                List[i].TimeAdjustNum = PIn.PInt(table.Rows[i][0].ToString());
                List[i].EmployeeNum   = PIn.PInt(table.Rows[i][1].ToString());
                List[i].TimeEntry     = PIn.PDateT(table.Rows[i][2].ToString());
                List[i].RegHours      = TimeSpan.FromHours(PIn.PDouble(table.Rows[i][3].ToString()));
                List[i].OTimeHours    = TimeSpan.FromHours(PIn.PDouble(table.Rows[i][4].ToString()));
                List[i].Note          = PIn.PString(table.Rows[i][5].ToString());
            }
            return(List);
        }
Exemplo n.º 10
0
        ///<summary></summary>
        public static void Insert(TimeAdjust adj)
        {
            if (PrefB.RandomKeys)
            {
                adj.TimeAdjustNum = MiscData.GetKey("timeadjust", "TimeAdjustNum");
            }
            string command = "INSERT INTO timeadjust (";

            if (PrefB.RandomKeys)
            {
                command += "TimeAdjustNum,";
            }
            command += "EmployeeNum,TimeEntry,RegHours,OTimeHours,Note) VALUES(";
            if (PrefB.RandomKeys)
            {
                command += "'" + POut.PInt(adj.TimeAdjustNum) + "', ";
            }
            command +=
                "'" + POut.PInt(adj.EmployeeNum) + "', "
                + POut.PDateT(adj.TimeEntry) + ", "
                + "'" + POut.PDouble(adj.RegHours.TotalHours) + "', "
                + "'" + POut.PDouble(adj.OTimeHours.TotalHours) + "', "
                + "'" + POut.PString(adj.Note) + "')";
            if (PrefB.RandomKeys)
            {
                General.NonQ(command);
            }
            else
            {
                adj.TimeAdjustNum = General.NonQ(command, true);
            }
        }
Exemplo n.º 11
0
        public void TimeCardRules_CalculateWeeklyOvertime_OneWeekOverTwoPayPeriods()
        {
            string    suffix    = "26";
            DateTime  startDate = DateTime.Parse("2001-02-01");         //This will create a pay period that splits a work week.
            Employee  emp       = EmployeeT.CreateEmployee(suffix);
            PayPeriod payP1     = PayPeriodT.CreateTwoWeekPayPeriodIfNotExists(startDate);
            PayPeriod payP2     = PayPeriodT.CreateTwoWeekPayPeriodIfNotExists(startDate.AddDays(14));

            PayPeriods.RefreshCache();
            Prefs.UpdateInt(PrefName.TimeCardOvertimeFirstDayOfWeek, 0);
            TimeCardRules.RefreshCache();
            long clockEvent1 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(10).AddHours(6), startDate.AddDays(10).AddHours(17), 0);
            long clockEvent2 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(11).AddHours(6), startDate.AddDays(11).AddHours(17), 0);
            long clockEvent3 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(12).AddHours(6), startDate.AddDays(12).AddHours(17), 0);
            //new pay period
            long clockEvent4 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(14).AddHours(6), startDate.AddDays(14).AddHours(17), 0);

            TimeCardRules.CalculateWeeklyOvertime(emp, payP1.DateStart, payP1.DateStop);
            TimeCardRules.CalculateWeeklyOvertime(emp, payP2.DateStart, payP2.DateStop);
            //Validate
            List <TimeAdjust> resultList = TimeAdjusts.Refresh(emp.EmployeeNum, startDate, startDate.AddDays(28));

            Assert.IsFalse(resultList.Count < 1);
            TimeAdjust result = resultList[0];

            Assert.AreEqual(TimeSpan.FromHours(-4), result.RegHours);
            Assert.AreEqual(TimeSpan.FromHours(4), result.OTimeHours);
        }
Exemplo n.º 12
0
 ///<summary></summary>
 public FormTimeAdjustEdit(TimeAdjust timeAdjustCur)
 {
     //
     // Required for Windows Form Designer support
     //
     InitializeComponent();
     Lan.F(this);
     TimeAdjustCur = timeAdjustCur.Copy();
 }
Exemplo n.º 13
0
        ///<summary></summary>
        public static void Update(TimeAdjust adj)
        {
            string command = "UPDATE timeadjust SET "
                             + "EmployeeNum = '" + POut.PInt(adj.EmployeeNum) + "' "
                             + ",TimeEntry = " + POut.PDateT(adj.TimeEntry) + " "
                             + ",RegHours = '" + POut.PDouble(adj.RegHours.TotalHours) + "' "
                             + ",OTimeHours = '" + POut.PDouble(adj.OTimeHours.TotalHours) + "' "
                             + ",Note = '" + POut.PString(adj.Note) + "' "
                             + "WHERE TimeAdjustNum = '" + POut.PInt(adj.TimeAdjustNum) + "'";

            General.NonQ(command);
        }
Exemplo n.º 14
0
        ///<summary>Updates one TimeAdjust in the database.</summary>
        internal static void Update(TimeAdjust timeAdjust)
        {
            string command = "UPDATE timeadjust SET "
                             + "EmployeeNum  =  " + POut.Long(timeAdjust.EmployeeNum) + ", "
                             + "TimeEntry    =  " + POut.DateT(timeAdjust.TimeEntry) + ", "
                             + "RegHours     = '" + POut.TSpan(timeAdjust.RegHours) + "', "
                             + "OTimeHours   = '" + POut.TSpan(timeAdjust.OTimeHours) + "', "
                             + "Note         = '" + POut.String(timeAdjust.Note) + "', "
                             + "IsAuto       =  " + POut.Bool(timeAdjust.IsAuto) + " "
                             + "WHERE TimeAdjustNum = " + POut.Long(timeAdjust.TimeAdjustNum);

            Db.NonQ(command);
        }
Exemplo n.º 15
0
 ///<summary>Inserts one TimeAdjust into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(TimeAdjust timeAdjust)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(timeAdjust, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             timeAdjust.TimeAdjustNum = DbHelper.GetNextOracleKey("timeadjust", "TimeAdjustNum");                  //Cacheless method
         }
         return(InsertNoCache(timeAdjust, true));
     }
 }
Exemplo n.º 16
0
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<TimeAdjust> TableToList(DataTable table){
			List<TimeAdjust> retVal=new List<TimeAdjust>();
			TimeAdjust timeAdjust;
			for(int i=0;i<table.Rows.Count;i++) {
				timeAdjust=new TimeAdjust();
				timeAdjust.TimeAdjustNum= PIn.Long  (table.Rows[i]["TimeAdjustNum"].ToString());
				timeAdjust.EmployeeNum  = PIn.Long  (table.Rows[i]["EmployeeNum"].ToString());
				timeAdjust.TimeEntry    = PIn.DateT (table.Rows[i]["TimeEntry"].ToString());
				timeAdjust.RegHours     = PIn.TSpan (table.Rows[i]["RegHours"].ToString());
				timeAdjust.OTimeHours   = PIn.TSpan (table.Rows[i]["OTimeHours"].ToString());
				timeAdjust.Note         = PIn.String(table.Rows[i]["Note"].ToString());
				timeAdjust.IsAuto       = PIn.Bool  (table.Rows[i]["IsAuto"].ToString());
				retVal.Add(timeAdjust);
			}
			return retVal;
		}
Exemplo n.º 17
0
        private void butCompute_Click(object sender, EventArgs e)
        {
            if (!Security.IsAuthorized(Permissions.TimecardsEditAll))
            {
                return;
            }
            //first, delete all existing overtime entries
            for (int i = 0; i < TimeAdjustList.Length; i++)
            {
                if (TimeAdjustList[i].OTimeHours.TotalHours != 0)
                {
                    TimeAdjusts.Delete(TimeAdjustList[i]);
                }
            }
            //then, fill grid
            FillMain(true);
            Calendar         cal  = CultureInfo.CurrentCulture.Calendar;
            CalendarWeekRule rule = CultureInfo.CurrentCulture.DateTimeFormat.CalendarWeekRule;

            //loop through all rows
            for (int i = 0; i < mergedAL.Count; i++)
            {
                //ignore rows that aren't weekly totals
                if (i < mergedAL.Count - 1           //if not the last row
                    //if the next row has the same week as this row
                    && cal.GetWeekOfYear(GetDateForRow(i + 1), rule, DayOfWeek.Sunday)
                    == cal.GetWeekOfYear(GetDateForRow(i), rule, DayOfWeek.Sunday))
                {
                    continue;
                }
                if (WeeklyTotals[i] <= TimeSpan.FromHours(40))
                {
                    continue;
                }
                //found a weekly total over 40 hours
                TimeAdjust adjust = new TimeAdjust();
                adjust.EmployeeNum = EmployeeCur.EmployeeNum;
                adjust.TimeEntry   = GetDateForRow(i).AddHours(20);            //puts it at 8pm on the same day.
                adjust.OTimeHours  = WeeklyTotals[i] - TimeSpan.FromHours(40);
                adjust.RegHours    = -adjust.OTimeHours;
                TimeAdjusts.Insert(adjust);
            }
            FillMain(true);
        }
Exemplo n.º 18
0
        ///<summary>Inserts one TimeAdjust into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(TimeAdjust timeAdjust, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO timeadjust (";

            if (!useExistingPK && isRandomKeys)
            {
                timeAdjust.TimeAdjustNum = ReplicationServers.GetKeyNoCache("timeadjust", "TimeAdjustNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "TimeAdjustNum,";
            }
            command += "EmployeeNum,TimeEntry,RegHours,OTimeHours,Note,IsAuto,ClinicNum,PtoDefNum,PtoHours) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(timeAdjust.TimeAdjustNum) + ",";
            }
            command +=
                POut.Long(timeAdjust.EmployeeNum) + ","
                + POut.DateT(timeAdjust.TimeEntry) + ","
                + "'" + POut.TSpan(timeAdjust.RegHours) + "',"
                + "'" + POut.TSpan(timeAdjust.OTimeHours) + "',"
                + DbHelper.ParamChar + "paramNote,"
                + POut.Bool(timeAdjust.IsAuto) + ","
                + POut.Long(timeAdjust.ClinicNum) + ","
                + POut.Long(timeAdjust.PtoDefNum) + ","
                + "'" + POut.TSpan(timeAdjust.PtoHours) + "')";
            if (timeAdjust.Note == null)
            {
                timeAdjust.Note = "";
            }
            OdSqlParameter paramNote = new OdSqlParameter("paramNote", OdDbType.Text, POut.StringParam(timeAdjust.Note));

            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command, paramNote);
            }
            else
            {
                timeAdjust.TimeAdjustNum = Db.NonQ(command, true, "TimeAdjustNum", "timeAdjust", paramNote);
            }
            return(timeAdjust.TimeAdjustNum);
        }
Exemplo n.º 19
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        internal static List <TimeAdjust> TableToList(DataTable table)
        {
            List <TimeAdjust> retVal = new List <TimeAdjust>();
            TimeAdjust        timeAdjust;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                timeAdjust = new TimeAdjust();
                timeAdjust.TimeAdjustNum = PIn.Long(table.Rows[i]["TimeAdjustNum"].ToString());
                timeAdjust.EmployeeNum   = PIn.Long(table.Rows[i]["EmployeeNum"].ToString());
                timeAdjust.TimeEntry     = PIn.DateT(table.Rows[i]["TimeEntry"].ToString());
                timeAdjust.RegHours      = PIn.TSpan(table.Rows[i]["RegHours"].ToString());
                timeAdjust.OTimeHours    = PIn.TSpan(table.Rows[i]["OTimeHours"].ToString());
                timeAdjust.Note          = PIn.String(table.Rows[i]["Note"].ToString());
                timeAdjust.IsAuto        = PIn.Bool(table.Rows[i]["IsAuto"].ToString());
                retVal.Add(timeAdjust);
            }
            return(retVal);
        }
Exemplo n.º 20
0
        ///<summary>Updates one TimeAdjust in the database.</summary>
        public static void Update(TimeAdjust timeAdjust)
        {
            string command = "UPDATE timeadjust SET "
                             + "EmployeeNum  =  " + POut.Long(timeAdjust.EmployeeNum) + ", "
                             + "TimeEntry    =  " + POut.DateT(timeAdjust.TimeEntry) + ", "
                             + "RegHours     = '" + POut.TSpan(timeAdjust.RegHours) + "', "
                             + "OTimeHours   = '" + POut.TSpan(timeAdjust.OTimeHours) + "', "
                             + "Note         =  " + DbHelper.ParamChar + "paramNote, "
                             + "IsAuto       =  " + POut.Bool(timeAdjust.IsAuto) + ", "
                             + "ClinicNum    =  " + POut.Long(timeAdjust.ClinicNum) + " "
                             + "WHERE TimeAdjustNum = " + POut.Long(timeAdjust.TimeAdjustNum);

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

            Db.NonQ(command, paramNote);
        }
Exemplo n.º 21
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <TimeAdjust> TableToList(DataTable table)
        {
            List <TimeAdjust> retVal = new List <TimeAdjust>();
            TimeAdjust        timeAdjust;

            foreach (DataRow row in table.Rows)
            {
                timeAdjust = new TimeAdjust();
                timeAdjust.TimeAdjustNum = PIn.Long(row["TimeAdjustNum"].ToString());
                timeAdjust.EmployeeNum   = PIn.Long(row["EmployeeNum"].ToString());
                timeAdjust.TimeEntry     = PIn.DateT(row["TimeEntry"].ToString());
                timeAdjust.RegHours      = PIn.TSpan(row["RegHours"].ToString());
                timeAdjust.OTimeHours    = PIn.TSpan(row["OTimeHours"].ToString());
                timeAdjust.Note          = PIn.String(row["Note"].ToString());
                timeAdjust.IsAuto        = PIn.Bool(row["IsAuto"].ToString());
                timeAdjust.ClinicNum     = PIn.Long(row["ClinicNum"].ToString());
                retVal.Add(timeAdjust);
            }
            return(retVal);
        }
Exemplo n.º 22
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;
 }
Exemplo n.º 23
0
        ///<summary></summary>
        public static void Delete(TimeAdjust adj)
        {
            string command = "DELETE FROM timeadjust WHERE TimeAdjustNum = " + POut.PInt(adj.TimeAdjustNum);

            General.NonQ(command);
        }
Exemplo n.º 24
0
 ///<summary>Inserts one TimeAdjust into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(TimeAdjust timeAdjust)
 {
     return(InsertNoCache(timeAdjust, false));
 }
Exemplo n.º 25
0
		///<summary>Updates one TimeAdjust 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(TimeAdjust timeAdjust,TimeAdjust oldTimeAdjust){
			string command="";
			if(timeAdjust.EmployeeNum != oldTimeAdjust.EmployeeNum) {
				if(command!=""){ command+=",";}
				command+="EmployeeNum = "+POut.Long(timeAdjust.EmployeeNum)+"";
			}
			if(timeAdjust.TimeEntry != oldTimeAdjust.TimeEntry) {
				if(command!=""){ command+=",";}
				command+="TimeEntry = "+POut.DateT(timeAdjust.TimeEntry)+"";
			}
			if(timeAdjust.RegHours != oldTimeAdjust.RegHours) {
				if(command!=""){ command+=",";}
				command+="RegHours = '"+POut.TSpan (timeAdjust.RegHours)+"'";
			}
			if(timeAdjust.OTimeHours != oldTimeAdjust.OTimeHours) {
				if(command!=""){ command+=",";}
				command+="OTimeHours = '"+POut.TSpan (timeAdjust.OTimeHours)+"'";
			}
			if(timeAdjust.Note != oldTimeAdjust.Note) {
				if(command!=""){ command+=",";}
				command+="Note = '"+POut.String(timeAdjust.Note)+"'";
			}
			if(timeAdjust.IsAuto != oldTimeAdjust.IsAuto) {
				if(command!=""){ command+=",";}
				command+="IsAuto = "+POut.Bool(timeAdjust.IsAuto)+"";
			}
			if(command==""){
				return false;
			}
			command="UPDATE timeadjust SET "+command
				+" WHERE TimeAdjustNum = "+POut.Long(timeAdjust.TimeAdjustNum);
			Db.NonQ(command);
			return true;
		}
Exemplo n.º 26
0
		///<summary>Updates one TimeAdjust in the database.</summary>
		public static void Update(TimeAdjust timeAdjust){
			string command="UPDATE timeadjust SET "
				+"EmployeeNum  =  "+POut.Long  (timeAdjust.EmployeeNum)+", "
				+"TimeEntry    =  "+POut.DateT (timeAdjust.TimeEntry)+", "
				+"RegHours     = '"+POut.TSpan (timeAdjust.RegHours)+"', "
				+"OTimeHours   = '"+POut.TSpan (timeAdjust.OTimeHours)+"', "
				+"Note         = '"+POut.String(timeAdjust.Note)+"', "
				+"IsAuto       =  "+POut.Bool  (timeAdjust.IsAuto)+" "
				+"WHERE TimeAdjustNum = "+POut.Long(timeAdjust.TimeAdjustNum);
			Db.NonQ(command);
		}
Exemplo n.º 27
0
        ///<summary>Updates one TimeAdjust 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(TimeAdjust timeAdjust, TimeAdjust oldTimeAdjust)
        {
            string command = "";

            if (timeAdjust.EmployeeNum != oldTimeAdjust.EmployeeNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "EmployeeNum = " + POut.Long(timeAdjust.EmployeeNum) + "";
            }
            if (timeAdjust.TimeEntry != oldTimeAdjust.TimeEntry)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "TimeEntry = " + POut.DateT(timeAdjust.TimeEntry) + "";
            }
            if (timeAdjust.RegHours != oldTimeAdjust.RegHours)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "RegHours = '" + POut.TSpan(timeAdjust.RegHours) + "'";
            }
            if (timeAdjust.OTimeHours != oldTimeAdjust.OTimeHours)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "OTimeHours = '" + POut.TSpan(timeAdjust.OTimeHours) + "'";
            }
            if (timeAdjust.Note != oldTimeAdjust.Note)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Note = " + DbHelper.ParamChar + "paramNote";
            }
            if (timeAdjust.IsAuto != oldTimeAdjust.IsAuto)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "IsAuto = " + POut.Bool(timeAdjust.IsAuto) + "";
            }
            if (timeAdjust.ClinicNum != oldTimeAdjust.ClinicNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ClinicNum = " + POut.Long(timeAdjust.ClinicNum) + "";
            }
            if (command == "")
            {
                return(false);
            }
            if (timeAdjust.Note == null)
            {
                timeAdjust.Note = "";
            }
            OdSqlParameter paramNote = new OdSqlParameter("paramNote", OdDbType.Text, POut.StringParam(timeAdjust.Note));

            command = "UPDATE timeadjust SET " + command
                      + " WHERE TimeAdjustNum = " + POut.Long(timeAdjust.TimeAdjustNum);
            Db.NonQ(command, paramNote);
            return(true);
        }