/// <summary> /// 获取指定模板的指定项目信息 /// </summary> /// <param name="deviceType"></param> /// <param name="project"></param> /// <returns></returns> public static Model.DeviceTemplate GetDeviceTemplate(Model.DeviceType deviceType, string project) { string sql = ""; switch (deviceType) { case Model.DeviceType.ROSO_RSJ: sql = "select * from ROSO_RSJ where Project=@Project"; break; case Model.DeviceType.ROSO_BZJ: sql = "select * from ROSO_BZJ where Project=@Project"; break; case Model.DeviceType.ROSO_DXJ: sql = "select * from ROSO_DXJ where Project=@Project"; break; case Model.DeviceType.ROSO_RDJ: sql = "select * from ROSO_RDJ where Project=@Project"; break; default: return(null); break; } SqlParameter[] p = { new SqlParameter("@Project", project) }; using (SqlDataReader reader = SQLHelper.ExecuteReader(sql, CommandType.Text, p)) { Model.DeviceTemplate dt = new Model.DeviceTemplate(); if (reader.Read()) { dt.ID = Convert.ToInt32(reader["ID"]); dt.Address = Convert.ToInt16(reader["Address"]); dt.Length = Convert.ToInt16(reader["Length"]); dt.Project = Convert.ToString(reader["Project"]); dt.Remark = Convert.ToString(reader["Remark"]); dt.Type = Convert.ToString(reader["Type"]); } return(dt); } }
/// <summary> /// 获取指定模板的全部信息 /// </summary> /// <param name="deviceType"></param> /// <returns></returns> public static List <Model.DeviceTemplate> GetDeviceTemplateList(Model.DeviceType deviceType) { string sql; switch (deviceType) { case Model.DeviceType.ROSO_RSJ: sql = "select * from ROSO_RSJ"; break; case Model.DeviceType.ROSO_BZJ: sql = "select * from ROSO_BZJ"; break; case Model.DeviceType.ROSO_DXJ: sql = "select * from ROSO_DXJ"; break; case Model.DeviceType.ROSO_RDJ: sql = "select * from ROSO_RDJ"; break; default: return(null); break; } using (SqlDataReader reader = SQLHelper.ExecuteReader(sql, CommandType.Text, null)) { List <Model.DeviceTemplate> list = new List <Model.DeviceTemplate>(); while (reader.Read()) { Model.DeviceTemplate dt = new Model.DeviceTemplate(); dt.ID = Convert.ToInt32(reader["ID"]); dt.Address = Convert.ToInt16(reader["Address"]); dt.Length = Convert.ToInt16(reader["Length"]); dt.Project = Convert.ToString(reader["Project"]); dt.Remark = Convert.ToString(reader["Remark"]); dt.Type = Convert.ToString(reader["Type"]); list.Add(dt); } return(list); } }
/// <summary> /// 在指定类型模板信息列表中获取指定项目的信息 /// </summary> /// <param name="list"></param> /// <param name="project"></param> /// <returns></returns> public static Model.DeviceTemplate GetDeviceTemplate(List <Model.DeviceTemplate> list, string project) { Model.DeviceTemplate dt = list.Find(p => p.Project.Equals(project)); return(dt); }