コード例 #1
0
        public void Update(DatabaseConnection dbConn)
        {
            if (id != null)
            {
                object obj = IDToDBObject(dbConn, id);
                if (obj is ERosterTable)
                {
                    ERosterTable rosterTable = (ERosterTable)obj;
                    ERosterCode  rosterCode  = new ERosterCode();
                    rosterCode.RosterCodeID = rosterTable.RosterCodeID;
                    if (ERosterCode.db.select(dbConn, rosterCode))
                    {
                        if (rosterCode.RosterCodeInTime.TimeOfDay.Equals(StartTime.TimeOfDay))
                        {
                            rosterTable.RosterTableOverrideInTime = new DateTime();
                        }
                        else
                        {
                            rosterTable.RosterTableOverrideInTime = StartTime;
                        }

                        if (rosterCode.RosterCodeOutTime.TimeOfDay.Equals(EndTime.TimeOfDay))
                        {
                            rosterTable.RosterTableOverrideOutTime = new DateTime();
                        }
                        else
                        {
                            rosterTable.RosterTableOverrideOutTime = EndTime;
                        }
                    }
                    ERosterTable.db.update(dbConn, rosterTable);
                }
            }
        }
コード例 #2
0
    //protected void RadCalendar1_SelectionChanged(object sender, Telerik.Web.UI.Calendar.SelectedDatesEventArgs e)
    //{
    //    if (!RadCalendar1.SelectedDate.Equals(DateTime.MinValue))
    //        RadScheduler1.SelectedDate = RadCalendar1.SelectedDate;
    //}
    //protected void RadScheduler1_NavigationComplete(object sender, SchedulerNavigationCompleteEventArgs e)
    //{
    //    RadCalendar1.SelectedDate = RadScheduler1.SelectedDate;
    //    RadCalendar1.FocusedDate = RadCalendar1.SelectedDate;
    //}
    protected void RadScheduler1_AppointmentDataBound(object sender, SchedulerEventArgs e)
    {
        //e.Appointment.ContextMenuID=
        e.Appointment.AllowDelete = false;

        if (e.Appointment.ID.ToString().StartsWith(HROne.Lib.Attendance.DataSource.RosterTableEvent.LEAVEAPP_ID_PREFIX))
        {
            e.Appointment.AllowEdit = false;
        }
        else
        {
            e.Appointment.AllowEdit = m_IsAllowWrite;
        }

        HROne.Lib.Attendance.DataSource.RosterTableEvent rosterTableEvent = (HROne.Lib.Attendance.DataSource.RosterTableEvent)e.Appointment.DataItem;
        e.Appointment.ToolTip = rosterTableEvent.ToolTip;
        if (rosterTableEvent.Id.StartsWith(HROne.Lib.Attendance.DataSource.RosterTableEvent.PUBLICHOLIDAY_PREFIX) ||
            rosterTableEvent.Id.StartsWith(HROne.Lib.Attendance.DataSource.RosterTableEvent.STATUTORYHOLIDAY_PREFIX))
        {
            e.Appointment.AllowEdit = false;
            e.Appointment.ForeColor = System.Drawing.Color.Red;
        }

        object dbObjectItem = HROne.Lib.Attendance.DataSource.RosterTableEvent.IDToDBObject(dbConn, e.Appointment.ID);

        if (dbObjectItem is ERosterTable)
        {
            ERosterTable rosterTable = (ERosterTable)dbObjectItem;
            ERosterCode  rosterCode  = new ERosterCode();
            rosterCode.RosterCodeID = rosterTable.RosterCodeID;
            if (ERosterCode.db.select(dbConn, rosterCode))
            {
                if (!string.IsNullOrEmpty(rosterCode.RosterCodeColorCode))
                {
                    try
                    {
                        e.Appointment.BackColor = System.Drawing.ColorTranslator.FromHtml(rosterCode.RosterCodeColorCode);
                        e.Appointment.ForeColor = AppUtils.ComputeTextColor(e.Appointment.BackColor);
                    }
                    catch
                    {
                    }
                }
            }
        }
        if (RadScheduler1.SelectedView == SchedulerViewType.TimelineView)
        {
            if (RadScheduler1.Appointments.Count > 10)
            {
                RadScheduler1.Height = Unit.Parse("");
            }
        }
    }
コード例 #3
0
    private ERosterTable getCurrentRosterTable(DateTime periodFromDate, int dayIdx, int empID)
    {
        DateTime            currentDate     = periodFromDate.AddDays(dayIdx);
        List <ERosterTable> rosterTableList = ERosterTable.GetRosterTableList(dbConn, empID, currentDate);

        if (rosterTableList.Count > 0)
        {
            ERosterTable currentRosterTable = (ERosterTable)rosterTableList[0];
            return(currentRosterTable);
        }
        else
        {
            return(null);
        }
    }
コード例 #4
0
    private TimeSpan getCurrentCutOffTimeSpan(DateTime periodFromDate, int dayIdx, int empID)
    {
        TimeSpan     cutOffTimeSpan     = new TimeSpan();
        ERosterTable currentRosterTable = getCurrentRosterTable(periodFromDate, dayIdx, empID);

        if (currentRosterTable != null)
        {
            ERosterCode currentRosterCode = new ERosterCode();
            currentRosterCode.RosterCodeID = currentRosterTable.RosterCodeID;
            if (ERosterCode.db.select(dbConn, currentRosterCode))
            {
                cutOffTimeSpan = currentRosterCode.RosterCodeCutOffTime.TimeOfDay;
            }
        }
        return(cutOffTimeSpan);
    }
コード例 #5
0
    private string getCurrentRosterCodeDesc(DateTime periodFromDate, int dayIdx, int empID)
    {
        string       rosterCodeDesc     = "--";
        ERosterTable currentRosterTable = getCurrentRosterTable(periodFromDate, dayIdx, empID);

        if (currentRosterTable != null)
        {
            ERosterCode currentRosterCode = new ERosterCode();
            currentRosterCode.RosterCodeID = currentRosterTable.RosterCodeID;
            if (ERosterCode.db.select(dbConn, currentRosterCode))
            {
                if (currentRosterTable.RosterTableID > 0)
                {
                    rosterCodeDesc = currentRosterCode.RosterCode + " - " + currentRosterCode.RosterCodeDesc;
                }
            }
        }
        return(rosterCodeDesc);
    }
コード例 #6
0
        public static DBObject IDToDBObject(DatabaseConnection dbConn, object appointmentID)
        {
            if (appointmentID != null)
            {
                string   item_ID  = appointmentID.ToString();
                string[] id_Array = item_ID.ToString().Split(new char[] { '_' });

                if (id_Array.GetLength(0) == 2)
                {
                    if (id_Array[0].Equals(RosterTableEvent.ROSTER_TABLE_ID_PREFIX))
                    {
                        ERosterTable rosterTable = new ERosterTable();
                        rosterTable.RosterTableID = int.Parse(id_Array[1]);
                        if (ERosterTable.db.select(dbConn, rosterTable))
                        {
                            return(rosterTable);
                        }
                    }
                }
            }
            return(null);
        }
コード例 #7
0
        public override void ImportToDatabase()
        {
            DBFilter sessionFilter = new DBFilter();

            sessionFilter.add(new Match("SessionID", m_SessionID));
            sessionFilter.add("EmpID", true);

            DBFilter removeOldRosterTable    = new DBFilter();
            DBFilter existsUploadRosterTable = new DBFilter();

            existsUploadRosterTable.add(new MatchField(ERosterTable.db.dbclass.tableName + ".EmpID", "ur.EmpID"));
            existsUploadRosterTable.add(new MatchField(ERosterTable.db.dbclass.tableName + ".RosterTableDate", "ur.RosterTableDate"));
            existsUploadRosterTable.add(new Match("ur.SessionID", m_SessionID));

            removeOldRosterTable.add(new Exists(EUploadRosterTable.db.dbclass.tableName + " ur", existsUploadRosterTable));
            //ArrayList recalLeaveBalanceEmpIDList = new ArrayList();
            //DateTime firstDate = new DateTime();
            ArrayList oldRosterTableList = ERosterTable.db.select(dbConn, removeOldRosterTable);

            foreach (ERosterTable oldRosterTable in oldRosterTableList)
            {
                //if (firstDate > oldRosterTable.RosterTableDate || firstDate.Ticks.Equals(0))
                //    firstDate = oldRosterTable.RosterTableDate;
                //if (oldRosterTable.LeaveAppID > 0)
                //{
                //    ELeaveApplication leaveApp = new ELeaveApplication();
                //    leaveApp.LeaveAppID = oldRosterTable.LeaveAppID;
                //    if (ELeaveApplication.db.select(dbConn, leaveApp))
                //        if (leaveApp.EmpPayrollID <= 0)
                //        {
                //            ELeaveApplication.db.delete(dbConn, leaveApp);
                //            if (!recalLeaveBalanceEmpIDList.Contains(oldRosterTable.EmpID))
                //                recalLeaveBalanceEmpIDList.Add(oldRosterTable.EmpID);
                //        }
                //}
                ERosterTable.db.delete(dbConn, oldRosterTable);
            }

            ArrayList uploadRosterTableList = EUploadRosterTable.db.select(dbConn, sessionFilter);

            foreach (EUploadRosterTable obj in uploadRosterTableList)
            {
                //if (firstDate > obj.RosterTableDate || firstDate.Ticks.Equals(0))
                //    firstDate = obj.RosterTableDate;
                if (obj.RosterCodeID > 0)
                {
                    ERosterCode rosterCode = new ERosterCode();
                    rosterCode.RosterCodeID = obj.RosterCodeID;
                    if (ERosterCode.db.select(dbConn, rosterCode))
                    {
                        ERosterTable rosterTable = new ERosterTable();
                        rosterTable.EmpID           = obj.EmpID;
                        rosterTable.RosterTableDate = obj.RosterTableDate;
                        rosterTable.RosterCodeID    = obj.RosterCodeID;
                        if (!obj.RosterTableOverrideInTime.Ticks.Equals(0) && !rosterCode.RosterCodeInTime.TimeOfDay.Equals(obj.RosterTableOverrideInTime.TimeOfDay))
                        {
                            rosterTable.RosterTableOverrideInTime = obj.RosterTableOverrideInTime;
                        }
                        if (!obj.RosterTableOverrideOutTime.Ticks.Equals(0) && !rosterCode.RosterCodeOutTime.TimeOfDay.Equals(obj.RosterTableOverrideOutTime.TimeOfDay))
                        {
                            rosterTable.RosterTableOverrideOutTime = obj.RosterTableOverrideOutTime;
                        }


                        //if (rosterCode.RosterCodeType.Equals(ERosterCode.ROSTERTYPE_CODE_LEAVE) && rosterCode.LeaveCodeID > 0)
                        //{
                        //    ELeaveCode leaveCode = new ELeaveCode();
                        //    leaveCode.LeaveCodeID = rosterCode.LeaveCodeID;
                        //    if (ELeaveCode.db.select(dbConn, leaveCode))
                        //    {
                        //        DBFilter leaveFilter = new DBFilter();
                        //        leaveFilter.add(new Match("EmpID", obj.EmpID));
                        //        leaveFilter.add(new Match("LeaveAppDateFrom", obj.RosterTableDate));
                        //        leaveFilter.add(new Match("LeaveAppDateTo", obj.RosterTableDate));
                        //        leaveFilter.add(new Match("LeaveAppDays", 1));
                        //        leaveFilter.add(new Match("LeaveCodeID", leaveCode.LeaveCodeID));
                        //        ArrayList oldLeaveAppList = ELeaveApplication.db.select(dbConn, leaveFilter);
                        //        if (oldLeaveAppList.Count > 0)
                        //            rosterTable.LeaveAppID = ((ELeaveApplication)oldLeaveAppList[0]).LeaveAppID;
                        //        else
                        //        {
                        //            ELeaveApplication leaveApp = new ELeaveApplication();
                        //            leaveApp.LeaveAppDateFrom = obj.RosterTableDate;
                        //            leaveApp.LeaveAppDateTo = obj.RosterTableDate;
                        //            leaveApp.LeaveAppDays = 1;
                        //            leaveApp.LeaveAppUnit = "D";
                        //            leaveApp.LeaveCodeID = leaveCode.LeaveCodeID;
                        //            leaveApp.EmpID = obj.EmpID;

                        //            ELeaveApplication.db.insert(dbConn, leaveApp);

                        //            rosterTable.LeaveAppID = leaveApp.LeaveAppID;
                        //        }
                        //        if (!recalLeaveBalanceEmpIDList.Contains(obj.EmpID))
                        //            recalLeaveBalanceEmpIDList.Add(obj.EmpID);
                        //    }
                        //}



                        ERosterTable.db.insert(dbConn, rosterTable);
                    }
                }
                EUploadRosterTable.db.delete(dbConn, obj);
            }
            //foreach (int EmpID in recalLeaveBalanceEmpIDList)
            //{
            //    LeaveBalanceCalc leaaveBalCal = new LeaveBalanceCalc(dbConn, EmpID);
            //    leaaveBalCal.RecalculateAfter(firstDate);
            //}
        }
コード例 #8
0
        protected RosterTableEventList GenerateEventList(ICollection DBObjectList)
        {
            RosterTableEventList tmpEventList = new RosterTableEventList();

            if (DBObjectList != null)
            {
                foreach (DBObject dbObject in DBObjectList)
                {
                    if (dbObject is ERosterTable)
                    {
                        ERosterTable rosterTable = (ERosterTable)dbObject;
                        ERosterCode  rosterCode  = new ERosterCode();
                        rosterCode.RosterCodeID = rosterTable.RosterCodeID;
                        bool hasRecord = ERosterCode.db.select(dbConn, rosterCode);
                        if (hasRecord || rosterCode.RosterCodeID == 0)
                        {
                            RosterTableEvent eventDetail = new RosterTableEvent();
                            eventDetail.Id = RosterTableEvent.ROSTER_TABLE_ID_PREFIX + "_" + rosterTable.RosterTableID;

                            //  Override Start/End time only when the roster code exists
                            if (rosterTable.RosterTableOverrideInTime.Ticks.Equals(0) || !hasRecord)
                            {
                                eventDetail.StartTime = rosterTable.RosterTableDate.Add(rosterCode.RosterCodeInTime.TimeOfDay);
                            }
                            else
                            {
                                eventDetail.StartTime = rosterTable.RosterTableDate.Add(rosterTable.RosterTableOverrideInTime.TimeOfDay);
                            }

                            if (rosterTable.RosterTableOverrideOutTime.Ticks.Equals(0) || !hasRecord)
                            {
                                eventDetail.EndTime = rosterTable.RosterTableDate.Add(rosterCode.RosterCodeOutTime.TimeOfDay);
                            }
                            else
                            {
                                eventDetail.EndTime = rosterTable.RosterTableDate.Add(rosterTable.RosterTableOverrideOutTime.TimeOfDay);
                            }
                            if (eventDetail.StartTime >= eventDetail.EndTime)
                            {
                                eventDetail.EndTime = eventDetail.EndTime.AddDays(1);

                                if (!DisplayOvernightToNextDay)
                                {
                                    eventDetail.EndTime = eventDetail.EndTime.Date;
                                }
                            }

                            EEmpPersonalInfo empInfo = new EEmpPersonalInfo();
                            empInfo.EmpID = rosterTable.EmpID;
                            EEmpPersonalInfo.db.select(dbConn, empInfo);

                            eventDetail.Subject = (hasRecord ? rosterCode.RosterCode : "(unspecified)") + " - " + empInfo.EmpEngDisplayName;
                            eventDetail.ToolTip = eventDetail.Subject;
                            eventDetail.Label   = rosterCode.RosterClientSiteID;

                            eventDetail.RecurrenceInfo = string.Empty;
                            eventDetail.OwnerId        = rosterCode.RosterClientSiteID;

                            tmpEventList.Add(eventDetail);
                        }
                    }
                    else if (dbObject is ELeaveApplication)
                    {
                        ELeaveApplication leaveApplication = (ELeaveApplication)dbObject;
                        ELeaveCode        leaveCode        = new ELeaveCode();
                        leaveCode.LeaveCodeID = leaveApplication.LeaveCodeID;
                        bool hasRecord = ELeaveCode.db.select(dbConn, leaveCode);
                        if (hasRecord)
                        {
                            RosterTableEvent eventDetail = new RosterTableEvent();
                            eventDetail.Id = RosterTableEvent.LEAVEAPP_ID_PREFIX + "_" + leaveApplication.LeaveAppID;

                            if (leaveApplication.LeaveAppUnit.Equals(ELeaveApplication.LEAVEUNIT_DAYS))
                            {
                                eventDetail.StartTime = leaveApplication.LeaveAppDateFrom;
                                eventDetail.EndTime   = leaveApplication.LeaveAppDateTo.AddDays(1);
                            }
                            else
                            {
                                eventDetail.StartTime = leaveApplication.LeaveAppDateFrom;
                                eventDetail.EndTime   = leaveApplication.LeaveAppDateFrom;
                                if (!leaveApplication.LeaveAppTimeFrom.Ticks.Equals(0))
                                {
                                    eventDetail.StartTime = eventDetail.StartTime.Add(leaveApplication.LeaveAppTimeFrom.TimeOfDay);
                                }
                                if (!leaveApplication.LeaveAppTimeTo.Ticks.Equals(0))
                                {
                                    eventDetail.EndTime = eventDetail.EndTime.Add(leaveApplication.LeaveAppTimeTo.TimeOfDay);
                                }

                                if (leaveApplication.LeaveAppUnit.Equals(ELeaveApplication.LEAVEUNIT_AM))
                                {
                                    if (eventDetail.StartTime.Equals(leaveApplication.LeaveAppDateFrom))
                                    {
                                        eventDetail.StartTime = eventDetail.StartTime.Add(new TimeSpan(0, 0, 0));
                                    }
                                    if (eventDetail.EndTime.Equals(leaveApplication.LeaveAppDateFrom))
                                    {
                                        eventDetail.EndTime = eventDetail.EndTime.Add(new TimeSpan(13, 0, 0));
                                    }
                                }
                                if (leaveApplication.LeaveAppUnit.Equals(ELeaveApplication.LEAVEUNIT_PM))
                                {
                                    if (eventDetail.StartTime.Equals(leaveApplication.LeaveAppDateFrom))
                                    {
                                        eventDetail.StartTime = eventDetail.StartTime.Add(new TimeSpan(13, 0, 0));
                                    }
                                    if (eventDetail.EndTime.Equals(leaveApplication.LeaveAppDateFrom))
                                    {
                                        eventDetail.EndTime = eventDetail.EndTime.AddDays(1);
                                    }
                                }
                                else
                                {
                                    if (eventDetail.StartTime.Equals(leaveApplication.LeaveAppDateFrom))
                                    {
                                        eventDetail.StartTime = eventDetail.StartTime.Add(new TimeSpan(0, 0, 0));
                                    }
                                    if (eventDetail.EndTime.Equals(leaveApplication.LeaveAppDateFrom))
                                    {
                                        eventDetail.EndTime = eventDetail.EndTime.AddDays(1);
                                    }
                                }
                            }


                            EEmpPersonalInfo empInfo = new EEmpPersonalInfo();
                            empInfo.EmpID = leaveApplication.EmpID;
                            EEmpPersonalInfo.db.select(dbConn, empInfo);

                            //eventDetail.Subject = (hasRecord ? leaveCode.LeaveCode : "(unspecified)") + " - " + empInfo.EmpEngDisplayName;

                            if (leaveApplication.LeaveAppDays < 0 || leaveApplication.LeaveAppHours < 0)
                            {
                                eventDetail.IsCancel = true;
                            }

                            string LeaveUnitDetail = string.Empty;
                            if (leaveApplication.LeaveAppUnit.Equals("D"))
                            {
                                LeaveUnitDetail = leaveApplication.LeaveAppDays + " " + "Day" + (leaveApplication.LeaveAppDays > 1 ? "s" : string.Empty);
                            }
                            else if (leaveApplication.LeaveAppUnit.Equals("H"))
                            {
                                if (leaveApplication.LeaveAppTimeFrom.Ticks.Equals(0) || leaveApplication.LeaveAppTimeTo.Ticks.Equals(0))
                                {
                                    LeaveUnitDetail = leaveApplication.LeaveAppHours + " " + "Hour" + (leaveApplication.LeaveAppHours > 1 ? "s" : string.Empty);
                                }
                                else
                                {
                                    LeaveUnitDetail = leaveApplication.LeaveAppTimeFrom.ToString("HH:mm") + "-" + leaveApplication.LeaveAppTimeTo.ToString("HH:mm");
                                }
                            }
                            else if (leaveApplication.LeaveAppUnit.Equals("A"))
                            {
                                if (leaveApplication.LeaveAppDays > 0)
                                {
                                    LeaveUnitDetail = "A.M.";
                                }
                                else
                                {
                                    LeaveUnitDetail = "-A.M.";
                                }
                            }
                            else if (leaveApplication.LeaveAppUnit.Equals("P"))
                            {
                                if (leaveApplication.LeaveAppDays > 0)
                                {
                                    LeaveUnitDetail = "P.M.";
                                }
                                else
                                {
                                    LeaveUnitDetail = "-P.M.";
                                }
                            }

                            eventDetail.Subject = (hasRecord ? leaveCode.LeaveCode : "(unspecified)")
                                                  + (string.IsNullOrEmpty(LeaveUnitDetail) ? string.Empty : ("(" + LeaveUnitDetail + ")"))
                                                  + " - " + empInfo.EmpEngDisplayName;
                            eventDetail.ToolTip = eventDetail.Subject;
                            //eventDetail.Label = rosterCode.RosterClientSiteID;

                            eventDetail.RecurrenceInfo = string.Empty;
                            //eventDetail.OwnerId = rosterCode.RosterClientSiteID;

                            tmpEventList.Add(eventDetail);
                        }
                    }
                    else if (dbObject is EPublicHoliday)
                    {
                        EPublicHoliday   holiday     = (EPublicHoliday)dbObject;
                        RosterTableEvent eventDetail = new RosterTableEvent();
                        eventDetail.Id = RosterTableEvent.PUBLICHOLIDAY_PREFIX + "_" + holiday.PublicHolidayID;

                        eventDetail.StartTime = holiday.PublicHolidayDate;
                        eventDetail.EndTime   = holiday.PublicHolidayDate.AddDays(1);



                        eventDetail.Subject = holiday.PublicHolidayDesc;
                        eventDetail.ToolTip = eventDetail.Subject;
                        //eventDetail.Label = rosterCode.RosterClientSiteID;

                        eventDetail.RecurrenceInfo = string.Empty;
                        //eventDetail.OwnerId = rosterCode.RosterClientSiteID;

                        tmpEventList.Add(eventDetail);
                    }
                    else if (dbObject is EStatutoryHoliday)
                    {
                        EStatutoryHoliday holiday     = (EStatutoryHoliday)dbObject;
                        RosterTableEvent  eventDetail = new RosterTableEvent();
                        eventDetail.Id = RosterTableEvent.STATUTORYHOLIDAY_PREFIX + "_" + holiday.StatutoryHolidayID;

                        eventDetail.StartTime = holiday.StatutoryHolidayDate;
                        eventDetail.EndTime   = holiday.StatutoryHolidayDate.AddDays(1);



                        eventDetail.Subject = holiday.StatutoryHolidayDesc;
                        eventDetail.ToolTip = eventDetail.Subject;
                        //eventDetail.Label = rosterCode.RosterClientSiteID;

                        eventDetail.RecurrenceInfo = string.Empty;
                        //eventDetail.OwnerId = rosterCode.RosterClientSiteID;

                        tmpEventList.Add(eventDetail);
                    }
                }
            }
            return(tmpEventList);
        }
コード例 #9
0
        protected void SubmitButton_Click(object sender, EventArgs e)
        {
            ERosterTable rosterTable = new ERosterTable();

            Binding ebinding = new Binding(dbConn, ERosterTable.db);

            ebinding.add(RosterTableID);
            ebinding.add(RosterTableDate);
            ebinding.add(EmpID);
            ebinding.add(new DropDownVLBinder(ERosterTable.db, RosterCodeID, ERosterCode.VLRosterCode));
            ebinding.add(RosterTableOverrideInTime);
            ebinding.add(RosterTableOverrideOutTime);

            Hashtable values = new Hashtable();

            ebinding.toValues(values);
            ERosterTable.db.parse(values, rosterTable);
            ERosterCode rosterCode = new ERosterCode();

            rosterCode.RosterCodeID = rosterTable.RosterCodeID;
            if (ERosterCode.db.select(dbConn, rosterCode))
            {
                if (rosterCode.RosterCodeInTime.TimeOfDay.Equals(rosterTable.RosterTableOverrideInTime.TimeOfDay))
                {
                    rosterTable.RosterTableOverrideInTime = new DateTime(0);
                }
                if (rosterCode.RosterCodeOutTime.TimeOfDay.Equals(rosterTable.RosterTableOverrideOutTime.TimeOfDay))
                {
                    rosterTable.RosterTableOverrideOutTime = new DateTime(0);
                }

                if (rosterCode.RosterCodeType.Equals(ERosterCode.ROSTERTYPE_CODE_LEAVE) && rosterCode.LeaveCodeID > 0)
                {
                    ELeaveCode leaveCode = new ELeaveCode();
                    leaveCode.LeaveCodeID = rosterCode.LeaveCodeID;
                    if (ELeaveCode.db.select(dbConn, leaveCode))
                    {
                        ELeaveApplication leaveApp = new ELeaveApplication();
                        leaveApp.LeaveAppDateFrom = rosterTable.RosterTableDate;
                        leaveApp.LeaveAppDateTo   = rosterTable.RosterTableDate;
                        leaveApp.LeaveAppDays     = 1;
                        leaveApp.LeaveAppUnit     = "D";
                        leaveApp.LeaveCodeID      = leaveCode.LeaveCodeID;
                        leaveApp.EmpID            = rosterTable.EmpID;

                        ELeaveApplication.db.insert(dbConn, leaveApp);

                        rosterTable.LeaveAppID = leaveApp.LeaveAppID;
                        //HROne.LeaveCalc.LeaveBalanceCalc leaaveBalCal = new HROne.LeaveCalc.LeaveBalanceCalc(dbConn, rosterTable.EmpID);
                        //leaaveBalCal.RecalculateAfter(rosterTable.RosterTableDate);
                    }
                    else
                    {
                        rosterTable.LeaveAppID = 0;
                    }
                }
            }
            ERosterTable oldRosterTable = new ERosterTable();

            oldRosterTable.RosterTableID = rosterTable.RosterTableID;
            if (ERosterTable.db.select(dbConn, oldRosterTable))
            {
                if (oldRosterTable.LeaveAppID > 0)
                {
                    ELeaveApplication leaveApp = new ELeaveApplication();
                    leaveApp.LeaveAppID = oldRosterTable.LeaveAppID;
                    if (ELeaveApplication.db.select(dbConn, leaveApp))
                    {
                        if (leaveApp.EmpPayrollID <= 0)
                        {
                            ELeaveApplication.db.delete(dbConn, leaveApp);
                            //HROne.LeaveCalc.LeaveBalanceCalc leaaveBalCal = new HROne.LeaveCalc.LeaveBalanceCalc(dbConn, oldRosterTable.EmpID);
                            //leaaveBalCal.RecalculateAfter(oldRosterTable.RosterTableDate);
                        }
                    }
                }
            }

            ERosterTable.db.update(dbConn, rosterTable);

            //// Create resource based on the selected user
            ////Resource user = new Resource("User", int.Parse(UserDropDown.SelectedValue), UserDropDown.SelectedItem.Text);
            //DateTime start = RadScheduler1.DisplayToUtc(StartTime.SelectedDate.Value);
            //DateTime end = RadScheduler1.DisplayToUtc(EndTime.SelectedDate.Value);

            //if (EditedAppointmentID == null)
            //{
            //    // Insert
            //    Appointment appointment = new Appointment(null, start, end, DescriptionText.Text);
            //    //appointment.Resources.Add(user);

            //    RadScheduler1.InsertAppointment(appointment);
            //}
            //else
            //{
            //    Appointment appointment = RadScheduler1.Appointments.FindByID(EditedAppointmentID);
            //    Appointment appointmentToUpdate = RadScheduler1.PrepareToEdit(appointment, RadScheduler1.EditingRecurringSeries);

            //    appointmentToUpdate.Subject = DescriptionText.Text;
            //    appointmentToUpdate.Start = start;
            //    appointmentToUpdate.End = end;

            //    // Remove the existing user resource, if any
            //    Resource existingUser = appointmentToUpdate.Resources.GetResourceByType("User");
            //    if (existingUser != null)
            //    {
            //        appointmentToUpdate.Resources.Remove(existingUser);
            //    }
            //    //appointmentToUpdate.Resources.Add(user);

            //    RadScheduler1.UpdateAppointment(appointmentToUpdate);
            //}
        }
コード例 #10
0
        protected void PopulateEditForm()
        {
            WebFormUtils.loadValues(dbConn, RosterClientID, ERosterClient.VLRosterClient, new DBFilter());

            object dbObjectItem = HROne.Lib.Attendance.DataSource.RosterTableEvent.IDToDBObject(dbConn, Appointment.ID);

            if (dbObjectItem is ERosterTable)
            {
                ERosterTable rosterTable = (ERosterTable)dbObjectItem;
                Hashtable    values      = new Hashtable();
                ERosterTable.db.populate(rosterTable, values);

                Binding ebinding = new Binding(dbConn, ERosterTable.db);
                ebinding.add(RosterTableID);
                ebinding.add(EmpID);
                ebinding.add(RosterTableDate);
                ebinding.add(RosterTableOverrideInTime);
                ebinding.add(RosterTableOverrideOutTime);

                if (values["RosterCodeID"].Equals("0"))
                {
                    values.Remove("RosterCodeID");
                }
                else
                {
                    ebinding.add(new DropDownVLBinder(ERosterTable.db, RosterCodeID, ERosterCode.VLRosterCode));
                }
                ebinding.init(Request, Session);
                ebinding.toControl(values);
                EEmpPersonalInfo empInfo = new EEmpPersonalInfo();
                empInfo.EmpID = rosterTable.EmpID;
                if (EEmpPersonalInfo.db.select(dbConn, empInfo))
                {
                    EmpNo.Text   = empInfo.EmpNo;
                    EmpName.Text = empInfo.EmpEngFullNameWithAlias;
                }
                else
                {
                    EmpNo.Text   = string.Empty;
                    EmpName.Text = string.Empty;
                }
                ERosterCode rosterCode = new ERosterCode();
                rosterCode.RosterCodeID = rosterTable.RosterCodeID;
                ERosterCode.db.select(dbConn, rosterCode);
                if (rosterCode.RosterClientID > 0)
                {
                    RosterClientID.SelectedValue = rosterCode.RosterClientID.ToString();
                }

                RefreshClientSite(rosterCode.RosterClientID);

                if (rosterCode.RosterClientSiteID > 0)
                {
                    RosterClientSiteID.SelectedValue = rosterCode.RosterClientSiteID.ToString();
                }

                RefreshRosterCode(rosterCode.RosterClientSiteID);

                if (rosterTable.RosterTableOverrideInTime.Ticks.Equals(0))
                {
                    RosterTableOverrideInTime.Text = string.Empty;
                }
                if (rosterTable.RosterTableOverrideOutTime.Ticks.Equals(0))
                {
                    RosterTableOverrideOutTime.Text = string.Empty;
                }

                RefreshRosterTableInOutTime(rosterTable.RosterCodeID, false);
            }

            //if (item_ID != null)
            //{
            //    string[] id_Array = item_ID.ToString().Split(new char[] { '_' });

            //    if (id_Array.GetLength(0) == 2)
            //    {
            //        if (id_Array[0].Equals("RosterTable"))
            //        {
            //            ERosterTable rosterTable = new ERosterTable();
            //            rosterTable.RosterTableID = int.Parse(id_Array[1]);
            //            if (ERosterTable.db.select(rosterTable))
            //            {
            //                Binding ebinding = new Binding(ERosterTable.db);
            //                ebinding.add(RosterTableID);
            //                ebinding.add(EmpID);
            //                ebinding.add(RosterTableDate);
            //                ebinding.add(new DropDownVLBinder(ERosterTable.db, RosterCodeID, ERosterCode.VLRosterCode));
            //                ebinding.init(Request, Session);
            //                Hashtable values = new Hashtable();
            //                ERosterTable.db.populate(rosterTable, values);
            //                ebinding.toControl(values);

            //                EEmpPersonalInfo empInfo = new EEmpPersonalInfo();
            //                empInfo.EmpID = rosterTable.EmpID;
            //                if (EEmpPersonalInfo.db.select(empInfo))
            //                    EmpName.Text = empInfo.EmpEngFullNameWithAlias;
            //                else
            //                    EmpName.Text = string.Empty;

            //            }

            //            ERosterCode rosterCode = new ERosterCode();
            //            rosterCode.RosterCodeID = rosterTable.RosterCodeID;
            //            ERosterCode.db.select(rosterCode);
            //            if (rosterCode.RosterClientID > 0)
            //                RosterClientID.SelectedValue = rosterCode.RosterClientID.ToString();



            //            RefreshClientSite(rosterCode.RosterClientID);

            //            if (rosterCode.RosterClientSiteID > 0)
            //                RosterClientSiteID.SelectedValue = rosterCode.RosterClientSiteID.ToString();

            //            RefreshRosterCode(rosterCode.RosterClientSiteID);
            //        }
            //    }
            //}
        }
コード例 #11
0
    //protected void PopulateEditForm(Appointment editedAppointment)
    //{
    //    WebFormUtils.loadValues(RosterClientID, ERosterClient.VLRosterClient, new DBFilter());

    //    if (editedAppointment.ID != null)
    //    {
    //        string[] id_Array = editedAppointment.ID.ToString().Split(new char[] { '_' });

    //        if (id_Array.GetLength(0) == 2)
    //        {
    //            if (id_Array[0].Equals("RosterTable"))
    //            {
    //                ERosterTable rosterTable = new ERosterTable();
    //                rosterTable.RosterTableID = int.Parse(id_Array[1]);
    //                if (ERosterTable.db.select(rosterTable))
    //                {
    //                    Binding ebinding = new Binding(ERosterTable.db);
    //                    ebinding.add(RosterTableID);
    //                    ebinding.add(EmpID);
    //                    ebinding.add(RosterTableDate);
    //                    ebinding.add(new DropDownVLBinder(ERosterTable.db, RosterCodeID, ERosterCode.VLRosterCode));
    //                    ebinding.init(Request, Session);
    //                    Hashtable values = new Hashtable();
    //                    ERosterTable.db.populate(rosterTable, values);
    //                    ebinding.toControl(values);

    //                    EEmpPersonalInfo empInfo = new EEmpPersonalInfo();
    //                    empInfo.EmpID = rosterTable.EmpID;
    //                    if (EEmpPersonalInfo.db.select(empInfo))
    //                        EmpName.Text = empInfo.EmpEngFullNameWithAlias;
    //                    else
    //                        EmpName.Text = string.Empty;

    //                }

    //                ERosterCode rosterCode = new ERosterCode();
    //                rosterCode.RosterCodeID = rosterTable.RosterCodeID;
    //                ERosterCode.db.select(rosterCode);
    //                if (rosterCode.RosterClientID > 0)
    //                    RosterClientID.SelectedValue = rosterCode.RosterClientID.ToString();

    //                RefreshClientSite(rosterCode.RosterClientID);

    //                if (rosterCode.RosterClientSiteID > 0)
    //                    RosterClientSiteID.SelectedValue = rosterCode.RosterClientSiteID.ToString();

    //                RefreshRosterCode(rosterCode.RosterClientSiteID);
    //            }
    //        }
    //    }
    //}

    //protected void RefreshClientSite(int RosterClientID)
    //{
    //    string selected = RosterClientSiteID.SelectedValue;

    //    DBFilter rosterClientSiteFilter = new DBFilter();
    //    rosterClientSiteFilter.add(new Match("RosterClientID", RosterClientID));
    //    WebFormUtils.loadValues(RosterClientSiteID, ERosterClientSite.VLRosterClientSite, rosterClientSiteFilter, null, (string)selected, (string)"combobox.notselected");

    //}

    //protected void RefreshRosterCode(int RosterClientSiteID)
    //{
    //    string selected = RosterCodeID.SelectedValue;

    //    DBFilter rosterCodeFilter = new DBFilter();
    //    rosterCodeFilter.add(new Match("RosterClientSiteID", RosterClientSiteID));
    //    WebFormUtils.loadValues(RosterCodeID, ERosterCode.VLRosterCode, rosterCodeFilter, null, (string)selected, (string)"combobox.notselected");


    //}

    //protected void SubmitButton_Click(object sender, EventArgs e)
    //{
    //    ERosterTable rosterTable = new ERosterTable();

    //    Binding ebinding = new Binding(ERosterTable.db);
    //    ebinding.add(RosterTableID);
    //    ebinding.add(RosterTableDate);
    //    ebinding.add(EmpID);
    //    ebinding.add(new DropDownVLBinder(ERosterTable.db, RosterCodeID, ERosterCode.VLRosterCode));
    //    Hashtable values = new Hashtable();
    //    ebinding.toValues(values);
    //    ERosterTable.db.parse(values, rosterTable);

    //    ERosterTable.db.update(rosterTable);

    //    //// Create resource based on the selected user
    //    ////Resource user = new Resource("User", int.Parse(UserDropDown.SelectedValue), UserDropDown.SelectedItem.Text);
    //    //DateTime start = RadScheduler1.DisplayToUtc(StartTime.SelectedDate.Value);
    //    //DateTime end = RadScheduler1.DisplayToUtc(EndTime.SelectedDate.Value);

    //    //if (EditedAppointmentID == null)
    //    //{
    //    //    // Insert
    //    //    Appointment appointment = new Appointment(null, start, end, DescriptionText.Text);
    //    //    //appointment.Resources.Add(user);

    //    //    RadScheduler1.InsertAppointment(appointment);
    //    //}
    //    //else
    //    //{
    //    //    Appointment appointment = RadScheduler1.Appointments.FindByID(EditedAppointmentID);
    //    //    Appointment appointmentToUpdate = RadScheduler1.PrepareToEdit(appointment, RadScheduler1.EditingRecurringSeries);

    //    //    appointmentToUpdate.Subject = DescriptionText.Text;
    //    //    appointmentToUpdate.Start = start;
    //    //    appointmentToUpdate.End = end;

    //    //    // Remove the existing user resource, if any
    //    //    Resource existingUser = appointmentToUpdate.Resources.GetResourceByType("User");
    //    //    if (existingUser != null)
    //    //    {
    //    //        appointmentToUpdate.Resources.Remove(existingUser);
    //    //    }
    //    //    //appointmentToUpdate.Resources.Add(user);

    //    //    RadScheduler1.UpdateAppointment(appointmentToUpdate);
    //    //}
    //    RadScheduler1.Rebind();
    //    RadDock1.Closed = true;
    //}



    //protected void RosterClientID_SelectedIndexChanged(object sender, EventArgs e)
    //{
    //    string selected = RosterClientID.SelectedValue;
    //    int intRosterClientID;

    //    if (int.TryParse(selected, out intRosterClientID))
    //        RefreshClientSite(intRosterClientID);
    //    else
    //        RefreshClientSite(0);

    //    selected = RosterClientSiteID.SelectedValue;
    //    int intRosterClientSiteID;

    //    if (int.TryParse(selected, out intRosterClientSiteID))
    //        RefreshRosterCode(intRosterClientSiteID);
    //    else
    //        RefreshRosterCode(0);

    //}
    //protected void RosterClientSiteID_SelectedIndexChanged(object sender, EventArgs e)
    //{
    //    string selected = RosterClientSiteID.SelectedValue;
    //    int intRosterClientSiteID;

    //    if (int.TryParse(selected, out intRosterClientSiteID))
    //        RefreshRosterCode(intRosterClientSiteID);
    //    else
    //        RefreshRosterCode(0);

    //}
    //protected void RadDock1_DockPositionChanged(object sender, DockPositionChangedEventArgs e)
    //{
    //    Console.Write(e.ToString());
    //}


    //protected void RadCalendar1_SelectionChanged(object sender, Telerik.Web.UI.Calendar.SelectedDatesEventArgs e)
    //{
    //    if (!RadCalendar1.SelectedDate.Equals(DateTime.MinValue))
    //        RadScheduler1.SelectedDate = RadCalendar1.SelectedDate;
    //}
    //protected void RadScheduler1_NavigationComplete(object sender, SchedulerNavigationCompleteEventArgs e)
    //{
    //    RadCalendar1.SelectedDate = RadScheduler1.SelectedDate;
    //    RadCalendar1.FocusedDate = RadCalendar1.SelectedDate;
    //}
    protected void RadScheduler1_AppointmentDataBound(object sender, SchedulerEventArgs e)
    {
        //e.Appointment.ContextMenuID=
        e.Appointment.AllowDelete = false;


        if (e.Appointment != null)
        {
            HROne.Lib.Attendance.DataSource.RosterTableEvent rosterTableEvent = (HROne.Lib.Attendance.DataSource.RosterTableEvent)e.Appointment.DataItem;
            e.Appointment.ToolTip   = rosterTableEvent.ToolTip;
            e.Appointment.AllowEdit = false;

            if (rosterTableEvent.Id.StartsWith(HROne.Lib.Attendance.DataSource.RosterTableEvent.PUBLICHOLIDAY_PREFIX) ||
                rosterTableEvent.Id.StartsWith(HROne.Lib.Attendance.DataSource.RosterTableEvent.STATUTORYHOLIDAY_PREFIX))
            {
                e.Appointment.ForeColor = System.Drawing.Color.Red;
            }

            if (rosterTableEvent.IsCancel)
            {
                e.Appointment.ForeColor = System.Drawing.Color.Green;
            }

            //EEmpPositionInfo userEmpPos = AppUtils.GetLastPositionInfo(dbConn, e.Appointment.Start.Date, m_ESSUserID);
            object dbObjectItem = HROne.Lib.Attendance.DataSource.RosterTableEvent.IDToDBObject(dbConn, e.Appointment.ID);

            if (dbObjectItem is ERosterTable)
            {
                ERosterTable rosterTable = (ERosterTable)dbObjectItem;


                ERosterCode rosterCode = new ERosterCode();
                rosterCode.RosterCodeID = rosterTable.RosterCodeID;

                if (ERosterCode.db.select(dbConn, rosterCode))
                {
                    if (!string.IsNullOrEmpty(rosterCode.RosterCodeColorCode))
                    {
                        try
                        {
                            e.Appointment.BackColor = System.Drawing.ColorTranslator.FromHtml(rosterCode.RosterCodeColorCode);
                            e.Appointment.ForeColor = AppUtils.ComputeTextColor(e.Appointment.BackColor);
                        }
                        catch
                        {
                        }
                    }
                }

                DBFilter userRosterTableGroupListFilter = new DBFilter();
                userRosterTableGroupListFilter.add(new Match("EmpID", m_ESSUserID));
                userRosterTableGroupListFilter.add(new Match("EmpRosterTableGroupIsSupervisor", true));
                userRosterTableGroupListFilter.add(new Match("empRosterTableGroupEffFr", "<=", e.Appointment.Start.Date));
                OR orEmpPosEffToTerms = new OR();
                orEmpPosEffToTerms.add(new Match("empRosterTableGroupEffTo", ">=", e.Appointment.Start.Date));
                orEmpPosEffToTerms.add(new NullTerm("empRosterTableGroupEffTo"));
                userRosterTableGroupListFilter.add(orEmpPosEffToTerms);
                ArrayList empRosterTableGroupList = EEmpRosterTableGroup.db.select(dbConn, userRosterTableGroupListFilter);

                foreach (EEmpRosterTableGroup empRosterTableGroup in empRosterTableGroupList)
                {
                    DBFilter subordinateRosterTableGroupListFilter = new DBFilter();
                    subordinateRosterTableGroupListFilter.add(new Match("EmpID", rosterTable.EmpID));
                    subordinateRosterTableGroupListFilter.add(new Match("RosterTableGroupID", empRosterTableGroup.RosterTableGroupID));
                    subordinateRosterTableGroupListFilter.add(new Match("empRosterTableGroupEffFr", "<=", e.Appointment.Start.Date));
                    OR orSubOrdinateEmpPosEffToTerms = new OR();
                    orSubOrdinateEmpPosEffToTerms.add(new Match("empRosterTableGroupEffTo", ">=", e.Appointment.Start.Date));
                    orSubOrdinateEmpPosEffToTerms.add(new NullTerm("empRosterTableGroupEffTo"));
                    subordinateRosterTableGroupListFilter.add(orSubOrdinateEmpPosEffToTerms);

                    if (EEmpRosterTableGroup.db.count(dbConn, subordinateRosterTableGroupListFilter) > 0)
                    {
                        e.Appointment.AllowEdit = true;
                    }

                    //EEmpPositionInfo empPos = AppUtils.GetLastPositionInfo(dbConn, e.Appointment.Start.Date, rosterTable.EmpID);
                    //if (empPos != null)
                    //    if (empPos.RosterTableGroupID.Equals(userEmpPos.RosterTableGroupID))
                    //        e.Appointment.AllowEdit = true;
                    //    else
                    //        e.Appointment.AllowEdit = false;
                }
            }
        }
        if (RadScheduler1.SelectedView == SchedulerViewType.TimelineView)
        {
            if (RadScheduler1.Appointments.Count > 10)
            {
                RadScheduler1.Height = Unit.Parse("");
            }
        }
    }