Example #1
0
        protected void RadCalendar1_OnLoad(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var cSiteLocation = (new CSiteLocation()).Get(CurrentSiteLocationId);
                var holiday       = (new CHoliday()).Get(cSiteLocation.Province);
                foreach (var h in holiday)
                {
                    var cal = new RadCalendarDay();
                    cal.Date         = h.HolidayDate;
                    cal.IsSelectable = false;
                    cal.ToolTip      = h.Name + (h.Abbreviation == string.Empty ? string.Empty : " (" + h.Abbreviation + ")") + " " + h.HolidayDate.Date.ToShortDateString();
                    cal.IsDisabled   = true;
                    RadCalendar1.SpecialDays.Add(cal);
                }

                var vacationList = (new CVacation()).GetDetail(Convert.ToInt32(ViewState["UserId"]));
                foreach (var v in vacationList)
                {
                    // without rejected, canceled
                    if (v.ApprovalStatus != (int)CConstValue.ApprovalStatus.Rejected && v.ApprovalStatus != (int)CConstValue.ApprovalStatus.Canceled)
                    {
                        CVacationDetail vacationDetail     = new CVacationDetail();
                        var             vacationDetailList = vacationDetail.Get(v.VacationId);
                        foreach (VacationDetail vd in vacationDetailList)
                        {
                            // except selectedDays to speaciaDays for selecting
                            if (RadCalendar1.SelectedDates.ToArray().Any(x => x.Date == vd.Date))
                            {
                                continue;
                            }

                            var cal = new RadCalendarDay();
                            cal.Date         = vd.Date;
                            cal.IsSelectable = false;

                            var vacationDict = (new CDict()).GetDictByTypeAndValue(1376, v.VacationType);
                            var totalDays    = vacationDetailList.Count();

                            var requestDict = (new CDict()).GetDictByTypeAndValue(217, (int)v.ApprovalStatus);

                            cal.ToolTip = vd.Date.ToShortDateString() + " " + vacationDict.Name + " (" + (vd.IsFullDay ? totalDays : totalDays - 0.5) + ") [" + requestDict.Name + "] No : " + v.VacationId;

                            switch (v.VacationType)
                            {
                            case (int)CConstValue.VacationType.PaidVacationDay:
                                if (vd.IsFullDay)
                                {
                                    cal.TemplateID = "DayTemplatePaidFullDay";
                                }
                                else
                                {
                                    cal.TemplateID = "DayTemplatePaidHalfDay";
                                }
                                break;

                            case (int)CConstValue.VacationType.UnPaidVacationDay:
                                if (vd.IsFullDay)
                                {
                                    cal.TemplateID = "DayTemplateUnPaidFullDay";
                                }
                                else
                                {
                                    cal.TemplateID = "DayTemplateUnPaidHalfDay";
                                }
                                break;

                            case (int)CConstValue.VacationType.SickDay:
                                if (vd.IsFullDay)
                                {
                                    cal.TemplateID = "DayTemplateSickFullDay";
                                }
                                else
                                {
                                    cal.TemplateID = "DayTemplateSickHalfDay";
                                }
                                break;

                            case (int)CConstValue.VacationType.EntitlementDay:
                                if (vd.IsFullDay)
                                {
                                    cal.TemplateID = "DayTemplateEntitlementFullDay";
                                }
                                else
                                {
                                    cal.TemplateID = "DayTemplateEntitlementHalfDay";
                                }
                                break;
                            }

                            RadCalendar1.SpecialDays.Add(cal);
                        }
                    }
                }

                // select current date
                if (RadCalendar1.SelectedDates.Count > 0)
                {
                    RadCalendar1.FocusedDate = RadCalendar1.SelectedDates[0].Date;
                }
            }
        }
Example #2
0
        protected void RadCalendar1_OnLoad(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var cSiteLocation = (new CSiteLocation()).Get(CurrentSiteLocationId);
                var holiday       = (new CHoliday()).Get(cSiteLocation.Province);
                foreach (var h in holiday)
                {
                    var cal = new RadCalendarDay();
                    cal.Date         = h.HolidayDate;
                    cal.IsSelectable = false;
                    cal.ToolTip      = h.Name + (h.Abbreviation == string.Empty ? string.Empty : " (" + h.Abbreviation + ")") + " " + h.HolidayDate.Date.ToShortDateString();
                    cal.IsDisabled   = true;
                    RadCalendar1.SpecialDays.Add(cal);
                }

                var vacationList = (new CVacation()).GetDetail(Convert.ToInt32(ViewState["UserId"]));
                foreach (var v in vacationList)
                {
                    // without rejected, canceled
                    if (v.ApprovalStatus != (int)CConstValue.ApprovalStatus.Rejected && v.ApprovalStatus != (int)CConstValue.ApprovalStatus.Canceled)
                    {
                        CVacationDetail vacationDetail     = new CVacationDetail();
                        var             vacationDetailList = vacationDetail.Get(v.VacationId);
                        foreach (VacationDetail vd in vacationDetailList)
                        {
                            var cal = new RadCalendarDay();
                            cal.Date = vd.Date;

                            var cVacationDict = new CDict();
                            var vacationDict  = cVacationDict.GetDictByTypeAndValue(1376, v.VacationType);
                            var totalDays     = vacationDetailList.Count();

                            var cRequestDict = new CDict();
                            var requestDict  = cRequestDict.GetDictByTypeAndValue(217, (int)v.ApprovalStatus);

                            cal.ToolTip = vd.Date.ToShortDateString() + " " + vacationDict.Name + " (" + (vd.IsFullDay ? totalDays : totalDays - 0.5) + ") [" + requestDict.Name + "] No : " + v.VacationId;

                            switch (v.VacationType)
                            {
                            // Paid
                            case 0:
                                if (vd.IsFullDay)
                                {
                                    cal.TemplateID = "DayTemplatePaidFullDay";
                                }
                                else
                                {
                                    cal.TemplateID = "DayTemplatePaidHalfDay";
                                }
                                break;

                            // Unpaid
                            case 1:
                                if (vd.IsFullDay)
                                {
                                    cal.TemplateID = "DayTemplateUnPaidFullDay";
                                }
                                else
                                {
                                    cal.TemplateID = "DayTemplateUnPaidHalfDay";
                                }
                                break;

                            // SickDay
                            case 2:
                                if (vd.IsFullDay)
                                {
                                    cal.TemplateID = "DayTemplateSickFullDay";
                                }
                                else
                                {
                                    cal.TemplateID = "DayTemplateSickHalfDay";
                                }
                                break;

                            // Entitlement
                            case 3:
                                if (vd.IsFullDay)
                                {
                                    cal.TemplateID = "DayTemplateEntitlementFullDay";
                                }
                                else
                                {
                                    cal.TemplateID = "DayTemplateEntitlementHalfDay";
                                }
                                break;
                            }

                            RadCalendar1.SpecialDays.Add(cal);
                        }
                    }
                }

                // set this year jan 1
                RadCalendar1.FocusedDate = new DateTime(DateTime.Now.Year, 1, 1);
            }
        }
Example #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Id = Convert.ToInt32(Request["id"]);

            if (!IsPostBack)
            {
                var scriptManager = (RadScriptManager)Page.Master.FindControl("RadScriptManager1");
                //scriptManager.Scripts.Add(new ScriptReference() { Path = ResolveUrl("~/assets/js/jquery.printArea.js") });
                //scriptManager.RegisterPostBackControl(RadButtonFileDownload);

                var obj = new CVacation();
                var requestOrApprovalType = Request["requestOrApprovalType"];
                var approvalType          = Request["approvalType"];

                var buttonList = new List <string>();

                // new
                if (Request["createOrListType"] == "0")
                {
                    obj = obj.GetNewDocument(CurrentUserId);

                    //buttonList.Add("TempSave");
                    buttonList.Add("Request");
                    buttonList.Add("Close");

                    SetVisibleItems(true);
                }
                // select
                else
                {
                    // date
                    obj = new CVacation(Id);

                    // request list
                    if (requestOrApprovalType == "0")
                    {
                        // Revise
                        if (approvalType == ((int)CConstValue.ApprovalStatus.Revise).ToString())
                        {
                            buttonList.Add("Request");
                            buttonList.Add("Cancel");
                            buttonList.Add("Close");

                            SetVisibleItems(true);
                        }
                        // TempSave
                        else if (approvalType == string.Empty)
                        {
                            buttonList.Add("Request");
                            buttonList.Add("Cancel");
                            buttonList.Add("Close");

                            SetVisibleItems(true);
                        }
                        // Request
                        else if (approvalType == "1")
                        {
                            buttonList.Add("Cancel");
                            buttonList.Add("Close");

                            SetVisibleItems(false);
                        }
                        else
                        {
                            buttonList.Add("Close");

                            SetVisibleItems(false);
                        }
                    }
                    // approval
                    else if (requestOrApprovalType == "1")
                    {
                        // approved or rejected
                        if (approvalType == ((int)CConstValue.ApprovalStatus.Approved).ToString())
                        {
                            // permission
                            if (CurrentGroupId == (int)CConstValue.UserGroupForVacation.IT ||
                                CurrentGroupId == (int)CConstValue.UserGroupForVacation.HR)
                            {
                                buttonList.Add("Cancel");
                            }

                            buttonList.Add("Close");
                        }
                        else if (approvalType == ((int)CConstValue.ApprovalStatus.Rejected).ToString() ||
                                 approvalType == ((int)CConstValue.ApprovalStatus.Canceled).ToString())
                        {
                            buttonList.Add("Close");
                        }
                        else
                        {
                            var refundApproveInfo = new CGlobal();
                            var supervisor        = refundApproveInfo.CheckApprovalEnable((int)CConstValue.Approval.Vacation, Convert.ToInt32(Id));

                            if (CurrentUserId == supervisor)
                            {
                                buttonList.Add("Approve");
                                buttonList.Add("Reject");
                                buttonList.Add("Revise");
                                buttonList.Add("Close");
                            }
                            else
                            {
                                buttonList.Add("Close");
                            }
                        }

                        SetVisibleItems(false);
                    }
                    // Hire from HQ
                    else if (requestOrApprovalType == "2")
                    {
                        // permission
                        if (CurrentGroupId == (int)CConstValue.UserGroupForVacation.IT ||
                            CurrentGroupId == (int)CConstValue.UserGroupForVacation.HR)
                        {
                            buttonList.Add("Cancel");
                        }

                        buttonList.Add("Print");
                        buttonList.Add("Close");

                        SetVisibleItems(false);
                    }
                }

                foreach (RadToolBarItem item in RadToolBar1.Items)
                {
                    if (buttonList.Contains(item.Text))
                    {
                        item.Visible = true;
                    }
                    else
                    {
                        item.Visible = false;
                    }
                }

                var dt = new DataTable();
                dt.Columns.Add("DocNo");
                dt.Columns.Add("DateOfIssue");
                var newDr = dt.NewRow();
                newDr["DocNo"]       = obj.DocNo;
                newDr["DateOfIssue"] = obj.DateOfIssue;
                dt.Rows.Add(newDr);
                RadGridInfo.DataSource = dt;

                // Get Data
                var vacationObj = obj.Get(Id);
                if (vacationObj != null)
                {
                    RadComboBoxVacationType.SelectedIndex = vacationObj.VacationType;

                    CVacationDetail vacationDetailClass = new CVacationDetail();

                    foreach (VacationDetail vd in vacationDetailClass.Get(vacationObj.VacationId))
                    {
                        RadComboBoxDayType.SelectedIndex = vd.IsFullDay ? 0 : 1;
                        RadCalendar1.SelectedDates.Add(new RadDate(vd.Date));
                    }

                    ViewState["SelectedDates"] = RadCalendar1.SelectedDates.ToArray();
                    RadTextBoxRemark.Text      = vacationObj.Remark;

                    SetDataInformation();

                    // save for remain Days in load
                    ViewState["UserId"] = vacationObj.CreatedId;
                }
                else
                {
                    // save for remain Days in load
                    ViewState["UserId"] = CurrentUserId;
                }
            }
        }