Hi
I am new to programing and learing c#. I am trying to create a windows based form which find the record from data base. The data base have three form Repair, customer and machine. The search criteria is when user enter repair ID the result populate into three grides one with all customer inoformation against that repair Id and one is to show repaie information and last one is to show machine information. My problem is how can I show the records into three grids using one Join query.
Thanks
Loading
always gullPosted Feb 25, 2009, 1:51 PM
Thanks
makando kabilaPosted Feb 21, 2009, 8:36 AM
This approach also could be useful if you select a row from one of the datagrids and then to only display the
corresponding ones in the other grids. There're various ways to do this.
Part of your code listing could be something like this:
DataView dvCustomers;
DataView dvRepairs;
DataView dvMachines;
DataSet ds = new DataSet();
private void Form1_Load(object sender, EventArgs e)
{
//Populate the dataset first
//Then
InitialiseDataviewsAndBind();
}
private void btnFindRecords_Click(object sender, EventArgs e)
{
string repairid = "your RepId comes here";
//or string repairid = textBox1.Text;
ApplyFilter(repairid);
}
private void ApplyFilter(string repairid)
{
string custfilter = string.Empty;
string machinefilter = string.Empty;
dvRepairs.RowFilter = "RepairId='" + repairid + "'";
if (dvRepairs.Count > 0)
{
DataRowView drvrepairs = dvRepairs[0];
custfilter = "Id='" + drvrepairs["CusId"].ToString() + "'";
machinefilter = "MachId='" + drvrepairs["MachId"].ToString() + "'";
}
dvCustomers.RowFilter = custfilter;
dvMachines.RowFilter = machinefilter;
}
private void InitialiseDataviewsAndBind()
{
/* Run after populating your dataset
*You could use table names if you know them correctlt
*instead of the index*/
dvCustomers = ds.Tables[0].DefaultView;
dvRepairs = ds.Tables[2].DefaultView;
dvMachines = ds.Tables[3].DefaultView;
dg1.DataSource = dvCustomers;
dg2.DataSource = dvRepairs;
dg3.DataSource = dvMachines;
}
LisaPosted Feb 18, 2009, 1:42 AM
thats quite simple
say dg1 is your first datagrid
dg1.DataSource = ds.Tables[0]
dg2.DataSource = ds.Tables[1]
dg3.DataSource = ds.Tables[2]
be sure which table goes to which datagrid.
Thanks,
Lisa
always gullPosted Feb 17, 2009, 12:05 PM
LisaPosted Feb 17, 2009, 9:28 AM
well consider a query like
select * from table1
select * from table2
select * from table3 in a single procedure this will return 3 different results
you can then use a dataadapter to fill the dataset with 3 different tables in the same dataset
and assign individual tables to datagridviews.
Thanks,
Lisa
always gullPosted Feb 17, 2009, 8:39 AM
Thanks Israr
LisaPosted Feb 17, 2009, 6:02 AM
you can create a query with actually returns 3 datasets or may be single dataset with 3 different tables and assign those values to the indivdual datagrid views.
Thanks,
Lisa
always gullPosted Feb 16, 2009, 3:30 PM
Tables
customer(Id, name, add,tel, email)
Repair(RepId, CusId,MachId,Redescription, RepStatus, RepCost) Machine(MachId,CusId,Make,Model,SerielNo)
Relation ships
1 Customer can have many repairs many Repair can have many customer
1 Customer can have many machine for repair Many machine can have many Cus
1 Machine can be repair many time Many repair can have same machine for repair
Thanks
Bechir BejaouiPosted Feb 1, 2009, 6:07 PM