/// <summary> /// 更新一条数据 /// </summary> public bool Update(KryptonAccessController.AccessDataBase.Model.InterControlProgram model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update InterControlProgram set "); strSql.Append("ICPName=@ICPName,"); strSql.Append("ICPWaitTimeLength=@ICPWaitTimeLength,"); strSql.Append("DesControllerInfoInLANID=@DesControllerInfoInLANID,"); strSql.Append("PointType=@PointType,"); strSql.Append("PointID=@PointID,"); strSql.Append("PointState=@PointState,"); strSql.Append("OutPutLength=@OutPutLength"); strSql.Append(" where ICPID=@ICPID "); SqlParameter[] parameters = { new SqlParameter("@ICPName", SqlDbType.NVarChar, 50), new SqlParameter("@ICPWaitTimeLength", SqlDbType.Int, 4), new SqlParameter("@DesControllerInfoInLANID", SqlDbType.Int, 4), new SqlParameter("@PointType", SqlDbType.Int, 4), new SqlParameter("@PointID", SqlDbType.Int, 4), new SqlParameter("@PointState", SqlDbType.Int, 4), new SqlParameter("@OutPutLength", SqlDbType.Int, 4), new SqlParameter("@ICPID", SqlDbType.Int, 4) }; parameters[0].Value = model.ICPName; parameters[1].Value = model.ICPWaitTimeLength; parameters[2].Value = model.DesControllerInfoInLANID; parameters[3].Value = model.PointType; parameters[4].Value = model.PointID; parameters[5].Value = model.PointState; parameters[6].Value = model.OutPutLength; parameters[7].Value = model.ICPID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public KryptonAccessController.AccessDataBase.Model.InterControlProgram DataRowToModel(DataRow row) { KryptonAccessController.AccessDataBase.Model.InterControlProgram model = new KryptonAccessController.AccessDataBase.Model.InterControlProgram(); if (row != null) { if (row["ICPID"] != null && row["ICPID"].ToString() != "") { model.ICPID = int.Parse(row["ICPID"].ToString()); } if (row["ICPName"] != null) { model.ICPName = row["ICPName"].ToString(); } if (row["ICPWaitTimeLength"] != null && row["ICPWaitTimeLength"].ToString() != "") { model.ICPWaitTimeLength = int.Parse(row["ICPWaitTimeLength"].ToString()); } if (row["DesControllerInfoInLANID"] != null && row["DesControllerInfoInLANID"].ToString() != "") { model.DesControllerInfoInLANID = int.Parse(row["DesControllerInfoInLANID"].ToString()); } if (row["PointType"] != null && row["PointType"].ToString() != "") { model.PointType = int.Parse(row["PointType"].ToString()); } if (row["PointID"] != null && row["PointID"].ToString() != "") { model.PointID = int.Parse(row["PointID"].ToString()); } if (row["PointState"] != null && row["PointState"].ToString() != "") { model.PointState = int.Parse(row["PointState"].ToString()); } if (row["OutPutLength"] != null && row["OutPutLength"].ToString() != "") { model.OutPutLength = int.Parse(row["OutPutLength"].ToString()); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(KryptonAccessController.AccessDataBase.Model.InterControlProgram model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into InterControlProgram("); strSql.Append("ICPID,ICPName,ICPWaitTimeLength,DesControllerInfoInLANID,PointType,PointID,PointState,OutPutLength)"); strSql.Append(" values ("); strSql.Append("@ICPID,@ICPName,@ICPWaitTimeLength,@DesControllerInfoInLANID,@PointType,@PointID,@PointState,@OutPutLength)"); SqlParameter[] parameters = { new SqlParameter("@ICPID", SqlDbType.Int, 4), new SqlParameter("@ICPName", SqlDbType.NVarChar, 50), new SqlParameter("@ICPWaitTimeLength", SqlDbType.Int, 4), new SqlParameter("@DesControllerInfoInLANID", SqlDbType.Int, 4), new SqlParameter("@PointType", SqlDbType.Int, 4), new SqlParameter("@PointID", SqlDbType.Int, 4), new SqlParameter("@PointState", SqlDbType.Int, 4), new SqlParameter("@OutPutLength", SqlDbType.Int, 4) }; parameters[0].Value = model.ICPID; parameters[1].Value = model.ICPName; parameters[2].Value = model.ICPWaitTimeLength; parameters[3].Value = model.DesControllerInfoInLANID; parameters[4].Value = model.PointType; parameters[5].Value = model.PointID; parameters[6].Value = model.PointState; parameters[7].Value = model.OutPutLength; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public KryptonAccessController.AccessDataBase.Model.InterControlProgram GetModel(int ICPID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ICPID,ICPName,ICPWaitTimeLength,DesControllerInfoInLANID,PointType,PointID,PointState,OutPutLength from InterControlProgram "); strSql.Append(" where ICPID=@ICPID "); SqlParameter[] parameters = { new SqlParameter("@ICPID", SqlDbType.Int, 4) }; parameters[0].Value = ICPID; KryptonAccessController.AccessDataBase.Model.InterControlProgram model = new KryptonAccessController.AccessDataBase.Model.InterControlProgram(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 得到一个对象实体 /// </summary> public KryptonAccessController.AccessDataBase.Model.InterControlProgram DataRowToModel(DataRow row) { KryptonAccessController.AccessDataBase.Model.InterControlProgram model=new KryptonAccessController.AccessDataBase.Model.InterControlProgram(); if (row != null) { if(row["ICPID"]!=null && row["ICPID"].ToString()!="") { model.ICPID=int.Parse(row["ICPID"].ToString()); } if(row["ICPName"]!=null) { model.ICPName=row["ICPName"].ToString(); } if(row["ICPWaitTimeLength"]!=null && row["ICPWaitTimeLength"].ToString()!="") { model.ICPWaitTimeLength=int.Parse(row["ICPWaitTimeLength"].ToString()); } if(row["DesControllerInfoInLANID"]!=null && row["DesControllerInfoInLANID"].ToString()!="") { model.DesControllerInfoInLANID=int.Parse(row["DesControllerInfoInLANID"].ToString()); } if(row["PointType"]!=null && row["PointType"].ToString()!="") { model.PointType=int.Parse(row["PointType"].ToString()); } if(row["PointID"]!=null && row["PointID"].ToString()!="") { model.PointID=int.Parse(row["PointID"].ToString()); } if(row["PointState"]!=null && row["PointState"].ToString()!="") { model.PointState=int.Parse(row["PointState"].ToString()); } if(row["OutPutLength"]!=null && row["OutPutLength"].ToString()!="") { model.OutPutLength=int.Parse(row["OutPutLength"].ToString()); } } return model; }
/// <summary> /// 得到一个对象实体 /// </summary> public KryptonAccessController.AccessDataBase.Model.InterControlProgram GetModel(int ICPID) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 ICPID,ICPName,ICPWaitTimeLength,DesControllerInfoInLANID,PointType,PointID,PointState,OutPutLength from InterControlProgram "); strSql.Append(" where ICPID=@ICPID "); SqlParameter[] parameters = { new SqlParameter("@ICPID", SqlDbType.Int,4) }; parameters[0].Value = ICPID; KryptonAccessController.AccessDataBase.Model.InterControlProgram model=new KryptonAccessController.AccessDataBase.Model.InterControlProgram(); DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }