1 public static string MrsGetMineDisasterAddress() 2 { 3 database db = GetMrsDB(); 4 string sql = @"SELECT Id,DisasterAddress FROM MineDisasterInf"; 5 string strJson = DataBaseLib.JsonHelper.DataTableToJson(db.getdataset(sql).Tables[0]); 6 db.close(); 7 return strJson; 8 } 9 10 11 public Dictionary<int, String> MrsGetMineDisasterAddress() 12 { 13 MrtmService.MrtmWebServiceSoapClient sc = new MrtmService.MrtmWebServiceSoapClient(); 14 string jsonRes = sc.MrsGetMineDisasterAddress(); 15 DataTable dt = DataBaseLib.JsonHelper.JsonToDataTable(jsonRes); 16 Dictionary<int, String> dictionary = new Dictionary<int, string>(); 17 foreach (DataRow dr in dt.Rows) 18 { 19 dictionary.Add(int.Parse(dr["Id"].ToString()), dr["DisasterAddress"].ToString()); 20 } 21 //List<AllAddress> retList = new List<AllAddress>(); 22 //if (dt.Rows.Count > 0) 23 //{ 24 // for (int i = 0; i < dt.Rows.Count; i++) 25 // { 26 // retList.Add(dt.Rows[i].ItemArray[0].ToString()); //将值加入到combox1中 27 // // retList.Add(dt.Rows[i].ItemArray); 28 // } 29 //} 30 return dictionary; 31 } 32 33 public ActionResult Create() 34 { 35 var model = new DisasterDeal(); 36 37 model.ID = 0; 38 model.ReportTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); 39 model.DealStatus = (int)EnumHelp.DealStatus.WaitDeal; 40 Dictionary<int, String> dictionary = DisasterService.MrsGetMineDisasterAddress(); 41 42 /* MineDisasterInfRequest request = new MineDisasterInfRequest(); 43 List<string> allAddress = DisasterService.MrsGetMineDisasterAddress(); 44 Dictionary<int, String> dictionary = new Dictionary<int, string>(); 45 for (int i = 0; i < allAddress.Count; i++) 46 { 47 dictionary.Add(i, allAddress[i]); 48 } 49 50 51 string jsonRes = DisasterService.MrsGetMineDisasterAddress(); 52 DataTable dt = new DataTable(); 53 //dt.Columns.Add("Id", typeof(Int32)); 54 // dt.Columns.Add("DisasterAddress", typeof(String)); 55 dt = DataBaseLib.JsonHelper.JsonToDataTable(jsonRes); 56 Dictionary<int, String> dictionary = new Dictionary<int, string>(); 57 foreach (DataRow dr in dt.Rows) 58 { 59 dictionary.Add(int.Parse(dr["Id"].ToString()), dr["DisasterAddress"].ToString()); 60 }*/ 61 62 this.ViewBag.AllAddress = new SelectList(dictionary, 63 "Key", "Value"); 64 return View("Add", model); 65 }