bafana mthivane

bafana mthivane

  • NA
  • 10
  • 2.7k

add using linq c#

Jun 12 2014 3:01 AM
#####Presentation
private void Grid_Loaded_1(object sender, RoutedEventArgs e) // load list box with a value or name of sorts
{
var getResults = data.LoadShip();
lsShipper.ItemsSource = getResults;
lsShipper.DisplayMemberPath = "CompanyName";
lsShipper.SelectedValuePath = "ShipperID";
txtShip.IsEnabled = false;
txtCompanyName.IsEnabled = false;
txtPhone.IsEnabled = false;
}
private void lsShipper_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
var getResults = data.ReturnString(Convert.ToInt32(lsShipper.SelectedValue));
foreach (var item in getResults) //binding to textbox
{
txtShip.Text = item.ShipperID.ToString();
txtCompanyName.Text = item.CompanyName;
txtPhone.Text = item.Phone;
}
###DataTier
public DataTable ExcelCustomer() //SELECT USING A JOINT STATEMENT
{
var query = from qry in data.Territories
join qrys in data.Regions
on qry.RegionID equals qrys.RegionID
orderby qry.RegionID
select new
{
qry.Employees,
qry.RegionID,
qry.Region,
qrys.Territories,
qrys.RegionDescription
};
DataTable dt = new DataTable();
dt.Columns.Add("Employees");
dt.Columns.Add("RegionID");
dt.Columns.Add("Region");
dt.Columns.Add("Territories");
dt.Columns.Add("RegionDescription");
foreach (var qry in query)
{
dt.NewRow();
dt.Rows.Add(qry.Employees, qry.RegionID, qry.Region, qry.Territories, qry.RegionDescription);
}
return dt;
}
public IEnumerable<NorthClass.Shipper> ReportShip() //LOADING A LISTBOX
{
var query = from qry in data.Shippers
select qry;
return query.ToList();
}
public IEnumerable<object> strString(int Ship) //RECIEVE AND LOAD TEXTBOX
{
var query = from qry in data.Suppliers
where qry.SupplierID.Equals(Ship)
select qry;
return query.ToList();
}
}

Answers (5)