예제 #1
0
        public CampRes GetCampRes(int campResNo)
        {
            CampRes reservationGroup = null;

            try
            {
                String       str_campRes = Convert.ToString(campResNo);
                String       sql         = String.Format("SELECT * FROM CAMPING_RES WHERE CampRes_No={0}", str_campRes);
                MySqlCommand command     = new MySqlCommand(sql, connection);

                connection.Open();
                MySqlDataReader reader = command.ExecuteReader();
                int             resNo, campId; DateTime startDate, endDate;
                while (reader.Read())
                {
                    resNo            = Convert.ToInt32(reader["CampRes_No"]);
                    campId           = Convert.ToInt32(reader["CAMP_CampID"]);
                    startDate        = Convert.ToDateTime(reader["Start_Date"]);
                    endDate          = Convert.ToDateTime(reader["End_Date"]);
                    reservationGroup = new CampRes(resNo, campId, startDate, endDate);
                }
            }
            catch
            { MessageBox.Show("error while loading from database."); }
            finally { connection.Close(); }

            return(reservationGroup);
        }
예제 #2
0
        /// <summary>
        /// Returns the a CampRes object if it exist in the databse otherwise it returns a null. If the accountId exists
        /// in the database as in the CampReservation table in database the method will return a CampRes object otherwise
        /// it will return an empty CampRes object.
        /// </summary>
        /// <param >int AccountId</param>
        /// <returns>CampRes</returns>
        public CampRes GetAReservation(int accountId)
        {
            accountDataHolder.eventAccountCalled += new EventAccountDataHelper.EventAccountDataHandler(EventAccountIdGetter);

            EventAccountIdGetter(accountDataHolder, accountId);

            CampRes reservation = null;

            String       str_campRes = Convert.ToString(accountId);
            String       sql         = String.Format("SELECT * FROM CAMPING_RES WHERE Account_ID={0}", str_campRes);
            MySqlCommand command     = new MySqlCommand(sql, connection);

            try
            {
                int      campResNo = 0;
                int      campId;
                DateTime startDate;
                DateTime endDate;
                int      camperAcctId = 0;


                connection.Open();
                MySqlDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    campResNo    = Convert.ToInt32(reader["CampRes_No"]);
                    camperAcctId = Convert.ToInt32(reader["Account_ID"]);
                    campId       = Convert.ToInt32(reader["CAMP_CampID"]);
                    startDate    = Convert.ToDateTime(reader["Start_Date"]);
                    endDate      = Convert.ToDateTime(reader["End_Date"]);

                    if (campComparison != null)
                    {
                        campComparison(this, campResNo);
                    }

                    reservation = new CampRes(campResNo, campId, startDate, endDate);
                }

                if (accountHolder.AccountId == camperAcctId)//this ensures that the person registered in the
                {
                    return(reservation);
                }                      //campingres table of database also exists in the EventAccount table of
                else
                {
                    reservation = null;
                }                           //the database
            }
            catch
            { MessageBox.Show("error while loading from database."); }
            finally { connection.Close(); }

            return(reservation);
        }
예제 #3
0
        /// <summary>
        /// Returns the a CampRes object if it exist in the databse otherwise it returns a null. If the accountId exists
        /// in the database as in the CampReservation table in database the method will return a CampRes object otherwise
        /// it will return an empty CampRes object.
        /// </summary>
        /// <param >int AccountId</param>
        /// <returns>CampRes</returns>
        public CampRes GetAReservation(int accountId)
        {
            accountDataHolder.eventAccountCalled += new EventAccountDataHelper.EventAccountDataHandler(EventAccountIdGetter);

            EventAccountIdGetter(accountDataHolder, accountId);

            CampRes reservation = null;

            String str_campRes = Convert.ToString(accountId);
            String sql = String.Format("SELECT * FROM CAMPING_RES WHERE Account_ID={0}", str_campRes);
            MySqlCommand command = new MySqlCommand(sql, connection);

            try
            {
                int campResNo = 0;
                int campId;
                DateTime startDate;
                DateTime endDate;
                int camperAcctId = 0;

                connection.Open();
                MySqlDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    campResNo = Convert.ToInt32(reader["CampRes_No"]);
                    camperAcctId = Convert.ToInt32(reader["Account_ID"]);
                    campId = Convert.ToInt32(reader["CAMP_CampID"]);
                    startDate = Convert.ToDateTime(reader["Start_Date"]);
                    endDate = Convert.ToDateTime(reader["End_Date"]);

                    if (campComparison != null)
                        campComparison(this, campResNo);

                    reservation = new CampRes(campResNo, campId, startDate, endDate);
                }

                if (accountHolder.AccountId == camperAcctId)//this ensures that the person registered in the
                { return reservation; }//campingres table of database also exists in the EventAccount table of
                else { reservation = null; }//the database

            }
            catch
            { MessageBox.Show("error while loading from database."); }
            finally { connection.Close(); }

            return reservation;
        }
예제 #4
0
        public CampRes GetCampRes(int campResNo)
        {
            CampRes reservationGroup = null;
            try
            {
                String str_campRes = Convert.ToString(campResNo);
                String sql = String.Format("SELECT * FROM CAMPING_RES WHERE CampRes_No={0}", str_campRes);
                MySqlCommand command = new MySqlCommand(sql, connection);

                connection.Open();
                MySqlDataReader reader = command.ExecuteReader();
                int resNo, campId; DateTime startDate, endDate;
                while (reader.Read())
                {
                    resNo = Convert.ToInt32(reader["CampRes_No"]);
                    campId = Convert.ToInt32(reader["CAMP_CampID"]);
                    startDate = Convert.ToDateTime(reader["Start_Date"]);
                    endDate = Convert.ToDateTime(reader["End_Date"]);
                    reservationGroup = new CampRes(resNo, campId, startDate, endDate);
                }

            }
            catch
            { MessageBox.Show("error while loading from database."); }
            finally { connection.Close(); }

            return reservationGroup;
        }
예제 #5
0
        //DataGridViewRow newrow = new DataGridViewRow();
        private void ChangeTagOnForm(object sender, TagEventArgs e)
        {
            label20.Text = phidgetScanner.RFIDtagNr;
            if (phidgetScanner.RFIDtagNr != null)
            {
                rfid = phidgetScanner.RFIDtagNr;
                currentAccount = accountHelper.GetEventAccountFromRFID(rfid);
                if (currentAccount != null)
                {
                    eID = accountHelper.GetEventIdFromRFID(rfid);
                    email = accountHelper.GetAccountEmailFromRFID(rfid);
                    if (email != "")
                    {
                        scannedMember = groupHelper.GetGroupMembers(email);
                        if (scannedMember != null)
                        { reservation = campDatHelper.GetCampRes(scannedMember.CampResNo); }
                    }

                    if (reservation != null)
                    {
                        DataGridViewRow newrow = new DataGridViewRow();
                        //try
                        //{
                            newrow.CreateCells(dataGridView1);
                            newrow.Cells[0].Value = scannedMember.CampResNo;
                            newrow.Cells[1].Value = reservation.EndDate;
                            newrow.Cells[2].Value = reservation.StartDate;
                            newrow.Cells[3].Value = reservation.CampId;
                            newrow.Cells[4].Value = scannedMember.Co_Email;
                            newrow.Cells[5].Value = eID;
                            newrow.Cells[6].Value = scannedMember.CheckIn;
                            dataGridView1.Rows.Clear();
                            dataGridView1.Rows.Add(newrow);
                            //row++;
                        //}
                        //catch { MessageBox.Show("This reservation information is already displayed."); }
                    }
                    else { MessageBox.Show("This accountId does not have a camping reservation."); }
                }
                else { MessageBox.Show("The scanned RFID code does not exist in database."); }
            }
        }