private void GridInfo_Loaded(object sender, RoutedEventArgs e)
        {
            textBlockPersonName.Text = person.Name;
            textBlockPId.Text        = "学号:" + person.pId;

            if (person is Administrator)
            {
                textBlockDepartment.Text = "管理员用户";
            }
            else
            {
                textBlockDepartment.Text = "专业:" + (person as User).Department;
            }

            List <Rent> listRent = DatabaseLinker.GetMyApplyingRents(person.pId);

            foreach (Rent r in listRent)
            {
                TextBlock tb = new TextBlock();
                MyTextBlockInitialize(tb, r);
                if (r.Approved)
                {
                    wrapPanelRents.Children.Add(tb);
                }
                else
                {
                    wrapPanelRentsUnapproved.Children.Add(tb);
                }
            }
        }
예제 #2
0
        public Rent Add(int rId)
        {
            Rent r = DatabaseLinker.GetRent(rId); if (r == null)

            {
                return(new Rent());
            }

            if (Contains(rId))
            {
                return(null);
            }

            Rents.Add(r);

            Rent rr = CheckMyTime();

            if (rr == null)
            {
                return(null);
            }

            Rents.Remove(r);
            return(rr);
        }
 public void AddToMyRentTable(int rId)
 {
     if (DatabaseLinker.AddTakepartin(pId, rId))
     {
         RentTable = DatabaseLinker.GetPersonRentTable(pid);
     }
 }
 public void DeleteFromMyRentTable(int rId)
 {
     if (DatabaseLinker.DeleteTakepartin(pId, rId))
     {
         RentTable = DatabaseLinker.GetPersonRentTable(pid);
     }
 }
예제 #5
0
        private void TBChoose_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (TBinfo.Text.Trim() == "")
            {
                MessageBox.Show("活动名称不能为空。");
                return;
            }
            if (TBinfo.Text.Length > 140)
            {
                MessageBox.Show("活动名称过长。");
                return;
            }

            RentTime rt = new RentTime(date, date, 0, classStart, classEnd);
            Rent     r  = new Rent(0, TBinfo.Text, classroom.cId, person.pId, false, rt);

            if (DatabaseLinker.SetRent(r))
            {
                MessageBox.Show("活动申请已发送。");
                father.RefreshSchedule();
                this.Close();
            }
            else
            {
                MessageBox.Show("活动申请发送失败。");
            }
        }
        private void Window_Loaded_1(object sender, RoutedEventArgs e)
        {
            if (rent == null)
            {
                return;
            }

            TBinfo.Text = rent.Info;
            if (!rent.Approved)
            {
                TBinfo.Text += " (未审核)";
            }
            TBinfo.Background = new SolidColorBrush(MyColor.NameColor(rent.Info, 0.2));
            TBinfo.Foreground = new SolidColorBrush(WindowIndex.textColor);

            TBhost.Content = "申请人: " + DatabaseLinker.GetName(rent.pId);

            Classroom c = Building.GetClassroom(rent.cId);

            if (c != null)
            {
                TBclassroom.Content = "教室: " + c.Name;
            }
            else
            {
                TBclassroom.Visibility      = Visibility.Collapsed;
                TBclassroom_Copy.Visibility = Visibility.Collapsed;
            }

            TBrentTime.Content = "时间: " + rent.Time.Display();

            List <int> listPId = DatabaseLinker.GetPIdList(rent.rId);

            TBtakepartinInfo.Content = "参加人数: " + listPId.Count;

            if (rent.Time.BeenOver)
            {
                TBChoose.Content = "课程已结束";
            }
            else if (father.personRentTable.Contains(rent.rId))
            {
                TBChoose.Content = "从我的课程表删除";
            }
            else
            {
                TBChoose.Content = "加入我的课程表";
            }

            if (rent.Approved || father.Peron is User)
            {
                TBOK.Visibility      = Visibility.Collapsed;
                TBDecline.Visibility = Visibility.Collapsed;
            }
        }
        private void TBDecline_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (DatabaseLinker.DeleteRent(rent))
            {
                rent.GetApproved();

                SysMsg msg = new SysMsg(0, rent.pId, DateTime.Now, "对不起, 您申请的课程 " + rent.rId + ", " + rent.Info + " 没有通过审核, 已被管理员删除.");
                DatabaseLinker.SendSysMsg(msg);

                MessageBox.Show("已删除课程.");
                this.Close();
            }
        }
        private void TBOK_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (DatabaseLinker.ApproveRent(rent))
            {
                rent.GetApproved();

                SysMsg msg = new SysMsg(0, rent.pId, DateTime.Now, "您申请的课程 " + rent.rId + ", " + rent.Info + " 已经通过审核.");
                DatabaseLinker.SendSysMsg(msg);

                MessageBox.Show("审核已通过.");
                this.Close();
            }
        }
        // 系统消息初始化
        private void TextBlockMessageInitialize(TextBlock tb, SysMsg msg)
        {
            string sendName = DatabaseLinker.GetName(msg.SendId);

            tb.FontSize = 24;
            tb.Padding  = new Thickness(16);
            tb.Inlines.Add(new Bold(new Run(sendName + ": (" + msg.Time.ToString("yyyy/MM/dd") + ")\r\n")));
            tb.Inlines.Add(new Run("  " + msg.Info));
            tb.TextWrapping = TextWrapping.Wrap;

            //  tb.MouseEnter += tbRent_MouseEnter;
            //  tb.MouseLeave += tbRent_MouseLeave;

            tb.Tag = msg;
        }
        private void TBtakepartinInfo_MouseDown(object sender, MouseButtonEventArgs e)
        {
            string s = "";

            List <int> listPId = DatabaseLinker.GetPIdList(rent.rId);

            foreach (int pId in listPId)
            {
                s += DatabaseLinker.GetName(pId) + " ";
            }

            if (listPId.Count == 0)
            {
                s = "暂时没有人参加。";
            }
            MessageBox.Show(s, "参加同学名单");
        }
예제 #11
0
        private void Window_Loaded_1(object sender, RoutedEventArgs e)
        {
            TBinfo.Text = person.Name + "申请的活动";
            TBinfo.Focus();

            TBhost.Content = "申请人: " + DatabaseLinker.GetName(person.pId);

            TBclassroom.Content = "教室: " + classroom.Name;

            for (int i = 0; i < 6; ++i)
            {
                if (classChosen >= RentTime.typicalClassRent[i, 0] && classChosen <= RentTime.typicalClassRent[i, 1])
                {
                    classStart = RentTime.typicalClassRent[i, 0];
                    classEnd   = RentTime.typicalClassRent[i, 1];
                }
            }
            TBrentTime.Content = "时间: " + date.Month + "月" + date.Day + "日, 第" + classStart + "节至第" + classEnd + "节";
        }
        //(管理员功能)查看未审核课程
        private void TextBlockUnapprovedRentInitialize(TextBlock tb, Rent r)
        {
            string    applicantName = DatabaseLinker.GetName(r.pId);
            string    s             = r.Info;
            Classroom c             = Building.GetClassroom(r.cId); if (c != null)

            {
                s += ("@" + c.Name);
            }

            tb.Inlines.Add(new Bold(new Run(applicantName + ":\r\n")));
            tb.Inlines.Add(new Run("  " + s));

            tb.FontSize = 24;
            tb.Padding  = new Thickness(16);

            tb.MouseDown  += tbRent_MouseDown;
            tb.MouseEnter += tbRent_MouseEnter;
            tb.MouseLeave += tbRent_MouseLeave;

            tb.Tag = r;
        }
        private void TBChoose_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (rent.Time.BeenOver)
            {
                MessageBox.Show("这个课程或活动已经结束了。");
                return;
            }

            if (father.personRentTable.Contains(rent.rId))
            {
                if (MessageBox.Show("确定删除 \"" + rent.Info + "\"?", "删除课程", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    DatabaseLinker.DeleteTakepartin(father.Peron.pId, rent.rId);
                    father.personRentTable.Remove(rent);
                    father.RefreshSchedule();
                    this.Close();
                }
            }
            else
            {
                Rent rr = father.personRentTable.Add(rent.rId);
                if (rr == null)
                {
                    DatabaseLinker.AddTakepartin(father.Peron.pId, rent.rId);
                }
                else
                {
                    MessageBox.Show("添加失败。此课程同您的课程 \"" + rr.Info + "\" 存在冲突。");
                    if (!rent.Time.OnceActivity)
                    {
                        father.GotoDateClass(rr.Time.StartDate, rr.Time.StartClass);
                    }
                }

                father.RefreshSchedule();

                this.Close();
            }
        }
예제 #14
0
        private void login()
        {
            int id;

            try { id = int.Parse(TextBoxPId.Text); }
            catch { status = Status.errorId; return; }

            Person p = DatabaseLinker.Login(id, TextBoxPassword.Password);

            if (null == p)
            {
                status = Status.errorPassword;
            }
            else if (p is Person)
            {
                winindex = new WindowIndex(p);
                status   = Status.success;
            }
            else
            {
                status = Status.errorPassword;
            }
        }
예제 #15
0
        public string Display()
        {
            string s = "";

            s += info + "\r\n";
            s += "申请人: " + DatabaseLinker.GetName(pId) + " 编号: R" + rid + "\r\n";

            Classroom c = Building.GetClassroom(cid);

            if (c != null)
            {
                s += "教室: " + c.Name + "  ";
            }
            s += "上课时间: " + Time.Display();


            //s += " :: ";
            //foreach (int id in Students)
            //{
            //    s += DatabaseLinker.GetName(id)+" ";
            //}

            return(s);
        }
        private void GridMessage_Loaded(object sender, RoutedEventArgs e)
        {
            listSysMsg = DatabaseLinker.GetPersonSysMsgList(person.pId);

            for (int i = listSysMsg.Count - 1; i >= 0; --i)
            {
                SysMsg    msg = listSysMsg[i];
                TextBlock tb  = new TextBlock();
                TextBlockMessageInitialize(tb, msg);
                stackPanelMessage.Children.Add(tb);
            }

            if (person.pId == 0)
            {
                List <Rent> listRent = DatabaseLinker.GetUnapprovedRentTable();

                foreach (Rent r in listRent)
                {
                    TextBlock tb = new TextBlock();
                    TextBlockUnapprovedRentInitialize(tb, r);
                    stackPanelMessage.Children.Add(tb);
                }
            }
        }
예제 #17
0
 public override void GetMyRentTable()
 {
     RentTable = DatabaseLinker.GetClassroomRentTable(cid);
 }
예제 #18
0
 public bool ApproveRent(Rent r)
 {
     r.GetApproved();
     return(DatabaseLinker.ApproveRent(r));
 }
        private void LabelClassroom_MouseDown(object sender, MouseButtonEventArgs e)
        {
            RentTable rt = new RentTable(DatabaseLinker.GetDateRentTable(Schedule.CurrDate).GetFromDateClass(Schedule.CurrDate, Schedule.CurrClass));

            new WindowClassroomList(rt, this).ShowDialog();
        }
예제 #20
0
 public override void GetMyRentTable()
 {
     RentTable = DatabaseLinker.GetPersonRentTable(pid);
 }
        //全体键盘托管
        private void Window_PreviewKeyDown_1(object sender, KeyEventArgs e)
        {
            //换肤
            switch (e.Key)
            {
            case Key.F1: SetSkin(skin.Starry); break;

            case Key.F2: SetSkin(skin.ColorBox); break;

            case Key.D1: SetStatus(status.Info); break;

            case Key.D2: SetStatus(status.Table); break;

            case Key.D3:
                RentTable rt = new RentTable(DatabaseLinker.GetDateRentTable(Schedule.CurrDate).GetFromDateClass(Schedule.CurrDate, Schedule.CurrClass));
                new WindowClassroomList(rt, this).ShowDialog();
                break;

            case Key.D4: SetStatus(status.Message); break;
            }

            switch (currStatus)
            {
            case status.Table:
                //课程表控制
                if (!TextBoxCId.IsKeyboardFocused)
                {
                    switch (e.Key)
                    {
                    case Key.Up: if (Schedule.CurrClass > 1)
                        {
                            --Schedule.CurrClass;
                        }
                        break;

                    case Key.Down: if (Schedule.CurrClass < cntRow)
                        {
                            ++Schedule.CurrClass;
                        }
                        break;

                    case Key.Left: if (Schedule.CurrDate > RentTime.FirstDate)
                        {
                            Schedule.CurrDate -= new TimeSpan(1, 0, 0, 0);
                        }
                        break;

                    case Key.Right: if (Schedule.CurrDate < RentTime.LastDate)
                        {
                            Schedule.CurrDate += new TimeSpan(1, 0, 0, 0);
                        }
                        break;

                    case Key.Home: Schedule.CurrClass = 1; break;

                    case Key.End: Schedule.CurrClass = cntRow; break;

                    case Key.PageUp: if (Schedule.CurrWeek > 1)
                        {
                            Schedule.CurrDate -= new TimeSpan(7, 0, 0, 0);
                        }
                        break;

                    case Key.PageDown: if (Schedule.CurrWeek < 23)
                        {
                            Schedule.CurrDate += new TimeSpan(7, 0, 0, 0);
                        }
                        break;

                    case Key.Enter:
                        Rent r = sch1.ChosenRent;
                        if (r == null)
                        {
                            break;
                        }
                        new WindowRent(r, this).ShowDialog();
                        break;
                    }
                    SetDateClass(Schedule.CurrDate, Schedule.CurrClass);
                }
                else
                //教室控制
                {
                    int b, c;
                    if (classroom == null)
                    {
                        b = 0; c = 0;
                    }
                    else
                    {
                        b = classroom.Building.bId; c = classroom.cId;
                    }

                    switch (e.Key)
                    {
                    case Key.Up:
                        while (c < Classroom.MaxCId)
                        {
                            ++c;
                            if (Building.GetClassroom(c) != null)
                            {
                                break;
                            }
                        }
                        break;

                    case Key.Down:
                        while (c > Classroom.MinCId)
                        {
                            --c;
                            if (Building.GetClassroom(c) != null)
                            {
                                break;
                            }
                        }
                        break;

                    case Key.PageUp:
                        while (b < Building.MaxBId)
                        {
                            ++b;
                            if (Building.GetBuilding(b) != null)
                            {
                                c = Building.GetBuilding(b).Classrooms[0].cId;
                                break;
                            }
                        }
                        break;

                    case Key.PageDown:
                        while (b > Building.MinBId)
                        {
                            --b;
                            if (Building.GetBuilding(b) != null)
                            {
                                c = Building.GetBuilding(b).Classrooms[0].cId;
                                break;
                            }
                        }
                        break;
                    }
                    SetCId(c);
                }
                break;
            }
        }