private void Searchcustdatagridclickcell(object sender, DataGridViewCellEventArgs e) { Search_custID.Clear(); try { if (e.RowIndex >= 0) { Search_custID.Text = Search_Cust_Datagrid.Rows[e.RowIndex].Cells["CustsearchID"].Value.ToString(); Search_custFN.Text = Search_Cust_Datagrid.Rows[e.RowIndex].Cells["CustsearchFN"].Value.ToString(); Search_custLN.Text = Search_Cust_Datagrid.Rows[e.RowIndex].Cells["CustsearchLN"].Value.ToString(); Search_custPhone.Text = Search_Cust_Datagrid.Rows[e.RowIndex].Cells["Custsearchphone"].Value.ToString(); Search_custGovid.Text = Search_Cust_Datagrid.Rows[e.RowIndex].Cells["Custsearchgovid"].Value.ToString(); Search_custAddress.Text = Search_Cust_Datagrid.Rows[e.RowIndex].Cells["Custsearchaddress"].Value.ToString(); } string query = "Select P.*, R.Reg_ID , R.Reg_date from Property P "; query += "inner join Registration R on R.Property_ID = P.Property_ID "; query += "inner join Customer C on C.Customer_ID = R.Customer_ID "; query += "where C.Customer_ID = \"" + Search_custID.Text.ToString() + "\""; try { connection.Open(); MySqlCommand cmd = new MySqlCommand(query, connection); MySqlDataAdapter mcmd = new MySqlDataAdapter(); MySqlDataReader reader; mcmd.SelectCommand = cmd; reader = cmd.ExecuteReader(); ListViewItem item; string[] data = new string[6]; Customer_owned_properties.Items.Clear(); while (reader.Read()) { data[0] = reader["Property_ID"].ToString().Trim(); data[1] = reader["Prop_type"].ToString().Trim(); data[2] = reader["Prop_area"].ToString().Trim(); data[3] = reader["Prop_Loc"].ToString().Trim(); data[4] = reader["Prop_price"].ToString().Trim(); data[5] = ((DateTime)reader["Reg_date"]).ToString("d"); item = new ListViewItem(data); Customer_owned_properties.Items.Add(item); } } catch { MessageBox.Show("Insert less parameters for more results"); } connection.Close(); } catch { } }
private void Resetcust_Click(object sender, EventArgs e) { Search_custID.Clear(); Search_custFN.Clear(); Search_custLN.Clear(); Search_custPhone.Clear(); Search_custGovid.Clear(); Search_custAddress.Clear(); Customer_owned_properties.Items.Clear(); Search_Cust_Datagrid.Rows.Clear(); }