Esempio n. 1
0
        private List <Customers1> GetCustomers()
        {
            var conn = Database.ConnectDB();

            conn.Open();
            string        query  = "select * from Customers";
            SqlCommand    cmd    = new SqlCommand(query, conn);
            SqlDataReader reader = cmd.ExecuteReader();
            //ArrayList list = new ArrayList();
            List <Customers1> list = new List <Customers1>();

            while (reader.Read())
            {
                Customers1 c = new Customers1();
                c.CustomerId      = reader.GetInt32(reader.GetOrdinal("CustomerId"));
                c.CustomerName    = reader.GetString(reader.GetOrdinal("CustomerName"));
                c.CustomerContact = reader.GetString(reader.GetOrdinal("CustomerContact"));
                c.CustomerRoomNo  = reader.GetString(reader.GetOrdinal("CustomerRoomNo"));
                c.Payment         = reader.GetString(reader.GetOrdinal("Payment"));


                list.Add(c);
            }
            return(list);
        }
Esempio n. 2
0
        private void BtnSearch_Click(object sender, EventArgs e)
        {
            int c_id = Int32.Parse(tbCId.Text);
            var conn = Database.ConnectDB();

            conn.Open();
            string        query  = string.Format("select * from Customers where CustomerId={0}", c_id);
            SqlCommand    cmd    = new SqlCommand(query, conn);
            SqlDataReader reader = cmd.ExecuteReader();
            Customers1    c      = new Customers1();

            while (reader.Read())
            {
                c.CustomerName    = reader.GetString(reader.GetOrdinal("CustomerName"));
                c.CustomerContact = reader.GetString(reader.GetOrdinal("CustomerContact"));
                c.CustomerRoomNo  = reader.GetString(reader.GetOrdinal("CustomerRoomNo"));
                c.Payment         = reader.GetString(reader.GetOrdinal("Payment"));
                c.CustomerId      = reader.GetInt32(reader.GetOrdinal("CustomerId"));
            }
            tbCName.Text    = c.CustomerName;
            tbCContact.Text = c.CustomerContact;
            tbCRoom.Text    = c.CustomerRoomNo;
            tbCPayment.Text = c.Payment;
        }