/// <summary> /// 得到一个对象实体 /// </summary> public KryptonAccessController.AccessDataBase.Model.EventInterControlProgram DataRowToModel(DataRow row) { KryptonAccessController.AccessDataBase.Model.EventInterControlProgram model = new KryptonAccessController.AccessDataBase.Model.EventInterControlProgram(); if (row != null) { if (row["EventICPID"] != null && row["EventICPID"].ToString() != "") { model.EventICPID = int.Parse(row["EventICPID"].ToString()); } if (row["EventICPName"] != null) { model.EventICPName = row["EventICPName"].ToString(); } if (row["EventICPEnable"] != null && row["EventICPEnable"].ToString() != "") { if ((row["EventICPEnable"].ToString() == "1") || (row["EventICPEnable"].ToString().ToLower() == "true")) { model.EventICPEnable = true; } else { model.EventICPEnable = false; } } 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["EventCodeID"] != null && row["EventCodeID"].ToString() != "") { model.EventCodeID = int.Parse(row["EventCodeID"].ToString()); } if (row["ICPID"] != null && row["ICPID"].ToString() != "") { model.ICPID = int.Parse(row["ICPID"].ToString()); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(KryptonAccessController.AccessDataBase.Model.EventInterControlProgram model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update EventInterControlProgram set "); strSql.Append("EventICPName=@EventICPName,"); strSql.Append("EventICPEnable=@EventICPEnable,"); strSql.Append("PointType=@PointType,"); strSql.Append("PointID=@PointID,"); strSql.Append("EventCodeID=@EventCodeID,"); strSql.Append("ICPID=@ICPID"); strSql.Append(" where EventICPID=@EventICPID "); SqlParameter[] parameters = { new SqlParameter("@EventICPName", SqlDbType.NVarChar, 50), new SqlParameter("@EventICPEnable", SqlDbType.Bit, 1), new SqlParameter("@PointType", SqlDbType.Int, 4), new SqlParameter("@PointID", SqlDbType.Int, 4), new SqlParameter("@EventCodeID", SqlDbType.Int, 4), new SqlParameter("@ICPID", SqlDbType.Int, 4), new SqlParameter("@EventICPID", SqlDbType.Int, 4) }; parameters[0].Value = model.EventICPName; parameters[1].Value = model.EventICPEnable; parameters[2].Value = model.PointType; parameters[3].Value = model.PointID; parameters[4].Value = model.EventCodeID; parameters[5].Value = model.ICPID; parameters[6].Value = model.EventICPID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public KryptonAccessController.AccessDataBase.Model.EventInterControlProgram GetModel(int EventICPID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 EventICPID,EventICPName,EventICPEnable,PointType,PointID,EventCodeID,ICPID from EventInterControlProgram "); strSql.Append(" where EventICPID=@EventICPID "); SqlParameter[] parameters = { new SqlParameter("@EventICPID", SqlDbType.Int, 4) }; parameters[0].Value = EventICPID; KryptonAccessController.AccessDataBase.Model.EventInterControlProgram model = new KryptonAccessController.AccessDataBase.Model.EventInterControlProgram(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }