public async Task ExecuteLoadItemsCommand() { if (IsBusy) { return; } IsBusy = true; try { Items1.Clear(); Items2.Clear(); Items3.Clear(); var items = dataAccess.GetDataFromServer("1"); Items1.ReplaceRange(items); items = dataAccess.GetDataFromServer("2"); Items2.ReplaceRange(items); items = dataAccess.GetDataFromServer("3"); Items3.ReplaceRange(items); } catch (Exception ex) { Debug.WriteLine(ex); MessagingCenter.Send(new MessagingCenterAlert { Title = "Error", Message = "Unable to load items.", Cancel = "OK" }, "message"); } finally { IsBusy = false; } }
private void date_slect_SelectedDateChanged(object sender, SelectionChangedEventArgs e) { if (dt == 1 && check1 == 1) { Items1.Clear(); purchase_grid.ItemsSource = null; podatagrid.ItemsSource = null; order_get(); } }
public void software_get() { bool success = connect.CheckForInternetConnection(); if (success) { String url = connect.software_get_url; try { HttpWebRequest req = WebRequest.Create(url) as HttpWebRequest; req.Headers["AdminAuthToken"] = connect.auth_token; string result = null; Mouse.OverrideCursor = Cursors.Wait; using (HttpWebResponse resp = req.GetResponse() as HttpWebResponse) { StreamReader reader = new StreamReader(resp.GetResponseStream()); result = reader.ReadToEnd(); } if (connect.IsValidJson(result)) { JObject obj2 = JObject.Parse(result); if (Convert.ToBoolean(obj2["status"].ToString())) { if (connect.IsValidJson(obj2["data"].ToString())) { var dt = (DataTable)JsonConvert.DeserializeObject(obj2["data"].ToString(), (typeof(DataTable))); Items1.Clear(); foreach (DataRow dr in dt.Rows) { _items1.Add(new Item1 { name = dr["first_name"].ToString(), user_name = dr["user_name"].ToString(), designation = dr["location"].ToString(), phone_no = dr["phone"].ToString(), email = dr["email"].ToString() }); } } } sdatagrid.ItemsSource = Items1; Mouse.OverrideCursor = Cursors.Arrow; } req.Abort(); } catch (Exception e) { MessageBox.Show(e.Message); } } }
public void order_get() { if (connect.CheckForInternetConnection()) { string d1 = date_slect.SelectedDate.Value.Date.ToString("MM-dd-yyyy"); String url = connect.order_get_url; try { HttpWebRequest req = WebRequest.Create(url) as HttpWebRequest; req.Headers["AdminAuthToken"] = connect.auth_token; string result = null; Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait; using (HttpWebResponse resp = req.GetResponse() as HttpWebResponse) { StreamReader reader = new StreamReader(resp.GetResponseStream()); result = reader.ReadToEnd(); } if (connect.IsValidJson(result)) { int i = 1; JToken token = JToken.Parse(result); if (string.Equals(token.SelectToken("status").ToString(), "true", StringComparison.CurrentCultureIgnoreCase)) { Items1.Clear(); int size = token.SelectToken("data").Count(); for (int v = 0; v < size; v++) { string pcode = "", pname = "", qty = "", cust = "", price1 = "", date = "", time = "", piece_count = "", porge_count = ""; string color1 = "Red"; string st = "View"; JArray details = (JArray)token.SelectToken("data[" + v.ToString() + "].details"); foreach (JToken m in details) { if (m["Customer"] != null) { pcode += m["Customer"].ToString() + ","; } else { pcode += "0,"; } if (m["Name"] != null) { pname += m["Name"].ToString() + ","; } else { pname += "0,"; } if (m["Pro_Img"] != null) { porge_count += m["Pro_Img"].ToString() + ","; } else { porge_count += "0,"; } if (m["count"] != null) { piece_count += m["count"].ToString() + ","; } else { piece_count += "0,"; } if (m["Cost"] != null) { price1 += m["Cost"].ToString() + ","; } else { price1 += "0,"; } if (m["Date"] != null) { date = m["Date"].ToString(); } else { date += "0,"; } if (m["Time"] != null) { time = m["Time"].ToString(); } else { time += "0,"; } } if (Convert.ToBoolean(token.SelectToken("data[" + v.ToString() + "].admin_view").ToString()) == true) { color1 = "Green"; st = "Seen"; } JObject ju = (JObject)token.SelectToken("data[" + v.ToString() + "].user"); JObject jc = (JObject)token.SelectToken("data[" + v.ToString() + "].customer"); if (date == d1) { _items1.Add(new Item1 { po = token.SelectToken("data[" + v.ToString() + "].invoice_id").ToString(), id = token.SelectToken("data[" + v.ToString() + "].id").ToString(), product_code = pcode, product_name = pname, pquantity = piece_count, poquantity = porge_count, price = price1, date = date, time = time, color = color1, stat = st, customer_name = jc["name"].ToString(), sales_man = ju["first_name"].ToString(), customer_details = jc }); i++; } } } Items1.Sort((y, x) => x.time.CompareTo(y.time)); purchase_grid.ItemsSource = Items1; Mouse.OverrideCursor = Cursors.Arrow; } } catch (Exception e) { MessageBox.Show(e.Message); } } }