I am doing system using window phone 7 and sql server as database.
I am using below coding to get shopping cart list at listbox.
public List<Order> FindOrder(string custemail, string orderstatus)
{
var findorder = from r in order.Orders
where (r.CustEmail == custemail && r.OrderStatus == orderstatus )
select r;
return findorder.ToList();
}
public pgShopCart()
{
var obj = App.Current as App;
custemail = obj.custEMAIL;
string orderstatus = "Pending";
proxy.FindOrderCompleted += new EventHandler<FindOrderCompletedEventArgs>(proxy_FindOrderCompleted);
proxy.FindOrderAsync(custemail, orderstatus);
}
void proxy_FindOrderCompleted(object sender, FindOrderCompletedEventArgs e)
{
ListBox1.ItemsSource = e.Result;
}
After that I want to update the orderId status become "success" but I am only able to update 1 row only by using assign listbox1.itemsource into observable collection
void proxy_FindOrderCompleted(object sender, FindOrderCompletedEventArgs e)
{
ListBox1.ItemsSource = e.Result;
ObservableCollection<Order> Orders = this.ListBox1.ItemsSource as ObservableCollection<Order>;
foreach (Order order in Orders)
{
orderid = order.OrderID;
}
}
and this to update row:
public void UpdateOrderStatus(int orderid, string orderstatus, string paymentdate)
{
Order data = order.Orders.Single(p => p.OrderID == orderid);
data.OrderStatus = orderstatus;
order.SubmitChanges();
}
private void btnPay_Click(object sender, RoutedEventArgs e)
{
proxy.UpdateOrderStatusCompleted += new EventHandler<UpdateOrderStatusCompletedEventArgs>(proxy_UpdateOrderStatusCompleted);
proxy.UpdateOrderStatusAsync(orderid, orderstatus);
}
Any idea to edit my coding for update multiple rows into database?