Esempio n. 1
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            var conn = Database.ConnectDB();

            try
            {
                conn.Open();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            int              id     = Int32.Parse(tbSearchID.Text);
            string           query  = "select * from [guest] where id =  " + id;
            SqlCommand       cmd    = new SqlCommand(query, conn);
            SqlDataReader    reader = cmd.ExecuteReader();
            CCustomerDetails c      = new CCustomerDetails();

            while (reader.Read())
            {
                c.Name = reader.GetString(reader.GetOrdinal("Name"));

                c.RoomNo = reader.GetString(reader.GetOrdinal("RoomNo"));
            }
            tbSearchedName.Text   = c.Name;
            tbSearchedRoomNo.Text = c.RoomNo;
            conn.Close();
        }
Esempio n. 2
0
        List <CCustomerDetails> GetAllCustomer()
        {
            List <CCustomerDetails> cCustomerDetails = new List <CCustomerDetails>();
            var conn = Database.ConnectDB();

            try
            {
                conn.Open();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            string query = "select * from guest";

            try
            {
                SqlCommand    cmd    = new SqlCommand(query, conn);
                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    CCustomerDetails cd = new CCustomerDetails();
                    cd.Id        = reader.GetInt32(reader.GetOrdinal("id"));
                    cd.Name      = reader.GetString(reader.GetOrdinal("Name"));
                    cd.Address   = reader.GetString(reader.GetOrdinal("Address"));
                    cd.ContactNo = reader.GetString(reader.GetOrdinal("ContactNo"));
                    cd.Gender    = reader.GetString(reader.GetOrdinal("Gender"));
                    cd.DOB       = reader.GetString(reader.GetOrdinal("DateOfBirth"));
                    cd.Email     = reader.GetString(reader.GetOrdinal("Email"));
                    cd.Bed       = reader.GetString(reader.GetOrdinal("Bed"));
                    cd.RoomType  = reader.GetString(reader.GetOrdinal("RoomType"));
                    cd.RoomNo    = reader.GetString(reader.GetOrdinal("RoomNo"));
                    cd.CheckIn   = reader.GetString(reader.GetOrdinal("CheckIn"));
                    cd.Price     = reader.GetString(reader.GetOrdinal("Price"));

                    cCustomerDetails.Add(cd);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            conn.Close();
            return(cCustomerDetails);
        }