示例#1
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public bool Del(int id)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append("delete from Dat_Info where id = @id ");
            SQLiteServer server = new SQLiteServer();

            SQLiteParameter[] parameters = { new SQLiteParameter("@Id", DbType.Int32, 4) };
            parameters[0].Value = id;
            return(server.ExecuteNonQuery(sql.ToString(), parameters) > 0);
        }
示例#2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(MInfo model)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append("INSERT INTO Dat_Info(");
            sql.Append("Id,IsCtrl,IsAlt,IsShift,Key,Title,Content,UserId,CreateDateTime,TypeId)");
            sql.Append(" values (");
            sql.Append("@Id,@IsCtrl,@IsAlt,@IsShift,@Key,@Title,@Content,@UserId,@CreateDateTime,@TypeId)");
            SQLiteServer server = new SQLiteServer();

            try
            {
                SQLiteParameter[] parameters =
                {
                    new SQLiteParameter("@Id",             DbType.Int32,         4),
                    new SQLiteParameter("@IsCtrl",         DbType.Boolean),
                    new SQLiteParameter("@IsAlt",          DbType.Boolean),
                    new SQLiteParameter("@IsShift",        DbType.Boolean),
                    new SQLiteParameter("@Key",            DbType.String,      500),
                    new SQLiteParameter("@Title",          DbType.String,      500),
                    new SQLiteParameter("@Content",        DbType.String,    30000),
                    new SQLiteParameter("@UserId",         DbType.Int16,       100),
                    new SQLiteParameter("@CreateDateTime", DbType.DateTime),
                    new SQLiteParameter("@TypeId",         DbType.Int16, 100)
                };

                parameters[0].Value = int.Parse(server.ExecuteQuery("select ifnull(max(id),0) from Dat_Info").Rows[0][0].ToString()) + 1;
                parameters[1].Value = model.IsCtrl;
                parameters[2].Value = model.IsAlt;
                parameters[3].Value = model.IsShift;
                parameters[4].Value = model.Key;
                parameters[5].Value = model.Title;
                parameters[6].Value = model.Content;
                parameters[7].Value = model.UserId;
                parameters[8].Value = DateTime.Now.ToString();
                parameters[9].Value = model.TypeId;

                server.ExecuteNonQuery(sql.ToString(), parameters);
            }
            catch (Exception ex)
            {
                Log.WriteErrLog(ex);
                return(false);
            }
            finally
            {
            }
            return(true);
        }
示例#3
0
        public bool Update(MInfo model)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append("Update Dat_Info set Title = @Title, Content =@Content,UserId=@UserId,CreateDateTime=@CreateDateTime,TypeId=@TypeId where Id = @Id");

            SQLiteServer server = new SQLiteServer();

            try
            {
                SQLiteParameter[] parameters =
                {
                    new SQLiteParameter("@Id",             DbType.Int32,         4),
                    new SQLiteParameter("@Title",          DbType.String,      500),
                    new SQLiteParameter("@Content",        DbType.String,    30000),
                    new SQLiteParameter("@UserId",         DbType.Int16,       100),
                    new SQLiteParameter("@CreateDateTime", DbType.DateTime),
                    new SQLiteParameter("@TypeId",         DbType.Int16, 100)
                };

                parameters[0].Value = model.Id;
                parameters[1].Value = model.Title;
                parameters[2].Value = model.Content;
                parameters[3].Value = model.UserId;
                parameters[4].Value = DateTime.Now.ToString();
                parameters[5].Value = model.TypeId;
                server.ExecuteNonQuery(sql.ToString(), parameters);
            }
            catch (Exception ex)
            {
                Log.WriteErrLog(ex);
                return(false);
            }
            finally
            {
            }
            return(true);
        }
示例#4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(MType model)
        {
            int           id  = -1;
            StringBuilder sql = new StringBuilder();

            sql.Append("INSERT INTO Dat_Type(");
            sql.Append("TypeId,Name,Remark)");
            sql.Append(" values (");
            sql.Append("@TypeId,@Name,@Remark)");
            SQLiteServer server = new SQLiteServer();

            try
            {
                SQLiteParameter[] parameters =
                {
                    new SQLiteParameter("@TypeId", DbType.Int32,    4),
                    new SQLiteParameter("@Name",   DbType.String, 100),
                    new SQLiteParameter("@Remark", DbType.String, 200),
                };
                id = int.Parse(server.ExecuteQuery("select ifnull(max(TypeId),0) from Dat_Type").Rows[0][0].ToString()) + 1;
                parameters[0].Value = id;
                parameters[1].Value = model.Name;
                parameters[2].Value = model.Name;

                server.ExecuteNonQuery(sql.ToString(), parameters);
            }
            catch (Exception ex)
            {
                Log.WriteErrLog(ex);
                return(id);
            }
            finally
            {
            }
            return(id);
        }