Ejemplo n.º 1
0
        void checkPriority(Task task, RadioButton rd)
        {
            var taskPriority = task.Priority;

            if (rd.Text.Equals(taskPriority.ToString()))
            {
                rd.Checked = true;
            }
        }
Ejemplo n.º 2
0
        public Task getData()
        {
            Task t = new Task();

            t.TaskID     = id;
            t.TaskName   = taskName.Text;
            t.Location   = loction.Text;
            t.CategoryID = Convert.ToInt32(category.SelectedValue);
            t.Date       = date.Value;
            t.IsFullDay  = isFullDay.Checked;
            if (isFullDay.Checked)
            {
                t.TimeFrom = "00:01";
                t.TimeTo   = "23:59";
            }
            t.Detail    = detail.Text;
            t.TimeFrom  = timeFrom.Text;
            t.TimeTo    = timeTo.Text;
            t.TimeTagID = Convert.ToInt32(timeTag.SelectedValue);
            if (p1.Checked)
            {
                t.Priority = 1;
            }
            else if (p2.Checked)
            {
                t.Priority = 2;
            }
            else if (p3.Checked)
            {
                t.Priority = 3;
            }
            else if (p4.Checked)
            {
                t.Priority = 4;
            }
            else if (p5.Checked)
            {
                t.Priority = 5;
            }

            return(t);
        }
Ejemplo n.º 3
0
        private void Button_Edit_Click(object sender, EventArgs e)
        {
            MyButton bt = (MyButton)sender;
            //            bt.date.Enabled = true;
            //            bt.category.Enabled = true;
            //            bt.detail.Enabled = true;
            //            bt.isFullDay.Enabled = true;
            //            bt.loction.Enabled = true;
            //            bt.p1.Enabled = true;
            //            bt.p2.Enabled = true;
            //            bt.p3.Enabled = true;
            //            bt.p4.Enabled = true;
            //            bt.p5.Enabled = true;
            //            bt.timeTag.Enabled = true;
            //            bt.taskName.Enabled = true;
            //            bt.timeTo.Enabled = true;
            //            bt.timeFrom.Enabled = true;
            Task t = bt.getData();

            Console.WriteLine(t.ToString());
            if (bt.Text.Equals("Save"))
            {
                tc.editTask(t);
                bt.enDisable();

                bt.Text = "Edit";
            }
            else
            {
                bt.enDisable();
                bt.category.DataSource    = db.getAllCategory();
                bt.category.DisplayMember = "categoryName";
                bt.category.ValueMember   = "categoryID";
                bt.timeTag.DataSource     = db.GetAllTimeTags(1);
                bt.timeTag.DisplayMember  = "TimeTagName";
                bt.timeTag.ValueMember    = "TimeTagID";
                bt.Text = "Save";
            }
            //
            //            MessageBox.Show(bt.id.ToString());
        }
Ejemplo n.º 4
0
        public void setnewCom(Task task)
        {
            //            Panel panF1 = new  Panel();
            ecp             = new ExpandCollapsePanel();
            ecp.ButtonStyle = ExpandCollapseButton.ExpandButtonStyle.Triangle;
            ecp.ButtonSize  = ExpandCollapseButton.ExpandButtonSize.Small;
            ecp.Width       = 510;
            ecp.Height      = 400;
            ecp.BorderStyle = BorderStyle.FixedSingle;

            //            ecp.AutoScroll = true;

            ecp.Visible = true;
            //
            ecp.Font = new Font(FontFamily.GenericSansSerif, 9f, FontStyle.Bold);

            ecp.UseAnimation = false; // disable animation for immediately collapsing
            ecp.IsExpanded   = false; // collapse all panels
                                      //            ecp.UseAnimation = true; // enable animation for further user clicks

            // set up
            ecp.Text = task.TaskName;
            Label          taskID   = new Label();
            TextBox        taskName = new TextBox();
            DateTimePicker date     = new DateTimePicker();
            DateTimePicker timeFrom = new DateTimePicker();
            DateTimePicker timeTo   = new DateTimePicker();

            timeFrom.Format       = DateTimePickerFormat.Custom;
            timeTo.Format         = DateTimePickerFormat.Custom;
            timeFrom.CustomFormat = "HH:mm";
            timeTo.CustomFormat   = "HH:mm";


            TextBox     location  = new TextBox();
            TextBox     detail    = new TextBox();
            RadioButton p1        = new RadioButton();
            RadioButton p2        = new RadioButton();
            RadioButton p3        = new RadioButton();
            RadioButton p4        = new RadioButton();
            RadioButton p5        = new RadioButton();
            ComboBox    timeTag   = new ComboBox();
            CheckBox    isFullDay = new CheckBox();
            ComboBox    category  = new ComboBox();

            MyButton bt_close = new MyButton(ecp);

            bt_close.Text = "Close";

            MyButton bt_edit = new MyButton(task.TaskID, taskName, timeFrom, timeTo, location, detail, p1, p2, p3, p4, p5, timeTag, category, isFullDay, date);

            bt_edit.Text = "Edit";
            MyButton bt_dele = new MyButton(task.TaskID, ecp);

            bt_dele.Text = "Delete";
            GroupBox groupBox = new GroupBox();

            /*int id, TextBox taskName, TextBox timeFrom, TextBox timeTo, TextBox loction, TextBox detail, RadioButton p1, RadioButton p2, RadioButton p3, RadioButton p4, RadioButton p5, ComboBox timeTag, ComboBox category, CheckBox isFullDay, DateTimePicker date)
             */
            // label
            Label t = new Label();

            t.Text = "To";


            Label lbName = new Label();

            lbName.Text = "Name";
            Label lbDate = new Label();

            lbDate.Text = "Date";
            Label lbTime = new Label();

            lbTime.Text = "Time";
            Label lbloc = new Label();

            lbloc.Text = "Location";
            Label lbDetail = new Label();

            lbDetail.Text = "Detail";
            Label lbPrio = new Label();

            lbPrio.Text = "Priority";
            Label lbTag = new Label();

            lbTag.Text = "Tag";
            Label lbCate = new Label();

            lbCate.Text = "Category";
            ecp.Controls.Add(t);
            ecp.Controls.Add(lbName);
            ecp.Controls.Add(lbDate);
            ecp.Controls.Add(lbTime);
            ecp.Controls.Add(lbloc);
            ecp.Controls.Add(lbDetail);
            ecp.Controls.Add(lbPrio);
            ecp.Controls.Add(lbTag);
            ecp.Controls.Add(lbCate);



            groupBox.Controls.Add(p1);
            groupBox.Controls.Add(p2);
            groupBox.Controls.Add(p3);
            groupBox.Controls.Add(p4);
            groupBox.Controls.Add(p5);

            //
            int  nextY = 45;
            int  nextX = 130;
            int  w     = 250;
            int  h     = 25;
            Size s     = new Size(w, h);
            int  tab   = 50;

            Font f = new Font("Microsoft Sans Serif", 8, FontStyle.Bold);

            //
            ecp.Controls.Add(date);
            ecp.Controls.Add(taskID);
            ecp.Controls.Add(taskName);
            ecp.Controls.Add(timeFrom);
            ecp.Controls.Add(timeTo);
            ecp.Controls.Add(location);
            ecp.Controls.Add(detail);
            ecp.Controls.Add(p1);
            ecp.Controls.Add(p2);
            ecp.Controls.Add(p3);
            ecp.Controls.Add(p4);
            ecp.Controls.Add(p5);
            ecp.Controls.Add(timeTag);
            ecp.Controls.Add(isFullDay);
            ecp.Controls.Add(category);
            ecp.Controls.Add(bt_close);
            ecp.Controls.Add(bt_dele);
            ecp.Controls.Add(bt_edit);

            //            // id
            //            taskID.Text = task.TaskID.ToString();
            //            taskID.Location = new Point(nextX, nextY);
            //            nextY += 30;
            //            // name
            int temp = nextX - 100;

            lbName.Location   = new Point(temp, nextY);
            taskName.Text     = task.TaskName;
            taskName.Location = new Point(nextX, nextY);
            taskName.Font     = f;
            taskName.AutoSize = false;
            taskName.Size     = s;
            taskName.Enabled  = false;
            nextY            += 30;
            //date
            lbDate.Location = new Point(temp, nextY);

            date.Value    = task.Date;
            date.Location = new Point(nextX, nextY);
            date.Font     = f;
            date.Size     = s;
            date.Enabled  = false;
            nextY        += 30;
            //from
            lbTime.Location = new Point(temp, nextY);

            timeFrom.Text     = task.TimeFrom;
            timeFrom.Font     = f;
            timeFrom.Enabled  = false;
            timeFrom.Size     = new Size(60, h);
            timeFrom.Location = new Point(nextX, nextY);
            //
            t.Location = new Point(nextX + 60, nextY);
            t.Size     = new Size(30, 25);
            // to
            timeTo.Text     = task.TimeTo;
            timeTo.Font     = f;
            timeTo.Enabled  = false;
            timeTo.Size     = new Size(60, 25);
            timeTo.Location = new Point(nextX + 90, nextY);

            isFullDay.Text     = "Full Day";
            isFullDay.Location = new Point(nextX + 180, nextY);
            isFullDay.Size     = s;
            isFullDay.Enabled  = false;
            isFullDay.Font     = f;
            nextY += 30;
            // loc
            lbloc.Location = new Point(temp, nextY);

            location.Text    = task.Location;
            location.Size    = s;
            location.Font    = f;
            location.Enabled = false;

            location.Location = new Point(nextX, nextY);
            nextY            += 30;

            // detail
            lbDetail.Location = new Point(temp, nextY);

            detail.Text = task.Detail;
            detail.Size = new Size(250, 70);

            detail.Font      = f;
            detail.Multiline = true;
            detail.Location  = new Point(nextX, nextY);
            detail.Enabled   = false;
            nextY           += 100;

            // p
            lbPrio.Location = new Point(temp, nextY);

            p1.Text     = 1.ToString();
            p1.Location = new Point(nextX, nextY);
            checkPriority(task, p1);
            p1.Enabled  = false;
            p1.AutoSize = true;
            p1.Font     = f;

            p2.Text     = 2.ToString();
            p2.Location = new Point(nextX + tab, nextY);
            checkPriority(task, p2);
            p2.Enabled  = false;
            p2.AutoSize = true;
            p2.Font     = f;


            p3.Text     = 3.ToString();
            p3.Location = new Point(nextX + tab * 2, nextY);
            checkPriority(task, p3);
            p3.Enabled  = false;
            p3.AutoSize = true;
            p3.Font     = f;

            p4.Text     = 4.ToString();
            p4.Location = new Point(nextX + tab * 3, nextY);
            checkPriority(task, p4);
            p4.Enabled  = false;
            p4.AutoSize = true;
            p4.Font     = f;

            p5.Text     = 5.ToString();
            p5.Location = new Point(nextX + tab * 4, nextY);
            p5.AutoSize = true;
            checkPriority(task, p5);
            p5.Enabled = false;

            p5.Font = f;
            nextY  += 30;

            //


            //
            lbCate.Location = new Point(temp, nextY);

            category.DataSource    = db.getAllCategory();
            category.DisplayMember = "categoryName";
            category.ValueMember   = "categoryID";
            timeTag.DataSource     = db.GetAllTimeTags(1);
            timeTag.DisplayMember  = "TimeTagName";
            timeTag.ValueMember    = "TimeTagID";
            category.Text         += task.CategoryID;

            category.Size     = new Size(100, h);
            category.Font     = f;
            category.Enabled  = false;
            category.Location = new Point(nextX, nextY);
            //
            lbTag.Location = new Point(nextX + 110, nextY);
            lbTag.Size     = new Size(45, 25);
            //
            timeTag.Text     = task.TimeTagID.ToString();
            timeTag.Location = new Point(nextX + 170, nextY);
            timeTag.Font     = f;
            timeTag.Enabled  = false;
            timeTag.Size     = new Size(80, h);

            nextY += 30;
            nextY += 30;
            // xu ly ui



            bt_close.Location = new Point(nextX + w, nextY);
            bt_edit.Location  = new Point(nextX + w - bt_close.Width - 10, nextY);
            bt_dele.Location  = new Point(nextX + w - bt_close.Width - 10 - bt_edit.Width - 10, nextY);
            bt_close.panel    = ecp;
            // close event
            bt_close.Click += new EventHandler(Button_Close_Click);
            // dele event
            bt_dele.Click += new EventHandler(Button_Dele_Click);
            // edit event
            bt_edit.Click += new EventHandler(Button_Edit_Click);



            pMyTask.Controls.Add(ecp);
        }