zoukankan      html  css  js  c++  java
  • c# 新建 数据库作为数据源 用于下拉列( id 和 地址)

     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          }
  • 相关阅读:
    软件开发过程须贯彻评估和测试
    【灌水】多维成功论
    改进c系列(目录)
    网站管理艺术
    .net 跨平台也是一句谎言
    用户界面和逻辑应该分离
    设计模式
    程序员找不到工作是因为管理差
    编码阶段
    保证软件开发质量的一种管理学
  • 原文地址:https://www.cnblogs.com/ceccf/p/5794414.html
Copyright © 2011-2022 走看看