Ejemplo n.º 1
0
        public void AddItem()
        {
            _room info = new _room();

            info.floor       = cmbFloor.Text;
            info.roomnumber  = txtRoom.Text;
            info.type        = cmbType.Text;
            info.price       = txtPrice.Text;
            info.description = txtDescription.Text;
            info.connect();

            if (btnADD.Text == "ADD")
            {
                info.Save();
                info.AddToCheckInCheckOut();
            }
            else
            {
                info.updateRoom();
            }
            clearTextbox();
            btnADD.Enabled   = false;
            btnNew.Text      = "NEW";
            btnADD.BackColor = System.Drawing.Color.White;
            ReadAllData();
        }
Ejemplo n.º 2
0
        private void BtnDelete_Click(object sender, EventArgs e)
        {
            if (lstRoom.SelectedItems != null)
            {
                for (int i = lstRoom.Items.Count - 1; i >= 0; i--)
                {
                    if (lstRoom.Items[i].Selected)
                    {
                        if (MessageBox.Show("Do you want to delete this record ?", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            _room info = new _room();
                            info.roomnumber = lstRoom.Items[i].SubItems[1].Text;
                            info.connect();
                            info.delete();
                            ReadAllData();
                            MessageBox.Show("Deleted!");
                        }

                        else

                        {
                            //do something if NO
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public void ReadAllData()
        {
            lstRoom.Items.Clear();
            SqlConnection con = new SqlConnection("Data Source=Rofat;Initial Catalog=hotel;Integrated Security=True");

            con.Open();
            SqlCommand cm = new SqlCommand();

            cm.Connection  = con;
            cm.CommandText = "Select * from tblRoom ";
            SqlDataReader dr = cm.ExecuteReader();

            while (dr.Read())
            {
                _room info = new _room();
                info.floor       = dr[0].ToString();
                info.roomnumber  = dr[1].ToString();
                info.type        = dr[2].ToString();
                info.price       = dr[3].ToString();
                info.description = dr[4].ToString();
                info.AddToList(lstRoom);
            }
        }