Beispiel #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(KryptonAccessController.SQLite.Model.ControllerRelation.ExpansionBoardInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into ExpansionBoardInfo(");
            strSql.Append("ExpansionBoardID,ExpansionBoardType,ExpansionBoardName,ExpansionBoardAddr,InputStateType,ExpansionBoardLocation)");
            strSql.Append(" values (");
            strSql.Append("@ExpansionBoardID,@ExpansionBoardType,@ExpansionBoardName,@ExpansionBoardAddr,@InputStateType,@ExpansionBoardLocation)");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@ExpansionBoardID",       DbType.Int32,   4),
                new SQLiteParameter("@ExpansionBoardType",     DbType.Int32,   4),
                new SQLiteParameter("@ExpansionBoardName",     DbType.String),
                new SQLiteParameter("@ExpansionBoardAddr",     DbType.Int32,   4),
                new SQLiteParameter("@InputStateType",         DbType.Int32,   4),
                new SQLiteParameter("@ExpansionBoardLocation", DbType.String)
            };
            parameters[0].Value = model.ExpansionBoardID;
            parameters[1].Value = model.ExpansionBoardType;
            parameters[2].Value = model.ExpansionBoardName;
            parameters[3].Value = model.ExpansionBoardAddr;
            parameters[4].Value = model.InputStateType;
            parameters[5].Value = model.ExpansionBoardLocation;

            int rows = DbHelperSQLite.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(KryptonAccessController.SQLite.Model.ControllerRelation.ExpansionBoardInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update ExpansionBoardInfo set ");
            strSql.Append("ExpansionBoardType=@ExpansionBoardType,");
            strSql.Append("ExpansionBoardName=@ExpansionBoardName,");
            strSql.Append("ExpansionBoardAddr=@ExpansionBoardAddr,");
            strSql.Append("InputStateType=@InputStateType,");
            strSql.Append("ExpansionBoardLocation=@ExpansionBoardLocation");
            strSql.Append(" where ExpansionBoardID=@ExpansionBoardID ");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@ExpansionBoardType",     DbType.Int32,   4),
                new SQLiteParameter("@ExpansionBoardName",     DbType.String),
                new SQLiteParameter("@ExpansionBoardAddr",     DbType.Int32,   4),
                new SQLiteParameter("@InputStateType",         DbType.Int32,   4),
                new SQLiteParameter("@ExpansionBoardLocation", DbType.String),
                new SQLiteParameter("@ExpansionBoardID",       DbType.Int32, 4)
            };
            parameters[0].Value = model.ExpansionBoardType;
            parameters[1].Value = model.ExpansionBoardName;
            parameters[2].Value = model.ExpansionBoardAddr;
            parameters[3].Value = model.InputStateType;
            parameters[4].Value = model.ExpansionBoardLocation;
            parameters[5].Value = model.ExpansionBoardID;

            int rows = DbHelperSQLite.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public KryptonAccessController.SQLite.Model.ControllerRelation.ExpansionBoardInfo DataRowToModel(DataRow row)
 {
     KryptonAccessController.SQLite.Model.ControllerRelation.ExpansionBoardInfo model=new KryptonAccessController.SQLite.Model.ControllerRelation.ExpansionBoardInfo();
     if (row != null)
     {
         if(row["ExpansionBoardID"]!=null && row["ExpansionBoardID"].ToString()!="")
         {
             model.ExpansionBoardID=int.Parse(row["ExpansionBoardID"].ToString());
         }
         if(row["ExpansionBoardType"]!=null && row["ExpansionBoardType"].ToString()!="")
         {
             model.ExpansionBoardType=int.Parse(row["ExpansionBoardType"].ToString());
         }
         if(row["ExpansionBoardName"]!=null)
         {
             model.ExpansionBoardName=row["ExpansionBoardName"].ToString();
         }
         if(row["ExpansionBoardAddr"]!=null && row["ExpansionBoardAddr"].ToString()!="")
         {
             model.ExpansionBoardAddr=int.Parse(row["ExpansionBoardAddr"].ToString());
         }
         if(row["InputStateType"]!=null && row["InputStateType"].ToString()!="")
         {
             model.InputStateType=int.Parse(row["InputStateType"].ToString());
         }
         if(row["ExpansionBoardLocation"]!=null)
         {
             model.ExpansionBoardLocation=row["ExpansionBoardLocation"].ToString();
         }
     }
     return model;
 }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public KryptonAccessController.SQLite.Model.ControllerRelation.ExpansionBoardInfo GetModel(int ExpansionBoardID)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select ExpansionBoardID,ExpansionBoardType,ExpansionBoardName,ExpansionBoardAddr,InputStateType,ExpansionBoardLocation from ExpansionBoardInfo ");
            strSql.Append(" where ExpansionBoardID=@ExpansionBoardID ");
            SQLiteParameter[] parameters = {
                    new SQLiteParameter("@ExpansionBoardID", DbType.Int32,4)			};
            parameters[0].Value = ExpansionBoardID;

            KryptonAccessController.SQLite.Model.ControllerRelation.ExpansionBoardInfo model=new KryptonAccessController.SQLite.Model.ControllerRelation.ExpansionBoardInfo();
            DataSet ds=DbHelperSQLite.Query(strSql.ToString(),parameters);
            if(ds.Tables[0].Rows.Count>0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }
Beispiel #5
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public KryptonAccessController.SQLite.Model.ControllerRelation.ExpansionBoardInfo DataRowToModel(DataRow row)
 {
     KryptonAccessController.SQLite.Model.ControllerRelation.ExpansionBoardInfo model = new KryptonAccessController.SQLite.Model.ControllerRelation.ExpansionBoardInfo();
     if (row != null)
     {
         if (row["ExpansionBoardID"] != null && row["ExpansionBoardID"].ToString() != "")
         {
             model.ExpansionBoardID = int.Parse(row["ExpansionBoardID"].ToString());
         }
         if (row["ExpansionBoardType"] != null && row["ExpansionBoardType"].ToString() != "")
         {
             model.ExpansionBoardType = int.Parse(row["ExpansionBoardType"].ToString());
         }
         if (row["ExpansionBoardName"] != null)
         {
             model.ExpansionBoardName = row["ExpansionBoardName"].ToString();
         }
         if (row["ExpansionBoardAddr"] != null && row["ExpansionBoardAddr"].ToString() != "")
         {
             model.ExpansionBoardAddr = int.Parse(row["ExpansionBoardAddr"].ToString());
         }
         if (row["InputStateType"] != null && row["InputStateType"].ToString() != "")
         {
             model.InputStateType = int.Parse(row["InputStateType"].ToString());
         }
         if (row["ExpansionBoardLocation"] != null)
         {
             model.ExpansionBoardLocation = row["ExpansionBoardLocation"].ToString();
         }
     }
     return(model);
 }
Beispiel #6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public KryptonAccessController.SQLite.Model.ControllerRelation.ExpansionBoardInfo GetModel(int ExpansionBoardID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select ExpansionBoardID,ExpansionBoardType,ExpansionBoardName,ExpansionBoardAddr,InputStateType,ExpansionBoardLocation from ExpansionBoardInfo ");
            strSql.Append(" where ExpansionBoardID=@ExpansionBoardID ");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@ExpansionBoardID", DbType.Int32, 4)
            };
            parameters[0].Value = ExpansionBoardID;

            KryptonAccessController.SQLite.Model.ControllerRelation.ExpansionBoardInfo model = new KryptonAccessController.SQLite.Model.ControllerRelation.ExpansionBoardInfo();
            DataSet ds = DbHelperSQLite.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }