protected void CopyCalendar(object sender, DirectEventArgs e)
        {
            string id = e.ExtraParams["caId"];
            CalendarDayListRequest req = new CalendarDayListRequest();

            req.CalendarId = id;
            req.Year       = CurrentYear.Text;
            ListResponse <Model.Attendance.CalendarDay> days = _branchService.ChildGetAll <Model.Attendance.CalendarDay>(req);

            if (!days.Success)
            {
                X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                X.Msg.Alert(Resources.Common.ErrorUpdatingRecord, GetGlobalResourceObject("Errors", days.ErrorCode) != null ? GetGlobalResourceObject("Errors", days.ErrorCode).ToString() + "<br>" + GetGlobalResourceObject("Errors", "ErrorLogId") + days.LogId : days.Summary).Show();
                return;
            }
            else if (days.count == 0)
            {
                X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                X.Msg.Alert(Resources.Common.ErrorUpdatingRecord, GetLocalResourceObject("NoDays").ToString()).Show();
                return;
            }
            else
            {
                PostRequest <Model.Attendance.CalendarDay[]> copy = new PostRequest <Model.Attendance.CalendarDay[]>();
                days.Items.ForEach(x => x.caId = Convert.ToInt32(CurrentCalendar.Text));
                copy.entity = days.Items.ToArray();
                PostResponse <Model.Attendance.CalendarDay[]> response = _branchService.ChildAddOrUpdate <Model.Attendance.CalendarDay[]>(copy);
                if (!response.Success)
                {
                    X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                    X.Msg.Alert(Resources.Common.ErrorUpdatingRecord, GetGlobalResourceObject("Errors", days.ErrorCode) != null ? GetGlobalResourceObject("Errors", days.ErrorCode).ToString() + "<br>" + GetGlobalResourceObject("Errors", "ErrorLogId") + days.LogId: days.Summary).Show();
                    return;
                }
                else
                {
                    X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                    X.Msg.Alert(Resources.Common.importCalendar, GetLocalResourceObject("CopiedSucc").ToString()).Show();
                    LoadDays();
                    return;
                }
            }
        }
        private void LoadDays()
        {
            CalendarDayListRequest req    = new CalendarDayListRequest();
            List <DayType>         dtypes = LoadDayTypes();

            req.CalendarId = CurrentCalendar.Text;
            req.Year       = CurrentYear.Text;
            if ((Convert.ToInt32(CurrentYear.Text) - 2016) % 4 != 0)
            {
                X.Call("setLeapDay");
            }
            ListResponse <Model.Attendance.CalendarDay> daysResponse = _branchService.ChildGetAll <Model.Attendance.CalendarDay>(req);

            if (!daysResponse.Success)
            {
                throw new Exception(daysResponse.Summary);
            }
            X.Call("init");
            foreach (var item in daysResponse.Items)
            {
                string dayId = item.dayId;
                string Month = dayId[4].ToString() + dayId[5].ToString();
                string Day   = dayId[6].ToString() + dayId[7].ToString();



                string color = dtypes.Where(x => x.recordId == item.dayTypeId.ToString()).First().color;
                X.Call("colorify", "td" + Month + Day, "#" + color.Trim(), DateTime.ParseExact(item.dayId, "yyyyMMdd", new CultureInfo("en")).ToString(_systemService.SessionHelper.GetDateformat()), GetGlobalResourceObject("Common", ((DayOfWeek)(item.dow % 7)).ToString() + "Text").ToString());



                //c.Style.Add("backgroud-color", "#" + color);
                //tbCalendar.Rows[int.Parse(Month)].Cells[int.Parse(Day)].InnerHtml = "<span >" + Month + Day + "</span>";// <span class='scheduleid'>" + item.scId.ToString() + "</span><span class='daytypeid'>" + item.dayTypeId.ToString() + "</span>";
                //tbCalendar.Rows[int.Parse(Month)].Cells[int.Parse(Day)].Attributes.Add("style", "background-color:#" + dtypes.Where(x => x.recordId == item.dayTypeId.ToString()).First().color) ;
            }
        }