Пример #1
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("活动申请发送失败。");
            }
        }
Пример #2
0
        protected RentTime time; //占用的时间

        #endregion Fields

        #region Constructors

        //     public List<int> Students;
        public Rent(int id, string info, int classroomId, int host ,bool approved, RentTime time)
        {
            this.rid = id;
            this.info = info;
            this.cid = classroomId;
            this.approved = approved;
            this.pid = host;
            this.time = time;
        }
Пример #3
0
        }                                          // 活动概述

        //     public List<int> Students;

        public Rent(int id, string info, int classroomId, int host, bool approved, RentTime time)
        {
            this.rid      = id;
            this.info     = info;
            this.cid      = classroomId;
            this.approved = approved;
            this.pid      = host;
            this.time     = time;
        }
        //Get rent and RentTable
        public static Rent GetRent(int rId)
        {
            MySqlConnection mConnect = null;
            MySqlCommand    mCommand = null;

            int      cId = 0, pId = 0;
            bool     approved = true;
            string   info     = "";
            RentTime rentTime;

            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 GetRent(" + rId + ")");
                return(null);
            }

            mCommand.CommandText  = "SELECT * FROM rent WHERE ";
            mCommand.CommandText += " rId = " + rId + ";";

            MySqlDataReader mReader = mCommand.ExecuteReader();

            while (mReader.Read())
            {
                cId = int.Parse(mReader["cId"].ToString());
                if (!int.TryParse(mReader["pId"].ToString(), out pId))
                {
                    pId = 0;
                }
                approved = "True" == mReader["approved"].ToString();
                info     = mReader["info"].ToString();
                rentTime = new RentTime(
                    mReader["startDate"].ToString(),
                    mReader["endDate"].ToString(),
                    int.Parse(mReader["cycDays"].ToString()),
                    int.Parse(mReader["startClass"].ToString()),
                    int.Parse(mReader["endClass"].ToString())
                    );

                mConnect.Close();
                return(new Rent(rId, info, cId, pId, approved, rentTime));
            }

            mConnect.Close();
            return(null);
        }
        //Get rent and RentTable
        public static Rent GetRent(int rId)
        {
            MySqlConnection mConnect = null;
            MySqlCommand mCommand = null;

            int cId = 0, pId = 0;
            bool approved = true;
            string info = "";
            RentTime rentTime;

            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 GetRent(" + rId + ")");
                return null;
            }

            mCommand.CommandText = "SELECT * FROM rent WHERE ";
            mCommand.CommandText += " rId = " + rId + ";";

            MySqlDataReader mReader = mCommand.ExecuteReader();

            while (mReader.Read())
            {
                cId = int.Parse(mReader["cId"].ToString());
                pId = int.Parse(mReader["pId"].ToString());
                approved = "True" == mReader["approved"].ToString();
                info = mReader["info"].ToString();
                rentTime = new RentTime(
                    mReader["startDate"].ToString(),
                    mReader["endDate"].ToString(),
                    int.Parse(mReader["cycDays"].ToString()),
                    int.Parse(mReader["startClass"].ToString()),
                    int.Parse(mReader["endClass"].ToString())
                    );

                mConnect.Close();
                return new Rent(rId, info, cId, pId, approved, rentTime);
            }

            mConnect.Close();
            return null;
        }
        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("活动申请发送失败。");
        }