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

            strSql.Append("update insurance_report set ");
            strSql.Append("query_id=@query_id,");
            strSql.Append("query_date=@query_date,");
            strSql.Append("ins_name=@ins_name,");
            strSql.Append("ins_no=@ins_no,");
            strSql.Append("ins_company=@ins_company,");
            strSql.Append("ins_value=@ins_value,");
            strSql.Append("remark=@remark,");
            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("@query_date",  DbType.DateTime),
                new SQLiteParameter("@ins_name",    DbType.String,    255),
                new SQLiteParameter("@ins_no",      DbType.String,     50),
                new SQLiteParameter("@ins_company", DbType.String,    200),
                new SQLiteParameter("@ins_value",   DbType.Decimal,     4),
                new SQLiteParameter("@remark",      DbType.String,    255),
                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.query_date;
            parameters[2].Value = model.ins_name;
            parameters[3].Value = model.ins_no;
            parameters[4].Value = model.ins_company;
            parameters[5].Value = model.ins_value;
            parameters[6].Value = model.remark;
            parameters[7].Value = model.add_user;
            parameters[8].Value = model.add_time;
            parameters[9].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.insurance_report DataRowToModel(DataRow row)
 {
     DXD.Model.insurance_report model = new DXD.Model.insurance_report();
     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["query_date"] != null && row["query_date"].ToString() != "")
         {
             model.query_date = DateTime.Parse(row["query_date"].ToString());
         }
         if (row["ins_name"] != null)
         {
             model.ins_name = row["ins_name"].ToString();
         }
         if (row["ins_no"] != null)
         {
             model.ins_no = row["ins_no"].ToString();
         }
         if (row["ins_company"] != null)
         {
             model.ins_company = row["ins_company"].ToString();
         }
         if (row["ins_value"] != null && row["ins_value"].ToString() != "")
         {
             model.ins_value = decimal.Parse(row["ins_value"].ToString());
         }
         if (row["remark"] != null)
         {
             model.remark = row["remark"].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.insurance_report model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into insurance_report(");
            strSql.Append("query_id,query_date,ins_name,ins_no,ins_company,ins_value,remark,add_user,add_time)");
            strSql.Append(" values (");
            strSql.Append("@query_id,@query_date,@ins_name,@ins_no,@ins_company,@ins_value,@remark,@add_user,@add_time)");
            strSql.Append(";select LAST_INSERT_ROWID()");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@query_id",    DbType.Int32,       8),
                new SQLiteParameter("@query_date",  DbType.DateTime),
                new SQLiteParameter("@ins_name",    DbType.String,    255),
                new SQLiteParameter("@ins_no",      DbType.String,     50),
                new SQLiteParameter("@ins_company", DbType.String,    200),
                new SQLiteParameter("@ins_value",   DbType.Decimal,     4),
                new SQLiteParameter("@remark",      DbType.String,    255),
                new SQLiteParameter("@add_user",    DbType.String,     50),
                new SQLiteParameter("@add_time",    DbType.DateTime)
            };
            parameters[0].Value = model.query_id;
            parameters[1].Value = model.query_date;
            parameters[2].Value = model.ins_name;
            parameters[3].Value = model.ins_no;
            parameters[4].Value = model.ins_company;
            parameters[5].Value = model.ins_value;
            parameters[6].Value = model.remark;
            parameters[7].Value = model.add_user;
            parameters[8].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.insurance_report GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select id,query_id,query_date,ins_name,ins_no,ins_company,ins_value,remark,add_user,add_time from insurance_report ");
            strSql.Append(" where id=@id");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@id", DbType.Int32, 4)
            };
            parameters[0].Value = id;

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

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