Ejemplo n.º 1
0
        private void MANSearchcustdatagridclickcell(object sender, DataGridViewCellEventArgs e)
        {
            MANSearch_custID.Clear();

            try
            {
                if (e.RowIndex >= 0)
                {
                    MANSearch_custID.Text    = MANSearch_Cust_Datagrid.Rows[e.RowIndex].Cells["CustsearchID"].Value.ToString();
                    MANSearch_custFN.Text    = MANSearch_Cust_Datagrid.Rows[e.RowIndex].Cells["CustsearchFN"].Value.ToString();
                    MANSearch_custLN.Text    = MANSearch_Cust_Datagrid.Rows[e.RowIndex].Cells["CustsearchLN"].Value.ToString();
                    MANSearch_custPhone.Text = MANSearch_Cust_Datagrid.Rows[e.RowIndex].Cells["Custsearchphone"].Value.ToString();
                    MANSearch_custGovid.Text = MANSearch_Cust_Datagrid.Rows[e.RowIndex].Cells["Custsearchgovid"].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 = \"" + MANSearch_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];

                    MANCustomer_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);
                        MANCustomer_owned_properties.Items.Add(item);
                    }
                }
                catch
                {
                    MessageBox.Show("Insert less parameters for more results");
                }
                connection.Close();
            }
            catch
            {
            }
        }
Ejemplo n.º 2
0
 private void MANResetcust_Click(object sender, EventArgs e)
 {
     MANSearch_custID.Clear();
     MANSearch_custFN.Clear();
     MANSearch_custLN.Clear();
     MANSearch_custPhone.Clear();
     MANSearch_custGovid.Clear();
     MANCustomer_owned_properties.Items.Clear();
     MANSearch_Cust_Datagrid.Rows.Clear();
 }