Exemplo n.º 1
0
 //添加历史记录
 public int Add(historic m)
 {
     using (var conn = new SqlConnection(comStr))
     {
         conn.Open();
         var cmd = conn.CreateCommand();
         cmd.CommandText = string.Format("insert into historic values('{0}')", m.Hname);
         return(cmd.ExecuteNonQuery());
     }
 }
Exemplo n.º 2
0
 //显示历史记录
 public List <historic> Shows()
 {
     using (var conn = new SqlConnection(comStr))
     {
         conn.Open();
         var cmd = conn.CreateCommand();
         cmd.CommandText = "select distinct Hname from historic";
         DataTable      dt = new DataTable();
         SqlDataAdapter da = new SqlDataAdapter(cmd);
         da.Fill(dt);
         var historiclist = new List <historic>();
         foreach (DataRow dr in dt.Rows)
         {
             var m = new historic();
             m.Hname = Convert.ToString(dr["Hname"]);
             historiclist.Add(m);
         }
         return(historiclist);
     }
 }
Exemplo n.º 3
0
 // POST: api/historic
 //历史记录添加
 public int Post([FromBody] historic m)
 {
     return(dal.Add(m));
 }