コード例 #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(DXD.Model.security_compare model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update security_compare set ");
            strSql.Append("query_id=@query_id,");
            strSql.Append("feedback_id=@feedback_id,");
            strSql.Append("report_id=@report_id,");
            strSql.Append("compare_type=@compare_type,");
            strSql.Append("less_number=@less_number,");
            strSql.Append("less_value=@less_value,");
            strSql.Append("add_user=@add_user,");
            strSql.Append("add_time=@add_time");
            strSql.Append(" where id=@id");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@query_id",     DbType.Int32,      8),
                new SQLiteParameter("@feedback_id",  DbType.Int32,      8),
                new SQLiteParameter("@report_id",    DbType.Int32,      8),
                new SQLiteParameter("@compare_type", DbType.Int32,      4),
                new SQLiteParameter("@less_number",  DbType.Decimal,    4),
                new SQLiteParameter("@less_value",   DbType.Decimal,    4),
                new SQLiteParameter("@add_user",     DbType.String,    50),
                new SQLiteParameter("@add_time",     DbType.DateTime),
                new SQLiteParameter("@id",           DbType.Int32, 8)
            };
            parameters[0].Value = model.query_id;
            parameters[1].Value = model.feedback_id;
            parameters[2].Value = model.report_id;
            parameters[3].Value = model.compare_type;
            parameters[4].Value = model.less_number;
            parameters[5].Value = model.less_value;
            parameters[6].Value = model.add_user;
            parameters[7].Value = model.add_time;
            parameters[8].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public DXD.Model.security_compare DataRowToModel(DataRow row)
 {
     DXD.Model.security_compare model = new DXD.Model.security_compare();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["query_id"] != null && row["query_id"].ToString() != "")
         {
             model.query_id = int.Parse(row["query_id"].ToString());
         }
         if (row["feedback_id"] != null && row["feedback_id"].ToString() != "")
         {
             model.feedback_id = int.Parse(row["feedback_id"].ToString());
         }
         if (row["report_id"] != null && row["report_id"].ToString() != "")
         {
             model.report_id = int.Parse(row["report_id"].ToString());
         }
         if (row["compare_type"] != null && row["compare_type"].ToString() != "")
         {
             model.compare_type = int.Parse(row["compare_type"].ToString());
         }
         if (row["less_number"] != null && row["less_number"].ToString() != "")
         {
             model.less_number = decimal.Parse(row["less_number"].ToString());
         }
         if (row["less_value"] != null && row["less_value"].ToString() != "")
         {
             model.less_value = decimal.Parse(row["less_value"].ToString());
         }
         if (row["add_user"] != null)
         {
             model.add_user = row["add_user"].ToString();
         }
         if (row["add_time"] != null && row["add_time"].ToString() != "")
         {
             model.add_time = DateTime.Parse(row["add_time"].ToString());
         }
     }
     return(model);
 }
コード例 #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(DXD.Model.security_compare model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into security_compare(");
            strSql.Append("query_id,feedback_id,report_id,compare_type,less_number,less_value,add_user,add_time)");
            strSql.Append(" values (");
            strSql.Append("@query_id,@feedback_id,@report_id,@compare_type,@less_number,@less_value,@add_user,@add_time)");
            strSql.Append(";select LAST_INSERT_ROWID()");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@query_id",     DbType.Int32,    8),
                new SQLiteParameter("@feedback_id",  DbType.Int32,    8),
                new SQLiteParameter("@report_id",    DbType.Int32,    8),
                new SQLiteParameter("@compare_type", DbType.Int32,    4),
                new SQLiteParameter("@less_number",  DbType.Decimal,  4),
                new SQLiteParameter("@less_value",   DbType.Decimal,  4),
                new SQLiteParameter("@add_user",     DbType.String,  50),
                new SQLiteParameter("@add_time",     DbType.DateTime)
            };
            parameters[0].Value = model.query_id;
            parameters[1].Value = model.feedback_id;
            parameters[2].Value = model.report_id;
            parameters[3].Value = model.compare_type;
            parameters[4].Value = model.less_number;
            parameters[5].Value = model.less_value;
            parameters[6].Value = model.add_user;
            parameters[7].Value = model.add_time;

            object obj = DbHelperSQLite.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
コード例 #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public DXD.Model.security_compare GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select id,query_id,feedback_id,report_id,compare_type,less_number,less_value,add_user,add_time from security_compare ");
            strSql.Append(" where id=@id");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@id", DbType.Int32, 4)
            };
            parameters[0].Value = id;

            DXD.Model.security_compare model = new DXD.Model.security_compare();
            DataSet ds = DbHelperSQLite.Query(strSql.ToString(), parameters);

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