コード例 #1
0
        /// <summary>
        /// Ensure the current user is authorized to view the calendar. If all are allowed then current user is not evaluated.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <returns></returns>
        private bool ValidateSecurity(HttpContext context)
        {
            int calendarId;

            if (request.QueryString["calendarid"] == null || !int.TryParse(request.QueryString["calendarId"], out calendarId))
            {
                SendNotAuthorized(context);
                return(false);
            }

            RockContext          rockContext          = new RockContext();
            EventCalendarService eventCalendarService = new EventCalendarService(rockContext);
            EventCalendar        eventCalendar        = eventCalendarService.Get(calendarId);

            if (eventCalendar == null)
            {
                SendBadRequest(context);
                return(false);
            }


            // Need to replace CurrentUser with the result of a person token, in the meantime this will always create a null person unless directly downloadng the ical when logged into the site
            UserLogin currentUser   = new UserLoginService(rockContext).GetByUserName(UserLogin.GetCurrentUserName());
            Person    currentPerson = currentUser != null ? currentUser.Person : null;
            var       isAuthorized  = eventCalendar.IsAuthorized(Rock.Security.Authorization.VIEW, currentPerson);

            if (isAuthorized)
            {
                return(true);
            }

            SendNotAuthorized(context);
            return(false);
        }
コード例 #2
0
        // devsolution 2003/6/17: Finished - Added items for calendar control

        /// <summary>
        /// devsolution 2003/6/17:
        /// Change to make a RenderEvents for modularity
        /// Routine to add show calendar logic
        /// And Clean up code as now the calendar next and previous
        /// controls must re-render the display and get the data again
        /// e.g. modularize the code
        /// </summary>
        /// <param name="DisplayMonth">Month to display 1=Jan, 2=Feb, etc</param>
        /// <param name="DisplayYear">Year to display YYYY, 2003 for 2003</param>
        private void RenderEvents(int DisplayMonth, int DisplayYear)
        {
            EventsDB events = new EventsDB();

            myDataList.RepeatDirection = (Settings["RepeatDirectionSetting"].ToString() == "Horizontal"
                                              ? RepeatDirection.Horizontal
                                              : RepeatDirection.Vertical);
            myDataList.RepeatColumns = Int32.Parse(Settings["RepeatColumns"].ToString());

            if (bool.Parse(Settings["ShowBorder"].ToString()))
            {
                //myDataList.BorderWidth=Unit.Pixel(1);
                myDataList.ItemStyle.BorderWidth = Unit.Pixel(1);
            }
            dsEventData           = events.GetEvents(ModuleID, Version);
            myDataList.DataSource = dsEventData;
            myDataList.DataBind();

            // devsolution 2003/6/17: Added items for calendar control
            if (bool.Parse(Settings["ShowCalendar"].ToString()))
            {
                CalendarPanel.Visible = true;
                string DisplayDate = string.Empty;
                // devsolution 2003/6/17: Must have Devsolution.Portal.dll in \bin for calendar display functionality
                EventCalendar eventcalendar = new EventCalendar();
                lblCalendar.Text =
                    eventcalendar.GenerateCalendar(ModuleID, DisplayMonth, DisplayYear, out DisplayDate, dsEventData);
                lblDisplayDate.Text = DisplayDate;
            }
            // devsolution 2003/6/17: Finished - Added items for calendar control

            myDataList.DataSource = dsEventData;
            myDataList.DataBind();
        }
コード例 #3
0
 public void EventCalendar_Anniversaries_WS_1084()
 {
     if (!DataParser.ReturnExecution("WS_1084"))
     {
         Assert.Ignore();
     }
     else
     {
         _file    = "Resources\\" + client + "\\TestsData\\WS_1084.xml";
         username = ProxyData.GetProxyUserName(_file);
         string username2        = ProxyData.GetProxySecondUserName(_file),
                award            = AwardData.GetAwardName(_file),
                msg              = AwardData.GetAwardMessage(_file);
         MainHomePage  home      = InitialPage.Go().Logon().ClickLogin();
         ProxyHomePage proxyPage = home.NavigateToAdminHomePage().LoginProxyAsuser();
         proxyPage.EnterUserName(username);
         home = proxyPage.ProxyToMainHomePage();
         Assert.AreEqual("You are proxied in under: " + username, home.GetProxyLoginMsg(),
                         "The message of proxy login is not correct");
         Assert.AreEqual("Exit Proxy", home.GetExitMsg(), "The exit proxy link is not present");
         EventCalendar eventPage = home.NavigateToEventCalendar();
         eventPage.ClickRecent();
         Assert.AreEqual(username2 + "\r\n12 year Anniversary", eventPage.GetNameList(6),
                         username2 + " is not present");
         NominationHomePage nomination =
             eventPage.clickSendAniversaryCard().SelectAward(award).FillMsg(msg).SelectImgs();
         nomination.EmailReward().ClickSendRecognition();
         Assert.AreEqual("Success!", nomination.GetSuccesMsg(), "Message its not success");
         Assert.AreEqual("FINISH", nomination.GetBtnFinishLabel(), "Button finish its not correct write");
         Assert.AreEqual("RECOGNIZE", nomination.GetBtnRecognizOtherLabel(),
                         "Button finish its not correct write");
     }
 }
コード例 #4
0
 private void monthView1_SelectionChanged(object sender, EventArgs e)
 {
     if (monthView1.SelectionEnd.Subtract(monthView1.SelectionStart).Days <= 70)
     {
         EventCalendar.SetViewRange(monthView1.SelectionStart, monthView1.SelectionEnd);
     }
 }
コード例 #5
0
        public async Task <EventCalendar> GetById(int Id, DataSource DataSource = DataSource.Cloud)
        {
            EventCalendar Event = null;

            if (DataSource == DataSource.Cloud)
            {
                Event = await HttpHelper.GetRequests <EventCalendar>(_methodPath + "/" + Id);

                if (Event is EventCalendar)
                {
                    var LocalEvent = LocalEvents.FirstOrDefault(p => p.Id == Event.Id);
                    if (LocalEvent is EventCalendar)
                    {
                        LocalEvents.Remove(LocalEvent);
                        LocalEvents.Add(Event);
                    }
                    else
                    {
                        LocalEvents.Add(Event);
                    }
                }
            }
            else
            {
                Event = LocalEvents.FirstOrDefault(p => p.Id == Id);
            }

            return(Event);
        }
コード例 #6
0
        public async Task AcceptInvatationAsync(int eventId, int userId)
        {
            var invitation = (await _invitationRepository.FindAllAsync(i => i.EventId == eventId && i.UserId == userId))
                             .FirstOrDefault();

            // TODO: Replace with another exception.

            if (invitation == null)
            {
                throw new NotFoundException();
            }

            var calendarId = await _calendarService.GetUserDefaultCalendarIdAsync(userId);

            // TODO: Replace with another exception.

            if (calendarId == null)
            {
                throw new NotFoundException();
            }

            var eventCalendar = new EventCalendar
            {
                CalendarId = calendarId.Value,
                EventId    = invitation.EventId,
                IsReadOnly = invitation.IsReadOnly
            };

            await _invitationRepository.RemoveAsync(invitation);

            await _eventCalendarRepository.CreateAsync(eventCalendar);

            await _eventCalendarRepository.SaveAsync();
        }
コード例 #7
0
        public ActionResult Create(EventCalendar item)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var calendarevent = _mapper.Map <Event>(item);
                    _api.CreateEvent(calendarevent, _calendarId);

                    return(RedirectToAction(nameof(Index)));
                }
                catch
                {
                    return(null);
                }
            }
            else

            {
                List <Client> clients = _context.Clients.ToList();
                ViewBag.Clients = clients.Select(s => new SelectListItem
                {
                    Text  = $"{s.Name} {s.Surname} : {s.PhoneNumber}",
                    Value = $"{s.Name} {s.Surname} : {s.PhoneNumber}"
                }
                                                 ).ToList();
                return(View(item));
            }
        }
コード例 #8
0
ファイル: CalendarDetail.ascx.cs プロジェクト: sjison/Rock
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Load" /> event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            if (!Page.IsPostBack)
            {
                ShowDetail(PageParameter("EventCalendarId").AsInteger());
            }
            else
            {
                if (pnlDetails.Visible)
                {
                    var           rockContext = new RockContext();
                    EventCalendar eventCalendar;
                    int?          itemId = PageParameter("EventCalendarId").AsIntegerOrNull();
                    if (itemId.HasValue && itemId > 0)
                    {
                        eventCalendar = new EventCalendarService(rockContext).Get(itemId.Value);
                    }
                    else
                    {
                        eventCalendar = new EventCalendar {
                            Id = 0
                        };
                    }

                    eventCalendar.LoadAttributes();
                    phAttributes.Controls.Clear();
                    Rock.Attribute.Helper.AddEditControls(eventCalendar, phAttributes, false, BlockValidationGroup);
                }

                ShowDialog();
            }
        }
コード例 #9
0
 public Task <EventCalendarInfo> GetEventCalendarDetail(int eventID, int userID)
 {
     return(Task.Run(() =>
     {
         using (MIUEntities db = new MIUEntities())
         {
             List <EventCalendarPhoto> dataList = db.EventCalendarPhotoes.Where(a => a.EventID == eventID).ToList();
             List <EventCalendarPhotoInfo> infoList = new List <EventCalendarPhotoInfo>();
             foreach (var data in dataList)
             {
                 EventCalendarPhotoInfo info = new EventCalendarPhotoInfo();
                 PropertyCopier <EventCalendarPhoto, EventCalendarPhotoInfo> .Copy(data, info);
                 info.PhotoName = MIUFileServer.GetFileUrl("EventCalendar/Photo", info.PhotoName);
                 infoList.Add(info);
             }
             string loginName = db.Users.Where(a => a.ID == userID).Select(a => a.LoginName).SingleOrDefault();
             EventCalendar eventData = db.EventCalendars.Where(a => a.ID == eventID).SingleOrDefault();
             EventCalendarInfo eventInfo = new EventCalendarInfo();
             PropertyCopier <EventCalendar, EventCalendarInfo> .Copy(eventData, eventInfo);
             eventInfo.IsFavorite = db.FavoriteLists.Any(a => a.FavoriteID == eventData.ID && a.UserID == userID && a.FavoriteType == "EventCalendar");
             eventInfo.IsGoing = db.EventCalendarReacts.Any(a => a.EventID == eventData.ID && a.LoginName == loginName && a.Action == "Going" && a.Flag == true);
             eventInfo.IsInterested = db.EventCalendarReacts.Any(a => a.EventID == eventData.ID && a.LoginName == loginName && a.Action == "Interested" && a.Flag == true);
             eventInfo.TotalGoing = db.EventCalendarReacts.Where(a => a.EventID == eventData.ID && a.Action == "Going" && a.Flag == true).Count();
             eventInfo.TotalInterested = db.EventCalendarReacts.Where(a => a.EventID == eventData.ID && a.Action == "Interested" && a.Flag == true).Count();
             eventInfo.CoverPhotoPath = MIUFileServer.GetFileUrl("EventCalendar/Photo", infoList.Where(a => a.IsCover == true).Select(a => a.PhotoName).SingleOrDefault());
             eventInfo.photoList = infoList;
             return eventInfo;
         }
     }));
 }
コード例 #10
0
ファイル: CalendarDetail.ascx.cs プロジェクト: ewin66/rockrms
        /// <summary>
        /// Handles the Click event of the btnDelete control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            using (var rockContext = new RockContext())
            {
                EventCalendarService eventCalendarService = new EventCalendarService(rockContext);
                AuthService          authService          = new AuthService(rockContext);
                EventCalendar        eventCalendar        = eventCalendarService.Get(int.Parse(hfEventCalendarId.Value));

                if (eventCalendar != null)
                {
                    bool adminAllowed = UserCanAdministrate || eventCalendar.IsAuthorized(Authorization.ADMINISTRATE, CurrentPerson);
                    if (!adminAllowed)
                    {
                        mdDeleteWarning.Show("You are not authorized to delete this calendar.", ModalAlertType.Information);
                        return;
                    }

                    string errorMessage;
                    if (!eventCalendarService.CanDelete(eventCalendar, out errorMessage))
                    {
                        mdDeleteWarning.Show(errorMessage, ModalAlertType.Information);
                        return;
                    }

                    eventCalendarService.Delete(eventCalendar);

                    rockContext.SaveChanges();
                }
            }

            NavigateToParentPage();
        }
コード例 #11
0
ファイル: DateEventWindow.cs プロジェクト: wee2tee/SN_Net
 public DateEventWindow(CustomDateEvent2 cde, bool begin_edit_at_first_show, EventCalendar ev)
     : this()
 {
     this.cde = cde;
     this.begin_edit_at_first_show = begin_edit_at_first_show;
     this.current_event = ev;
 }
コード例 #12
0
        public void ShouldReturnEmptyStringForBlankDates()
        {
            var eventCalendar = new EventCalendar();

            var result = eventCalendar.GetCustomEventFilterName();

            result.Should().Be(string.Empty);
        }
コード例 #13
0
        public void ShouldReturnFalseForNonExistingCategory()
        {
            var eventCalendar = new EventCalendar(new List <Event>(), new List <string> {
                "test1", "test2"
            });

            eventCalendar.DoesCategoryExist("test").Should().BeFalse();
        }
コード例 #14
0
        public ActionResult DeleteConfirmed(int id)
        {
            EventCalendar eventCalendar = db.EventCalendars.Find(id);

            db.EventCalendars.Remove(eventCalendar);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #15
0
        private EventDto GetEventDto(Event e, EventCalendar c)
        {
            var data = new EventDto()
            {
                ID                = e.EventID.ToString(),
                CalendarId        = c.EventCalendarID.ToString(),
                IsAllDay          = e.EventIsAllDay,
                BgColor           = c.EventCalendarBgColor,
                BorderColor       = c.EventCalendarBorderColor,
                Color             = c.EventCalendarColor,
                Location          = e.EventLocation,
                Title             = e.EventName,
                Url               = pageUrlRetriever.Retrieve(e).AbsoluteUrl,
                Start             = e.EventStart.ToString("yyyy-MM-ddTHH:mm:ss"),
                End               = e.EventIsAllDay ? e.EventStart.ToString("yyyy-MM-ddTHH:mm:ss") : e.EventEnd.ToString("yyyy-MM-ddTHH:mm:ss"),
                ShowAttendeeCount = c.EventCalendarShowAttendeeCount,
                ShowAttendeeNames = c.EventCalendarShowAttendeeNames,
                Summary           = e.EventSummary
            };

            // Get attendee count
            IEnumerable <EventAttendeeInfo> attendees = null;

            if (c.EventCalendarShowAttendeeCount && e.EventCapacity > 0)
            {
                attendees = EventAttendeeInfo.Provider.Get()
                            .WhereEquals(nameof(EventAttendeeInfo.NodeID), e.NodeID)
                            .Column(nameof(EventAttendeeInfo.ContactID));
                data.AttendeeCount = attendees.Count();
                data.Capacity      = e.EventCapacity;
            }

            // Get contacts attending event
            if (c.EventCalendarShowAttendeeNames)
            {
                if (attendees is null)
                {
                    attendees = EventAttendeeInfo.Provider.Get()
                                .WhereEquals(nameof(EventAttendeeInfo.NodeID), e.NodeID)
                                .Column(nameof(EventAttendeeInfo.ContactID));
                }

                // Get contacts in attendee list
                var contactIds = attendees.Select(a => a.ContactID).ToList();
                var contacts   = ContactInfo.Provider.Get()
                                 .WhereIn(nameof(ContactInfo.ContactID), contactIds)
                                 .Columns(nameof(ContactInfo.ContactFirstName), nameof(ContactInfo.ContactLastName));

                if (contacts.Count > 0)
                {
                    var names = contacts.Select(c => $"{c.ContactFirstName} {c.ContactLastName}").ToArray();
                    data.AttendeeNames = names.Join(", ");
                }
            }

            return(data);
        }
コード例 #16
0
    public List <EventCalendar> GetEventCalendarData(int empid)
    {
        List <EventCalendar> eventlist = new List <EventCalendar>();

        con.Open();
        SqlCommand     sql_com = new SqlCommand("Select_Detail_EvenCalendar_EmpID", con);
        SqlDataAdapter adapter = new SqlDataAdapter(sql_com);

        try
        {
            adapter.SelectCommand             = sql_com;
            adapter.SelectCommand.CommandType = CommandType.StoredProcedure;
            adapter.SelectCommand.Parameters.AddWithValue("@EmpID", empid);
            DataTable ds = new DataTable();
            adapter.Fill(ds);
            sql_com.ExecuteNonQuery();

            foreach (DataRow item in ds.Rows)
            {
                eventcalender = new EventCalendar()
                {
                    Detail_Event_No   = item["Detail_Event_No"].ToString(),
                    Event_No          = item["Event_No"].ToString(),
                    Emp_id            = Convert.ToInt32(item["Emp_id"].ToString()),
                    Event_Place       = item["Event_Place"].ToString(),
                    Event_TimeStart   = item["Event_TimeStart"].ToString() == string.Empty ? DateTime.MinValue : Convert.ToDateTime(item["Event_TimeStart"].ToString()),
                    Event_TimeEnd     = item["Event_TimeEnd"].ToString() == string.Empty ? DateTime.MinValue : Convert.ToDateTime(item["Event_TimeEnd"].ToString()),
                    TimeStart         = item["TimeStart"].ToString() == string.Empty ? DateTime.MinValue : Convert.ToDateTime(item["TimeStart"].ToString()),
                    TimeEnd           = item["TimeEnd"].ToString() == string.Empty ? DateTime.MinValue : Convert.ToDateTime(item["TimeEnd"].ToString()),
                    Event_Date        = item["Event_Date"].ToString() == string.Empty ? DateTime.MinValue : Convert.ToDateTime(item["Event_Date"].ToString()),
                    EmpName           = item["EmpName"].ToString(),
                    NickName          = item["NickName"].ToString(),
                    Tel               = item["Tel"].ToString(),
                    Team              = item["Team"].ToString(),
                    companybranchname = item["companybranchname"].ToString(),
                    ID_SC             = item["ID_SC"].ToString() == string.Empty ? 0 : Convert.ToInt32(item["ID_SC"]),
                    PictureStart      = item["PictureStart"].ToString(),
                    PictureEnd        = item["PictureEnd"].ToString(),
                    LatitudeIn        = item["LatitudeIn"].ToString(),
                    LongitudeIn       = item["LongitudeIn"].ToString(),
                    LatitudeOut       = item["LatitudeOut"].ToString(),
                    LongitudeOut      = item["LongitudeOut"].ToString(),
                    ID_CCW            = item["ID_CCW"].ToString() == string.Empty ? null : item["ID_CCW"].ToString(),
                };
                eventlist.Add(eventcalender);
            }
        }
        catch (Exception)
        {
            eventlist = new List <EventCalendar>();
        }
        finally
        {
            con.Close();
        }
        return(eventlist);
    }
コード例 #17
0
 private void PlaceItems()
 {
     foreach (CalendarItem item in _items)
     {
         if (EventCalendar.ViewIntersects(item))
         {
             EventCalendar.Items.Add(item);
         }
     }
 }
コード例 #18
0
        public IActionResult Edit(EventCalendar model)
        {
            if (ModelState.IsValid)
            {
                _eventCalendarRepo.Update(model);
                return RedirectToAction("Index");
            }

            return View(model);
        }
コード例 #19
0
        public ActionResult Delete(int id)
        {
            using (BusinessDataBaseEntities db = new BusinessDataBaseEntities())
            {
                EventCalendar ca = db.EventCalendars.Where(x => x.CalendarID == id).FirstOrDefault <EventCalendar>();
                db.EventCalendars.Remove(ca);
                db.SaveChanges();

                return(Json(new { success = true, message = "刪除成功" }, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #20
0
ファイル: EventsController.cs プロジェクト: Raakost/OSG
        // GET: Events
        public ActionResult Index(DateTime?month)
        {
            if (!month.HasValue)
            {
                month = DateTime.Now;
            }
            var ec = new EventCalendar();

            ec.Month  = month.Value;
            ec.Events = facade.GetEventGateway().ReadByMonth(month.Value);
            return(View(ec));
        }
コード例 #21
0
        public List <Event> TodaysEvents(Settlement.Settlement settlement)
        {
            var today = settlement.TodaysDate.DaysSinceSettlement;

            PurgeYesterday(today);
            //Generate a new event if there isn't one
            if (!EventCalendar.ContainsKey(today))
            {
                Generate(settlement);
            }
            return(EventCalendar[today]);
        }
コード例 #22
0
 public ActionResult Edit([Bind(Include = "CalendarID,employeeID,Subject,DepartmentID,StartTime,EndTime,Location,Description,IsImportant,IsFullday")] EventCalendar eventCalendar)
 {
     if (ModelState.IsValid)
     {
         db.Entry(eventCalendar).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.DepartmentID = new SelectList(db.Departments, "departmentID", "name", eventCalendar.DepartmentID);
     ViewBag.employeeID   = new SelectList(db.Employees, "employeeID", "EmployeeName", eventCalendar.employeeID);
     return(View(eventCalendar));
 }
コード例 #23
0
ファイル: CalendarDetail.ascx.cs プロジェクト: ewin66/rockrms
        /// <summary>
        /// Shows the readonly details.
        /// </summary>
        /// <param name="eventCalendar">The event calendar.</param>
        private void ShowReadonlyDetails(EventCalendar eventCalendar)
        {
            SetEditMode(false);

            hfEventCalendarId.SetValue(eventCalendar.Id);
            EventAttributesState = null;
            ContentChannelsState = null;

            lReadOnlyTitle.Text = eventCalendar.Name.FormatAsHtmlTitle();

            lCalendarIcon.Text             = string.Format("<i class='{0}'></i>", string.IsNullOrWhiteSpace(eventCalendar.IconCssClass) ? "fa fa-calendar" : eventCalendar.IconCssClass);
            lEventCalendarDescription.Text = eventCalendar.Description;
        }
コード例 #24
0
        private RandomEvent Generate(Settlement.Settlement settlement)
        {
            var today  = settlement.TodaysDate.DaysSinceSettlement;
            var rarity =
                RandomUtil.WeightedPercentGet(EventRarity.Rarities, null, eventRarity => eventRarity.PercentChance);
            var ev = !(rarity == null) ? RandomUtil.Get(RandomEventArrays[rarity].Where(ev => ev.IsAvailable(settlement)).ToList()) : null;

            //Add Today's Event to Calendar if not null
            EventCalendar.Add(today, ev != null ? new List <Event> {
                ev
            } : new List <Event>());
            return(ev);
        }
コード例 #25
0
        public void ShouldReturnDateRangeForCustomDate()
        {
            var eventCalendar = new EventCalendar
            {
                DateRange = "customdate",
                DateFrom  = new DateTime(2016, 01, 01),
                DateTo    = new DateTime(2016, 01, 10)
            };

            var result = eventCalendar.GetCustomEventFilterName();

            result.Should().Be("01/01/2016 to 10/01/2016");
        }
コード例 #26
0
        private EventCalendar ResolveCalendarSettingOrThrow(RockContext rockContext, string calendarSettingValue)
        {
            var calendarService = new EventCalendarService(rockContext);

            EventCalendar calendar = null;

            // Verify that a calendar reference has been provided.
            if (string.IsNullOrWhiteSpace(calendarSettingValue))
            {
                throw new Exception($"A calendar reference must be specified.");
            }

            // Get by ID.
            var calendarId = calendarSettingValue.AsIntegerOrNull();

            if (calendarId != null)
            {
                calendar = calendarService.Get(calendarId.Value);
            }

            // Get by Guid.
            if (calendar == null)
            {
                var calendarGuid = calendarSettingValue.AsGuidOrNull();

                if (calendarGuid != null)
                {
                    calendar = calendarService.Get(calendarGuid.Value);
                }
            }

            // Get By Name.
            if (calendar == null)
            {
                var calendarName = calendarSettingValue.ToString();

                if (!string.IsNullOrWhiteSpace(calendarName))
                {
                    calendar = calendarService.Queryable()
                               .Where(x => x.Name != null && x.Name.Equals(calendarName, StringComparison.OrdinalIgnoreCase))
                               .FirstOrDefault();
                }
            }

            if (calendar == null)
            {
                throw new Exception($"Cannot find a calendar matching the reference \"{ calendarSettingValue }\".");
            }

            return(calendar);
        }
コード例 #27
0
        static void Main(string[] args)
        {
            var event1 = new Event()
            {
                Title = "Event 1"
            };
            var eventCalendar  = new EventCalendar();                    //publisher
            var mailService    = new MailService();                      // subscriber
            var messageService = new MessageService();                   //subscriber

            eventCalendar.EventCreated += mailService.OnEventCreated;    //registers the handler for the event. This is a pointer to a method
            eventCalendar.EventCreated += messageService.OnEventCreated; //registers the handler for the event. This is a pointer to a method
            eventCalendar.Create(event1);
        }
コード例 #28
0
        // GET: EventCalendars/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            EventCalendar eventCalendar = db.EventCalendars.Find(id);

            if (eventCalendar == null)
            {
                return(HttpNotFound());
            }
            return(View(eventCalendar));
        }
コード例 #29
0
        public IActionResult Create(EventCalendar model)
        {
            if (ModelState.IsValid)
            {
                try {
                    _eventCalendarRepo.Add(model);
                    return RedirectToAction("Index");
                }
                catch (Exception ex) {
                    throw ex;
                }
            }

            return View();
        }
コード例 #30
0
        public static string GetEventCalendarTimeString(this EventCalendar ev)
        {
            TimeSpan to_time    = new TimeSpan(Convert.ToInt32(ev.to_time.Split(':')[0]), Convert.ToInt32(ev.to_time.Split(':')[1]), 0);
            TimeSpan from_time  = new TimeSpan(Convert.ToInt32(ev.from_time.Split(':')[0]), Convert.ToInt32(ev.from_time.Split(':')[1]), 0);
            DateTime event_date = DateTime.Parse(ev.date, CultureInfo.GetCultureInfo("en-US"), DateTimeStyles.None);

            if (from_time.Hours <= 12 && to_time.Hours >= 13)
            {
                return(((to_time - from_time - TimeSpan.Parse("01:00:00")).Hours >= 1 ? (to_time - from_time - TimeSpan.Parse("01:00:00")).Hours.ToString() + ((to_time - from_time - TimeSpan.Parse("01:00:00")).Minutes > 1 ? ":" + (to_time - from_time - TimeSpan.Parse("01:00:00")).Minutes.ToString() + " ชม." : " ชม.") : (to_time - from_time - TimeSpan.Parse("01:00:00")).Minutes.ToString() + " นาที") + ((event_date.GetDayIntOfWeek() >= 2 && event_date.GetDayIntOfWeek() <= 6) && (from_time.Equals(TimeSpan.Parse("08:30:00")) && to_time.Equals(TimeSpan.Parse("17:30:00"))) ? "(เต็มวัน)" : "(" + from_time.ToString().Substring(0, 5) + " - " + to_time.ToString().Substring(0, 5) + ")"));
            }
            else
            {
                return(((to_time - from_time).Hours >= 1 ? (to_time - from_time).Hours.ToString() + ((to_time - from_time).Minutes > 1 ? ":" + (to_time - from_time).Minutes.ToString() + " ชม." : " ชม.") : (to_time - from_time).Minutes.ToString() + " นาที") + ((event_date.GetDayIntOfWeek() >= 2 && event_date.GetDayIntOfWeek() <= 6) && (from_time.Equals(TimeSpan.Parse("08:30:00")) && to_time.Equals(TimeSpan.Parse("17:30:00"))) ? "(เต็มวัน)" : "(" + from_time.ToString().Substring(0, 5) + " - " + to_time.ToString().Substring(0, 5) + ")"));
            }
        }
コード例 #31
0
        public async Task ShouldReturnCurrentURLForPagination()
        {
            // Arrange
            int numItems   = 10;
            var controller = SetUpController(numItems);
            var model      = new EventCalendar()
            {
                FromSearch = true
            };

            // Act
            await controller.Index(model, 0, 12);

            // Assert
            model.Pagination.CurrentUrl.Should().NotBeNull();
        }
コード例 #32
0
        /// <summary>
        /// Loads the state details.
        /// </summary>
        /// <param name="eventCalendar">The event calendar.</param>
        /// <param name="rockContext">The rock context.</param>
        private void LoadStateDetails( EventCalendar eventCalendar, RockContext rockContext )
        {
            var attributeService = new AttributeService( rockContext );
            AttributesState = attributeService
                .GetByEntityTypeId( new EventCalendarItem().TypeId ).AsQueryable()
                .Where( a =>
                    a.EntityTypeQualifierColumn.Equals( "EventCalendarId", StringComparison.OrdinalIgnoreCase ) &&
                    a.EntityTypeQualifierValue.Equals( eventCalendar.Id.ToString() ) )
                .OrderBy( a => a.Order )
                .ThenBy( a => a.Name )
                .ToList();

            ContentChannelsState = new Dictionary<Guid,string>();
            new EventCalendarContentChannelService( rockContext )
                .Queryable()
                .Where( c => c.EventCalendarId == eventCalendar.Id )
                .ToList()
                .ForEach( c => ContentChannelsState.Add( c.ContentChannel.Guid, c.ContentChannel.Name ) );
        }
コード例 #33
0
        /// <summary>
        /// Shows the edit details.
        /// </summary>
        /// <param name="eventCalendar">the event calendar</param>
        private void ShowEditDetails( EventCalendar eventCalendar, RockContext rockContext )
        {
            if ( eventCalendar == null )
            {
                eventCalendar = new EventCalendar();
            }

            if ( eventCalendar.Id == 0 )
            {
                lReadOnlyTitle.Text = ActionTitle.Add( EventCalendar.FriendlyTypeName ).FormatAsHtmlTitle();
            }
            else
            {
                lReadOnlyTitle.Text = eventCalendar.Name.FormatAsHtmlTitle();
            }

            lCalendarIcon.Text = string.Format( "<i class='{0}'></i>", string.IsNullOrWhiteSpace( eventCalendar.IconCssClass ) ? "fa fa-calendar" : eventCalendar.IconCssClass );

            SetEditMode( true );

            // General
            cbActive.Checked = eventCalendar.IsActive;
            tbName.Text = eventCalendar.Name;
            tbDescription.Text = eventCalendar.Description;
            tbIconCssClass.Text = eventCalendar.IconCssClass;

            BindAttributesGrid();

            BindContentChannelsGrid();

            ddlContentChannel.DataSource = new ContentChannelService( rockContext )
                .Queryable()
                .Select( c => new
                {
                    c.Guid,
                    c.Name
                } )
                .OrderBy( c => c.Name )
                .ToList();

            ddlContentChannel.DataBind();
        }
コード例 #34
0
        /// <summary>
        /// Shows the edit.
        /// </summary>
        /// <param name="eventCalendarId">The Event Calendar Type identifier.</param>
        public void ShowDetail( int eventCalendarId )
        {
            pnlDetails.Visible = false;

            EventCalendar eventCalendar = null;
            var rockContext = new RockContext();

            if ( !eventCalendarId.Equals( 0 ) )
            {
                eventCalendar = GetEventCalendar( eventCalendarId, rockContext );
            }

            if ( eventCalendar == null )
            {
                eventCalendar = new EventCalendar { Id = 0 };
            }

            // Admin rights are needed to edit a calendar ( Edit rights only allow adding/removing items )
            bool adminAllowed = UserCanAdministrate || eventCalendar.IsAuthorized( Authorization.ADMINISTRATE, CurrentPerson );

            pnlDetails.Visible = true;
            hfEventCalendarId.Value = eventCalendar.Id.ToString();

            bool readOnly = false;

            nbEditModeMessage.Text = string.Empty;
            if ( !adminAllowed )
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed( EventCalendar.FriendlyTypeName );
            }

            if ( readOnly )
            {
                btnEdit.Visible = false;
                btnDelete.Visible = false;
                btnSecurity.Visible = false;
                ShowReadonlyDetails( eventCalendar );
            }
            else
            {
                btnEdit.Visible = true;
                btnDelete.Visible = true;
                btnSecurity.Visible = true;

                btnSecurity.Title = "Secure " + eventCalendar.Name;
                btnSecurity.EntityId = eventCalendar.Id;

                if ( !eventCalendarId.Equals( 0 ) )
                {
                    ShowReadonlyDetails( eventCalendar );
                }
                else
                {
                    LoadStateDetails( eventCalendar, rockContext );
                    ShowEditDetails( eventCalendar, rockContext );
                }
            }
        }
コード例 #35
0
        /// <summary>
        /// Handles the Click event of the btnSave control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void btnSave_Click( object sender, EventArgs e )
        {
            EventCalendar eventCalendar;
            using ( var rockContext = new RockContext() )
            {
                EventCalendarService eventCalendarService = new EventCalendarService( rockContext );
                EventCalendarContentChannelService eventCalendarContentChannelService = new EventCalendarContentChannelService( rockContext );
                ContentChannelService contentChannelService = new ContentChannelService( rockContext );
                AttributeService attributeService = new AttributeService( rockContext );
                AttributeQualifierService qualifierService = new AttributeQualifierService( rockContext );

                int eventCalendarId = int.Parse( hfEventCalendarId.Value );

                if ( eventCalendarId == 0 )
                {
                    eventCalendar = new EventCalendar();
                    eventCalendarService.Add( eventCalendar );
                }
                else
                {
                    eventCalendar = eventCalendarService.Get( eventCalendarId );
                }

                eventCalendar.IsActive = cbActive.Checked;
                eventCalendar.Name = tbName.Text;
                eventCalendar.Description = tbDescription.Text;
                eventCalendar.IconCssClass = tbIconCssClass.Text;

                if ( !eventCalendar.IsValid )
                {
                    // Controls will render the error messages
                    return;
                }

                // need WrapTransaction due to Attribute saves
                rockContext.WrapTransaction( () =>
                {
                    rockContext.SaveChanges();

                    var dbChannelGuids = eventCalendarContentChannelService.Queryable()
                        .Where( c => c.EventCalendarId == eventCalendar.Id )
                        .Select( c => c.Guid )
                        .ToList();

                    var uiChannelGuids = ContentChannelsState.Select( c => c.Key ).ToList();

                    var toDelete = eventCalendarContentChannelService
                        .Queryable()
                        .Where( c =>
                            dbChannelGuids.Contains( c.Guid ) &&
                            !uiChannelGuids.Contains( c.Guid ));

                    eventCalendarContentChannelService.DeleteRange( toDelete );
                    contentChannelService.Queryable()
                        .Where( c =>
                            uiChannelGuids.Contains( c.Guid ) &&
                            !dbChannelGuids.Contains( c.Guid ) )
                        .ToList()
                        .ForEach( c =>
                        {
                            var eventCalendarContentChannel = new EventCalendarContentChannel();
                            eventCalendarContentChannel.EventCalendarId = eventCalendar.Id;
                            eventCalendarContentChannel.ContentChannelId = c.Id;
                            eventCalendarContentChannelService.Add( eventCalendarContentChannel );
                        } );

                    rockContext.SaveChanges();

                    /* Save Attributes */
                    string qualifierValue = eventCalendar.Id.ToString();
                    SaveAttributes( new EventCalendarItem().TypeId, "EventCalendarId", qualifierValue, AttributesState, rockContext );

                    // Reload calendar and make sure that the person who may have just added a calendar has security to view/edit/administrate the calendar
                    eventCalendar = eventCalendarService.Get( eventCalendar.Id );
                    if ( eventCalendar != null )
                    {
                        if ( !eventCalendar.IsAuthorized( Authorization.VIEW, CurrentPerson ) )
                        {
                            eventCalendar.AllowPerson( Authorization.VIEW, CurrentPerson, rockContext );
                        }
                        if ( !eventCalendar.IsAuthorized( Authorization.EDIT, CurrentPerson ) )
                        {
                            eventCalendar.AllowPerson( Authorization.EDIT, CurrentPerson, rockContext );
                        }
                        if ( !eventCalendar.IsAuthorized( Authorization.ADMINISTRATE, CurrentPerson ) )
                        {
                            eventCalendar.AllowPerson( Authorization.ADMINISTRATE, CurrentPerson, rockContext );
                        }
                    }

                } );
            }

            // Redirect back to same page so that item grid will show any attributes that were selected to show on grid
            var qryParams = new Dictionary<string, string>();
            qryParams["EventCalendarId"] = eventCalendar.Id.ToString();
            NavigateToPage( RockPage.Guid, qryParams );
        }
コード例 #36
0
        // devsolution 2003/6/17: Finished - Added items for calendar control
        /// <summary>
        /// devsolution 2003/6/17:
        /// Change to make a RenderEvents for modularity
        /// Routine to add show calendar logic
        /// And Clean up code as now the calendar next and previous
        /// controls must re-render the display and get the data again
        /// e.g. modularize the code
        /// </summary>
        /// <param name="DisplayMonth">Month to display 1=Jan, 2=Feb, etc</param>
        /// <param name="DisplayYear">Year to display YYYY, 2003 for 2003</param>
        private void RenderEvents(int DisplayMonth, int DisplayYear)
        {
            EventsDB events = new EventsDB();

            myDataList.RepeatDirection = (Settings["RepeatDirectionSetting"].ToString() == "Horizontal"
                                              ? RepeatDirection.Horizontal
                                              : RepeatDirection.Vertical);
            myDataList.RepeatColumns = Int32.Parse(Settings["RepeatColumns"].ToString());

            if (bool.Parse(Settings["ShowBorder"].ToString()))
            {
                //myDataList.BorderWidth=Unit.Pixel(1);
                myDataList.ItemStyle.BorderWidth = Unit.Pixel(1);
            }
            dsEventData = events.GetEvents(ModuleID, Version);
            myDataList.DataSource = dsEventData;
            myDataList.DataBind();

            // devsolution 2003/6/17: Added items for calendar control
            if (bool.Parse(Settings["ShowCalendar"].ToString()))
            {
                CalendarPanel.Visible = true;
                string DisplayDate = string.Empty;
                // devsolution 2003/6/17: Must have Devsolution.Portal.dll in \bin for calendar display functionality
                EventCalendar eventcalendar = new EventCalendar();
                lblCalendar.Text =
                    eventcalendar.GenerateCalendar(ModuleID, DisplayMonth, DisplayYear, out DisplayDate, dsEventData);
                lblDisplayDate.Text = DisplayDate;
            }
            // devsolution 2003/6/17: Finished - Added items for calendar control

            myDataList.DataSource = dsEventData;
            myDataList.DataBind();
        }
コード例 #37
0
 /// <summary>
 /// Wrapper to call Devsolution.Portal dll
 /// If all day should not return anything
 /// if time passed and not allday should display in HH:MM AM or HH:MM PM format
 /// </summary>
 /// <param name="AllDay">if set to <c>true</c> [all day].</param>
 /// <param name="StartTime">The start time.</param>
 /// <returns></returns>
 public string DisplayTime(bool AllDay, object StartTime)
 {
     EventCalendar eventcalendar = new EventCalendar();
     return eventcalendar.DisplayTime(AllDay, StartTime);
 }
コード例 #38
0
ファイル: CustomDateEvent.cs プロジェクト: wee2tee/SN_Net
        public string GetTimeString(EventCalendar ev)
        {
            if (ev.customer.Length == 0)
            {
                TimeSpan to_time = new TimeSpan(Convert.ToInt32(ev.to_time.Split(':')[0]), Convert.ToInt32(ev.to_time.Split(':')[1]), 0);
                TimeSpan from_time = new TimeSpan(Convert.ToInt32(ev.from_time.Split(':')[0]), Convert.ToInt32(ev.from_time.Split(':')[1]), 0);
                DateTime event_date = DateTime.Parse(ev.date, cinfo_us, DateTimeStyles.None);

                if (from_time.Hours <= 12 && to_time.Hours >= 13)
                {
                    return ((to_time - from_time - TimeSpan.Parse("01:00:00")).Hours >= 1 ? (to_time - from_time - TimeSpan.Parse("01:00:00")).Hours.ToString() + ((to_time - from_time - TimeSpan.Parse("01:00:00")).Minutes > 1 ? ":" + (to_time - from_time - TimeSpan.Parse("01:00:00")).Minutes.ToString() + " ชม." : " ชม.") : (to_time - from_time - TimeSpan.Parse("01:00:00")).Minutes.ToString() + " นาที") + ((event_date.GetDayIntOfWeek() >= 2 && event_date.GetDayIntOfWeek() <= 6) && (from_time.Equals(TimeSpan.Parse("08:30:00")) && to_time.Equals(TimeSpan.Parse("17:30:00"))) ? "(เต็มวัน)" : "(" + from_time.ToString().Substring(0, 5) + " - " + to_time.ToString().Substring(0, 5) + ")");
                }
                else
                {
                    return ((to_time - from_time).Hours >= 1 ? (to_time - from_time).Hours.ToString() + ((to_time - from_time).Minutes > 1 ? ":" + (to_time - from_time).Minutes.ToString() + " ชม." : " ชม.") : (to_time - from_time).Minutes.ToString() + " นาที") + ((event_date.GetDayIntOfWeek() >= 2 && event_date.GetDayIntOfWeek() <= 6) && (from_time.Equals(TimeSpan.Parse("08:30:00")) && to_time.Equals(TimeSpan.Parse("17:30:00"))) ? "(เต็มวัน)" : "(" + from_time.ToString().Substring(0, 5) + " - " + to_time.ToString().Substring(0, 5) + ")");
                }
            }
            else
            {
                return ev.customer;
            }
        }
コード例 #39
0
ファイル: CustomDateEvent.cs プロジェクト: wee2tee/SN_Net
        private void DoCopy(DateTime date, EventCalendar event_calendar)
        {
            bool post_success = false;
            string err_msg = "";
            int inserted_id = -1;

            this.Ready = false;

            string json_data = "{\"users_name\":\"" + event_calendar.users_name + "\",";
            json_data += "\"date\":\"" + date.ToMysqlDate() + "\",";
            json_data += "\"from_time\":\"" + event_calendar.from_time + "\",";
            json_data += "\"to_time\":\"" + event_calendar.to_time + "\",";
            json_data += "\"event_type\":\"" + event_calendar.event_type + "\",";
            json_data += "\"event_code\":\"" + event_calendar.event_code + "\",";
            json_data += "\"customer\":\"" + event_calendar.customer + "\",";
            json_data += "\"status\":\"" + event_calendar.status.ToString() + "\",";
            json_data += "\"med_cert\":\"" + event_calendar.med_cert + "\",";
            json_data += "\"fine\":" + event_calendar.fine.ToString() + ",";
            json_data += "\"rec_by\":\"" + this.G.loged_in_user_name + "\"}";

            BackgroundWorker worker = new BackgroundWorker();
            worker.DoWork += delegate
            {
                CRUDResult post = ApiActions.POST(PreferenceForm.API_MAIN_URL() + "eventcalendar/create", json_data);
                ServerResult sr = JsonConvert.DeserializeObject<ServerResult>(post.data);

                if (sr.result == ServerResult.SERVER_RESULT_SUCCESS)
                {
                    post_success = true;
                    inserted_id = Convert.ToInt32(sr.message);
                }
                else
                {
                    post_success = false;
                    err_msg = sr.message;
                }
            };
            worker.RunWorkerCompleted += delegate
            {
                if (post_success)
                {
                    foreach (CustomDateEvent ct in this.Parent.Controls)
                    {
                        if (ct.Date.ToDMYDateValue() == date.ToDMYDateValue())
                        {
                            ct.RefreshData();
                            ct.RefreshView();
                        }
                    }
                    if (this.Date.ToDMYDateValue() == date.ToDMYDateValue())
                    {
                        this.RefreshData();
                        this.RefreshView();
                        this.dgv.Rows[this.event_list.FindIndex(t => t.id == inserted_id)].Cells[1].Selected = true;
                    }
                    this.Ready = true;
                }
                else
                {
                    if (MessageAlert.Show(err_msg, "Error", MessageAlertButtons.RETRY_CANCEL, MessageAlertIcons.ERROR) == DialogResult.Retry)
                    {
                        this.DoCopy(date, event_calendar);
                    }
                    this.Ready = true;
                }
            };
            worker.RunWorkerAsync();
        }
コード例 #40
0
ファイル: DateEventWindow.cs プロジェクト: wee2tee/SN_Net
        private EventCalendar GetInlineEvent()
        {
            EventCalendar ev = new EventCalendar();
            if(this.dgv.Rows[this.dgv.CurrentCell.RowIndex].Tag is EventCalendar)
            {
                ev.id = ((EventCalendar)this.dgv.Rows[this.dgv.CurrentCell.RowIndex].Tag).id;
            }

            ev.date = this.cde.date.Value.ToMysqlDate();
            if (this.dgv.Parent.Controls.Find("inline_users_name", true).Length > 0)
            {
                ev.users_name = ((ComboboxItem)((CustomComboBox)this.dgv.Parent.Controls.Find("inline_users_name", true)[0]).comboBox1.SelectedItem).string_value;
            }
            if (this.dgv.Parent.Controls.Find("inline_from_time", true).Length > 0)
            {
                CustomTimePicker inline_from_time = (CustomTimePicker)this.dgv.Parent.Controls.Find("inline_from_time", true)[0];
                ev.from_time = inline_from_time.Time.ToString("HH:mm", cinfo_th);
            }
            if (this.dgv.Parent.Controls.Find("inline_to_time", true).Length > 0)
            {
                CustomTimePicker inline_to_time = (CustomTimePicker)this.dgv.Parent.Controls.Find("inline_to_time", true)[0];
                ev.to_time = inline_to_time.Time.ToString("HH:mm", cinfo_th);
            }
            if (this.dgv.Parent.Controls.Find("inline_leave_cause", true).Length > 0)
            {
                ev.event_type = ((Istab)((ComboboxItem)((CustomComboBox)this.dgv.Parent.Controls.Find("inline_leave_cause", true)[0]).comboBox1.SelectedItem).Tag).tabtyp;
                ev.event_code = ((Istab)((ComboboxItem)((CustomComboBox)this.dgv.Parent.Controls.Find("inline_leave_cause", true)[0]).comboBox1.SelectedItem).Tag).typcod;
            }
            if (this.dgv.Parent.Controls.Find("inline_status", true).Length > 0)
            {
                ev.status = ((ComboboxItem)((CustomComboBox)this.dgv.Parent.Controls.Find("inline_status", true)[0]).comboBox1.SelectedItem).int_value;
            }
            if (this.dgv.Parent.Controls.Find("inline_customer", true).Length > 0)
            {
                CustomTextBox inline_customer = (CustomTextBox)this.dgv.Parent.Controls.Find("inline_customer", true)[0];
                ev.customer = inline_customer.Texts.cleanString();
            }
            if (this.dgv.Parent.Controls.Find("inline_medcert", true).Length > 0)
            {
                CustomComboBox inline_medcert = (CustomComboBox)this.dgv.Parent.Controls.Find("inline_medcert", true)[0];
                ev.med_cert = ((ComboboxItem)inline_medcert.comboBox1.SelectedItem).string_value;
            }
            if (this.dgv.Parent.Controls.Find("inline_medcert", true).Length > 0)
            {
                NumericUpDown inline_fine = (NumericUpDown)this.dgv.Parent.Controls.Find("inline_fine", true)[0];
                ev.fine = Convert.ToInt32(inline_fine.Value);
            }
            ev.rec_by = this.cde.main_form.G.loged_in_user_name;

            return ev;
        }
コード例 #41
0
ファイル: DateEventWindow.cs プロジェクト: wee2tee/SN_Net
        private void FillDataGrid(EventCalendar selected_item = null)
        {
            this.dgv.Rows.Clear();
            this.dgv.Columns.Clear();
            this.dgv.Tag = DGV_TAG.NORMAL;

            DataGridViewTextBoxColumn col0 = new DataGridViewTextBoxColumn();
            col0.Visible = false;
            this.dgv.Columns.Add(col0);

            DataGridViewTextBoxColumn col1 = new DataGridViewTextBoxColumn();
            col1.Width = 40;
            col1.HeaderText = "ลำดับ";
            col1.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
            this.dgv.Columns.Add(col1);

            DataGridViewTextBoxColumn col2 = new DataGridViewTextBoxColumn();
            col2.Width = 120;
            col2.HeaderText = "ชื่อพนักงาน";
            col2.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
            this.dgv.Columns.Add(col2);

            DataGridViewTextBoxColumn col3 = new DataGridViewTextBoxColumn();
            col3.Width = 120;
            col3.HeaderText = "เหตุผล";
            col3.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
            this.dgv.Columns.Add(col3);

            DataGridViewTextBoxColumn col4 = new DataGridViewTextBoxColumn();
            col4.Width = 60;
            col4.HeaderText = "จาก";
            col4.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
            this.dgv.Columns.Add(col4);

            DataGridViewTextBoxColumn col5 = new DataGridViewTextBoxColumn();
            col5.Width = 60;
            col5.HeaderText = "ถึง";
            col5.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
            this.dgv.Columns.Add(col5);

            DataGridViewTextBoxColumn col6 = new DataGridViewTextBoxColumn();
            col6.Width = 80;
            col6.HeaderText = "สถานะ";
            col6.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
            this.dgv.Columns.Add(col6);

            DataGridViewTextBoxColumn col7 = new DataGridViewTextBoxColumn();
            col7.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            col7.HeaderText = "หมายเหตุ/ชื่อลูกค้า";
            col7.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
            this.dgv.Columns.Add(col7);

            DataGridViewTextBoxColumn col8 = new DataGridViewTextBoxColumn();
            col8.Width = 120;
            col8.HeaderText = "เอกสารอ้างอิง";
            col8.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
            this.dgv.Columns.Add(col8);

            DataGridViewTextBoxColumn col9 = new DataGridViewTextBoxColumn();
            col9.Width = 90;
            col9.HeaderText = "หักค่าคอมฯ";
            col9.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
            this.dgv.Columns.Add(col9);

            int row_count = 0;

            List<EventCalendar> support_list = new List<EventCalendar>();
            List<EventCalendar> supervisor_list = new List<EventCalendar>();
            foreach (EventCalendar e in this.cde.absent_list.ExtractToEventCalendar())
            {
                if (this.users_list.Where(u => u.username == e.users_name && u.level >= GlobalVar.USER_LEVEL_SUPERVISOR).Count<Users>() > 0)
                {
                    supervisor_list.Add(e);
                }
                else
                {
                    support_list.Add(e);
                }
            }

            foreach (EventCalendar ev in support_list)
            {
                int r = this.dgv.Rows.Add();
                this.dgv.Rows[r].Tag = ev;

                this.dgv.Rows[r].Cells[0].ValueType = typeof(int);
                this.dgv.Rows[r].Cells[0].Value = ev.id;

                row_count += (ev.status == (int)CustomDateEvent.EVENT_STATUS.CANCELED ? 0 : 1);
                this.dgv.Rows[r].Cells[1].ValueType = typeof(string);
                this.dgv.Rows[r].Cells[1].Value = (ev.status == (int)CustomDateEvent.EVENT_STATUS.CANCELED ? "" : row_count.ToString());
                this.dgv.Rows[r].Cells[1].Style.Alignment = DataGridViewContentAlignment.MiddleRight;
                this.dgv.Rows[r].Cells[1].Style.BackColor = (ev.status == (int)CustomDateEvent.EVENT_STATUS.WAIT_FOR_CONFIRM ? CustomDateEvent.color_light_blue : (ev.status == (int)CustomDateEvent.EVENT_STATUS.CANCELED ? CustomDateEvent.color_light_red : Color.White));
                this.dgv.Rows[r].Cells[1].Style.SelectionBackColor = (ev.status == (int)CustomDateEvent.EVENT_STATUS.WAIT_FOR_CONFIRM ? CustomDateEvent.color_light_blue : (ev.status == (int)CustomDateEvent.EVENT_STATUS.CANCELED ? CustomDateEvent.color_light_red : Color.White));

                this.dgv.Rows[r].Cells[2].ValueType = typeof(string);
                this.dgv.Rows[r].Cells[2].Value = ev.users_name + " : " + ev.realname;
                this.dgv.Rows[r].Cells[2].Style.BackColor = (ev.status == (int)CustomDateEvent.EVENT_STATUS.WAIT_FOR_CONFIRM ? CustomDateEvent.color_light_blue : (ev.status == (int)CustomDateEvent.EVENT_STATUS.CANCELED ? CustomDateEvent.color_light_red : Color.White));
                this.dgv.Rows[r].Cells[2].Style.SelectionBackColor = (ev.status == (int)CustomDateEvent.EVENT_STATUS.WAIT_FOR_CONFIRM ? CustomDateEvent.color_light_blue : (ev.status == (int)CustomDateEvent.EVENT_STATUS.CANCELED ? CustomDateEvent.color_light_red : Color.White));

                this.dgv.Rows[r].Cells[3].ValueType = typeof(string);
                this.dgv.Rows[r].Cells[3].Value = this.GetEventTypdes(ev.event_type, ev.event_code);
                this.dgv.Rows[r].Cells[3].Style.BackColor = (ev.status == (int)CustomDateEvent.EVENT_STATUS.WAIT_FOR_CONFIRM ? CustomDateEvent.color_light_blue : (ev.status == (int)CustomDateEvent.EVENT_STATUS.CANCELED ? CustomDateEvent.color_light_red : Color.White));
                this.dgv.Rows[r].Cells[3].Style.SelectionBackColor = (ev.status == (int)CustomDateEvent.EVENT_STATUS.WAIT_FOR_CONFIRM ? CustomDateEvent.color_light_blue : (ev.status == (int)CustomDateEvent.EVENT_STATUS.CANCELED ? CustomDateEvent.color_light_red : Color.White));

                this.dgv.Rows[r].Cells[4].ValueType = typeof(string);
                this.dgv.Rows[r].Cells[4].Value = ev.from_time.Substring(0, 5);
                this.dgv.Rows[r].Cells[4].Style.BackColor = (ev.status == (int)CustomDateEvent.EVENT_STATUS.WAIT_FOR_CONFIRM ? CustomDateEvent.color_light_blue : (ev.status == (int)CustomDateEvent.EVENT_STATUS.CANCELED ? CustomDateEvent.color_light_red : Color.White));
                this.dgv.Rows[r].Cells[4].Style.SelectionBackColor = (ev.status == (int)CustomDateEvent.EVENT_STATUS.WAIT_FOR_CONFIRM ? CustomDateEvent.color_light_blue : (ev.status == (int)CustomDateEvent.EVENT_STATUS.CANCELED ? CustomDateEvent.color_light_red : Color.White));

                this.dgv.Rows[r].Cells[5].ValueType = typeof(string);
                this.dgv.Rows[r].Cells[5].Value = ev.to_time.Substring(0, 5);
                this.dgv.Rows[r].Cells[5].Style.BackColor = (ev.status == (int)CustomDateEvent.EVENT_STATUS.WAIT_FOR_CONFIRM ? CustomDateEvent.color_light_blue : (ev.status == (int)CustomDateEvent.EVENT_STATUS.CANCELED ? CustomDateEvent.color_light_red : Color.White));
                this.dgv.Rows[r].Cells[5].Style.SelectionBackColor = (ev.status == (int)CustomDateEvent.EVENT_STATUS.WAIT_FOR_CONFIRM ? CustomDateEvent.color_light_blue : (ev.status == (int)CustomDateEvent.EVENT_STATUS.CANCELED ? CustomDateEvent.color_light_red : Color.White));

                this.dgv.Rows[r].Cells[6].ValueType = typeof(string);
                this.dgv.Rows[r].Cells[6].Value = this.GetLeaveStatusString((int)ev.status);
                this.dgv.Rows[r].Cells[6].Style.BackColor = (ev.status == (int)CustomDateEvent.EVENT_STATUS.WAIT_FOR_CONFIRM ? CustomDateEvent.color_light_blue : (ev.status == (int)CustomDateEvent.EVENT_STATUS.CANCELED ? CustomDateEvent.color_light_red : Color.White));
                this.dgv.Rows[r].Cells[6].Style.SelectionBackColor = (ev.status == (int)CustomDateEvent.EVENT_STATUS.WAIT_FOR_CONFIRM ? CustomDateEvent.color_light_blue : (ev.status == (int)CustomDateEvent.EVENT_STATUS.CANCELED ? CustomDateEvent.color_light_red : Color.White));

                this.dgv.Rows[r].Cells[7].ValueType = typeof(string);
                this.dgv.Rows[r].Cells[7].Value = ev.customer; //(ev.customer.Length > 0 ? ev.customer : this.cde.GetTimeString(ev));
                this.dgv.Rows[r].Cells[7].Style.BackColor = (ev.status == (int)CustomDateEvent.EVENT_STATUS.WAIT_FOR_CONFIRM ? CustomDateEvent.color_light_blue : (ev.status == (int)CustomDateEvent.EVENT_STATUS.CANCELED ? CustomDateEvent.color_light_red : Color.White));
                this.dgv.Rows[r].Cells[7].Style.SelectionBackColor = (ev.status == (int)CustomDateEvent.EVENT_STATUS.WAIT_FOR_CONFIRM ? CustomDateEvent.color_light_blue : (ev.status == (int)CustomDateEvent.EVENT_STATUS.CANCELED ? CustomDateEvent.color_light_red : Color.White));

                this.dgv.Rows[r].Cells[8].ValueType = typeof(string);
                this.dgv.Rows[r].Cells[8].Value = (ev.med_cert == "Y" ? "มีใบรับรองแพทย์" : (ev.med_cert == "N" ? "ไม่มีเอกสาร" : ""));
                this.dgv.Rows[r].Cells[8].Style.BackColor = (ev.status == (int)CustomDateEvent.EVENT_STATUS.WAIT_FOR_CONFIRM ? CustomDateEvent.color_light_blue : (ev.status == (int)CustomDateEvent.EVENT_STATUS.CANCELED ? CustomDateEvent.color_light_red : Color.White));
                this.dgv.Rows[r].Cells[8].Style.SelectionBackColor = (ev.status == (int)CustomDateEvent.EVENT_STATUS.WAIT_FOR_CONFIRM ? CustomDateEvent.color_light_blue : (ev.status == (int)CustomDateEvent.EVENT_STATUS.CANCELED ? CustomDateEvent.color_light_red : Color.White));
                this.dgv.Rows[r].Cells[8].Style.ForeColor = (ev.med_cert == "N" ? Color.Red : Color.Black);
                this.dgv.Rows[r].Cells[8].Style.SelectionForeColor = (ev.med_cert == "N" ? Color.Red : Color.Black);

                this.dgv.Rows[r].Cells[9].ValueType = typeof(string);
                this.dgv.Rows[r].Cells[9].Value = (ev.fine > 0 ? ev.fine.ToString() : "");
                this.dgv.Rows[r].Cells[9].Style.Alignment = DataGridViewContentAlignment.MiddleRight;
                this.dgv.Rows[r].Cells[9].Style.BackColor = (ev.status == (int)CustomDateEvent.EVENT_STATUS.WAIT_FOR_CONFIRM ? CustomDateEvent.color_light_blue : (ev.status == (int)CustomDateEvent.EVENT_STATUS.CANCELED ? CustomDateEvent.color_light_red : Color.White));
                this.dgv.Rows[r].Cells[9].Style.SelectionBackColor = (ev.status == (int)CustomDateEvent.EVENT_STATUS.WAIT_FOR_CONFIRM ? CustomDateEvent.color_light_blue : (ev.status == (int)CustomDateEvent.EVENT_STATUS.CANCELED ? CustomDateEvent.color_light_red : Color.White));
                this.dgv.Rows[r].Cells[9].Style.ForeColor = Color.Red;
                this.dgv.Rows[r].Cells[9].Style.SelectionForeColor = Color.Red;
            }
            foreach (EventCalendar ev in supervisor_list)
            {
                int r = this.dgv.Rows.Add();
                this.dgv.Rows[r].Tag = ev;

                this.dgv.Rows[r].Cells[0].ValueType = typeof(int);
                this.dgv.Rows[r].Cells[0].Value = ev.id;

                this.dgv.Rows[r].Cells[1].ValueType = typeof(string);
                this.dgv.Rows[r].Cells[1].Value = "";
                this.dgv.Rows[r].Cells[1].Style.Alignment = DataGridViewContentAlignment.MiddleRight;
                this.dgv.Rows[r].Cells[1].Style.BackColor = Color.Wheat;
                this.dgv.Rows[r].Cells[1].Style.SelectionBackColor = Color.Wheat;

                this.dgv.Rows[r].Cells[2].ValueType = typeof(string);
                this.dgv.Rows[r].Cells[2].Value = ev.users_name + " : " + ev.realname;
                this.dgv.Rows[r].Cells[2].Style.BackColor = Color.Wheat;
                this.dgv.Rows[r].Cells[2].Style.SelectionBackColor = Color.Wheat;

                this.dgv.Rows[r].Cells[3].ValueType = typeof(string);
                this.dgv.Rows[r].Cells[3].Value = this.GetEventTypdes(ev.event_type, ev.event_code);
                this.dgv.Rows[r].Cells[3].Style.BackColor = Color.Wheat;
                this.dgv.Rows[r].Cells[3].Style.SelectionBackColor = Color.Wheat;

                this.dgv.Rows[r].Cells[4].ValueType = typeof(string);
                this.dgv.Rows[r].Cells[4].Value = ev.from_time.Substring(0, 5);
                this.dgv.Rows[r].Cells[4].Style.BackColor = Color.Wheat;
                this.dgv.Rows[r].Cells[4].Style.SelectionBackColor = Color.Wheat;

                this.dgv.Rows[r].Cells[5].ValueType = typeof(string);
                this.dgv.Rows[r].Cells[5].Value = ev.to_time.Substring(0, 5);
                this.dgv.Rows[r].Cells[5].Style.BackColor = Color.Wheat;
                this.dgv.Rows[r].Cells[5].Style.SelectionBackColor = Color.Wheat;

                this.dgv.Rows[r].Cells[6].ValueType = typeof(string);
                this.dgv.Rows[r].Cells[6].Value = this.GetLeaveStatusString((int)ev.status);
                this.dgv.Rows[r].Cells[6].Style.BackColor = Color.Wheat;
                this.dgv.Rows[r].Cells[6].Style.SelectionBackColor = Color.Wheat;

                this.dgv.Rows[r].Cells[7].ValueType = typeof(string);
                this.dgv.Rows[r].Cells[7].Value = ev.customer;
                this.dgv.Rows[r].Cells[7].Style.BackColor = Color.Wheat;
                this.dgv.Rows[r].Cells[7].Style.SelectionBackColor = Color.Wheat;

                this.dgv.Rows[r].Cells[8].ValueType = typeof(string);
                this.dgv.Rows[r].Cells[8].Value = (ev.med_cert == "Y" ? "มีใบรับรองแพทย์" : (ev.med_cert == "N" ? "ไม่มีเอกสาร" : ""));
                this.dgv.Rows[r].Cells[8].Style.BackColor = Color.Wheat;
                this.dgv.Rows[r].Cells[8].Style.SelectionBackColor = Color.Wheat;
                this.dgv.Rows[r].Cells[8].Style.ForeColor = (ev.med_cert == "N" ? Color.Red : Color.Black);
                this.dgv.Rows[r].Cells[8].Style.SelectionForeColor = (ev.med_cert == "N" ? Color.Red : Color.Black);

                this.dgv.Rows[r].Cells[9].ValueType = typeof(string);
                this.dgv.Rows[r].Cells[9].Value = (ev.fine > 0 ? ev.fine.ToString() : "");
                this.dgv.Rows[r].Cells[9].Style.Alignment = DataGridViewContentAlignment.MiddleRight;
                this.dgv.Rows[r].Cells[9].Style.BackColor = Color.Wheat;
                this.dgv.Rows[r].Cells[9].Style.SelectionBackColor = Color.Wheat;
                this.dgv.Rows[r].Cells[9].Style.ForeColor = Color.Red;
                this.dgv.Rows[r].Cells[9].Style.SelectionForeColor = Color.Red;
            }
            this.dgv.FillLine(this.cde.absent_list.ExtractToEventCalendar().Count + 4);

            if (selected_item != null)
            {
                if (this.dgv.Rows.Cast<DataGridViewRow>().Where(r => r.Tag is EventCalendar).Where(r => ((EventCalendar)r.Tag).id == selected_item.id).Count() > 0)
                {
                    this.dgv.Rows.Cast<DataGridViewRow>().Where(r => r.Tag is EventCalendar).Where(r => ((EventCalendar)r.Tag).id == selected_item.id).First<DataGridViewRow>().Cells[1].Selected = true;
                }
            }
        }
コード例 #42
0
ファイル: CustomDateEvent2.cs プロジェクト: wee2tee/SN_Net
        private void DoCopy(DateTime date, EventCalendar event_calendar)
        {
            bool post_success = false;
            string err_msg = "";
            int inserted_id = -1;

            string json_data = "{\"users_name\":\"" + event_calendar.users_name + "\",";
            json_data += "\"date\":\"" + date.ToMysqlDate() + "\",";
            json_data += "\"from_time\":\"" + event_calendar.from_time + "\",";
            json_data += "\"to_time\":\"" + event_calendar.to_time + "\",";
            json_data += "\"event_type\":\"" + event_calendar.event_type + "\",";
            json_data += "\"event_code\":\"" + event_calendar.event_code + "\",";
            json_data += "\"customer\":\"" + event_calendar.customer + "\",";
            json_data += "\"status\":\"" + event_calendar.status.ToString() + "\",";
            json_data += "\"med_cert\":\"" + event_calendar.med_cert + "\",";
            json_data += "\"fine\":" + event_calendar.fine.ToString() + ",";
            json_data += "\"rec_by\":\"" + this.main_form.G.loged_in_user_name + "\"}";

            BackgroundWorker worker = new BackgroundWorker();
            worker.DoWork += delegate
            {
                CRUDResult post = ApiActions.POST(PreferenceForm.API_MAIN_URL() + "eventcalendar/create", json_data);
                ServerResult sr = JsonConvert.DeserializeObject<ServerResult>(post.data);

                if (sr.result == ServerResult.SERVER_RESULT_SUCCESS)
                {
                    post_success = true;
                    inserted_id = Convert.ToInt32(sr.message);
                }
                else
                {
                    post_success = false;
                    err_msg = sr.message;
                }
            };
            worker.RunWorkerCompleted += delegate
            {
                if (post_success)
                {
                    foreach (Control ct in this.ParentForm.Controls["tableLayoutPanel1"].Controls)
                    {
                        if (ct.GetType() == typeof(CustomDateEvent2))
                        {
                            CustomDateEvent2 date_event = ct as CustomDateEvent2;
                            if (date_event.date.Value.ToString("dd/MM/yyyy") == date.ToString("dd/MM/yyyy"))
                            {
                                date_event.RefreshData();
                                date_event.RefreshView();

                                DataGridViewRow target_row = ((CustomDateEvent2)ct).dgv.Rows.Cast<DataGridViewRow>().Where(r => r.Cells[0].Value != null && ((EventCalendar)r.Cells[0].Value).id == inserted_id).FirstOrDefault();
                                if (target_row != null)
                                {
                                    date_event.dgv.Focus();
                                    date_event.dgv.CurrentCell = target_row.Cells[1];
                                    break;
                                }
                            }
                        }
                    }
                }
                else
                {
                    if (MessageAlert.Show(err_msg, "Error", MessageAlertButtons.RETRY_CANCEL, MessageAlertIcons.ERROR) == DialogResult.Retry)
                    {
                        this.DoCopy(date, event_calendar);
                    }
                }
            };
            worker.RunWorkerAsync();
        }
コード例 #43
0
        /// <summary>
        /// Shows the readonly details.
        /// </summary>
        /// <param name="eventCalendar">The event calendar.</param>
        private void ShowReadonlyDetails( EventCalendar eventCalendar )
        {
            SetEditMode( false );

            hfEventCalendarId.SetValue( eventCalendar.Id );
            AttributesState = null;
            ContentChannelsState = null;

            lReadOnlyTitle.Text = eventCalendar.Name.FormatAsHtmlTitle();

            lCalendarIcon.Text = string.Format( "<i class='{0}'></i>", string.IsNullOrWhiteSpace( eventCalendar.IconCssClass ) ? "fa fa-calendar" : eventCalendar.IconCssClass );
            lEventCalendarDescription.Text = eventCalendar.Description;
        }
コード例 #44
0
ファイル: LeaveWindow.cs プロジェクト: wee2tee/SN_Net
        private void LoadEventAndFill(EventCalendar event_calendar = null)
        {
            this.lblUserFrom.Text = this.current_user_from.username;
            this.lblUserTo.Text = this.current_user_to.username;
            this.lblDateFrom.Text = this.current_date_from.ToString("dd/MM/yy", cinfo_th);
            this.lblDateTo.Text = this.current_date_to.ToString("dd/MM/yy", cinfo_th);

            bool get_success = false;
            string err_msg = "";
            this.FormProcessing();

            BackgroundWorker worker = new BackgroundWorker();
            worker.DoWork += delegate
            {
                CRUDResult get = ApiActions.GET(PreferenceForm.API_MAIN_URL() + "eventcalendar/get_event_with_user&username_from=" + this.current_user_from.username + "&username_to=" + this.current_user_to.username + "&from_date=" + this.current_date_from.ToMysqlDate() + "&to_date=" + this.current_date_to.ToMysqlDate());
                ServerResult sr = JsonConvert.DeserializeObject<ServerResult>(get.data);
                if (sr.result == ServerResult.SERVER_RESULT_SUCCESS)
                {
                    get_success = true;
                    this.event_calendar = sr.event_calendar;
                    this.users_list = sr.users;
                }
                else
                {
                    get_success = false;
                    err_msg = sr.message;
                }
            };
            worker.RunWorkerCompleted += delegate
            {
                if (get_success)
                {
                    this.FillDgvAbsentSummary();
                    this.FillDgvServiceSummary();
                    this.FillDataGridLeaveList(event_calendar);
                    this.FilllDataGridLeaveGroup();
                    //this.ClearInlineFormLeaveList();
                    this.FormReadItem();
                }
                else
                {
                    MessageAlert.Show(err_msg, "Error", MessageAlertButtons.OK, MessageAlertIcons.ERROR);
                }
            };
            worker.RunWorkerAsync();
        }
コード例 #45
0
 private string GetDescription(EventCalendar.Core.Models.RecurringEvent e, string culture)
 {
     if (e.descriptions != null && e.descriptions.Any(x => x.CultureCode == culture))
     {
         return e.descriptions.SingleOrDefault(x => x.CultureCode == culture).Content;
     }
     else
     {
         return "";
     }
 }
コード例 #46
0
ファイル: LeaveWindow.cs プロジェクト: wee2tee/SN_Net
        private void FillDataGridLeaveList(EventCalendar event_calendar = null)
        {
            this.dgvLeaveList.Rows.Clear();
            this.dgvLeaveList.Columns.Clear();

            DataGridViewTextBoxColumn col0 = new DataGridViewTextBoxColumn();
            col0.Visible = false;
            col0.SortMode = DataGridViewColumnSortMode.NotSortable;
            this.dgvLeaveList.Columns.Add(col0);

            DataGridViewTextBoxColumn col1 = new DataGridViewTextBoxColumn();
            col1.Width = 40;
            col1.SortMode = DataGridViewColumnSortMode.NotSortable;
            col1.HeaderText = "ลำดับ";
            col1.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
            this.dgvLeaveList.Columns.Add(col1);

            DataGridViewTextBoxColumn col2 = new DataGridViewTextBoxColumn();
            col2.Width = 80;
            col2.SortMode = DataGridViewColumnSortMode.NotSortable;
            col2.HeaderText = "วันที่";
            col2.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
            this.dgvLeaveList.Columns.Add(col2);

            DataGridViewTextBoxColumn col3 = new DataGridViewTextBoxColumn();
            col3.Width = 100;
            col3.SortMode = DataGridViewColumnSortMode.NotSortable;
            col3.HeaderText = "ชื่อพนักงาน";
            col3.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
            this.dgvLeaveList.Columns.Add(col3);

            DataGridViewTextBoxColumn col4 = new DataGridViewTextBoxColumn();
            col4.Width = 120;
            col4.SortMode = DataGridViewColumnSortMode.NotSortable;
            col4.HeaderText = "เหตุผล";
            col4.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
            this.dgvLeaveList.Columns.Add(col4);

            DataGridViewTextBoxColumn col5 = new DataGridViewTextBoxColumn();
            col5.Width = 60;
            col5.SortMode = DataGridViewColumnSortMode.NotSortable;
            col5.HeaderText = "จาก";
            col5.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
            this.dgvLeaveList.Columns.Add(col5);

            DataGridViewTextBoxColumn col6 = new DataGridViewTextBoxColumn();
            col6.Width = 60;
            col6.SortMode = DataGridViewColumnSortMode.NotSortable;
            col6.HeaderText = "ถึง";
            col6.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
            this.dgvLeaveList.Columns.Add(col6);

            DataGridViewTextBoxColumn col7 = new DataGridViewTextBoxColumn();
            col7.Width = 120;
            col7.SortMode = DataGridViewColumnSortMode.NotSortable;
            col7.HeaderText = "รวมเวลา";
            col7.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
            this.dgvLeaveList.Columns.Add(col7);

            DataGridViewTextBoxColumn col8 = new DataGridViewTextBoxColumn();
            col8.Width = 90;
            col8.SortMode = DataGridViewColumnSortMode.NotSortable;
            col8.HeaderText = "สภานะ";
            col8.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
            this.dgvLeaveList.Columns.Add(col8);

            DataGridViewTextBoxColumn col9 = new DataGridViewTextBoxColumn();
            col9.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            col9.SortMode = DataGridViewColumnSortMode.NotSortable;
            col9.HeaderText = "หมายเหตุ/ชื่อลูกค้า";
            col9.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
            this.dgvLeaveList.Columns.Add(col9);

            DataGridViewTextBoxColumn col10 = new DataGridViewTextBoxColumn();
            col10.Width = 120;
            col10.SortMode = DataGridViewColumnSortMode.NotSortable;
            col10.HeaderText = "ใบรับรองแพทย์";
            col10.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
            this.dgvLeaveList.Columns.Add(col10);

            DataGridViewTextBoxColumn col11 = new DataGridViewTextBoxColumn();
            col11.Width = 100;
            col11.SortMode = DataGridViewColumnSortMode.NotSortable;
            col11.HeaderText = "หักค่าคอมฯ";
            col11.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
            this.dgvLeaveList.Columns.Add(col11);

            int row_count = 0;
            List<EventCalendar> filter_event_calendar = new List<EventCalendar>();
            foreach (DataGridViewRow row in this.dgvAbsentSummary.Rows)
            {
                if ((bool)row.Cells[0].Value == true)
                {
                    //List<EventCalendar> tmp1 = this.event_calendar.Where<EventCalendar>(t => t.event_type == ((Istab)row.Tag).tabtyp && t.event_code == ((Istab)row.Tag).typcod).ToList<EventCalendar>().ConvertAll(t => t).ToList<EventCalendar>();
                    //filter_event_calendar = filter_event_calendar.Concat(tmp1).ToList<EventCalendar>();
                    filter_event_calendar = filter_event_calendar.Concat(this.event_calendar.Where<EventCalendar>(t => t.event_type == ((Istab)row.Tag).tabtyp && t.event_code == ((Istab)row.Tag).typcod).ToList<EventCalendar>()).ToList<EventCalendar>();
                }
            }
            foreach (DataGridViewRow row in this.dgvServiceSummary.Rows)
            {
                if ((bool)row.Cells[0].Value == true)
                {
                    //List<EventCalendar> tmp2 = this.event_calendar.Where<EventCalendar>(t => t.event_type == ((Istab)row.Tag).tabtyp && t.event_code == ((Istab)row.Tag).typcod).ToList<EventCalendar>().ConvertAll(t => t).ToList<EventCalendar>();
                    //filter_event_calendar = filter_event_calendar.Concat(tmp2).ToList<EventCalendar>();
                    filter_event_calendar = filter_event_calendar.Concat(this.event_calendar.Where<EventCalendar>(t => t.event_type == ((Istab)row.Tag).tabtyp && t.event_code == ((Istab)row.Tag).typcod).ToList<EventCalendar>()).ToList<EventCalendar>();
                }
            }

            this.sorted_list = filter_event_calendar.OrderBy(t => t.users_name + t.date).ToList<EventCalendar>();
            //foreach (EventCalendar ev in this.event_calendar)
            //{
            //    int r = this.dgvLeaveList.Rows.Add();
            //    this.dgvLeaveList.Rows[r].Tag = ev;

            //    this.dgvLeaveList.Rows[r].Cells[0].ValueType = typeof(int);
            //    this.dgvLeaveList.Rows[r].Cells[0].Value = ev.id;
            //    this.dgvLeaveList.Rows[r].Cells[1].ValueType = typeof(string);
            //    this.dgvLeaveList.Rows[r].Cells[1].Value = "count";
            //    this.dgvLeaveList.Rows[r].Cells[2].ValueType = typeof(string);
            //    this.dgvLeaveList.Rows[r].Cells[2].Value = ev.date;
            //    this.dgvLeaveList.Rows[r].Cells[3].ValueType = typeof(string);
            //    this.dgvLeaveList.Rows[r].Cells[3].Value = ev.realname;
            //}
            foreach (EventCalendar ev in this.sorted_list)
            {
                int r = this.dgvLeaveList.Rows.Add();
                this.dgvLeaveList.Rows[r].Tag = ev;

                this.dgvLeaveList.Rows[r].Cells[0].ValueType = typeof(int);
                this.dgvLeaveList.Rows[r].Cells[0].Value = ev.id;

                this.dgvLeaveList.Rows[r].Cells[1].ValueType = typeof(int);
                this.dgvLeaveList.Rows[r].Cells[1].Value = ++row_count;
                this.dgvLeaveList.Rows[r].Cells[1].Style.Alignment = DataGridViewContentAlignment.MiddleRight;
                this.dgvLeaveList.Rows[r].Cells[1].Style.BackColor = (ev.status == (int)CustomDateEvent.EVENT_STATUS.WAIT_FOR_CONFIRM ? CustomDateEvent.color_light_blue : (ev.status == (int)CustomDateEvent.EVENT_STATUS.CANCELED ? CustomDateEvent.color_light_red : Color.White));
                this.dgvLeaveList.Rows[r].Cells[1].Style.SelectionBackColor = (ev.status == (int)CustomDateEvent.EVENT_STATUS.WAIT_FOR_CONFIRM ? CustomDateEvent.color_light_blue : (ev.status == (int)CustomDateEvent.EVENT_STATUS.CANCELED ? CustomDateEvent.color_light_red : Color.White));

                this.dgvLeaveList.Rows[r].Cells[2].ValueType = typeof(string);
                this.dgvLeaveList.Rows[r].Cells[2].pickedDate(ev.date);
                this.dgvLeaveList.Rows[r].Cells[2].Style.BackColor = (ev.status == (int)CustomDateEvent.EVENT_STATUS.WAIT_FOR_CONFIRM ? CustomDateEvent.color_light_blue : (ev.status == (int)CustomDateEvent.EVENT_STATUS.CANCELED ? CustomDateEvent.color_light_red : Color.White));
                this.dgvLeaveList.Rows[r].Cells[2].Style.SelectionBackColor = (ev.status == (int)CustomDateEvent.EVENT_STATUS.WAIT_FOR_CONFIRM ? CustomDateEvent.color_light_blue : (ev.status == (int)CustomDateEvent.EVENT_STATUS.CANCELED ? CustomDateEvent.color_light_red : Color.White));

                this.dgvLeaveList.Rows[r].Cells[3].ValueType = typeof(string);
                this.dgvLeaveList.Rows[r].Cells[3].Value = ev.realname;
                this.dgvLeaveList.Rows[r].Cells[3].Style.BackColor = (ev.status == (int)CustomDateEvent.EVENT_STATUS.WAIT_FOR_CONFIRM ? CustomDateEvent.color_light_blue : (ev.status == (int)CustomDateEvent.EVENT_STATUS.CANCELED ? CustomDateEvent.color_light_red : Color.White));
                this.dgvLeaveList.Rows[r].Cells[3].Style.SelectionBackColor = (ev.status == (int)CustomDateEvent.EVENT_STATUS.WAIT_FOR_CONFIRM ? CustomDateEvent.color_light_blue : (ev.status == (int)CustomDateEvent.EVENT_STATUS.CANCELED ? CustomDateEvent.color_light_red : Color.White));

                this.dgvLeaveList.Rows[r].Cells[4].ValueType = typeof(string);
                this.dgvLeaveList.Rows[r].Cells[4].Value = (this.leave_cause.Find(t => t.typcod == ev.event_code) != null ? this.leave_cause.Find(t => t.typcod == ev.event_code).typdes_th : "");
                this.dgvLeaveList.Rows[r].Cells[4].Style.BackColor = (ev.status == (int)CustomDateEvent.EVENT_STATUS.WAIT_FOR_CONFIRM ? CustomDateEvent.color_light_blue : (ev.status == (int)CustomDateEvent.EVENT_STATUS.CANCELED ? CustomDateEvent.color_light_red : Color.White));
                this.dgvLeaveList.Rows[r].Cells[4].Style.SelectionBackColor = (ev.status == (int)CustomDateEvent.EVENT_STATUS.WAIT_FOR_CONFIRM ? CustomDateEvent.color_light_blue : (ev.status == (int)CustomDateEvent.EVENT_STATUS.CANCELED ? CustomDateEvent.color_light_red : Color.White));

                this.dgvLeaveList.Rows[r].Cells[5].ValueType = typeof(string);
                this.dgvLeaveList.Rows[r].Cells[5].Value = ev.from_time.Substring(0, 5);
                this.dgvLeaveList.Rows[r].Cells[5].Style.BackColor = (ev.status == (int)CustomDateEvent.EVENT_STATUS.WAIT_FOR_CONFIRM ? CustomDateEvent.color_light_blue : (ev.status == (int)CustomDateEvent.EVENT_STATUS.CANCELED ? CustomDateEvent.color_light_red : Color.White));
                this.dgvLeaveList.Rows[r].Cells[5].Style.SelectionBackColor = (ev.status == (int)CustomDateEvent.EVENT_STATUS.WAIT_FOR_CONFIRM ? CustomDateEvent.color_light_blue : (ev.status == (int)CustomDateEvent.EVENT_STATUS.CANCELED ? CustomDateEvent.color_light_red : Color.White));

                this.dgvLeaveList.Rows[r].Cells[6].ValueType = typeof(string);
                this.dgvLeaveList.Rows[r].Cells[6].Value = ev.to_time.Substring(0, 5);
                this.dgvLeaveList.Rows[r].Cells[6].Style.BackColor = (ev.status == (int)CustomDateEvent.EVENT_STATUS.WAIT_FOR_CONFIRM ? CustomDateEvent.color_light_blue : (ev.status == (int)CustomDateEvent.EVENT_STATUS.CANCELED ? CustomDateEvent.color_light_red : Color.White));
                this.dgvLeaveList.Rows[r].Cells[6].Style.SelectionBackColor = (ev.status == (int)CustomDateEvent.EVENT_STATUS.WAIT_FOR_CONFIRM ? CustomDateEvent.color_light_blue : (ev.status == (int)CustomDateEvent.EVENT_STATUS.CANCELED ? CustomDateEvent.color_light_red : Color.White));

                this.dgvLeaveList.Rows[r].Cells[7].ValueType = typeof(string);
                this.dgvLeaveList.Rows[r].Cells[7].Value = this.sorted_list.Where(t => t.id == ev.id).ToList<EventCalendar>().GetSummaryLeaveDayString();
                this.dgvLeaveList.Rows[r].Cells[7].Style.Alignment = DataGridViewContentAlignment.MiddleLeft;
                this.dgvLeaveList.Rows[r].Cells[7].Style.BackColor = (ev.status == (int)CustomDateEvent.EVENT_STATUS.WAIT_FOR_CONFIRM ? CustomDateEvent.color_light_blue : (ev.status == (int)CustomDateEvent.EVENT_STATUS.CANCELED ? CustomDateEvent.color_light_red : Color.White));
                this.dgvLeaveList.Rows[r].Cells[7].Style.SelectionBackColor = (ev.status == (int)CustomDateEvent.EVENT_STATUS.WAIT_FOR_CONFIRM ? CustomDateEvent.color_light_blue : (ev.status == (int)CustomDateEvent.EVENT_STATUS.CANCELED ? CustomDateEvent.color_light_red : Color.White));

                this.dgvLeaveList.Rows[r].Cells[8].ValueType = typeof(string);
                this.dgvLeaveList.Rows[r].Cells[8].Value = (ev.status == (int)CustomDateEvent.EVENT_STATUS.WAIT_FOR_CONFIRM ? "WAIT" : (ev.status == (int)CustomDateEvent.EVENT_STATUS.CANCELED ? "CANCELED" : "CONFIRMED"));
                this.dgvLeaveList.Rows[r].Cells[8].Style.BackColor = (ev.status == (int)CustomDateEvent.EVENT_STATUS.WAIT_FOR_CONFIRM ? CustomDateEvent.color_light_blue : (ev.status == (int)CustomDateEvent.EVENT_STATUS.CANCELED ? CustomDateEvent.color_light_red : Color.White));
                this.dgvLeaveList.Rows[r].Cells[8].Style.SelectionBackColor = (ev.status == (int)CustomDateEvent.EVENT_STATUS.WAIT_FOR_CONFIRM ? CustomDateEvent.color_light_blue : (ev.status == (int)CustomDateEvent.EVENT_STATUS.CANCELED ? CustomDateEvent.color_light_red : Color.White));

                this.dgvLeaveList.Rows[r].Cells[9].ValueType = typeof(string);
                this.dgvLeaveList.Rows[r].Cells[9].Value = ev.customer;
                this.dgvLeaveList.Rows[r].Cells[9].Style.BackColor = (ev.status == (int)CustomDateEvent.EVENT_STATUS.WAIT_FOR_CONFIRM ? CustomDateEvent.color_light_blue : (ev.status == (int)CustomDateEvent.EVENT_STATUS.CANCELED ? CustomDateEvent.color_light_red : Color.White));
                this.dgvLeaveList.Rows[r].Cells[9].Style.SelectionBackColor = (ev.status == (int)CustomDateEvent.EVENT_STATUS.WAIT_FOR_CONFIRM ? CustomDateEvent.color_light_blue : (ev.status == (int)CustomDateEvent.EVENT_STATUS.CANCELED ? CustomDateEvent.color_light_red : Color.White));

                this.dgvLeaveList.Rows[r].Cells[10].ValueType = typeof(string);
                this.dgvLeaveList.Rows[r].Cells[10].Value = (ev.med_cert == "Y" ? "มีใบรับรองแพทย์" : (ev.med_cert == "N" ? "ไม่มีใบรับรองแพทย์" : ""));
                this.dgvLeaveList.Rows[r].Cells[10].Style.BackColor = (ev.status == (int)CustomDateEvent.EVENT_STATUS.WAIT_FOR_CONFIRM ? CustomDateEvent.color_light_blue : (ev.status == (int)CustomDateEvent.EVENT_STATUS.CANCELED ? CustomDateEvent.color_light_red : Color.White));
                this.dgvLeaveList.Rows[r].Cells[10].Style.SelectionBackColor = (ev.status == (int)CustomDateEvent.EVENT_STATUS.WAIT_FOR_CONFIRM ? CustomDateEvent.color_light_blue : (ev.status == (int)CustomDateEvent.EVENT_STATUS.CANCELED ? CustomDateEvent.color_light_red : Color.White));
                this.dgvLeaveList.Rows[r].Cells[10].Style.ForeColor = (ev.med_cert == "N" ? Color.Red : Color.Black);
                this.dgvLeaveList.Rows[r].Cells[10].Style.SelectionForeColor = (ev.med_cert == "N" ? Color.Red : Color.Black);

                this.dgvLeaveList.Rows[r].Cells[11].ValueType = typeof(string);
                this.dgvLeaveList.Rows[r].Cells[11].Value = (ev.fine > 0 ? ev.fine.ToString() : "");
                this.dgvLeaveList.Rows[r].Cells[11].Style.Alignment = DataGridViewContentAlignment.MiddleRight;
                this.dgvLeaveList.Rows[r].Cells[11].Style.BackColor = (ev.status == (int)CustomDateEvent.EVENT_STATUS.WAIT_FOR_CONFIRM ? CustomDateEvent.color_light_blue : (ev.status == (int)CustomDateEvent.EVENT_STATUS.CANCELED ? CustomDateEvent.color_light_red : Color.White));
                this.dgvLeaveList.Rows[r].Cells[11].Style.SelectionBackColor = (ev.status == (int)CustomDateEvent.EVENT_STATUS.WAIT_FOR_CONFIRM ? CustomDateEvent.color_light_blue : (ev.status == (int)CustomDateEvent.EVENT_STATUS.CANCELED ? CustomDateEvent.color_light_red : Color.White));
            }

            this.groupTotal.Text = " สะสมจากต้นปี (" + DateTime.Parse(this.current_date_from.Year.ToString() + "-01-01", cinfo_us).ToString("dd/MM/yy", cinfo_th.DateTimeFormat) + " - " + DateTime.Parse(this.current_date_from.Year.ToString() + "-12-31", cinfo_us).ToString("dd/MM/yy", cinfo_th.DateTimeFormat) + ") ";
            this.groupPeriod.Text = "  สรุปตามช่วงวันที่ ที่กำหนด (" + this.current_date_from.ToString("dd/MM/yy", cinfo_th) + " - " + this.current_date_to.ToString("dd/MM/yy", cinfo_th) + ") ";

            int max_absent = 0;
            List<EventCalendar> users_year_event = null;
            if (this.current_user_from != null && this.current_user_to != null)
            {
                CRUDResult get_max_absent = ApiActions.GET(PreferenceForm.API_MAIN_URL() + "eventcalendar/get_user_year_leave_data&id=" + this.current_user_from.id.ToString() + "&year=" + this.current_date_from.Year.ToString());
                ServerResult sr_max_absent = JsonConvert.DeserializeObject<ServerResult>(get_max_absent.data);
                if (sr_max_absent.result == ServerResult.SERVER_RESULT_SUCCESS)
                {
                    max_absent = sr_max_absent.users[0].max_absent;
                    users_year_event = sr_max_absent.event_calendar;
                }
                else
                {
                    users_year_event = new List<EventCalendar>();
                }
                List<EventCalendar> period_absent_day = this.sorted_list.Where(t => t.event_type == EventCalendar.EVENT_TYPE_ABSENT_CAUSE && t.status != (int)CustomDateEvent.EVENT_STATUS.CANCELED).ToList<EventCalendar>();
                List<EventCalendar> period_service_day = this.sorted_list.Where(t => t.event_type == EventCalendar.EVENT_TYPE_SERVICE_CASE && t.status != (int)CustomDateEvent.EVENT_STATUS.CANCELED).ToList<EventCalendar>();
                List<EventCalendar> total_absent_day = users_year_event.Where(t => t.event_type == EventCalendar.EVENT_TYPE_ABSENT_CAUSE && t.status != (int)CustomDateEvent.EVENT_STATUS.CANCELED).ToList<EventCalendar>();
                List<EventCalendar> total_service_day = users_year_event.Where(t => t.event_type == EventCalendar.EVENT_TYPE_SERVICE_CASE && t.status != (int)CustomDateEvent.EVENT_STATUS.CANCELED).ToList<EventCalendar>();

                if (this.current_user_from.username == this.current_user_to.username)
                {
                    this.lblPeriodAbsent.Text = (period_absent_day != null ? period_absent_day.GetSummaryLeaveDayString() : "-");
                    this.lblPeriodServ.Text = (period_service_day != null ? period_service_day.GetSummaryLeaveDayString() : "-");
                    this.lblTotalAbsent.Text = (total_absent_day.Count > 0 ? total_absent_day.GetSummaryLeaveDayString() : "0 วัน") + " / (max. = " + max_absent.ToString() + " วัน/ปี)";
                    this.lblTotalAbsent.ForeColor = (total_absent_day.GetSummaryTimeSpan().TotalSeconds >= (max_absent * 28800) ? Color.Red : Color.Black);
                    this.lblTotalAbsent.Font = (total_absent_day.GetSummaryTimeSpan().TotalSeconds >= (max_absent * 28800) ? new Font("tahoma", 9.75f, FontStyle.Bold) : new Font("tahoma", 9.75f, FontStyle.Regular));
                    this.lblTotalServ.Text = (total_service_day != null ? total_service_day.GetSummaryLeaveDayString() : "-");
                }
                else
                {
                    this.lblPeriodAbsent.Text = "-";
                    this.lblPeriodServ.Text = "-";
                    this.lblTotalAbsent.Text = "-";
                    this.lblTotalAbsent.ForeColor = Color.Black;
                    this.lblTotalAbsent.Font = new Font("tahoma", 9.75f);
                    this.lblTotalServ.Text = "-";
                }
            }
            if (event_calendar != null)
            {
                if (this.dgvLeaveList.Rows.Count > -1)
                {
                    if (this.dgvLeaveList.Rows.Cast<DataGridViewRow>().Where(r => ((EventCalendar)r.Tag).id == event_calendar.id).Count<DataGridViewRow>() > 0)
                    {
                        this.dgvLeaveList.Rows.Cast<DataGridViewRow>().Where(r => ((EventCalendar)r.Tag).id == event_calendar.id).First<DataGridViewRow>().Cells[1].Selected = true;
                    }
                    else
                    {
                        this.dgvLeaveList.Rows[0].Cells[1].Selected = true;
                    }
                }
            }
            this.dgvLeaveList.Focus();
        }
コード例 #47
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnInit( EventArgs e )
        {
            base.OnInit( e );

            // if this block has a specific EventCalendarId set, use that, otherwise, determine it from the PageParameters
            Guid eventCalendarGuid = GetAttributeValue( "EventCalendar" ).AsGuid();
            int eventCalendarId = 0;

            if ( eventCalendarGuid == Guid.Empty )
            {
                eventCalendarId = PageParameter( "EventCalendarId" ).AsInteger();
            }

            if ( !( eventCalendarId == 0 && eventCalendarGuid == Guid.Empty ) )
            {
                string key = string.Format( "EventCalendar:{0}", eventCalendarId );
                _eventCalendar = RockPage.GetSharedItem( key ) as EventCalendar;
                if ( _eventCalendar == null )
                {
                    _eventCalendar = new EventCalendarService( new RockContext() ).Queryable()
                        .Where( g => g.Id == eventCalendarId || g.Guid == eventCalendarGuid )
                        .FirstOrDefault();
                    RockPage.SaveSharedItem( key, _eventCalendar );
                }

                if ( _eventCalendar != null )
                {
                    _canEdit = UserCanEdit || _eventCalendar.IsAuthorized( Authorization.EDIT, CurrentPerson );
                    _canView = _canEdit || _eventCalendar.IsAuthorized( Authorization.VIEW, CurrentPerson );

                    rFilter.ApplyFilterClick += rFilter_ApplyFilterClick;

                    gEventCalendarItems.DataKeyNames = new string[] { "Id" };
                    gEventCalendarItems.Actions.ShowAdd = _canEdit;
                    gEventCalendarItems.Actions.AddClick += gEventCalendarItems_AddClick;
                    gEventCalendarItems.GridRebind += gEventCalendarItems_GridRebind;
                    gEventCalendarItems.ExportFilename = _eventCalendar.Name;
                    gEventCalendarItems.IsDeleteEnabled = _canEdit;
                }
            }
        }
コード例 #48
0
 private string GetDescription(EventCalendar.Core.Models.Event e, string culture)
 {
     if (e.descriptions != null && e.descriptions.Any(x => x.CultureCode == culture))
     {
         return Umbraco.StripHtml(e.descriptions.SingleOrDefault(x => x.CultureCode == culture).Content).ToString();
     }
     else
     {
         return "";
     }
 }