Hi all,
I have Visual C#2008 Express and SQL Server 2008 Express installed in my Microsoft Windows XP Pro PC that is part of Microsoft NT 4 LAN System in our office. Recently, I picked up some skills of handling the Relational Database Management, T-SQL, etc. in SQL Server 2008 Express. Now I am doing "Managing the Data" and "ADO.NET, Data Binding, and LINQ" in Visual C#2008 Express . I am using a book "Building a Program Now! Microsoft Visual C# 2008 Express Edition" by Patrice Pelland and following the example "CarTrack" in Chapter 8 (Managing the Data) of the book to do my first project "scCarTrack": I followed the Steps 1-8 listed on Pages 159-160 of the book to create a Windows Application project "scCarTreck", the Steps on Pages 161-162 to create 4 Tables (Make, CarType, Color & Listing), the Steps on Pages 163 -166 to create Relationships between Tables, and the Steps on Page 167-170 to enter Data in SQL Server Tables using Visual Studio.
I went on to develop the scCarTrack application: I followed the Steps on Pages 174-176 of the book to create a Dataset and have the Dataset in the Data Sources window. I completed Step 10 (on Page 176): Change ColorID, MakeID, and CarTypeID to ComboBox type by clicking the drop-down arrow next to each column and selecting ComboBox. I followed the Step 11 (on Page 176): Select the Listing nodes by clicking it, and then drag it near the top-left corner of the designer surface Form1. I got the following on Form1:
|< <| 0 of (0)| > >| + X
Listing ID ColorID MakeID
|> | | | |
carTrackerDataSet ListingBindingSource
ListingTableAdapter tableAdapterManager
ListingBindingNavigator
This result is like the result of Figure 8-19 on Page 177:
|< <|0 of (0)| > >| + X
ListingID: | |
ColorID: | v|
MakeID: | v|
CarTypeID: | v|
DataSeen: | Saturday December 12, 2007 v |
Year: | |
Price: | |
Cylinder: | |
HP: | |
RUL: | |
EPGCity: | |
EPGHighway | |
Notes: | |
(1) I tried to re-organize the boxes of Combox in Figure 8-19 (shown above) in the different areas of Form1 (like Figure 8-29 on Page 190) without luck. Please help and tell me how to re-organize the existing boxes of ComboBox on the Form1 to the different areas of the Form1.
(2) I want to add 3 filters (Filter By Color, Filter By Make, and Filter By Car Type) to this project. How can I add the 3 filters on the Form1?
(3) I want to use LINQ and add LINQ query:
var queryResults = from cust in customers _
where cust.Country = "USA"
select cust.CompanyName, cust.Country;
var filterByMake = from Listing in this.carTrackerDataSet.Listing
join Make in this.carTrackerDataSet.Make
on Listing.MakeID equals MakeMakeID
where (MakeName.ToLower().Contains(tstbFilterByMake.Text.ToLower()))
select Listing;
this.listingBindingSource.DataSource = filterByMake;
These things are used after the following code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
namespace scCarTrack
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void listingBindingNavigatorSaveItem_Click(object sender, EventArgs e)
{
this.Validate();
this.listingBindingSource.EndEdit();
this.tableAdapterManager.UpdateAll(this.carTrackerDataSet);
}
private void Form1_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'carTrackerDataSet.Listing' table. You can move, or remove it, as needed.
this.listingTableAdapter.Fill(this.carTrackerDataSet.Listing);
}
}
}
Please help and advise.
Thanks in advance,
Scott Chang
SHC