public static int AddRightsTemplate(User user, Events evnt, string RoleTemplatePost, string RoleTemplateDescription, List<EnumFunctions> functionID)
        {
            if (!user.isSystemAdmin)
            {
                if (!user.isAuthorized(evnt, EnumFunctions.Add_Role))
                    throw new FaultException<SException>(new SException(),
                       new FaultReason("Invalid User, User Does Not Have Rights To Add New Role Template!"));
            }
            try
            {

                using (TransactionScope t = new TransactionScope(TransactionScopeOption.Required))
                {
                    DAL dalDataContext = new DAL();

                    RoleTemplate role = RoleTemplateController.AddRoleTemplate(evnt, RoleTemplatePost, RoleTemplateDescription, dalDataContext);
                    int roleid = role.RoleTemplateID;
                    role = null;

                    RightTemplateController.AddRight(roleid, functionID, dalDataContext);
                    t.Complete();
                    return roleid;
                }
            }
            catch
            {
                throw new FaultException<SException>(new SException(),
                   new FaultReason("An Error occured While Adding New Role Template, Please Try Again!"));
            }
        }
        public static RoleTemplate AddRoleTemplate(Events evnt, string RoleTemplatePost, string RoleTemplateDescription, DAL dalDataContext)
        {
            try
            {

                Table<RoleTemplate> roles = dalDataContext.roleTemplate;
                RoleTemplate creatingRole;
                //if(e == null)
                creatingRole = new RoleTemplate(RoleTemplatePost, RoleTemplateDescription, evnt);
                //else
                //    creatingRole = new RoleTemplate(RoleTemplatePost, RoleTemplateDescription, evnt.EventID);

                roles.InsertOnSubmit(creatingRole);

                roles.Context.SubmitChanges();

                return creatingRole;

            }
            catch
            {
                throw new FaultException<SException>(new SException(),
                   new FaultReason("An Error occured While Adding New Role Template, Please Try Again!"));
            }
        }
 public frmFacBookingDetails(User u, Events e, EventDay d,List<Facility> m)
     : this()
 {
     this.user = u;
     this.models = m;
     this.event_ = e;
     this.eventDay_ = d;
 }
 public frmBudgetItemList(User u, Events e)
     : this()
 {
     this.user = u;
     this.event_ = e;
     this.lvBItem.lv.SelectionChanged += lv_SelectionChanged;
     loadBudgetItems();
 }
Esempio n. 5
0
 public frmWizEvent(frmWizard c)
 {
     evnt = c._event;
     days = c._days;
     programs = c._programs;
     guests = c._guests;
     InitializeComponent();
 }
 public frmAllocateBudget(User u, Events e,
     List<ItemTypes> typeList, List<Items> itemList, decimal maxBudget)
     : this()
 {
     this.user = u;
     this.event_ = e;
     this.typeList = typeList;
     this.itemList = itemList;
     this.maxBudget = maxBudget;
 }
Esempio n. 7
0
        public void EditItemType(User u, Events event_, Boolean Important)
        {
            EventItemsHelper client = new EventItemsHelper();

            //Insert server code here
            ItemTypes Item2Edit=ItemTypeCollection[lv.SelectedIndex];
            ItemTypeCollection[lv.SelectedIndex].IsImportantType = Important;
            client.SetItemTypeImportance(u, Item2Edit, Important);
            client.Close();
        }
 public frmServiceContactList(User u, Events e)
     : this()
 {
     txtsearch.TextChanged += txtsearch_TextChanged;
     this.user = u;
     if (e != null)
     {
         this.event_ = e;
     }
     // Insert code required on object creation below this point.
 }
Esempio n. 9
0
        public frmWizTask(frmWizard c)
        {
            user = c._user;
            event_ = c._event;
            Origtasks  = c._task;
            tasks = new List<Task>();

            clone(Origtasks, tasks);

            InitializeComponent();
            loadExisting();
            txtTaskName.Focus();
        }
Esempio n. 10
0
        public void DeleteItemType(User u, Events event_)
        {
            EventItemsHelper client = new EventItemsHelper();

            //Insert server code here
            if (lv.SelectedIndex != -1)
            {
                ItemTypes type2delete = ItemTypeCollection[lv.SelectedIndex];
                client.DeleteEventItemType(u, type2delete);
                ItemTypeCollection.RemoveAt(lv.SelectedIndex);
            }
            client.Close();
        }
Esempio n. 11
0
        //List<Guest> guestList;
        //List<EventDay> _day;
        //EventDay eventDay_;
        //int selectedIndex = -1;
        public frmWizGuest(frmWizard c)
        {
            //_guests = c._guests;
            //_day = c._days;
            _event = c._event;
            user = c._user;
            OrigGuests = c._guests;
            _day = c._days;

            InitializeComponent();

            guests = new List<List<Guest>>();
            clone(OrigGuests, guests);
        }
Esempio n. 12
0
        public frmOverView(User u, Events e)
            : this()
        {
            this.user = u;
            this.event_ = e;

            if (e != null)
            {
                loadDays();
                loadEventItems();
                EventDay firstDay=DayList[0];
                loadFacilityBookings(firstDay);
            }
        }
Esempio n. 13
0
 public ExportData(Events evnt, EventDay[] days, Task[] tasks, FacilityBookingConfirmed[][] facilities, Program[][] programs, Guest[][] guests, Participant[] participants
     , OptimizedBudgetItems optitems, BudgetIncome[] budgetincomes, Field[] field)
 {
     this.evnts = evnt;
     this.days = days;
     this.tasks = tasks;
     this.facilities = facilities;
     this.programs = programs;
     this.guests = guests;
     this.participants = participants;
     this.optitems = optitems;
     this.budgetincomes = budgetincomes;
     this.field = field;
 }
Esempio n. 14
0
        public frmWizItem(frmWizard c)
        {
            InitializeComponent();
            user = c._user;
            event_ = c._event;
            items = c._items;
            itemtypes = c._itemTypes;

            radItemType.IsChecked = true;
            refreshItemTypes();

            cboItemType.Focus();
            loadExisting();
        }
Esempio n. 15
0
        public frmWizProgramme(frmWizard c)
        {
            _day = c._days;
            _event = c._event;
            _programs_Original = c._programs;
            parent = c;
            _programs = new List<List<Program>>();
            clone(_programs_Original, _programs);

            InitializeComponent();

            lstProgram.PreviewMouseLeftButtonDown += new MouseButtonEventHandler(lstProgram_PreviewMouseLeftButtonDown);
            lstProgram.Drop += new DragEventHandler(lstProgram_Drop);

            lstProgram.DragOver += new DragEventHandler(lstProgram_DragOver);
        }
Esempio n. 16
0
        //private User user;
        //private List<List<Guest>> guests;
        //private List<List<Guest>> OrigGuests;
        //private List<EventDay> _day;
        //private Events _event;
        //List<Guest> guestList;
        //List<EventDay> _day;
        //EventDay eventDay_;
        //int selectedIndex = -1;
        public frmWizSummary(frmWizard c)
        {
            //_guests = c._guests;
            //_day = c._days;
            _event = c._event;
            _days = c._days;
            //_programs = new List<List<Program>>();
            _programs = c._programs;
            _items = c._items;
            _itemTypes = new List<ItemTypes>();
            _guests = c._guests;
            //_guests = new List<List<Guest>>();
            _publish = c._publish;
            _task = c._task;

            InitializeComponent();
        }
Esempio n. 17
0
 public void AddNewItemType(User u, Events event_, String ItemType, Boolean Important)
 {
     EventItemsHelper client = new EventItemsHelper();
     try
     {
         ItemTypes type = client.AddEventItemType(u, event_.EventID, ItemType, Important);
         ItemTypeCollection.Add(type);
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error have occured: " + ex.Message, "Error!",
             MessageBoxButton.OK, MessageBoxImage.Error);
     }
     finally
     {
         client.Close();
     }
 }
Esempio n. 18
0
        public frmOverview_Old(User u, Events e, EventDay evd, Events pEvent)
            : this()
        {
            this.user = u;
            this.event_ = e;
            this.eventday_ = evd;

            if (e != null && evd != null && (pEvent == null || pEvent.EventID != e.EventID))
            {
                //when evd and e are not null, pEvent not null or pEvent ID is not equal to EID
                loadEventItems();

            }
            else if (e != null && evd != null && e.EventID == evd.EventID)
            {
                //when both id are the same
                loadDayItems();
            }
        }
Esempio n. 19
0
        //Publish orginal_publish;
        public frmWizPublish(frmWizard c)
        {
            InitializeComponent();
            publish = c._publish;
            user = c._user;
            event_ = c._event;

            //publish.StartDateTime = orginal_publish.StartDateTime;
            //publish.Remarks = orginal_publish.Remarks;
            //publish.EndDateTime = orginal_publish.EndDateTime;
            //publish.IsPayable = orginal_publish.IsPayable;
            //publish.PaymentAMount = orginal_publish.PaymentAMount;

            if (publish.Remarks != null)
            {
                txtRemarks.Text = publish.Remarks;
                dtpStart.SelectedDateTime = publish.StartDateTime;
                dtpEnd.SelectedDateTime = publish.EndDateTime;
                cboIsPayable.IsChecked = publish.IsPayable;
                txtamount.Text = publish.PaymentAMount.ToString();
            }
            else
            {
                btnDelete.IsEnabled = false;
            }

            dtpStart.dtpDate.SelectedDateChanged += dateChanged;
            dtpEnd.dtpDate.SelectedDateChanged += dateChanged;

            dtpStart.cboHr.SelectionChanged += dateChanged;
            dtpStart.cboMin.SelectionChanged += dateChanged;

            dtpEnd.cboHr.SelectionChanged += dateChanged;
            dtpEnd.cboMin.SelectionChanged += dateChanged;

            dtpStart.cboHr.SelectionChanged += starthourChanged;

            dtpEnd.cboHr.SelectionChanged += endhourChanged;
        }
Esempio n. 20
0
        public frmRoleList(User u, Events e)
            : this()
        {
            this.user = u;
            this.event_ = e;
            this.checkBoxes = new Dictionary<string, List<CheckBox>>();
            accbUsers.AutoCompleteManager.DataProvider = new UserDataProvider();
            accbUsers.AutoCompleteManager.AutoAppend = true;

            RoleHelper client = new RoleHelper();
            try
            {

                List<Function> functions = client.ViewFunction().ToList();

                TreeViewItem root = new TreeViewItem() { Header = "All Rights", IsExpanded = true };
                tvFunctions.Items.Add(root);
                string currGroup = "";
                TreeViewItem parent = null;
                foreach (Function function in functions)
                {
                    if (function.Grouping != currGroup)
                    {
                        currGroup = function.Grouping;
                        parent = new TreeViewItem() { Header = function.Grouping, IsExpanded = true };
                        root.Items.Add(parent);
                    }
                    parent.Items.Add(new TreeViewItem() { Header = function.Description, Tag = function.FunctionEnum });
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                client.Close();
            }
        }
Esempio n. 21
0
        public static void DeleteEvent(User user, Events evnt)
        {
            //chk if user can do this anot
            if (!user.isAuthorized(evnt))
                throw new FaultException<SException>(new SException(),
                   new FaultReason("Invalid User, User Does Not Have Rights To Delete this Events!"));

            DAL dalDataContext = new DAL();

            try
            {
                Events matchedevent = (from events in dalDataContext.events
                                       where events.EventID == evnt.EventID
                                       select events).FirstOrDefault();

                dalDataContext.events.DeleteOnSubmit(matchedevent);
                dalDataContext.SubmitChanges();
            }
            catch (Exception ex)
            {
                throw new FaultException<SException>(new SException(ex.Message),
                   new FaultReason("An Error occured While Deleting Event, Please Try Again!"));
            }
        }
Esempio n. 22
0
        public static Events AddEvent(User user, string EventName, DateTime EventStartDateTime, DateTime EventEndDatetime,
            string EventDescription, string EventWebsite, string EventTag, DAL dalDataContext)
        {
            try
            {
                //DAL dalDataContext = new DAL();
                Table<Events> events = dalDataContext.events;
                //seperate into diff day here

                Events creatingevent;

                creatingevent = new Events(user.UserID, EventName, EventStartDateTime, EventEndDatetime, EventDescription, EventWebsite, EventTag);

                events.InsertOnSubmit(creatingevent);

                events.Context.SubmitChanges();
                return creatingevent;
            }
            catch
            {
                throw new FaultException<SException>(new SException(),
                   new FaultReason("An Error occured While Adding New Event, Please Try Again!"));
            }
        }
Esempio n. 23
0
        public void ToggleItemTypeImpt(User u, Events event_)
        {
            if (lv.SelectedIndex==-1)
            {
                MessageBox.Show("Please Select an Item Type to toggle!", "Error!",
                    MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            EventItemsHelper client = new EventItemsHelper();

            //Insert server code here
            ItemTypes Item2Edit = ItemTypeCollection[lv.SelectedIndex];
            bool Important=!Item2Edit.IsImportantType;
            ItemTypeCollection[lv.SelectedIndex].IsImportantType = Important;
            client.SetItemTypeImportance(u, Item2Edit, Important);
            client.Close();
        }
Esempio n. 24
0
 public static bool HaveRights(Events evnt, User user, EnumFunctions FunctionEnum)
 {
     if (evnt.Organizerid == user.UserID)
         return true;
     List<EnumFunctions> rights = GetRights(evnt.EventID, user.UserID);
     for (int i = 0; i < rights.Count; i++)
     {
         if (rights[i] == FunctionEnum)
             return true;
     }
     return false;
 }
Esempio n. 25
0
        public static void EditRoleTemplate(int RoleTemplateID, User user, Events evnt, string RoleTemplatePost, string RoleTemplateDescription)
        {
            if (!user.isAuthorized( evnt, EnumFunctions.Add_Role))
                throw new FaultException<SException>(new SException(),
                   new FaultReason("Invalid User, User Does Not Have Rights To Edit This Role Template!"));

            try
            {
                DAL dalDataContext = new DAL();

                RoleTemplate matchedrole;

                if (evnt != null)
                {
                    matchedrole = (from roles in dalDataContext.roleTemplate
                                   where roles.RoleTemplateID == RoleTemplateID
                                   select roles).FirstOrDefault();
                }
                else
                {
                    matchedrole = (from roles in dalDataContext.roleTemplate
                                   where roles.RoleTemplateID == null
                                   select roles).FirstOrDefault();
                }

                if (matchedrole == null)
                {

                    throw new FaultException<SException>(new SException(),
                       new FaultReason("Invalid Role Template"));
                }
                else
                {
                    matchedrole.Description = RoleTemplateDescription;
                    matchedrole.Post = RoleTemplatePost;

                    dalDataContext.SubmitChanges();
                }
            }
            catch
            {
                throw new FaultException<SException>(new SException(),
                   new FaultReason("An Error occured While Editing Role Template, Please Try Again!"));
            }
        }
 public frmPublishWebsite(User u, Events e)
     : this()
 {
     this.user = u;
     this.event_ = e;
 }
Esempio n. 27
0
        public static void EditEvent(User user, Events evnt, string EventName,
            DateTime newStartDateTime, DateTime newEndDateTime, string EventDescription, string EventWebsite, string EventTag)
        {
            if (!user.isAuthorized(evnt))
                throw new FaultException<SException>(new SException(),
                   new FaultReason("Invalid User, User Does Not Have Rights To Edit this Events!"));
            //chk if user can do this anot

            Events matchedevent = EventController.GetEvent(evnt.EventID);
            DateTime oldEventStartDate = matchedevent.StartDateTime.Date;

            if (matchedevent == null)
            {
                throw new FaultException<SException>(new SException(),
                   new FaultReason("Invalid Event"));
            }

            try
            {

                using (TransactionScope tScope = new TransactionScope(TransactionScopeOption.Required))
                {

                    DAL dalDataContext = new DAL();
                    //old - new
                    //if position = number of days to add
                    TimeSpan start_diff = matchedevent.StartDateTime.Date - newStartDateTime.Date;

                    int start_day_diff = start_diff.Days;

                    DateTime end_old = matchedevent.EndDateTime;
                    if (!end_old.Date.Equals(end_old))
                        end_old = end_old.Date.AddDays(1);

                    DateTime end_new = newEndDateTime;
                    if (!end_new.Date.Equals(end_new))
                        end_new = end_new.Date.AddDays(1);

                    //new-old
                    //if position = number of days to add
                    TimeSpan end_diff = end_new - end_old;
                    int end_day_diff = end_diff.Days;

                    int actualydaydiff = start_day_diff + end_day_diff;

                    EventController.EditEvent(user, evnt, EventName, newStartDateTime, newEndDateTime, EventDescription, EventWebsite, EventTag, dalDataContext);

                    List<EventDay> days = DayController.GetDays(evnt.EventID);

                    TimeSpan temp = end_new - newStartDateTime.Date;
                    int total_days = temp.Days;

                    //need to know if old date is got cross path with new date
                    bool isWithin = false;

                    //DateTime oldEventStartDate = days[0].StartDateTime.Date;
                    //DateTime oldEventEndDate = oldEventStartDate.AddDays(days.Count);

                    //if (newStartDateTime <= oldEventStartDate && newEndDateTime >= oldEventEndDate)
                    //    isWithin = true;

                    for (int i = 0; i < days.Count(); i++)
                    {
                        DateTime t = oldEventStartDate.AddDays(i);
                        if (newStartDateTime <= t && newEndDateTime >= t)
                        {
                            isWithin = true;
                        }
                    }

                    if (!isWithin)
                    {

                        //first delete all
                        for (int i = 0; i < days.Count(); i++)
                        {
                            DayController.DeleteDay(days[i], dalDataContext);
                        }

                        //add all new

                        int day = 1;
                        DateTime EventStartDateTime = newStartDateTime;
                        DateTime EventEndDatetime = newEndDateTime;

                        DateTime current_date = EventStartDateTime.Date;
                        current_date = current_date.AddHours(EventStartDateTime.Hour);
                        current_date = current_date.AddMinutes(EventStartDateTime.Minute);

                        DateTime end_date = EventEndDatetime.Date;
                        end_date = end_date.AddHours(EventEndDatetime.Hour);
                        end_date = end_date.AddMinutes(EventEndDatetime.Minute);

                        do
                        {
                            EventDay d = DayController.AddDay(evnt.EventID, day, dalDataContext);
                            day++;

                            current_date = current_date.Date;
                            current_date = current_date.AddDays(1);
                        } while (current_date < end_date);

                    }
                    else
                    {
                        for (int i = start_day_diff; i < 0; i++)
                        {

                            DayController.DeleteDay(days[0], dalDataContext);
                            days.RemoveAt(0);
                            start_day_diff++;
                        }

                        for (int i = end_day_diff; i < 0; i++)
                        {
                            DayController.DeleteDay(days[days.Count - 1], dalDataContext);
                            days.RemoveAt(days.Count - 1);
                            end_day_diff++;
                        }

                        int data = start_day_diff + end_day_diff + days.Count;
                        //total days must = data or means programming something wrong, or manaully edited
                        //throw error
                        if (!data.Equals(total_days))
                            throw new FaultException<SException>(new SException(),
                                    new FaultReason("days code may have been edited"));
                        //maybe add chk procedure to make sure the db always in series?
                        //add code here to add back the days
                        //mod first

                        int temp_count = days.Count + start_day_diff;
                        for (int i = start_day_diff; i < temp_count; i++)
                        {
                            DayController.EditDay(days[0].DayID, i + 1, dalDataContext);

                            days.RemoveAt(0);
                        }

                        for (int i = 0; i < start_day_diff; i++)
                        {
                            if (start_day_diff > 0)
                            {
                                DayController.AddDay(evnt.EventID, i + 1, dalDataContext);
                                continue;
                            }
                        }
                        start_day_diff = 0;
                        for (int i = total_days - end_day_diff; i < total_days; i++)
                        {

                            if (end_day_diff > 0)
                            {
                                //add new
                                DayController.AddDay(evnt.EventID, i + 1, dalDataContext);
                                end_day_diff--;
                                continue;
                            }

                            throw new FaultException<SException>(new SException(),
                                    new FaultReason("days code may have been edited"));

                        }

                        if (days.Count != 0 || end_day_diff != 0)
                            throw new FaultException<SException>(new SException(),
                                new FaultReason("days code may have been edited"));
                    }
                    tScope.Complete();
                }
            }
            catch (Exception ex)
            {

                throw new FaultException<SException>(new SException(),
                   new FaultReason("An Error occured While Editing New Event, Please Try Again!"));
            }
        }
Esempio n. 28
0
        public static void EditEvent(User user, Events evnt, string EventName,
            DateTime newStartDateTime, DateTime newEndDateTime, string EventDescription, string EventWebsite, string EventTag, DAL dalDataContext)
        {
            Events matchedevent = (from events in dalDataContext.events
                                   where events.EventID == evnt.EventID
                                   select events).FirstOrDefault();

            if (matchedevent == null)
            {
                throw new FaultException<SException>(new SException(),
                   new FaultReason("Invalid Event"));
            }
            else
            {
                if (newEndDateTime <= newStartDateTime)
                {
                    throw new FaultException<SException>(new SException("Error!"),
                      new FaultReason("Event's end time must be after its start time."));
                }

                if ((matchedevent.StartDateTime != newStartDateTime) ||
                    (matchedevent.EndDateTime != newEndDateTime))
                {
                    matchedevent.StartDateTime = newStartDateTime;
                    matchedevent.EndDateTime = newEndDateTime;
                    FaciRequestController.CancelRequestDueToEventTimeChange(matchedevent.EventID, newStartDateTime, newEndDateTime);
                }

                matchedevent.Description = EventDescription;

                //Bug Fix
                if (string.Compare(EventWebsite.ToLower(), "http://", true) == 0)
                    matchedevent.Website = "";
                else
                    matchedevent.Website = EventWebsite;

                matchedevent.Name = EventName;
                matchedevent.Tag = EventTag;

                dalDataContext.SubmitChanges();

            }
        }
Esempio n. 29
0
 public frmViewTask(User u, Events e)
     : this()
 {
     this.user = u;
     this.event_ = e;
 }
Esempio n. 30
0
        public static List<RoleTemplate> ViewRoleTemplates(User user, Events evnt)
        {
            DAL dalDataContext = new DAL();

            List<RoleTemplate> Roles;
            if (evnt  != null)
            {
                Roles = (from roles in dalDataContext.roleTemplate
                         where roles.EventID == evnt.EventID
                         select roles).ToList<RoleTemplate>();
            }
            else
            {
                Roles = (from roles in dalDataContext.roleTemplate
                         where roles.EventID == null
                         select roles).ToList<RoleTemplate>();
            }

            return Roles;
        }