using System; using System.Data; using System.Data.SqlClient; using System.Web.Configuration; public partial class Manage : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { try { this.GetData(); } catch (Exception) { } } protected void Timer_Tick(object sender, EventArgs e) { } protected void GetData() { SqlConnection con = null; try { string ip = Context.Request.ServerVariables["REMOTE_ADDR"].ToString(); string sDeviceCode = string.Empty; string title = string.Empty; if (ip == "192.168.0.223") { sDeviceCode = "('14004','14005','14006')"; title = "一号投料口"; } else if (ip == "192.168.0.224") { sDeviceCode = "('14007','14008','14009')"; title = "二号投料口"; } else if (ip == "192.168.0.225") { sDeviceCode = "('14010','14011','14012')"; title = "三号投料口"; } else if (ip == "192.168.0.226") { sDeviceCode = "('14013','14014','14015')"; title = "四号投料口"; } else if (ip == "192.168.0.227") { sDeviceCode = "('14016','14017','14018')"; title = "五号投料口"; } else if (ip == "192.168.0.228") { sDeviceCode = "('14019','14020','14021')"; title = "六号投料口"; } else { sDeviceCode = "('14004','14005','14006','14007','14008','14009','14010','14011','14012','14013','14014','14015','14016','14017','14018','14019','14020','14021')"; title = "三楼投料口"; } string StrCon = WebConfigurationManager.ConnectionStrings["myConn"].ToString(); con = new SqlConnection(StrCon); con.Open(); string strSqlRecord = string.Format("select STOCK_BARCODE,GOODS_NAME,END_POSITION,GOODS_PROPERTY3 from V_RECORD_TOULIAO where END_POSITION in {0} and MANAGE_END_TIME>'{1}' order by RECORD_ID", sDeviceCode, DateTime.Now.AddMinutes(-10).ToString("yyyy-MM-dd HH:mm:ss")); SqlDataAdapter sdaRecord = new SqlDataAdapter(strSqlRecord, con); DataTable dtRecord = new DataTable(); sdaRecord.Fill(dtRecord); string strSqlManage = string.Format("select STOCK_BARCODE,GOODS_NAME,END_POSITION,GOODS_PROPERTY3 from V_MANAGE_TOULIAO where END_POSITION in {0} order by END_POSITION,MANAGE_ID", sDeviceCode); SqlDataAdapter sdaManage = new SqlDataAdapter(strSqlManage, con); DataTable dtManage = new DataTable(); sdaManage.Fill(dtManage); this.gvHeader.DataSource = new DataTable().DefaultView; this.gvHeader.DataBind(); this.gvRecord.DataSource = dtRecord.DefaultView; this.gvRecord.DataBind(); this.gvManage.DataSource = dtManage.DefaultView; this.gvManage.DataBind(); } catch { this.gvHeader.DataSource = new DataTable().DefaultView; this.gvHeader.DataBind(); this.gvManage.DataSource = new DataTable().DefaultView; this.gvManage.DataBind(); } finally { try { if (con != null) { con.Close(); } } catch { } } } }