Пример #1
0
 private void CampaignDonorsItems_VisibleChanged(object sender, EventArgs e)
 {
     if (CampaignDonorsItems.Visible)
     {
         DataTable donor = cms.GetTable(@"SELECT Name_, SSN, Campaign_ID
                                          FROM Donate_to, Donor, Person
                                          WHERE Person.SSN = Donor.Donor_SSN AND Donate_to.Donor_SSN = Donor.Donor_SSN", TableType.CustomQuery);
         DataTable item  = cms.GetTable(@"SELECT Name_, Campaign_ID
                                         FROM Donate_to, Item
                                         WHERE Item.Name_ = Donate_to.ItemName AND Item.MainName = Donate_to.ItemMainName and Item.SubName = Donate_to.ItemSubName", TableType.CustomQuery);
         dataSet.Tables.Add(cms.GetTable("Campaign"));
         dataSet.Tables.Add(donor);
         dataSet.Tables.Add(item);
         dataSet.Relations.Add(new DataRelation("CampaignDonor",
                                                dataSet.Tables["Campaign"].Columns["ID_"], donor.Columns["Campaign_ID"]));
         dataSet.Relations.Add(new DataRelation("CampaignItem",
                                                dataSet.Tables["Campaign"].Columns["ID_"], item.Columns["Campaign_ID"]));
         CampaignTable.DataSource = new BindingSource(dataSet, "Campaign");
         DonorsTable.DataSource   = new BindingSource(CampaignTable.DataSource, "CampaignDonor");
         ItemsTable.DataSource    = new BindingSource(CampaignTable.DataSource, "CampaignItem");
     }
 }