Пример #1
0
        private void btnFind_Click(object sender, EventArgs e)
        {
            String[]      fields = { "id", "room_id", "date_booked" };
            SqlConnection conn   = DBUtils.GetDBConnection();

            string sql = "SELECT id as ID, room_id as Room_ID, date_booked as Date, time_start as TimeStart, time_end as TimeEnd, members_qtt as Members FROM BookedRoom_table where user_id= " + DBUtils.currentUserID + " and " + fields[dropFields.selectedIndex] + " like '%" + txtValue.Text + "%'";

            conn.Open();

            SqlCommand     cmd = new SqlCommand(sql, conn);
            SqlDataAdapter da  = new SqlDataAdapter(cmd);
            DataSet        ds  = new DataSet();

            da.Fill(ds);

            dataGrid1.DataSource = ds.Tables[0];

            cmd.Dispose();
            conn.Close();
        }
Пример #2
0
        private void btnFind_Click(object sender, EventArgs e)
        {
            String[]      fields = { "id", "user_id", "room_id", "date_booked" };
            SqlConnection conn   = DBUtils.GetDBConnection();

            string sql = "SELECT * FROM BookedRoom_table where " + fields[dropFields.selectedIndex] + " like '%" + txtValue.Text + "%'";

            conn.Open();

            SqlCommand     cmd = new SqlCommand(sql, conn);
            SqlDataAdapter da  = new SqlDataAdapter(cmd);
            DataSet        ds  = new DataSet();

            da.Fill(ds);

            dataGrid1.DataSource = ds.Tables[0];

            cmd.Dispose();
            conn.Close();
        }
Пример #3
0
        public UserHistory()
        {
            InitializeComponent();
            dropFields.selectedIndex = 0;

            SqlConnection conn = DBUtils.GetDBConnection();

            string sql = "SELECT id as ID, room_id as Room_ID, date_booked as Date, time_start as TimeStart, time_end as TimeEnd, members_qtt as Members FROM BookedRoom_table where user_id= " + DBUtils.currentUserID;

            conn.Open();

            SqlCommand     cmd = new SqlCommand(sql, conn);
            SqlDataAdapter da  = new SqlDataAdapter(cmd);
            DataSet        ds  = new DataSet();

            da.Fill(ds);

            dataGrid1.DataSource = ds.Tables[0];

            cmd.Dispose();
            conn.Close();
        }
Пример #4
0
        private bool checkLoginExist()
        {
            bool result = false;

            if (!userDefaulLogin.Equals(txtLogin.Text))
            {
                SqlConnection conn = DBUtils.GetDBConnection();
                conn.Open();
                SqlCommand    cmd;
                SqlDataReader reader;
                String        sql = "";

                sql = "Select * from user_table where login='******';";

                cmd = new SqlCommand(sql, conn);

                reader = cmd.ExecuteReader();

                result = reader.HasRows;
                cmd.Dispose();
                conn.Close();
            }
            return(result);
        }
Пример #5
0
 public ManageRooms()
 {
     InitializeComponent();
     conn = DBUtils.GetDBConnection();
     dropFields.selectedIndex = 0;
 }