1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43:
| static Dictionary<String, Dictionary<String, decimal>> wdpGroup = new Dictionary<String, Dictionary<String, decimal>>(); public Dictionary<String, Dictionary<String, decimal>> getGroupMappping() { String connectionString = "Data Source=mention.wdp.intern; Initial Catalog=mention_wdp; Persist Security Info=True;User ID=********;Password=********"; using (SqlConnection con = new SqlConnection(connectionString)) { con.Open(); String sql = @"SELECT AEL.ARANUMMER as [group], (SELECT TOP 1 XUMB.ARANUMMER FROM AEL AS XUMB WITH(NOLOCK) WHERE XUMB.ARIDNR = AEL.ARUMBIDNR) as group_article, AELX.ARANUMMER as article, CAST(AEL2.AGMENGE AS NUMERIC(8, 0)) as amount FROM AEL LEFT JOIN AEL2 WITH(NOLOCK)ON ael2.agaidnr = ael.aridnr LEFT JOIN AEL AS AELx WITH(NOLOCK) ON AELx.aridnr = ael2.agidnr WHERE AEL.ARMANKEY = 1000 AND ael.artyp = 'A' AND ael.argruppe IN('G', 'Z') ORDER BY[group]"; SqlCommand cmd = new SqlCommand(sql, con); cmd.CommandTimeout = 300; SqlDataReader reader = cmd.ExecuteReader(); if (reader != null) { int count = 0; while (reader.Read()) { String group = reader.GetString(0).Trim(); String article = reader.GetString(2).Trim(); decimal amount = reader.GetDecimal(3);
if (!wdpGroup.ContainsKey(group)) { wdpGroup.Add(group, new Dictionary<string, decimal>(article, amount)); } } } return wdpGroup; } |