Ejemplo n.º 1
0
        internal void EditMode(BusyTime busyTime, ViewList viewList)
        {
            this.viewList                     = viewList;
            this.busyTime                     = busyTime;
            textBox_Name.Text                 = busyTime.Name;
            comboBox_Type.SelectedItem        = busyTime.Type;
            textBox_Description.Text          = busyTime.Description;
            dateTimePicker_StartingTime.Value = (DateTime.Today + busyTime.StartTime);
            dateTimePicker_EndingTime.Value   = (DateTime.Today.AddDays(1) + busyTime.EndTime);
            button2.Text = "Cancel";

            for (int i = 0; i <= (checkedListBox_Frequency.Items.Count - 1); i++)
            {
                if (busyTime.Frequency.Contains(checkedListBox_Frequency.Items[i].ToString().Substring(0, 2)))
                {
                    checkedListBox_Frequency.SetItemCheckState(i, CheckState.Checked);
                }
                else
                {
                    checkedListBox_Frequency.SetItemCheckState(i, CheckState.Unchecked);
                }
            }



            button1.Text = "Save Changes";
        }
Ejemplo n.º 2
0
        public static int BusyTimeTableAdd(BusyTime busyTime)
        {
            if (!ConnectToDatabase())
            {
                return(0);
            }
            string sqlCMD = $"INSERT INTO BusyTime(name, type, description,frequency,personID,startTime,endTime) OUTPUT INSERTED.ID " +
                            $"VALUES ('{busyTime.Name}','{busyTime.Type}', '{busyTime.Description}','{busyTime.Frequency}', {busyTime.PersonID}, '{busyTime.StartTime}', '{busyTime.EndTime}')";

            SqlCommand command     = new SqlCommand(sqlCMD, connection);
            int        busyTimeKey = (int)command.ExecuteScalar();

            DisconnectFromDatabase();
            return(busyTimeKey);
        }
Ejemplo n.º 3
0
        public static List <BusyTime> BusyTimeTableGetByHomeID(int homeID)
        {
            string          sqlCMD    = $"SELECT * FROM BusyTime WHERE personID IN (Select ID from Person WHERE homeID = {homeID})";
            DataTable       dataTable = GetDataTable(sqlCMD);
            List <BusyTime> busyTimes = new List <BusyTime>();


            foreach (DataRow row in dataTable.Rows)
            {
                BusyTime busyTime = new BusyTime(row.Field <int>("ID"), row.Field <string>("Name"), row.Field <string>("Type"), row.Field <string>("Description"), row.Field <string>("Frequency"), row.Field <int>("personID"), row.Field <TimeSpan>("startTime"), row.Field <TimeSpan>("endTime"));
                busyTimes.Add(busyTime);
            }


            return(busyTimes);
        }
        private void ShowBusyTime(BusyTime busyTime)
        {
            pictureBox1.Image = imageList.Images[1];

            textBox_Name.Text  = busyTime.Name;
            textBox_Info1.Text = busyTime.Type;
            string formatted = (DateTime.Today + busyTime.StartTime).ToString("hh:mm");

            textBox_Info2.Text = formatted;
            formatted          = (DateTime.Today + busyTime.EndTime).ToString("hh:mm");
            textBox_Info3.Text = formatted;

            string frequency = viewList.SplitStringByUppercase(busyTime.Frequency, ", ");

            textBox_Info4.Text = frequency;
            textBox_Info5.Text = busyTime.Description;

            toolTip_Info1.SetToolTip(textBox_Info1, "Type");
            toolTip_Info1.SetToolTip(textBox_Info2, "Starting Time");
            toolTip_Info1.SetToolTip(textBox_Info3, "Ending Time");
            toolTip_Info1.SetToolTip(textBox_Info4, "Frequency");
            toolTip_Info1.SetToolTip(textBox_Info5, "Description");
        }
Ejemplo n.º 5
0
        public static bool BusyTimeTableUpdate(BusyTime busyTime)
        {
            if (!ConnectToDatabase())
            {
                return(false);
            }
            string     sqlCMD  = "UPDATE BusyTime SET name=@name, description=@description, type =@type, frequency =@frequency,startTime=@startTime,endTime =@endTime  WHERE ID = @ID";
            SqlCommand command = new SqlCommand(sqlCMD, connection);

            command.Parameters.AddWithValue("@ID", busyTime.ID);
            command.Parameters.AddWithValue("@name", busyTime.Name);
            command.Parameters.AddWithValue("@description", busyTime.Description);
            command.Parameters.AddWithValue("@type", busyTime.Type);
            command.Parameters.AddWithValue("@frequency", busyTime.Frequency);
            command.Parameters.AddWithValue("@personID", busyTime.PersonID);
            command.Parameters.AddWithValue("@startTime", busyTime.StartTime);
            command.Parameters.AddWithValue("@endTime", busyTime.EndTime);

            command.ExecuteNonQuery();

            DisconnectFromDatabase();
            return(true);
        }
Ejemplo n.º 6
0
        public CalendarInformationPopUp(List <object> occasion)
        {
            InitializeComponent();
            this.occasion = occasion;

            var      activity         = occasion[0];
            DateTime startingDateTime = (DateTime)occasion[1];
            DateTime endingDateTime   = (DateTime)occasion[2];
            Person   person           = (Person)occasion[3];



            label_Info2.Text = person.Nickname;
            label_Info3.Text = startingDateTime.ToString("HH:mm dd/MM/yyyy");
            label_Info4.Text = endingDateTime.ToString("HH:mm dd/MM/yyyy");

            label_Title2.Text = "Creator:";
            label_Title3.Text = "Starting Date:";
            label_Title4.Text = "Ending Date:";

            pictureBox1.Parent = this;
            this.Controls.SetChildIndex(pictureBox1, 0);

            Type type = activity.GetType();

            label_Activity.Text = type.Name;
            if (type == typeof(BusyTime))
            {
                BusyTime busyTime = (BusyTime)activity;

                label_Info1.Text = busyTime.Name;
                label_Info5.Text = busyTime.Type;

                pictureBox1.Image = imageList1.Images[0];

                label_Title1.Text = "Name:";
                label_Title5.Text = "Type:";
            }
            else if (type == typeof(Event))
            {
                Event @event = (Event)activity;

                label_Info1.Text = @event.Name;
                label_Info5.Text = @event.Type;

                pictureBox1.Image = imageList1.Images[1];

                label_Title1.Text = "Name:";
                label_Title5.Text = "Type:";
            }
            else if (type == typeof(Request))
            {
                Request request = (Request)activity;

                label_Info1.Text = request.Name;
                label_Info5.Text = request.AccepterName;
                label_Info6.Text = request.Description;

                pictureBox1.Image = imageList1.Images[3];

                label_Title1.Text = "Name:";
                label_Title5.Text = "Accepter:";
                label_Title6.Text = "Description:";
            }
            else if (type == typeof(Housework))
            {
                Housework housework = (Housework)activity;

                label_Info1.Text = housework.Name;
                label_Info5.Text = housework.Type;
                label_Info6.Text = housework.Description;

                pictureBox1.Image = imageList1.Images[2];

                label_Title1.Text = "Name:";
                label_Title5.Text = "Type:";
                label_Title6.Text = "Description:";

                string[] questions = { "", "", "" };
                string[] answers   = { "", "", "" };
                for (int i = 0; i < housework.Answers.Count; i++)
                {
                    answers[i] = housework.Answers[i];
                }
                for (int i = 0; i < housework.Questions.Count; i++)
                {
                    questions[i] = housework.Questions[i];
                }



                label_Info7.Text = answers[0];
                label_Info8.Text = answers[1];
                label_Info9.Text = answers[2];

                label_Title7.Text = questions[0];
                label_Title8.Text = questions[1];
                label_Title9.Text = questions[2];
            }

            GiveAllChildsDrag(this);
            Coloring();
        }
Ejemplo n.º 7
0
        private void button_CreateBusyTime_Click(object sender, EventArgs e)
        {
            label_Error.Text = "";
            label_Error.Hide();
            label_Finished.Hide();

            if (textBox_Name.Text == "" || textBox_Name.Text == null)
            {
                label_Error.Text = "Name can't be empty";
                label_Error.Show();
                return;
            }
            if (textBox_Description.Text == "" || textBox_Description.Text == null)
            {
                label_Error.Text = "Description can't be empty";
                label_Error.Show();
                return;
            }
            if (comboBox_Type.SelectedIndex == -1)
            {
                label_Error.Text = "Type can't be empty";
                label_Error.Show();
                return;
            }
            if (checkedListBox_Frequency.CheckedItems.Count == 0)
            {
                label_Error.Text = "Frequency can't be empty";
                label_Error.Show();
                return;
            }
            if ((dateTimePicker_EndingTime.Value.TimeOfDay - dateTimePicker_StartingTime.Value.TimeOfDay).TotalMinutes <= 0)
            {
                label_Error.Text = "Ending time can't be earlier than Starting time!";
                label_Error.Show();
                return;
            }


            string   name          = textBox_Name.Text;
            string   description   = textBox_Description.Text;
            string   type          = comboBox_Type.SelectedItem.ToString();
            TimeSpan startDateTime = dateTimePicker_StartingTime.Value.TimeOfDay;
            TimeSpan endDateTime   = dateTimePicker_EndingTime.Value.TimeOfDay;
            string   frequency     = "";

            foreach (object item in checkedListBox_Frequency.CheckedItems)
            {
                frequency += item.ToString().Substring(0, 2);
            }

            if (busyTime == null)
            {
                BusyTime busyTime = new BusyTime(name, type, description, frequency, mainScreen.User.ID, startDateTime, endDateTime);
                mainScreen.User.BusyTimes.Add(busyTime);
                if (mainScreen.home != null)
                {
                    mainScreen.home.BusyTimes.Add(busyTime);
                }
                ClearBoxes();
                label_Finished.Text = "Busy Time Created Successfully!";
            }
            else
            {
                busyTime.Name        = name;
                busyTime.Description = description;
                busyTime.Frequency   = frequency;
                busyTime.Type        = comboBox_Type.SelectedItem.ToString();
                busyTime.StartTime   = startDateTime;
                busyTime.EndTime     = endDateTime;


                Database.BusyTimeTableUpdate(busyTime);
                this.Parent.Controls.Remove(this);
                viewList.DrawObjects();

                label_Finished.Text = "Busy Time Updated Successfully!";
            }
            label_Finished.Show();
        }
Ejemplo n.º 8
0
        public static bool BusyTimeTableRemove(BusyTime busyTime)
        {
            string sqlCMD = $"DELETE FROM BusyTime WHERE ID={busyTime.ID}";

            return(RemoveRow(sqlCMD));
        }