Esempio n. 1
0
        public List <Process> GetProcesses()
        {
            var processes = new List <Process>();

            if (ParentForm != null)
            {
                var appForms         = (MadeiraMuseum)ParentForm;
                var dashboardControl = appForms.DashboardControl;

                var role = GetPersonRole(dashboardControl.Person.Id);

                var processesResult = DbQuery.GetProcessByPerson(GetProcessByPerson(role.RoleId()));

                if (processesResult != null)
                {
                    foreach (var process in processesResult)
                    {
                        var processesAdapter = new DictionaryAdapter(process);

                        var roomsResult = DbQuery.GetAllRoomsByProcess(processesAdapter.GetValue("id"));

                        var itemsResult = DbQuery.GetAllItemsByProcess(processesAdapter.GetValue("id"));

                        var otherEntety = GetOtherPerson(processesAdapter);

                        var scheduleResult = DbQuery.GetSchedulesById(processesAdapter.GetValue("schedule_id"));

                        var schedule = new Schedule(scheduleResult[0]);

                        var rooms = new List <Room>();

                        foreach (var room in roomsResult)
                        {
                            var adapterRoom    = new DictionaryAdapter(room);
                            var specRoomResult = DbQuery.GetAllRoomsById(adapterRoom.GetValue("rooms_id"));
                            var newRoom        = new Room(specRoomResult[0]);
                            rooms.Add(newRoom);
                        }

                        var newProcesses = CreateProcess(process, role, otherEntety, schedule, rooms);
                        foreach (var item in itemsResult)
                        {
                            var adapter      = new DictionaryAdapter(item);
                            var specificItem = GetSpecificItem(adapter.GetValue("items_id"));
                            newProcesses.DecorateWithArtPiece(specificItem);
                        }

                        processes.Add(newProcesses);
                    }
                }
            }

            return(processes);
        }
Esempio n. 2
0
        public override Person GetOtherPerson(DictionaryAdapter dictionaryAdapter)
        {
            var personResult = DbQuery.GetEmployeeByRoleId(dictionaryAdapter.GetValue("employees_id"));
            var employee     = (Employee)FactoryCreator.Instance.CreateFactory(FactoryCreator.PersonFactory)
                               .ImportData(PersonFactory.Employee, personResult[0]);

            return(employee);
        }
Esempio n. 3
0
        public override Person GetOtherPerson(DictionaryAdapter dictionaryAdapter)
        {
            var personResult = DbQuery.GetExhibitorByRoleId(dictionaryAdapter.GetValue("exhibitors_id"));
            var exhibitor    = (Exhibitor)FactoryCreator.Instance.CreateFactory(FactoryCreator.PersonFactory)
                               .ImportData(PersonFactory.Exhibitor, personResult[0]);

            return(exhibitor);
        }
Esempio n. 4
0
        public void GetEmployees()
        {
            var list = DbQuery.GetAllEmployeesOrderedByLastUpdate();

            if (list != null)
            {
                Debug.WriteLine(list.Count);
                var personFactory = FactoryCreator.Instance.CreateFactory("PersonFactory");

                foreach (var demployee in list)
                {
                    var daEmployee = new DictionaryAdapter(demployee);
                    var personId   = daEmployee.GetValue("persons_id");
                    if (personId != null)
                    {
                        var valueExists = false;
                        foreach (var emp in Employees)
                        {
                            if (emp.Id == int.Parse(personId))
                            {
                                valueExists = true; // ja existe, nao adiciona
                                if (emp.LastUpdateSalary == daEmployee.GetValue("empLastUpdate"))
                                {
                                    //não altera pois já está o mais atualizado
                                }
                                else
                                {
                                    emp.LastUpdateSalary =
                                        daEmployee.GetValue("empLastUpdate"); //atualiza o lastupdate na instância classe
                                }
                            }
                        }

                        if (!valueExists) //não existe logo adiciona à lista Employees
                        {
                            var employee = personFactory.ImportData("Employee", demployee);
                            Employees.Insert(0, (Employee)employee);
                        }
                    }
                }

                Debug.WriteLine("emp count: " + Employees.Count);
            }
        }
        public void ListRooms()
        {
            comboBoxRooms.Items.Clear();
            var roomsList = DbQuery.GetAllRooms();

            if (roomsList != null)
            {
                foreach (var room in roomsList)
                {
                    var dictionaryAdapter = new DictionaryAdapter(room);
                    var comboItem         = new ComboboxItem
                    {
                        Text  = "Room " + dictionaryAdapter.GetValue("id"),
                        Value = int.Parse(dictionaryAdapter.GetValue("id"))
                    };
                    comboBoxRooms.Items.Add(comboItem);
                }
            }
        }
Esempio n. 6
0
        public IList <Schedule> GetSchedules()
        {
            // Time now
            var date  = new DateTime();
            var day   = date.Day;
            var month = date.Month;
            var year  = date.Year;

            // Schedules
            var schedules     = DbQuery.GetAllSchedules();
            var schedulesList = new List <Schedule>();

            foreach (var schedule in schedules)
            {
                var scheduleAdapter = new DictionaryAdapter(schedule);
                var startDateValue  = scheduleAdapter.GetValue("firstDay");
                var lastDateValue   = scheduleAdapter.GetValue("lastDay");

                var startDayMonthYear = startDateValue.Split('-');
                var endDayMonthYear   = lastDateValue.Split('-');

                if (month.ToString().Equals(startDayMonthYear[1]) && year.ToString().Equals(endDayMonthYear[1]))
                {
                    if (day.ToString().Equals(startDayMonthYear[0]) || day.ToString().Equals(endDayMonthYear[0]))
                    {
                        var selectedSchedule = new Schedule(schedule);
                        schedulesList.Add(selectedSchedule);
                    }
                    else if (day > int.Parse(startDayMonthYear[0]) && day < int.Parse(endDayMonthYear[0]))
                    {
                        var selectedSchedule = new Schedule(schedule);
                        schedulesList.Add(selectedSchedule);
                    }
                }
            }

            if (schedulesList.Count == 0)
            {
                return(null);
            }
            return(schedulesList);
        }
Esempio n. 7
0
        private void button1_Click(object sender, EventArgs e)
        {
            var myTimer = new Timer {
                Interval = 1000
            };

            try
            {
                var mailAddress = new MailAddress(MailBox.Text);
            }
            catch (FormatException)
            {
                MissingFields.Text    = @"You have insert a value in format of an email!";
                MissingFields.Visible = true;
                myTimer.Tick         += ShowAndHideFail;
                myTimer.Start();
                return;
            }

            var personResult = DbQuery.GetPeopleByMail(MailBox.Text);

            if (personResult.Count > 0)
            {
                var adapter = new DictionaryAdapter(personResult[0]);
                try
                {
                    var newPassword = RandomString(20);
                    DbQuery.UpdatePersonPassword(adapter.GetValue("id"), newPassword);
                    SendEmail(newPassword, MailBox.Text);
                    Sucess.Visible = true;
                    myTimer.Tick  += ShowAndHideSucess;
                    myTimer.Start();
                }
                catch (Exception exception)
                {
                    Console.WriteLine(exception.Message);
                }
            }
            else
            {
                MissingFields.Text    = @"No user in the records have this email!";
                MissingFields.Visible = true;
                myTimer.Tick         += ShowAndHideFail;
                myTimer.Start();
            }
        }
Esempio n. 8
0
        public void UpdateExhibitions()
        {
            var exhibitionsResult = DbQuery.GetAllEventsOrderedByLast();

            if (exhibitionsResult?.Count >= 2)
            {
                for (var i = 0; i < 2; i++)
                {
                    var adapter = new DictionaryAdapter(exhibitionsResult[i]);

                    var temporaryResult = DbQuery.GetTemporariesInEvents(adapter.GetValue("id"));

                    if (temporaryResult.Count == 0)
                    {
                        var permanentResult = DbQuery.GetPermanentsInEvents(adapter.GetValue("id"));
                        if (permanentResult.Count > 0)
                        {
                            adapter = new DictionaryAdapter(permanentResult[0]);

                            if (i == 0)
                            {
                                TitleFirstExhibition.Text     = adapter.GetValue("title");
                                NameExhibitionOne.Text        = adapter.GetValue("name");
                                DescriptionExhibitionOne.Text = adapter.GetValue("description");
                                FromExhibitionOne.Text        = @"---";
                                ToExhibitionOne.Text          = @"---";
                                ScheduleExhibitionOne.Text    = @"9:00 - 19:00";
                                ArtistExhibitionOne.Text      = @"Museum Property";
                            }
                            else
                            {
                                TitleSecondExhibition.Text    = adapter.GetValue("title");
                                NameExhibitionTwo.Text        = adapter.GetValue("name");
                                DescriptionExhibitionTwo.Text = adapter.GetValue("description");
                                ToExhibitionTwo.Text          = @"---";
                                FromExhibitionTwo.Text        = @"---";
                                ScheduleExhibitionTwo.Text    = @"9:00 - 19:00";
                                ArtistExhibitionTwo.Text      = @"Museum Property";
                            }
                        }
                    }
                    else
                    {
                        foreach (var property in temporaryResult)
                        {
                            var temporaryAdapter = new DictionaryAdapter(property);

                            var schedulesResult = DbQuery.GetSchedulesById(temporaryAdapter.GetValue("schedule_id"));

                            var schedulesAdapter = new DictionaryAdapter(schedulesResult[0]);

                            var processesResult = DbQuery.GetProcessesById(temporaryAdapter.GetValue("processes_id"));

                            var processesAdapter = new DictionaryAdapter(processesResult[0]);

                            var exhibitorResult =
                                DbQuery.GetExhibitorsById(processesAdapter.GetValue("exhibitors_id"));

                            var exhibitorAdapter = new DictionaryAdapter(exhibitorResult[0]);

                            var personResult = DbQuery.GetPeopleById(exhibitorAdapter.GetValue("persons_id"));

                            var personAdapter = new DictionaryAdapter(personResult[0]);

                            if (i == 0)
                            {
                                TitleFirstExhibition.Text     = adapter.GetValue("title");
                                NameExhibitionOne.Text        = adapter.GetValue("name");
                                DescriptionExhibitionOne.Text = adapter.GetValue("description");
                                FromExhibitionOne.Text        =
                                    schedulesAdapter.GetValue("startDay") + @"/" +
                                    schedulesAdapter.GetValue("startMonth") + @"/" +
                                    schedulesAdapter.GetValue("startYear");
                                ToExhibitionOne.Text =
                                    schedulesAdapter.GetValue("endDay") + @"/" +
                                    schedulesAdapter.GetValue("endMonth") + @"/" +
                                    schedulesAdapter.GetValue("endYear");
                                ScheduleExhibitionOne.Text =
                                    schedulesAdapter.GetValue("startTime") + @"-" +
                                    schedulesAdapter.GetValue("endTime");
                                ArtistExhibitionOne.Text = personAdapter.GetValue("name");
                            }
                            else
                            {
                                TitleSecondExhibition.Text    = adapter.GetValue("title");
                                NameExhibitionTwo.Text        = adapter.GetValue("name");
                                DescriptionExhibitionTwo.Text = adapter.GetValue("description");
                                FromExhibitionTwo.Text        =
                                    schedulesAdapter.GetValue("startDay") + @"/" +
                                    schedulesAdapter.GetValue("startMonth") + @"/" +
                                    schedulesAdapter.GetValue("startYear");
                                ToExhibitionTwo.Text =
                                    schedulesAdapter.GetValue("endDay") + @"/" +
                                    schedulesAdapter.GetValue("endMonth") + @"/" +
                                    schedulesAdapter.GetValue("endYear");
                                ScheduleExhibitionTwo.Text =
                                    schedulesAdapter.GetValue("startTime") + @"-" +
                                    schedulesAdapter.GetValue("endTime");
                                ArtistExhibitionTwo.Text = personAdapter.GetValue("name");
                            }
                        }
                    }
                }

                ExhibitionOne.Visible = true;
                ExhibitionTwo.Visible = true;
            }
            else
            {
                ExhibitionOne.Visible = false;
                ExhibitionTwo.Visible = false;
            }
        }
Esempio n. 9
0
        private void SpecSchedule_Click(object sender, EventArgs e)
        {
            Exhibitions.Controls.Clear();
            var  value = (ComboboxItem)RoomsCombo.SelectedItem;
            long idRoom;

            try
            {
                idRoom = value.Value;
            }
            catch (NullReferenceException)
            {
                return;
            }

            var date  = dateTimePicker.Value;
            var day   = date.Day;
            var month = date.Month;
            var year  = date.Year;

            var eventsId     = DbQuery.GetEventsByRoom(idRoom.ToString());
            var hasPermanent = false;

            if (eventsId.Count > 0)
            {
                var idSchedules = new List <int>();
                foreach (var events in eventsId)
                {
                    var adapter = new DictionaryAdapter(events);

                    var temporariesList = DbQuery.GetTemporariesInEvents(adapter.GetValue("events_id"));

                    var permanentsList = DbQuery.GetPermanentsInEvents(adapter.GetValue("events_id"));

                    if (permanentsList?.Count > 0)
                    {
                        hasPermanent = true;
                    }
                    else if (temporariesList.Count > 0)
                    {
                        var eventsAdapter = new DictionaryAdapter(temporariesList[0]);
                        idSchedules.Add(int.Parse(eventsAdapter.GetValue("schedule_id")));
                    }
                }

                var heigtht = Exhibitions.Size.Height;
                var width   = Exhibitions.Size.Width;

                if (idSchedules.Count > 0)
                {
                    var allSchedules = DbQuery.GetSchedulesByIds(idSchedules, day, month, year);

                    var scheduleList = new List <Schedule>();
                    foreach (var schedule in allSchedules)
                    {
                        var addSchedule = new Schedule(schedule);
                        scheduleList.Add(addSchedule);
                    }

                    var totalDivisions = 20;
                    var spacesList     = new List <int>();
                    var pickList       = new List <string>();
                    var textsLabel     = new List <string>();

                    var baseTime = "9:00";

                    foreach (var schedule in scheduleList)
                    {
                        var startTime            = schedule.StartTime;
                        var startTimeComponentes = startTime.Split(':');
                        var endTime            = schedule.EndTime;
                        var endTimeComponentes = endTime.Split(':');

                        if (!baseTime.Equals(startTime))
                        {
                            var baseSplit   = baseTime.Split(':');
                            var baseInicial = int.Parse(baseSplit[0]) * 2;
                            baseInicial = startTimeComponentes[1].Equals("30") ? baseInicial + 1 : baseInicial;

                            var startTimeNext = int.Parse(startTimeComponentes[0]) * 2;
                            startTimeNext = startTimeComponentes[1].Equals("30")
                                ? startTimeNext + 1
                                : startTimeNext;

                            var spaceWithout = startTimeNext - baseInicial;
//                            totalDivisions += spaceWithout;
                            textsLabel.Add("Free Schedule");
                            spacesList.Add(spaceWithout);
                            pickList.Add("Without");
                        }

                        var horaInicial = int.Parse(startTimeComponentes[0]) * 2;
                        horaInicial = startTimeComponentes[1].Equals("30") ? horaInicial + 1 : horaInicial;

                        var horaFinal = int.Parse(endTimeComponentes[0]) * 2;
                        horaFinal = endTimeComponentes[1].Equals("30") ? horaFinal + 1 : horaFinal;

                        var space = horaFinal - horaInicial;
//                        totalDivisions += space;
                        spacesList.Add(space);
                        pickList.Add("Schedule");
                        baseTime = endTime;

                        var processEventResult = DbQuery.GetProcessByScheduleId(schedule.Id.ToString());
                        var adapter            = new DictionaryAdapter(processEventResult[0]);
                        textsLabel.Add(adapter.GetValue("title") + "-" + adapter.GetValue("name"));
                    }

                    if (!baseTime.Equals("19:00"))
                    {
                        var final         = 38;
                        var componentTime = baseTime.Split(':');
                        var lastDivision  = componentTime[1].Equals("30")
                            ? int.Parse(componentTime[0]) * 2 + 1
                            : int.Parse(componentTime[0]) * 2;
                        lastDivision = final - lastDivision + 1;
                        spacesList.Add(lastDivision);
                        pickList.Add("Without");
                        textsLabel.Add("Free Schedule");
                    }

                    var listOfPanels = new List <Panel>();

                    var distanceTop = 0;
                    var pie         = (float)heigtht / totalDivisions;
                    for (var i = 0; i < spacesList.Count; i++)
                    {
                        var panel = new Panel
                        {
                            Dock        = DockStyle.Top,
                            Location    = new Point(0, (int)(i * (distanceTop * pie))),
                            Name        = "Time" + i,
                            BackColor   = pickList[i].Equals("Without") ? Color.White : Color.Yellow,
                            Size        = new Size(width, (int)(spacesList[i] * pie)),
                            AutoSize    = false,
                            TabIndex    = i,
                            BorderStyle = BorderStyle.FixedSingle
                        };

                        var label = new Label
                        {
                            Dock      = DockStyle.Fill,
                            Font      = new Font("Microsoft Sans Serif", 12F, FontStyle.Bold, GraphicsUnit.Point, 0),
                            Location  = new Point(0, (int)(i * (distanceTop * pie))),
                            Name      = "Event-" + i,
                            Size      = new Size(width, (int)(spacesList[i] * pie)),
                            TabIndex  = 1,
                            Text      = textsLabel[i],
                            TextAlign = ContentAlignment.MiddleCenter
                        };

                        distanceTop += spacesList[i];

                        panel.Controls.Add(label);
                        listOfPanels.Add(panel);
                    }

                    listOfPanels.Reverse();
                    foreach (var panel in listOfPanels)
                    {
                        Exhibitions.Controls.Add(panel);
                    }
                }
                else
                {
                    if (hasPermanent)
                    {
                        var panel = new Panel
                        {
                            Dock        = DockStyle.Top,
                            Location    = new Point(0, 0),
                            Name        = "Time",
                            BackColor   = Color.Yellow,
                            Size        = new Size(width, heigtht),
                            AutoSize    = false,
                            TabIndex    = 0,
                            BorderStyle = BorderStyle.FixedSingle
                        };

                        var label = new Label
                        {
                            Dock      = DockStyle.Fill,
                            Font      = new Font("Microsoft Sans Serif", 12F, FontStyle.Bold, GraphicsUnit.Point, 0),
                            Location  = new Point(0, 0),
                            Name      = "Event-",
                            Size      = new Size(width, heigtht),
                            TabIndex  = 1,
                            Text      = "Permanent Event",
                            TextAlign = ContentAlignment.MiddleCenter
                        };
                        panel.Controls.Add(label);
                        Exhibitions.Controls.Add(panel);
                    }
                }
            }
        }
Esempio n. 10
0
        public void GetUsers()
        {
            senderLabel.Text = Person.Name;
            var r     = new Regex("(Employee -)");
            var rName = new Regex("(" + Person.Name + ")");

            var l = DbQuery.GetAllPeople();

            foreach (var d in l)
            {
                var valueExists = false;
                var da          = new DictionaryAdapter(d);

                var counter       = 0;
                var cmbEnumerator = receivercomboBox1.Items.GetEnumerator();
                while (counter < receivercomboBox1.Items.Count && receivercomboBox1.Items.Count > 0)
                {
                    cmbEnumerator.MoveNext();
                    var cmbItem = (ComboboxItem)cmbEnumerator.Current;
                    if (cmbItem != null && cmbItem.Value == int.Parse(da.GetValue("id")))
                    {
                        valueExists = true;
                    }
                    Debug.WriteLine("Items count:" + receivercomboBox1.Items.Count + " counter: " + counter);

                    counter++;
                }

                if (!valueExists)
                {
                    var item = new ComboboxItem {
                        Value = int.Parse(da.GetValue("id"))
                    };
                    var queryex = DbQuery.GetExhibitorByPersonId(da.GetValue("id"));
                    if (queryex.Count > 0)
                    {
                        item.Text = "Exhibitor - " + da.GetValue("name");
                    }
                    else
                    {
                        item.Text = "Employee - " + da.GetValue("name");
                    }
                    var m     = r.Match(item.Text);
                    var mName = rName.Match(item.Text);
                    Debug.WriteLine(mName.Success);
                    if (Role == "Exhibitor" && m.Success)
                    {
                        if (mName.Success)
                        {
                            // caso seja o seu nome, não mostra o seu nome nos destinatarios
                        }
                        else
                        {
                            Debug.WriteLine("Value added: " + receivercomboBox1.Items.Count);
                            receivercomboBox1.Items.Add(item);
                        }
                    }
                    else if (Role == "Employee")
                    {
                        if (mName.Success)
                        {
                            // caso seja o seu nome, não mostra o seu nome nos destinatarios
                        }
                        else
                        {
                            Debug.WriteLine("Value added");
                            receivercomboBox1.Items.Add(item);
                        }
                    }
                }

                //MessageBox.Show((receivercomboBox1.SelectedItem as ComboboxItem).Value.ToString());
            }

            receivercomboBox1.SelectedIndex = 0;
        }
Esempio n. 11
0
        private void Submit_Click(object sender, EventArgs e)
        {
            if (CheckFields())
            {
                var rooms = new List <Room>();

                var roomsResult = DbQuery.GetAllRoomsByIds(_roomsIdList);
                if (roomsResult.Count > 0)
                {
                    if (CheckRoomAvailbility(_roomsIdList))
                    {
                        if (ParentForm != null)
                        {
                            var appForms         = (MadeiraMuseum)ParentForm;
                            var dashboardControl = appForms.DashboardControl;

                            var exhibitorResult =
                                DbQuery.GetExhibitorByPersonId(dashboardControl.Person.Id.ToString());
                            var exhibitor = (Exhibitor)FactoryCreator.Instance
                                            .CreateFactory(FactoryCreator.PersonFactory)
                                            .ImportData(PersonFactory.Exhibitor, exhibitorResult[0]);

                            foreach (var room in roomsResult)
                            {
                                var newRoom = new Room(room);
                                rooms.Add(newRoom);
                            }

                            var date       = FromPicker.Value;
                            var dayStart   = date.Day;
                            var monthStart = date.Month;
                            var yearStart  = date.Year;

                            date = UntilPicker.Value;
                            var dayEnd   = date.Day;
                            var monthEnd = date.Month;
                            var yearEnd  = date.Year;

                            var schedule = new Schedule(dayStart.ToString(), monthStart.ToString(),
                                                        yearStart.ToString(),
                                                        dayEnd.ToString(), monthEnd.ToString(), yearEnd.ToString(), startBox.Text, endBox.Text);
                            schedule.Save();

                            var employeesResult = DbQuery.GetAllEmployees();

                            var number   = 0;
                            var chosenId = 0;

                            for (var i = 0; i < employeesResult.Count; i++)
                            {
                                var adapterEmployee = new DictionaryAdapter(employeesResult[i]);

                                var processesResult =
                                    DbQuery.GetProcessesByEmployeeIdandActive(adapterEmployee.GetValue("id"));
                                if (i == 0)
                                {
                                    number   = processesResult.Count;
                                    chosenId = int.Parse(adapterEmployee.GetValue("id"));
                                }
                                else
                                {
                                    if (number > processesResult.Count)
                                    {
                                        number   = processesResult.Count;
                                        chosenId = int.Parse(adapterEmployee.GetValue("id"));
                                    }
                                }
                            }

                            var employeeResult = DbQuery.GetAllEmployeesByRoleId(chosenId.ToString());

                            var employee = (Employee)FactoryCreator.Instance
                                           .CreateFactory(FactoryCreator.PersonFactory)
                                           .ImportData(PersonFactory.Employee, employeeResult[0]);

                            var process = new Process(exhibitor, employee, schedule, rooms, textBoxName.Text,
                                                      textBoxDescription.Text, textBoxTitle.Text, "img");
                            process.Save();
                        }

                        _roomsIdList.Clear();

                        if (ParentForm != null)
                        {
                            var appForms = (MadeiraMuseum)ParentForm;
                            var processesExhibitorControl = appForms.ProcessesExhibitorControl;
                            processesExhibitorControl.GetProcesses();
                            processesExhibitorControl.ResetProcesses();
                            processesExhibitorControl.ListProcesses(processesExhibitorControl.ActualPage);
                            processesExhibitorControl.BringToFront();
                        }
                    }
                    else
                    {
                        var myTimer = new Timer {
                            Interval = 1000
                        };
                        InvalidValue.Text    = @"These schedule is not available in this rooms!";
                        InvalidValue.Visible = true;
                        myTimer.Tick        += HideFail;
                        myTimer.Start();
                    }
                }
                else
                {
                    var myTimer = new Timer {
                        Interval = 1000
                    };
                    InvalidValue.Text    = @"You add atleast one room!";
                    InvalidValue.Visible = true;
                    myTimer.Tick        += HideFail;
                    myTimer.Start();
                }
            }
        }
Esempio n. 12
0
        private bool CheckRoomAvailbility(List <int> roomsId)
        {
            var date       = FromPicker.Value;
            var dayStart   = date.Day;
            var monthStart = date.Month;
            var yearStart  = date.Year;

            date = UntilPicker.Value;
            var dayEnd   = date.Day;
            var monthEnd = date.Month;
            var yearEnd  = date.Year;


            var desiredStartDayMonthYear = new[] { dayStart.ToString(), monthStart.ToString(), yearStart.ToString() };
            var desiredEndDayMonthYear   = new[] { dayEnd.ToString(), monthEnd.ToString(), yearEnd.ToString() };
            var desiredStartTime         = startBox.Text.Split(':');
            var desiredEndTime           = endBox.Text.Split(':');

            foreach (var room in roomsId)
            {
                var roomsEventsResult = DbQuery.GetEventsByRoom(room.ToString());

                if (roomsEventsResult != null)
                {
                    foreach (var events in roomsEventsResult)
                    {
                        var eventAdapter = new DictionaryAdapter(events);

                        var temporaries = DbQuery.GetTemporariesInEvents(eventAdapter.GetValue("events_id"));

                        var temporariesAdapter = new DictionaryAdapter(temporaries[0]);

                        var scheduleEventResult =
                            DbQuery.GetScheduleByIdOrderByLastUpdateDesc(temporariesAdapter.GetValue("schedule_id"));

                        if (scheduleEventResult != null)
                        {
                            foreach (var schedule in scheduleEventResult)
                            {
                                var scheduleAdapter = new DictionaryAdapter(schedule);

                                var startDayValue   = scheduleAdapter.GetValue("startDay");
                                var startMonthValue = scheduleAdapter.GetValue("startMonth");
                                var startYearValue  = scheduleAdapter.GetValue("startMonth");

                                var lastDayValue   = scheduleAdapter.GetValue("endDay");
                                var lastMonthValue = scheduleAdapter.GetValue("endMonth");
                                var lastYearValue  = scheduleAdapter.GetValue("endYear");

                                var startTime = scheduleAdapter.GetValue("startTime");
                                var endTime   = scheduleAdapter.GetValue("endTime");

                                var startHourMin = startTime.Split(':');
                                var endHourMin   = endTime.Split(':');
                                if (int.Parse(desiredEndDayMonthYear[2]) == int.Parse(startYearValue) ||
                                    int.Parse(desiredEndDayMonthYear[2]) == int.Parse(lastYearValue) ||
                                    int.Parse(desiredStartDayMonthYear[2]) == int.Parse(startYearValue) ||
                                    int.Parse(desiredStartDayMonthYear[2]) == int.Parse(lastYearValue))
                                {
                                    if (startMonthValue.Equals(desiredStartDayMonthYear[1]) &&
                                        lastMonthValue.Equals(desiredEndDayMonthYear[1]))
                                    {
                                        if (int.Parse(startDayValue) > int.Parse(desiredStartDayMonthYear[0]))
                                        {
                                            if (int.Parse(startDayValue) < int.Parse(desiredEndDayMonthYear[0]))
                                            {
                                            }
                                            else if (int.Parse(startDayValue) > int.Parse(desiredEndDayMonthYear[0]))
                                            {
                                                return(false);
                                            }
                                            else if (int.Parse(startDayValue) ==
                                                     int.Parse(desiredEndDayMonthYear[0]))
                                            {
                                                if (!CheckTimeConflict(desiredStartTime, desiredEndTime, startHourMin,
                                                                       endHourMin))
                                                {
                                                    return(false);
                                                }
                                            }
                                        }
                                        else if (int.Parse(startDayValue) < int.Parse(desiredStartDayMonthYear[0]))
                                        {
                                            if (int.Parse(startDayValue) < int.Parse(desiredEndDayMonthYear[0]))
                                            {
                                            }
                                            else if (int.Parse(lastDayValue) > int.Parse(desiredStartDayMonthYear[0]))
                                            {
                                                return(false);
                                            }
                                            else if (int.Parse(lastDayValue) ==
                                                     int.Parse(desiredStartDayMonthYear[0]))
                                            {
                                                if (!CheckTimeConflict(desiredStartTime, desiredEndTime, startHourMin,
                                                                       endHourMin))
                                                {
                                                    return(false);
                                                }
                                            }
                                        }
                                        else if (int.Parse(lastDayValue) == int.Parse(desiredStartDayMonthYear[0]))
                                        {
                                            if (!CheckTimeConflict(desiredStartTime, desiredEndTime, startHourMin,
                                                                   endHourMin))
                                            {
                                                return(false);
                                            }
                                        }
                                        else
                                        {
                                            return(false);
                                        }
                                    }
                                    else if (lastMonthValue.Equals(desiredStartDayMonthYear[1]))
                                    {
                                        if (int.Parse(lastDayValue) < int.Parse(desiredStartDayMonthYear[0]))
                                        {
                                        }
                                        else if (int.Parse(lastDayValue) > int.Parse(desiredStartDayMonthYear[0]))
                                        {
                                            return(false);
                                        }
                                        else if (int.Parse(lastDayValue) == int.Parse(desiredStartDayMonthYear[0]))
                                        {
                                            if (!CheckTimeConflict(desiredStartTime, desiredEndTime, startHourMin,
                                                                   endHourMin))
                                            {
                                                return(false);
                                            }
                                        }
                                    }
                                    else if (startMonthValue.Equals(desiredEndDayMonthYear[1]))
                                    {
                                        if (int.Parse(desiredEndDayMonthYear[1]) < int.Parse(startMonthValue))
                                        {
                                        }
                                        else if (int.Parse(desiredEndDayMonthYear[1]) > int.Parse(startMonthValue))
                                        {
                                            return(false);
                                        }
                                        else if (int.Parse(lastDayValue) == int.Parse(desiredStartDayMonthYear[1]))
                                        {
                                            if (!CheckTimeConflict(desiredStartTime, desiredEndTime, startHourMin,
                                                                   endHourMin))
                                            {
                                                return(false);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return(true);
        }
Esempio n. 13
0
        private void AddMessage(int c)
        {
            if (Enumerator.Current == null) // caso inicial quando ainda n foi efetuado o primeiro movenext
            {
                Enumerator.MoveNext();
            }
            var msg   = Enumerator.Current;
            var nrMsg = Person.Messages.Count;

            if (nrMsg > 0)
            {
                Debug.WriteLine("nr_msg: " + nrMsg);
                if (msg != null)
                {
                    var    list       = DbQuery.GetMessageLastUpdate(msg.Id.ToString());
                    string lastUpdate = null;
                    foreach (var msgdict in list)
                    {
                        var da = new DictionaryAdapter(msgdict);
                        lastUpdate = da.GetValue("lastUpdate");
                    }

                    if (lastUpdate != null)
                    {
                        var msgtext = AddMessageField(80 * c); //Cria o campo do label no windows forms
                        msgtext.AutoSize    = false;
                        msgtext.BorderStyle = BorderStyle.FixedSingle;
                        msgtext.BackColor   = Color.BurlyWood;
                        msgtext.Text        = @"Title: " + msg.Title + Environment.NewLine + @"From: " +
                                              msg.Sender.Name +
                                              @" - Received at: " + lastUpdate;


                        msgtext.TextAlign   = ContentAlignment.MiddleCenter;
                        msgtext.Width       = 625;
                        msgtext.Height      = 80;
                        msgtext.Click      += delegate { msgtext_Click(msg); };
                        msgtext.MouseHover += delegate
                        {
                            msgtext.BackColor = Color.AntiqueWhite;
                            Cursor.Current    = Cursors.Hand;
                        };
                        msgtext.MouseEnter += delegate
                        {
                            msgtext.BackColor = Color.AntiqueWhite;
                            Cursor.Current    = Cursors.Hand;
                        };
                        msgtext.MouseLeave += delegate
                        {
                            msgtext.BackColor = Color.BurlyWood;
                            Cursor.Current    = Cursors.Default;
                        };

                        if (Enumerator.Current != null)
                        {
                            Debug.WriteLine(Enumerator.Current.Id);
                        }
                    }
                }
            }
            else
            {
                var msgtext = AddMessageField(20 * 1); //Cria o campo no windows forms
                msgtext.AutoSize  = false;
                msgtext.Font      = new Font("Microsoft Sans Serif", 18F);
                msgtext.BackColor = Color.BurlyWood;
                msgtext.Text      = @"No messages";
                msgtext.TextAlign = ContentAlignment.MiddleCenter;
                msgtext.Width     = 625;
                msgtext.Height    = 80;
            }
        }