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

            strSql.Append("update country_list set ");
            strSql.Append("country_name=@country_name,");
            strSql.Append("order_no=@order_no,");
            strSql.Append("add_user=@add_user,");
            strSql.Append("add_time=@add_time");
            strSql.Append(" where id=@id");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@country_name", DbType.String,    50),
                new SQLiteParameter("@order_no",     DbType.Int32,      8),
                new SQLiteParameter("@add_user",     DbType.String,    50),
                new SQLiteParameter("@add_time",     DbType.DateTime),
                new SQLiteParameter("@id",           DbType.Int32, 8)
            };
            parameters[0].Value = model.country_name;
            parameters[1].Value = model.order_no;
            parameters[2].Value = model.add_user;
            parameters[3].Value = model.add_time;
            parameters[4].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(DXD.Model.country_list model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into country_list(");
            strSql.Append("country_name,order_no,add_user,add_time)");
            strSql.Append(" values (");
            strSql.Append("@country_name,@order_no,@add_user,@add_time)");
            strSql.Append(";select LAST_INSERT_ROWID()");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@country_name", DbType.String, 50),
                new SQLiteParameter("@order_no",     DbType.Int32,   8),
                new SQLiteParameter("@add_user",     DbType.String, 50),
                new SQLiteParameter("@add_time",     DbType.DateTime)
            };
            parameters[0].Value = model.country_name;
            parameters[1].Value = model.order_no;
            parameters[2].Value = model.add_user;
            parameters[3].Value = model.add_time;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Example #3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public DXD.Model.country_list DataRowToModel(DataRow row)
 {
     DXD.Model.country_list model = new DXD.Model.country_list();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["country_name"] != null)
         {
             model.country_name = row["country_name"].ToString();
         }
         if (row["order_no"] != null && row["order_no"].ToString() != "")
         {
             model.order_no = int.Parse(row["order_no"].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);
 }
Example #4
0
        public Model.country_list GetModel(string country_name)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select id,country_name,order_no,add_user,add_time from country_list ");
            strSql.Append(" where country_name=@country_name");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@country_name", DbType.String, 50)
            };
            parameters[0].Value = country_name;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Example #5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(DXD.Model.country_list model)
 {
     return(dal.Update(model));
 }
Example #6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(DXD.Model.country_list model)
 {
     return(dal.Add(model));
 }