private void Add_DividerClick(object sender, RoutedEventArgs e) { var divider = new DividerItem { Id = Guid.NewGuid() }; navigationItems.Add(divider); }
public static List <DividerItem> GetDivider(int week, int year) { try { List <DividerItem> Items = new List <DividerItem>(); using (SqlConnection npdConnection = new SqlConnection(Static.Secrets.NpdConnectionString)) { string sql = $@"SELECT z.zfinIndex, d.* FROM tbDivider d LEFT JOIN tbZfin z ON z.zfinId = d.ProductId WHERE Week = {week} AND Year = {year}"; SqlCommand command = new SqlCommand(sql, npdConnection); if (npdConnection.State == ConnectionState.Closed || npdConnection.State == ConnectionState.Broken) { npdConnection.Open(); } SqlDataReader reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { string zfinIndex = reader["zfinIndex"].ToString(); DividerItem d; LocationAmount la = new LocationAmount(); la.L = reader["L"].ToString(); la.Amount = Convert.ToInt32(reader["Amount"].ToString()); if (Items.Any(i => i.ZfinIndex == zfinIndex)) { //there's already this product row in collection, append it d = Items.FirstOrDefault(i => i.ZfinIndex == zfinIndex); d.Locations.Add(la); } else { //there is not this product yet, let's add it d = new DividerItem(); d.ZfinIndex = reader["zfinIndex"].ToString(); d.Locations = new List <LocationAmount>(); d.Locations.Add(la); Items.Add(d); } } } return(Items); } } catch (Exception ex) { throw; } }
private async void LoadNavigationItems() { var roamingFolder = ApplicationData.Current.RoamingFolder; var settingsFolder = await roamingFolder.CreateFolderAsync("settings", CreationCollisionOption.OpenIfExists); // Bug FileNotFound var navSettingsFile = await settingsFolder.GetFileAsync("nav_settings.json"); var json = await FileIO.ReadTextAsync(navSettingsFile); JObject rss = JObject.Parse(json); var version = (string)rss["version"]; JArray items = (JArray)rss["navigation_items"]; var count = items.Count; foreach (var item in items) { var type = (string)item["type"]; switch (type) { case "divider": var dividerItem = new DividerItem(); navigationItems.Add(dividerItem); break; case "header": var headerItem = new HeaderItem { Label = (string)item["label"] }; navigationItems.Add(headerItem); break; case "link": var linkItem = new LinkItem { Label = (string)item["label"], PageId = Guid.Parse((string)item["link_id"]) }; navigationItems.Add(linkItem); break; } } }
//分压器监测时初始化获取数据到dividerData public static List <DividerItem> GetDividerDataFromSql(EnumMode mode) { string table = ""; string strMode = ""; switch (mode) { case EnumMode.Divider_V_AC: table = "divider_now_ac"; strMode = "AC"; break; case EnumMode.Divider_V_DCP: table = "divider_now_dcp"; strMode = "DCP"; break; case EnumMode.Divider_V_DCN: table = "divider_now_dcn"; strMode = "DCN"; break; case EnumMode.Divider_F: table = "divider_now_f"; strMode = "F"; break; } string sql = @"select * from " + table; DataBase db = new DataBase(); DataTable dt = db.ExecuteQuery(sql); if (dt == null) { return(null); } List <DividerItem> list = new List <DividerItem>(); for (int i = 0; i < dt.Rows.Count; i++) { DividerItem item = new DividerItem(strMode); item.Source = float.Parse(dt.Rows[i]["source"].ToString()); item.Frequency = float.Parse(dt.Rows[i]["frequency"].ToString()); list.Add(item); } return(list); }
public static List <DividerItem> GetDefaultDestinations() { try { List <DividerItem> Items = new List <DividerItem>(); using (SqlConnection npdConnection = new SqlConnection(Static.Secrets.NpdConnectionString)) { string sql = $@"SELECT z.zfinIndex, cs.location FROM tbZfin z LEFT JOIN tbCustomerString cs ON cs.custStringId = z.custString WHERE z.custString IS NOT NULL AND prodStatus = 'PR'"; SqlCommand command = new SqlCommand(sql, npdConnection); if (npdConnection.State == ConnectionState.Closed || npdConnection.State == ConnectionState.Broken) { npdConnection.Open(); } SqlDataReader reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { DividerItem d = new DividerItem(); d.ZfinIndex = reader["zfinIndex"].ToString(); d.Locations = new List <LocationAmount>(); LocationAmount la = new LocationAmount(); la.L = reader["location"].ToString().Trim(); la.Amount = 0; d.Locations.Add(la); Items.Add(d); } } return(Items); } } catch (Exception ex) { throw; } }