public void LoadGrid() { using (SqlConnection con = new SqlConnection(dbsource.main)) { con.Open(); GridTools gt = new GridTools(con, Context); int featureID = int.Parse(id); int i1 = gt.GetIndicatorID(var1.id); int i2 = gt.GetIndicatorID(var2.id); gridID = gt.GetGridID(featureID, i1, i2); String query = "SELECT * FROM TblSelection WHERE fGridRef = @fGridRef"; using (SqlCommand cmd = new SqlCommand(query, con)) { cmd.Parameters.AddWithValue("@fGridRef", gridID); using (SqlDataReader set = cmd.ExecuteReader()) { while (set.Read() == true) { GridSel gs = new GridSel(); gs.color1 = set["fColor1"].ToString(); gs.color2 = set["fColor2"].ToString(); gridSelection.Add(gs); } } } } }
protected void LoadSelection() { using (SqlConnection con = new SqlConnection(dbsource.main)) { con.Open(); GridTools gt = new GridTools(con, Context); int featureID = int.Parse(Request["fid"]); int i1 = gt.GetIndicatorID(Request["i1"]); int i2 = gt.GetIndicatorID(Request["i2"]); int gridID = gt.GetGridID(featureID, i1, i2); double total = 0; bool valFound = false; String query = "SELECT * FROM TblSelection WHERE fGridRef = @fGridRef"; using (SqlCommand cmd = new SqlCommand(query, con)) { cmd.Parameters.AddWithValue("@fGridRef", gridID); using (SqlDataReader set = cmd.ExecuteReader()) { while (set.Read() == true) { double val = (double)set["fValue"]; total += val; valFound = true; } } } if (valFound == true) { ColorRamp ramp = new ColorRamp(); ramp.Load(Server.MapPath("images/ramp.png")); String color = ramp.GetColor(total / 100); Response.Write(Request["id"] + "|" + Math.Round(total) + "|" + color); } else { Response.Write(Request["id"] + "|" + "0" + "|" + "#ffffff"); } } }