示例#1
0
        public void CheckCurrentHours()
        {
            //miWarnLvl = 0;
            COScheduleHour.GridHoursLevel ghl = CBScheduleHour.GetEmployeeTimeLevel(miEmployeeID, miWeekID, moHrsType);

            if (OnHoursWarning != null)
            {
                OnHoursWarning(ghl);
            }
        }
示例#2
0
        public COScheduleHour.GridHoursLevel GetEmployeeTimeLevel(int empID, int wkID, COScheduleHour.ScheduleHourType typeH)
        {
            SqlDataReader dr;

            RSLib.CDbConnection cnn;
            SqlCommand          cmd;
            SqlParameter        prm;

            COScheduleHour.GridHoursLevel ghl;
            decimal minHrs, maxReg, maxAll;
            decimal pHrs, fHrs;
            decimal compHr;
            int     flagVal;

            cnn             = new RSLib.CDbConnection();
            cmd             = new SqlCommand("spScheduleHour_EmployeeWeekTime", cnn.GetConnection());
            cmd.CommandType = CommandType.StoredProcedure;

            prm       = cmd.Parameters.Add("@EmployeeID", SqlDbType.Int);
            prm.Value = empID;
            prm       = cmd.Parameters.Add("@WeekID", SqlDbType.Int);
            prm.Value = wkID;

            dr = cmd.ExecuteReader();

            minHrs = 35;
            maxReg = 40;
            maxAll = 50;
            pHrs   = 0;
            fHrs   = 0;

            while (dr.Read())
            {
                minHrs = Convert.ToDecimal(dr["MinHrs"]);
                maxReg = Convert.ToDecimal(dr["MaxRegHrs"]);
                maxAll = Convert.ToDecimal(dr["MaxAllHrs"]);
                pHrs   = Convert.ToDecimal(dr["totP"]);
                fHrs   = Convert.ToDecimal(dr["totF"]);
            }

            dr.Close();

            switch (typeH)
            {
            case COScheduleHour.ScheduleHourType.enForecast:
                compHr = fHrs;
                break;

            default:
                compHr = pHrs;
                break;
            }

            if (compHr < minHrs)
            {
                flagVal = -1;
            }
            else if (compHr > maxAll)
            {
                flagVal = 2;
            }
            else if (compHr > maxReg)
            {
                flagVal = 1;
            }
            else
            {
                flagVal = 0;
            }

            ghl = new COScheduleHour.GridHoursLevel();

            ghl.EmployeeID = empID;
            ghl.WeekID     = wkID;
            ghl.HrsType    = typeH;
            ghl.WarnLvl    = flagVal;
            switch (typeH)
            {
            case COScheduleHour.ScheduleHourType.enForecast:
                ghl.HrsType = COScheduleHour.ScheduleHourType.enForecast;
                break;

            default:
                ghl.HrsType = COScheduleHour.ScheduleHourType.enPlanned;
                break;
            }



            cmd = null;
            cnn.CloseConnection();

            return(ghl);
        }