コード例 #1
0
        // Button 'Search'
        private void buttonSearchHousekeeping_Click(object sender, EventArgs e)
        {
            string searchinput = @textBoxSearch.Text.Trim();

            // Fetch dataset
            DataSet housekeepingDS = DBGetData.GetHousekeepingDGVSearch(searchinput);

            if (housekeepingDS != null)
            {
                // No tables fetched
                if (housekeepingDS.Tables.Count == 0)
                {
                    new StatusMessage("No datatable found, contact administrator.");
                    return;
                }
                // No rows fetched
                else if (housekeepingDS.Tables[0].Rows.Count == 0)
                {
                    new StatusMessage("No datarows found matching search.");
                    return;
                }
                // Clear labelStatus for previous messages
                else
                {
                    new StatusMessage("");
                }

                // Set the dataset as source for datagridview and make sure its displayed
                dataGridViewHousekeeping.DataSource = housekeepingDS;
                dataGridViewHousekeeping.DataMember = "Get_Housekeeping_Search";
                LoadDataGridViewHousekeeping();
            }
        }