コード例 #1
0
        private void UpdateTimeSpan(Strcture.TimeSpan t) //更新时间段t及对应的数据结构
        {
            Vector <int> PersonTimeSpanArr = Global.storage.Persons[t.personID].timeSpanCollection;

            for (int i = 0; i < PersonTimeSpanArr.size(); i++)
            {
                if (PersonTimeSpanArr[i] == t.ID)
                {
                    PersonTimeSpanArr.remove(i);
                    break;
                }
            }
            Vector <int> SiteTimeSpanArr = Global.storage.Sites[t.siteID].timeSpanCollection;

            for (int i = 0; i < SiteTimeSpanArr.size(); i++)
            {
                if (SiteTimeSpanArr[i] == t.ID)
                {
                    SiteTimeSpanArr.remove(i);
                    break;
                }
            }
            t.startHour       = int.Parse(txtStartHour.Text);
            t.endHour         = int.Parse(txtEndHour.Text);
            t.personID        = int.Parse(txtPersonID.Text);
            t.siteID          = int.Parse(txtSiteID.Text);
            t.isProtected     = chkIsProtected.IsChecked == true;
            PersonTimeSpanArr = Global.storage.Persons[t.personID].timeSpanCollection;
            PersonTimeSpanArr.append(t.ID);
            SiteTimeSpanArr = Global.storage.Sites[t.siteID].timeSpanCollection;
            SiteTimeSpanArr.append(t.ID);
        }
コード例 #2
0
 private void LoadTimeSpan(Strcture.TimeSpan t) //加载时间段t的信息到GUI窗体中
 {
     txtID.Text               = t.ID.ToString();
     txtStartHour.Text        = t.startHour.ToString();
     txtEndHour.Text          = t.endHour.ToString();
     txtPersonID.Text         = t.personID.ToString();
     txtSiteID.Text           = t.siteID.ToString();
     chkIsProtected.IsChecked = t.isProtected;
 }
コード例 #3
0
        private void btnSubmit_Click(object sender, RoutedEventArgs e) //btnSubmit的Click事件
        {
            if (!Algorithm.IsInt(txtStartHour.Text))
            {
                MessageBox.Show("输入的开始时间不是数字!请核对后重试!", "提示信息");
                return;
            }
            if (!Algorithm.IsInt(txtEndHour.Text))
            {
                MessageBox.Show("输入的结束时间不是数字!请核对后重试!", "提示信息");
                return;
            }
            if (!Algorithm.IsInt(txtPersonID.Text))
            {
                MessageBox.Show("输入的人员ID不是数字!请核对后重试!", "提示信息");
                return;
            }
            if (!Algorithm.IsInt(txtSiteID.Text))
            {
                MessageBox.Show("输入的地点ID不是数字!请核对后重试!", "提示信息");
                return;
            }
            Storage storage = Global.storage;

            if (int.Parse(txtPersonID.Text) >= storage.Persons.size())
            {
                MessageBox.Show("输入人员ID错误!请核对后重试!", "提示信息");
                return;
            }
            if (int.Parse(txtSiteID.Text) >= storage.Sites.size())
            {
                MessageBox.Show("输入地点ID错误!请核对后重试!", "提示信息");
                return;
            }
            if (lstPeople.SelectedItems.Count == 0)
            {
                Strcture.TimeSpan p = new Strcture.TimeSpan(storage.timespanIncCnt++,
                                                            int.Parse(txtStartHour.Text), int.Parse(txtEndHour.Text),
                                                            int.Parse(txtPersonID.Text), int.Parse(txtSiteID.Text),
                                                            chkIsProtected.IsChecked == true);
                storage.TimeSpans.append(p);
                storage.Persons[int.Parse(txtPersonID.Text)].timeSpanCollection.append(p.ID);
                storage.Sites[int.Parse(txtSiteID.Text)].timeSpanCollection.append(p.ID);
            }
            else
            {
                Strcture.TimeSpan p = Global.storage.TimeSpans[int.Parse(txtID.Text)];
                UpdateTimeSpan(p);
            }
            RefreshList();
            CreateTimeSpanGUI();
        }