public ActionResult DeleteConfirmed(int id) { WaterResources waterResources = db.WaterResourcess.Find(id); db.WaterResourcess.Remove(waterResources); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "ID,Questions")] WaterResources waterResources) { if (ModelState.IsValid) { db.Entry(waterResources).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(waterResources)); }
public ActionResult Create([Bind(Include = "ID,Questions")] WaterResources waterResources) { if (ModelState.IsValid) { db.WaterResourcess.Add(waterResources); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(waterResources)); }
// GET: WaterResources/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } WaterResources waterResources = db.WaterResourcess.Find(id); if (waterResources == null) { return(HttpNotFound()); } return(View(waterResources)); }
private ArrayList m_aryClients = new ArrayList(); // List of Client Connections /// <summary> /// Application starts here. Create an instance of this class and use it /// as the main object. /// </summary> /// <param name="args"></param> static void Main(string[] args) { AppMain app = new AppMain(); oc = new OtherClass(); wr = new WaterResources(); // Welcome and Start listening Console.WriteLine("*** hash水质监测 Server Started {0} *** ", DateTime.Now.ToString("G")); //测试报文 // byte[] test = strToToHexByte("683D68BA9970990E04C05F0600001841020000550800008300000010000000420000005200000000000000500000005000000034020000000030000000081600F816"); objhelper = new SqlHelper(); connABB = objhelper.getConn(); if (connABB.State != ConnectionState.Open) { connABB.Open(); } objhelper = new SqlHelper(); connABB = objhelper.getConn(); connABB.Open(); // Method 2 // int nPortListen = oc.lPort(); IPAddress ip = IPAddress.Parse(oc.IPAddress()); // Determine the IPAddress of this machine String strHostName = ""; try { // NOTE: DNS lookups are nice and all but quite time consuming. strHostName = Dns.GetHostName(); } catch (Exception ex) { Console.WriteLine("试图获得本地地址错误 {0} ", ex.Message); } Console.WriteLine("开始监听数据: [{0}] {1}:{2}", strHostName, ip, nPortListen); // Create the listener socket in this machines IP address Socket listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); listener.Bind(new IPEndPoint(ip, nPortListen)); //listener.Bind( new IPEndPoint( IPAddress.Loopback, 399 ) ); // For use with localhost 127.0.0.1 listener.Listen(30); // Setup a callback to be notified of connection requests listener.BeginAccept(new AsyncCallback(app.OnConnectRequest), listener); Console.WriteLine("按任意键退出"); Console.ReadLine(); Console.WriteLine("退出中..."); // Clean up before we go home if (connABB.State != ConnectionState.Closed) { connABB.Close(); } connABB.Close(); listener.Close(); GC.Collect(); GC.WaitForPendingFinalizers(); }