public IActionResult BedBoardDeviceView(string id) { DataSet dsBedBoard = DataServices.DataSetFromSQL("SELECT bedboard_id, bedboardname FROM eboards.bedboard"); ViewBag.BedBoard = ToSelectList(dsBedBoard.Tables[0], "bedboard_id", "bedboardname"); DataSet dsWard = DataServices.DataSetFromSQL("SELECT wardcode, warddisplay FROM entitystorematerialised.meta_ward ORDER BY warddisplay"); ViewBag.Ward = ToSelectList(dsWard.Tables[0], "wardcode", "warddisplay"); string sql = "SELECT * FROM eboards.bedboarddevice WHERE bedboarddevice_id = @bedboarddevice_id;"; DataSet ds = new DataSet(); var paramList = new List <KeyValuePair <string, string> >() { new KeyValuePair <string, string>("bedboarddevice_id", id) }; ds = DataServices.DataSetFromSQL(sql, paramList); DataTable dt = ds.Tables[0]; BedBoardDeviceModel model = new BedBoardDeviceModel(); model.DeviceId = id; try { model.DeviceName = dt.Rows[0]["bedboarddevicename"].ToString(); } catch { } try { model.IPAddress = dt.Rows[0]["deviceipaddress"].ToString(); } catch { } model.BedBoardId = dt.Rows[0]["bedboard_id"].ToString(); model.WardId = dt.Rows[0]["locationward"].ToString(); //dt.Rows[0]["bedboard_id"].ToString(); DataSet dsBayRoom = DataServices.DataSetFromSQL("SELECT baycode, baydisplay FROM entitystorematerialised.meta_wardbay WHERE wardcode = '" + dt.Rows[0]["locationward"].ToString() + "' ORDER BY baydisplay;"); ViewBag.BayRoom = ToSelectList(dsBayRoom.Tables[0], "baycode", "baydisplay"); model.BayRoomId = dt.Rows[0]["locationbayroom"].ToString(); DataSet dsBed = DataServices.DataSetFromSQL("SELECT wardbaybed_id, beddisplay FROM entitystorematerialised.meta_wardbaybed WHERE " + "wardcode = '" + dt.Rows[0]["locationward"].ToString() + "' AND baycode = '" + dt.Rows[0]["locationbayroom"].ToString() + "' ORDER BY beddisplay;"); ViewBag.Bed = ToSelectList(dsBed.Tables[0], "wardbaybed_id", "beddisplay"); model.BedId = dt.Rows[0]["locationbed"].ToString(); string uri = SynapseHelpers.GetEBoardURL(); ViewBag.BoardUrl = uri + "DynamicBedBoard.aspx"; return(View(model)); }
public IActionResult BedBoardDeviceViewSave(BedBoardDeviceModel model) { string sql = @"UPDATE eboards.bedboarddevice SET bedboarddevicename = @bedboarddevicename, bedboard_id = @bedboard_id, deviceipaddress = @deviceipaddress, locationward = @locationward, locationbayroom = @locationbayroom, locationbed = @locationbed WHERE bedboarddevice_id = @bedboarddevice_id;" ; var paramList = new List <KeyValuePair <string, string> >() { new KeyValuePair <string, string>("bedboarddevice_id", model.DeviceId), new KeyValuePair <string, string>("bedboarddevicename", model.DeviceName), new KeyValuePair <string, string>("bedboard_id", model.BedBoardId), new KeyValuePair <string, string>("deviceipaddress", model.IPAddress), new KeyValuePair <string, string>("locationward", model.WardId), new KeyValuePair <string, string>("locationbayroom", model.BayRoomId), new KeyValuePair <string, string>("locationbed", model.BedId) }; DataServices.ExcecuteNonQueryFromSQL(sql, paramList); return(Json("OK")); }
public IActionResult BedBoardDeviceNewSave(BedBoardDeviceModel model) { string sql = @"INSERT INTO eboards.bedboarddevice( bedboarddevice_id, bedboarddevicename, bedboard_id, deviceipaddress, locationward, locationbayroom, locationbed) VALUES(@bedboarddevice_id, @bedboarddevicename, @bedboard_id, @deviceipaddress, @locationward, @locationbayroom, @locationbed);" ; var paramList = new List <KeyValuePair <string, string> >() { new KeyValuePair <string, string>("bedboarddevice_id", System.Guid.NewGuid().ToString()), new KeyValuePair <string, string>("bedboarddevicename", model.DeviceName), new KeyValuePair <string, string>("bedboard_id", model.BedBoardId), new KeyValuePair <string, string>("deviceipaddress", model.IPAddress), new KeyValuePair <string, string>("locationward", model.WardId), new KeyValuePair <string, string>("locationbayroom", model.BayRoomId), new KeyValuePair <string, string>("locationbed", model.BedId) }; DataServices.ExcecuteNonQueryFromSQL(sql, paramList); return(Json("OK")); }