Пример #1
0
        private void TimeTable_TextChanged(object sender, EventArgs e)
        {
            try
            {
                TextBox s = ((TextBox)sender);
                double  d = 0.0;
                switch (s.Name)
                {
                case "business":
                case "note":
                case "project":
                case "language":
                case "fantasy":
                    d        += DConvert.ToDoble(business.Text);
                    d        += DConvert.ToDoble(note.Text);
                    d        += DConvert.ToDoble(project.Text);
                    d        += DConvert.ToDoble(language.Text);
                    d        += DConvert.ToDoble(fantasy.Text);
                    work.Text = Convert.ToString(d);
                    break;

                case "live":
                case "sleep":
                case "communication":
                case "discipline":
                case "exercise":
                    d        += DConvert.ToDoble(live.Text);
                    d        += DConvert.ToDoble(sleep.Text);
                    d        += DConvert.ToDoble(communication.Text);
                    d        += DConvert.ToDoble(discipline.Text);
                    d        += DConvert.ToDoble(exercise.Text);
                    life.Text = Convert.ToString(d);
                    break;

                case "book":
                case "animation":
                case "game":
                case "movie":
                case "ero":
                    //case "others":
                    d        += DConvert.ToDoble(book.Text);
                    d        += DConvert.ToDoble(animation.Text);
                    d        += DConvert.ToDoble(game.Text);
                    d        += DConvert.ToDoble(ero.Text);
                    d        += DConvert.ToDoble(movie.Text);
                    play.Text = Convert.ToString(d);
                    break;
                }
                double w = DConvert.ToDoble(work.Text);
                double l = DConvert.ToDoble(life.Text);
                double p = DConvert.ToDoble(play.Text);
                total.Text      = Convert.ToString(w + l + p);
                workLabel.Text  = Convert.ToString(Convert.ToInt32(w / 24 * 100)) + "%";
                lifeLabel.Text  = Convert.ToString(Convert.ToInt32(l / 24 * 100)) + "%";
                playLabel.Text  = Convert.ToString(Convert.ToInt32(p / 24 * 100)) + "%";
                totalLabel.Text = Convert.ToString(Convert.ToInt32((w + l + p) / 24.0 * 100)) + "%";
            }
            catch { }
        }
Пример #2
0
        private void LoadCurTimeTable()
        {
            try
            {
                FormClearTimeTable();
                CurTimeTable = null;
                CurMonthDays = 0;
                foreach (var ctb in TBData.TimeTable.Items)
                {
                    if (ctb.Date >= new DateTime(dateTimePicker1.Value.Year, dateTimePicker1.Value.Month, 1) &&
                        ctb.Date < new DateTime(dateTimePicker1.Value.Year, dateTimePicker1.Value.Month + 1, 1))
                    {
                        CurMonthDays++;
                        foreach (var col in ctb.Columns)
                        {
                            foreach (Control c in TimeTable.Controls)
                            {
                                if (c is TextBox &&
                                    c.Name == col.Name)
                                {
                                    if (((TextBox)c).ReadOnly == false)
                                    {
                                        c.Text = (DConvert.ToDoble(c.Text) + col.Duration).ToString();
                                    }
                                }
                            }
                        }
                    }
                }
                if (CurMonthDays == 0)
                {
                    CurMonthDays = DateTime.DaysInMonth(dateTimePicker1.Value.Year, dateTimePicker1.Value.Month);
                }

                foreach (Control c in TimeTable.Controls)
                {
                    if (c is TextBox)
                    {
                        if (((TextBox)c).ReadOnly == false)
                        {
                            Object obj = TimeTable.Controls.Find(c.Name + "Description", false).First();
                            if (obj != null)
                            {
                                ((Label)obj).Text = "% Cnt: ";
                            }
                        }
                    }
                }

                foreach (Control c in TimeTable.Controls)
                {
                    if (c is TextBox)
                    {
                        if (((TextBox)c).ReadOnly == true)
                        {
                            double d = 0.0;
                            switch (c.Name)
                            {
                            case "work":
                                d        += DConvert.ToDoble(business.Text);
                                d        += DConvert.ToDoble(note.Text);
                                d        += DConvert.ToDoble(project.Text);
                                d        += DConvert.ToDoble(language.Text);
                                d        += DConvert.ToDoble(fantasy.Text);
                                work.Text = Convert.ToString(d);
                                break;

                            case "life":
                                d        += DConvert.ToDoble(live.Text);
                                d        += DConvert.ToDoble(sleep.Text);
                                d        += DConvert.ToDoble(communication.Text);
                                d        += DConvert.ToDoble(discipline.Text);
                                d        += DConvert.ToDoble(exercise.Text);
                                life.Text = Convert.ToString(d);
                                break;

                            case "play":
                                d        += DConvert.ToDoble(book.Text);
                                d        += DConvert.ToDoble(animation.Text);
                                d        += DConvert.ToDoble(game.Text);
                                d        += DConvert.ToDoble(ero.Text);
                                d        += DConvert.ToDoble(other.Text);
                                play.Text = Convert.ToString(d);
                                break;
                            }
                        }
                    }
                }

                double w = DConvert.ToDoble(work.Text);
                double l = DConvert.ToDoble(life.Text);
                double p = DConvert.ToDoble(play.Text);
                total.Text      = Convert.ToString(w + l + p);
                workLabel.Text  = Convert.ToString(Convert.ToInt32(w / 24 / CurMonthDays * 100)) + "%";
                lifeLabel.Text  = Convert.ToString(Convert.ToInt32(l / 24 / CurMonthDays * 100)) + "%";
                playLabel.Text  = Convert.ToString(Convert.ToInt32(p / 24 / CurMonthDays * 100)) + "%";
                totalLabel.Text = Convert.ToString(Convert.ToInt32((w + l + p) / 24.0 / CurMonthDays * 100)) + "%";
                totalCount.Text = "Count: " + CurMonthDays.ToString();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Пример #3
0
        // --- Event ---
        private void SaveEvent()
        {
            //if (CheckVaildEvent() == false)
            //{
            //    return;
            //}

            DEvents CurDEvs  = null;
            DEvents NextDEvs = null;

            foreach (var evs in EData.EventList.EventList)
            {
                if (evs.Date == dateTimePicker1.Value.Date)
                {
                    CurDEvs = evs;
                }
                else if (evs.Date == dateTimePicker1.Value.AddDays(1).Date)
                {
                    NextDEvs = evs;
                }
            }
            if (CurDEvs == null)
            {
                int curDiaryIndex = EData.EventList.EventList.Count;
                for (int i = 0; i < EData.EventList.EventList.Count; i++)
                {
                    if (dateTimePicker1.Value < EData.EventList.EventList[i].Date)
                    {
                        curDiaryIndex = i;
                        break;
                    }
                }
                EData.EventList.EventList.Insert(curDiaryIndex, CurDEvents);
            }
            if (NextDEvs == null)
            {
                int nextDiaryIndex = EData.EventList.EventList.Count;
                for (int i = 0; i < EData.EventList.EventList.Count; i++)
                {
                    if (dateTimePicker1.Value.AddDays(1).Date < EData.EventList.EventList[i].Date)
                    {
                        nextDiaryIndex = i;
                        break;
                    }
                }
                EData.EventList.EventList.Insert(nextDiaryIndex, NextDEvents);
            }

            foreach (var ev in CurDEvents.Items)
            {
                if (ev.Status != "")
                {
                    int statusCode = Convert.ToInt32(DConvert.ToDoble(ev.Status));
                    switch (statusCode)
                    {
                    case -1:
                        ev.Status = "放弃";
                        break;

                    case 0:
                        break;

                    case 1:
                        ev.Status = "完成";
                        break;

                    default:
                        ev.Status = statusCode.ToString() + "%";
                        break;
                    }
                }
            }


            EData.Save(EData.EventList);

            //SaveListDEvent(CurDEvents.Plans, dataGridViewCurPlan);
            //SaveListDEvent(CurDEvents.Items, dataGridViewCurResult);
            //SaveListDEvent(NextDEvents.Plans, dataGridViewNextPlan);
            LoadCurEvents();
            //dataGridViewEvent.Sort(dataGridViewEvent.Columns[3], ListSortDirection.Ascending);
            //FormClearEvent();
        }