コード例 #1
0
        public static bool ApproveRent(Rent r)
        {
            MySqlConnection mConnect = null;
            MySqlCommand mCommand = null;

            try
            {
                mConnect = new MySqlConnection("server=localhost;user id=root;Password=;database=classroomad");
                mCommand = new MySqlCommand();
                mCommand.Connection = mConnect;
                mConnect.Open();
            }
            catch
            {
                Console.WriteLine("FAILED to link MySQL in ApproveRent()");
                return false;
            }

            mCommand.CommandText = "UPDATE rent SET approved = true , ";
            mCommand.CommandText += " cId=" + r.cId + " WHERE ";
            mCommand.CommandText += " rId=" + r.rId;

            mCommand.Prepare();
            int i = mCommand.ExecuteNonQuery();

            mConnect.Close();

            return i > 0;
        }
コード例 #2
0
        public static bool DeleteRent(Rent r)
        {
            MySqlConnection mConnect = null;
            MySqlCommand mCommand = null;

            List<SysMsg> list = new List<SysMsg>();

            try
            {
                mConnect = new MySqlConnection("server=localhost;user id=root;Password=;database=classroomad");
                mCommand = new MySqlCommand();
                mCommand.Connection = mConnect;
                mConnect.Open();
            }
            catch
            {
                Console.WriteLine("FAILED to link MySQL in DeleteRent(" + r.Info + ")");
                return false;
            }

            mCommand.CommandText = "DELETE FROM rent WHERE rId=" + r.rId + ";"
                                 + " DELETE FROM takepartin WHERE rId=" + r.rId + ";";

            mCommand.Prepare();
            int i = mCommand.ExecuteNonQuery();

            mConnect.Close();

            return i > 0;
        }
コード例 #3
0
        public WindowRent(Rent r, WindowIndex fatherWindow)
        {
            InitializeComponent();
            rent = r;
            father = fatherWindow;

            if (father.WindowState == WindowState.Maximized)
            {
                this.Width = 450;
                this.Height = 450;
                BorderBackground.Width = 450;
                BorderBackground.Height = 450;
                TBinfo.FontSize = 40;

                TBhost.FontSize =
                TBrentTime.FontSize =
                TBtakepartinInfo.FontSize =
                TBclassroom.FontSize =
                TBclassroom_Copy.FontSize =
                TBChoose.FontSize =
                TBexit.FontSize =
                TBOK.FontSize =
                TBDecline.FontSize = 22;
            }
        }
コード例 #4
0
        //Rent Control
        public void MoveRentToFirst(int rId)
        {
            Rent r = GetRent(rId);

            if (r == null)
            {
                return;
            }

            if (Rents.Contains(r))
            {
                Rents.Remove(r);
            }
            Rents.Insert(0, r);
        }
コード例 #5
0
 public WindowRent(Rent r, WindowIndex fatherWindow,string str)
 {
     InitializeComponent();
     if (str == "big")
     {
         this.Width = 450;
         this.Height = 450;
         BorderBackground.Width = 450;
         BorderBackground.Height = 450;
         TBinfo.FontSize = 40;
         TBhost.FontSize = 22;
         TBrentTime.FontSize = 22;
         TBclassroom.FontSize = 22;
         TBChoose.FontSize = 22;
         TBexit.FontSize = 22;
     }
     rent = r;
     father = fatherWindow;
 }
コード例 #6
0
        private TextBlock Hightlight(TextBlock tbh, Rent r, Grid grid)
        {
            if (grid.Children.Contains(tbh))
            {
                tbh.Visibility = Visibility.Collapsed;
                grid.Children.Remove(tbh);
            }

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

            tbh = new TextBlock();
            grid.Children.Add(tbh);
            TextBlockInitialize(tbh, r, false);

            tbh.Background = MyColor.NameBrush(r.Info, 1);

            return(tbh);
        }
コード例 #7
0
        //初始化单个课程
        private void TextBlockInitialize(TextBlock tb, Rent r, bool MouseShow = true)
        {
            tb.Tag = r;

            tb.Background = MyColor.NameBrush(r.Info);
            tb.Text       = r.Info; if (!r.Approved)
            {
                tb.Text += "(未审核)";
            }
            Classroom c = Building.GetClassroom(r.cId); if (c != null)

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

            if (Father.WindowState == WindowState.Maximized)
            {
                tb.FontSize = 16;
            }
            else
            {
                tb.FontSize = 14;
            }

            tb.Foreground   = new SolidColorBrush(WindowIndex.textColor);
            tb.TextWrapping = TextWrapping.Wrap;


            tb.SetValue(Grid.ColumnProperty, r.Time.WeekDay);
            tb.SetValue(Grid.RowProperty, r.Time.StartClass - 1);
            tb.SetValue(Grid.RowSpanProperty, r.Time.KeepClass);

            tb.MouseDown += tb_MouseDown;

            if (MouseShow)
            {
                tb.MouseEnter += tb_MouseEnter;
                tb.MouseLeave += tb_MouseLeave;
            }
        }
コード例 #8
0
        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();
            }
        }
コード例 #9
0
        //(管理员功能)查看未审核课程
        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;
        }
コード例 #10
0
        //检查选中的时间点的课程
        public void ChosenRentControl()
        {
            if (Owner == null || Owner.RentTable == null) return;

            chosenRent = Owner.RentTable.GetRentFromDateClass(CurrDate, CurrClass);
            TBHighlight = Hightlight(TBHighlight, chosenRent, GridSchedule);
        }
コード例 #11
0
        //全体键盘托管
        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;
            }
        }
コード例 #12
0
        private TextBlock Hightlight(TextBlock tbh, Rent r, Grid grid)
        {
            if (grid.Children.Contains(tbh))
            {
                tbh.Visibility = Visibility.Collapsed;
                grid.Children.Remove(tbh);
            }

            if (r == null) return null;

            tbh = new TextBlock();
            grid.Children.Add(tbh);
            TextBlockInitialize(tbh, r, false);

            tbh.Background = MyColor.NameBrush(r.Info, 1);

            return tbh;
        }
コード例 #13
0
 public bool ApproveRent(Rent r)
 {
     r.GetApproved();
     return DatabaseLinker.ApproveRent(r);
 }
コード例 #14
0
        //检查选中的时间点的课程
        private void ChosenRentControl()
        {
            if (schedule1 != null && schedule2 != null)
            {
                chosenRent1 = schedule1.GetRentFromDateClass(currDate, currClass);
                TBHighlight1 = Hightlight(TBHighlight1, chosenRent1, GridSchedule1);
                chosenRent2 = schedule2.GetRentFromDateClass(currDate, currClass);
                TBHighlight2 = Hightlight(TBHighlight2, chosenRent2, GridSchedule2);

                if (schedule1.QuiteFreeTime(currDate, currClass) && schedule2.QuiteFreeTime(currDate, currClass))
                {
                    RectangleChosonClass1.Content = "+申请活动";
                    RectangleChosonClass1.Foreground = new SolidColorBrush(Color.FromArgb(230, 255, 255, 255));
                    RectangleChosonClass2.Content = "+申请活动";
                    RectangleChosonClass2.Foreground = new SolidColorBrush(Color.FromArgb(230, 255, 255, 255));
                }
                else
                {
                    RectangleChosonClass1.Content = "";//chosenRent1 == null ? "" : "查看信息";
                    RectangleChosonClass2.Content = "";//chosenRent2 == null ? "" : "查看信息";
                }
            }
            else if (schedule1 != null)
            {
                chosenRent1 = schedule1.GetRentFromDateClass(currDate, currClass);
                TBHighlight1 = Hightlight(TBHighlight1, chosenRent1, GridSchedule1);
            }
        }
コード例 #15
0
        //初始化单个课程
        private void TextBlockInitialize(TextBlock tb, Rent r, bool MouseShow = true)
        {
            tb.Tag = r;

            tb.Background = MyColor.NameBrush(r.Info);
            tb.Text = r.Info; if (!r.Approved) tb.Text += "(未审核)";
            Classroom c = Building.GetClassroom(r.cId); if (c != null) tb.Text += ("@" + c.Name);
            if (Father.WindowState == WindowState.Maximized) tb.FontSize = 16; else tb.FontSize = 14;

            tb.Foreground = new SolidColorBrush(WindowIndex.textColor);
            tb.TextWrapping = TextWrapping.Wrap;

            tb.SetValue(Grid.ColumnProperty, r.Time.WeekDay);
            tb.SetValue(Grid.RowProperty, r.Time.StartClass - 1);
            tb.SetValue(Grid.RowSpanProperty, r.Time.KeepClass);

            tb.MouseDown += tb_MouseDown;

            if (MouseShow)
            {
                tb.MouseEnter += tb_MouseEnter;
                tb.MouseLeave += tb_MouseLeave;
            }
        }
コード例 #16
0
        private void MyTextBlockInitialize(TextBlock tb, Rent r)
        {
            tb.Tag = r;
            tb.Height = 125; tb.Width = 125;
            tb.Margin = new Thickness(10);

            tb.Background = MyColor.NameBrush(r.Info);
            tb.Text = r.Info; if (!r.Approved) tb.Text += "(未审核)";
            Classroom c = Building.GetClassroom(r.cId); if (c != null) tb.Text += ("@" + c.Name);
            tb.FontSize = 16;

              //  tb.Foreground = new SolidColorBrush(textColor);
            tb.TextWrapping = TextWrapping.Wrap;

            tb.MouseDown += tb_MouseDown;

            tb.MouseEnter += tb_MouseEnter;
            tb.MouseLeave += tb_MouseLeave;
        }
コード例 #17
0
        //(管理员功能)查看未审核课程
        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;
        }
コード例 #18
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("活动申请发送失败。");
        }
コード例 #19
0
 public void Remove(Rent r)
 {
     if (Rents.Contains(r)) Rents.Remove(r);
 }
コード例 #20
0
        //初始化单个课程
        private void TextBlockInitialize(TextBlock tb, Rent r, bool MouseShow = true)
        {
            tb.Tag = r;

            tb.Background = new SolidColorBrush(MyColor.NameColor(r.Info));
            tb.Text = r.Info;
            Classroom c = Building.GetClassroom(r.cId); if (c != null) tb.Text += ("@" + c.Name);
            tb.FontSize = 16;

            tb.Foreground = new SolidColorBrush(Color.FromArgb(200, 255, 255, 255));
            tb.TextWrapping = TextWrapping.Wrap;
            tb.SetValue(Grid.ColumnProperty, r.Time.WeekDay);
            tb.SetValue(Grid.RowProperty, r.Time.StartClass - 1);
            tb.SetValue(Grid.RowSpanProperty, r.Time.KeepClass);

            if (MouseShow)
            {
                tb.MouseEnter += tb_MouseEnter;
                tb.MouseLeave += tb_MouseLeave;
            }
        }
コード例 #21
0
 private TextBlock Rent2Block(Rent r)
 {
     foreach (TextBlock tb in TextBlockRents1)
         if ((Rent)tb.Tag == r) return tb;
     foreach (TextBlock tb in TextBlockRents2)
         if ((Rent)tb.Tag == r) return tb;
     return null;
 }
コード例 #22
0
        private TextBlock Hightlight(TextBlock tbh, Rent r, Grid grid)
        {
            if (grid.Children.Contains(tbh))
            {
                tbh.Visibility = Visibility.Collapsed;
                grid.Children.Remove(tbh);
            }

            if (r == null) return null;

            Console.WriteLine("Rent: " + r.Info);

            tbh = new TextBlock();
            grid.Children.Add(tbh);
            TextBlockInitialize(tbh, r, false);

            tbh.Background = new SolidColorBrush(MyColor.NameColor(r.Info, 1));
            tbh.Foreground = new SolidColorBrush(Colors.White);

            if (GridSchedule1 == grid) tbh.MouseDown += RectangleChosonRent1_MouseDown;
            else if (GridSchedule2 == grid) tbh.MouseDown += RectangleChosonRent2_MouseDown;

            return tbh;
        }
コード例 #23
0
        private void stackPanel_Loaded(object sender, RoutedEventArgs e)
        {
            switch (WindowIndex.currSkin)
            {
            case WindowIndex.skin.Starry:
                BorderBack.Background = new ImageBrush(WindowIndex.ChangeBitmapToImageSource(Properties.Resources.listback));
                break;

            case WindowIndex.skin.ColorBox:
                BorderBack.Background = new ImageBrush(WindowIndex.ChangeBitmapToImageSource(Properties.Resources.Color1));
                break;
            }

            foreach (Building building in Building.AllBuildings)
            {
                TextBlock tbTitle = new TextBlock();
                tbTitle.Padding      = new Thickness(24, 16, 26, 10);
                tbTitle.TextWrapping = TextWrapping.Wrap;
                tbTitle.Text         = building.Name;
                tbTitle.FontSize     = 24;
                //   tbTitle.Background = new SolidColorBrush(MyColor.NameColor(building.Name, 0.05));

                WrapPanel subPanel = new WrapPanel();
                subPanel.Orientation = Orientation.Horizontal;
                subPanel.Margin      = new Thickness(24, 0, 24, 0);

                foreach (Classroom classroom in building.Classrooms)
                {
                    TextBlock tb = new TextBlock();
                    tb.Height       = 125;
                    tb.Width        = 125;
                    tb.FontSize     = 16;
                    tb.Margin       = new Thickness(5);
                    tb.TextWrapping = TextWrapping.Wrap;

                    Rent rent = rentTable.GetClassroom(classroom.cId);
                    if (rent == null)
                    {
                        tb.Height     = 60;
                        tb.Width      = 60;
                        tb.FontSize   = 12;
                        tb.Text       = classroom.Name;
                        tb.Background = MyColor.NameBrush(tb.Text, 0.05); //new SolidColorBrush(MyColor.NameColor(tb.Text, 0.05));
                    }
                    else
                    {
                        tb.Text       = classroom.Name + ":" + rent.Info;
                        tb.Background = MyColor.NameBrush(tb.Text); //new SolidColorBrush(MyColor.NameColor(tb.Text));
                    }

                    tb.Tag         = classroom;
                    tb.MouseDown  += tb_MouseDown;
                    tb.MouseEnter += tb_MouseEnter;
                    tb.MouseLeave += tb_MouseLeave;

                    subPanel.Children.Add(tb);
                }

                stackPanel.Children.Add(tbTitle);
                stackPanel.Children.Add(subPanel);
            }
        }
コード例 #24
0
 public bool ApproveRent(Rent r)
 {
     r.GetApproved();
     return(DatabaseLinker.ApproveRent(r));
 }
コード例 #25
0
 public WindowRent(Rent r, WindowIndex fatherWindow)
 {
     InitializeComponent();
     rent = r;
     father = fatherWindow;
 }
コード例 #26
0
        public static bool SetRent(Rent r)
        {
            MySqlConnection mConnect = null;
            MySqlCommand mCommand = null;

            try
            {
                mConnect = new MySqlConnection("server=localhost;user id=root;Password=;database=classroomad");
                mCommand = new MySqlCommand();
                mCommand.Connection = mConnect;
                mConnect.Open();
            }
            catch
            {
                Console.WriteLine("FAILED to link MySQL in SetRent()");
                return false;
            }

            mCommand.CommandText = "INSERT INTO rent VALUES( 0 , "
                + r.cId + " , "
                + " false , "
                + r.pId + " , "
                + "\"" + r.Info + "\" , "
                + r.Time.ToString()
                + ");";

            mCommand.Prepare();
            int i = mCommand.ExecuteNonQuery();

            mConnect.Close();

            return i > 0;
        }