Ejemplo n.º 1
0
    protected void Page_PreRender(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            if (CurID > 0)
            {
                loadObject();

                if (!string.IsNullOrEmpty(RosterCodeColorCode.Text))
                {
                    try
                    {
                        RosterCodeColorCode.BackColor = System.Drawing.ColorTranslator.FromHtml(RosterCodeColorCode.Text);
                        RosterCodeColorCode.ForeColor = AppUtils.ComputeTextColor(RosterCodeColorCode.BackColor);
                        //double brightness = RosterCodeColorCode.BackColor.GetBrightness();
                        //double hue = RosterCodeColorCode.BackColor.GetHue();
                        //double saturation = RosterCodeColorCode.BackColor.GetSaturation();
                        //if (brightness * saturation < 0.5)
                        //    RosterCodeColorCode.ForeColor = System.Drawing.Color.White;
                        //else
                        //    RosterCodeColorCode.ForeColor = System.Drawing.Color.Black;
                    }
                    catch
                    {
                    }
                }
            }
            else
            {
                toolBar.DeleteButton_Visible = false;
            }
        }
    }
Ejemplo n.º 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("");
            }
        }
    }
Ejemplo n.º 3
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("");
            }
        }
    }