Exemple #1
0
        /// <summary>
        /// 查询:返回数据表
        /// </summary>
        /// <param name="sqlWhere">查询条件,可带参数,如username='******' and usertype=@usertype</param>
        /// <param name="sqlSort">排序,如 date desc,id asc</param>
        /// <param name="sqlCols">需要查询的字段列表,如:ID,Name,CreateTime,默认*或空标识全部字段</param>
        /// <param name="ParamsList">参数值列表,需与sqlWhere中顺序对应,相同参数只提供一次,如 {"123",1}</param>
        /// <param name="ReadOnlyDataSource">是否使用只读数据源</param>
        /// <returns></returns>
        public static DataTable GetTable(string sqlWhere = "", string sqlSort = "", string sqlCols = "*", object[] ParamsList = null, bool ReadOnlyDataSource = true)
        {
            DataTable table   = new DataTable();
            string    txtCols = sqlCols;

            if (string.IsNullOrEmpty(sqlCols))
            {
                txtCols = "*";
            }
            StringBuilder sql = new StringBuilder("SELECT " + sqlCols + " FROM [NBlock_Trace](NOLOCK)");

            if (!string.IsNullOrEmpty(sqlWhere))
            {
                sql.Append(" WHERE ").Append(sqlWhere);
            }
            if (!string.IsNullOrEmpty(sqlSort))
            {
                sql.Append(" ORDER BY ").Append(sqlSort);
            }
            SqlCommand cmd = BuildCommand(sql.ToString(), ParamsList);

            table = new Trans.Db.DBUtility.DBHelper(ReadOnlyDataSource).ExecDataTable(cmd);
            if (table == null)
            {
                table = new DataTable();
            }
            table.TableName = "table";
            return(table);
        }
Exemple #2
0
        /// <summary>
        /// 根据主键:UserId 查询
        /// </summary>
        /// <param name="UserId"></param>
        /// <param name="ReadOnlyDataSource">是否使用只读数据源</param>
        /// <returns></returns>
        public static DataTable GetTableByUserId(Int32 _UserId, bool ReadOnlyDataSource = true)
        {
            DataTable  table = new DataTable();
            string     sql   = "SELECT * FROM NUser_Info(NOLOCK) WHERE [UserId]=@UserId";
            SqlCommand cmd   = new SqlCommand();

            cmd.CommandText = sql;
            cmd.Parameters.Add("@UserId", System.Data.SqlDbType.Int).Value = _UserId;
            table = new Trans.Db.DBUtility.DBHelper(ReadOnlyDataSource).ExecDataTable(cmd);
            if (table == null)
            {
                table = new DataTable();
            }
            table.TableName = "table";
            return(table);
        }
Exemple #3
0
        /// <summary>
        /// 根据主键:ID 查询
        /// </summary>
        /// <param name="ID"></param>
        /// <param name="ReadOnlyDataSource">是否使用只读数据源</param>
        /// <returns></returns>
        public static DataTable GetTableByID(Int64 _ID, bool ReadOnlyDataSource = true)
        {
            DataTable  table = new DataTable();
            string     sql   = "SELECT * FROM NBlock_Trace(NOLOCK) WHERE [ID]=@ID";
            SqlCommand cmd   = new SqlCommand();

            cmd.CommandText = sql;
            cmd.Parameters.Add("@ID", System.Data.SqlDbType.BigInt).Value = _ID;
            table = new Trans.Db.DBUtility.DBHelper(ReadOnlyDataSource).ExecDataTable(cmd);
            if (table == null)
            {
                table = new DataTable();
            }
            table.TableName = "table";
            return(table);
        }
Exemple #4
0
        /// <summary>
        /// 查询记录总数
        /// </summary>
        /// <param name="sqlWhere">查询条件,如username='******' and password='******',并可带排序条件</param>
        /// <param name="ParamsList">参数值列表,需与sqlWhere中顺序对应,相同参数只提供一次,如 {"123",1}</param>
        /// <param name="ReadOnlyDataSource">是否使用只读数据源</param>
        /// <returns></returns>
        public static long CountOutLong(string sqlWhere, object[] ParamsList = null, bool ReadOnlyDataSource = true)
        {
            StringBuilder sql = new StringBuilder("SELECT COUNT(1) FROM NBlock_Trace(NOLOCK) WHERE 1=1");

            if (!string.IsNullOrEmpty(sqlWhere))
            {
                sql.Append(" AND ").Append(sqlWhere);
            }
            SqlCommand cmd      = BuildCommand(sql.ToString(), ParamsList);
            object     CountObj = new Trans.Db.DBUtility.DBHelper(ReadOnlyDataSource).ExecScalar(cmd);
            long       RtnCount = 0;

            if (CountObj != null && CountObj != DBNull.Value && !string.IsNullOrEmpty(CountObj.ToString()))
            {
                long.TryParse(CountObj.ToString(), out RtnCount);
            }
            return(RtnCount);
        }
Exemple #5
0
        /// <summary>
        /// 查询并构建对象,返回第一个对象
        /// </summary>
        /// <param name="sqlWhere">查询条件</param>
        /// <param name="sqlSort">排序条件</param>
        /// <param name="ParamsList">参数值列表,需与sqlWhere中顺序对应,相同参数只提供一次,如 {"123",1}</param>
        /// <param name="ReadOnlyDataSource">是否使用只读数据源</param>
        /// <returns></returns>
        public static Trans.Db.Model.NBlock_Trace Get(string sqlWhere, string sqlSort = "", object[] ParamsList = null, bool ReadOnlyDataSource = true)
        {
            StringBuilder sql = new StringBuilder("SELECT TOP 1 * FROM NBlock_Trace(NOLOCK)");

            if (!string.IsNullOrEmpty(sqlWhere))
            {
                sql.Append(" WHERE ").Append(sqlWhere);
            }
            if (!string.IsNullOrEmpty(sqlSort))
            {
                sql.Append(" ORDER BY ").Append(sqlSort);
            }
            SqlCommand cmd = BuildCommand(sql.ToString(), ParamsList);
            DataTable  DT  = new Trans.Db.DBUtility.DBHelper(ReadOnlyDataSource).ExecDataTable(cmd);

            if (DT != null && DT.Rows.Count > 0)
            {
                return(new Trans.Db.Model.NBlock_Trace(DT.Rows[0]));
            }
            else
            {
                return(new Trans.Db.Model.NBlock_Trace());
            }
        }
Exemple #6
0
        /// <summary>
        /// 插入数据
        /// </summary>
        /// <returns></returns>
        public static bool insert(Trans.Db.Model.NBlock_Trace NBlock_Trace_obj)
        {
            SqlCommand    cmd        = new SqlCommand();
            StringBuilder cols       = new StringBuilder();
            StringBuilder parameters = new StringBuilder();
            string        sql        = "INSERT INTO NBlock_Trace({0}) values({1})";

            if (cols.Length > 0)
            {
                cols.Append(",");
                parameters.Append(",");
            }
            cols.Append("[Title]");
            parameters.Append("@Title");
            if (!string.IsNullOrEmpty(NBlock_Trace_obj.Title))
            {
                cmd.Parameters.AddWithValue("@Title", NBlock_Trace_obj.Title);
            }
            else
            {
                cmd.Parameters.AddWithValue("@Title", "");
            }
            if (cols.Length > 0)
            {
                cols.Append(",");
                parameters.Append(",");
            }
            cols.Append("[Site]");
            parameters.Append("@Site");
            if (!string.IsNullOrEmpty(NBlock_Trace_obj.Site))
            {
                cmd.Parameters.AddWithValue("@Site", NBlock_Trace_obj.Site);
            }
            else
            {
                cmd.Parameters.AddWithValue("@Site", "");
            }
            if (cols.Length > 0)
            {
                cols.Append(",");
                parameters.Append(",");
            }
            cols.Append("[Description]");
            parameters.Append("@Description");
            if (!string.IsNullOrEmpty(NBlock_Trace_obj.Description))
            {
                cmd.Parameters.AddWithValue("@Description", NBlock_Trace_obj.Description);
            }
            else
            {
                cmd.Parameters.AddWithValue("@Description", "");
            }
            if (cols.Length > 0)
            {
                cols.Append(",");
                parameters.Append(",");
            }
            cols.Append("[BlockCode]");
            parameters.Append("@BlockCode");
            if (!string.IsNullOrEmpty(NBlock_Trace_obj.BlockCode))
            {
                cmd.Parameters.AddWithValue("@BlockCode", NBlock_Trace_obj.BlockCode);
            }
            else
            {
                cmd.Parameters.AddWithValue("@BlockCode", "");
            }
            if (cols.Length > 0)
            {
                cols.Append(",");
                parameters.Append(",");
            }
            cols.Append("[YearVal]");
            parameters.Append("@YearVal");
            if (!string.IsNullOrEmpty(NBlock_Trace_obj.YearVal))
            {
                cmd.Parameters.AddWithValue("@YearVal", NBlock_Trace_obj.YearVal);
            }
            else
            {
                cmd.Parameters.AddWithValue("@YearVal", "");
            }
            if (cols.Length > 0)
            {
                cols.Append(",");
                parameters.Append(",");
            }
            cols.Append("[MonthVal]");
            parameters.Append("@MonthVal");
            if (!string.IsNullOrEmpty(NBlock_Trace_obj.MonthVal))
            {
                cmd.Parameters.AddWithValue("@MonthVal", NBlock_Trace_obj.MonthVal);
            }
            else
            {
                cmd.Parameters.AddWithValue("@MonthVal", "");
            }
            if (cols.Length > 0)
            {
                cols.Append(",");
                parameters.Append(",");
            }
            cols.Append("[DayVal]");
            parameters.Append("@DayVal");
            if (!string.IsNullOrEmpty(NBlock_Trace_obj.DayVal))
            {
                cmd.Parameters.AddWithValue("@DayVal", NBlock_Trace_obj.DayVal);
            }
            else
            {
                cmd.Parameters.AddWithValue("@DayVal", "");
            }
            if (cols.Length > 0)
            {
                cols.Append(",");
                parameters.Append(",");
            }
            cols.Append("[IsDel]");
            parameters.Append("@IsDel");
            cmd.Parameters.AddWithValue("@IsDel", NBlock_Trace_obj.IsDel);
            if (cols.Length > 0)
            {
                cols.Append(",");
                parameters.Append(",");
            }
            cols.Append("[CreateTime]");
            parameters.Append("@CreateTime");
            if (NBlock_Trace_obj.CreateTime == null || NBlock_Trace_obj.CreateTime == DateTime.MinValue)
            {
                cmd.Parameters.AddWithValue("@CreateTime", DateTime.Now);
            }
            else
            {
                cmd.Parameters.AddWithValue("@CreateTime", NBlock_Trace_obj.CreateTime);
            }
            sql             = string.Format(sql, cols.ToString(), parameters.ToString());
            cmd.CommandText = sql;
            bool b = true;

            try
            {
                int QueryCount = new Trans.Db.DBUtility.DBHelper(false).ExecNonQuery(cmd);
                if (QueryCount < 1)
                {
                    b = false;
                }
            }
            catch { b = false; }
            return(b);
        }
Exemple #7
0
        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="sqlWhere">查询条件,如username='******' and password='******'</param>
        /// <param name="sqlSort">排序条件,如username desc</param>
        /// <param name="sqlCols">数据库字段名组,用逗号分割,例如:username,userpwd,userid</param>
        /// <param name="pageIndex">页码</param>
        /// <param name="pageSize">页大小</param>
        /// <param name="recordCount">记录行数</param>
        /// <param name="ParamsList">参数值列表,需与sqlWhere中顺序对应,相同参数只提供一次,如 {"123",1}</param>
        /// <param name="ReadOnlyDataSource">是否使用只读数据源</param>
        /// <returns></returns>
        public static DataTable GetTable(string sqlWhere, string sqlSort, string sqlCols, int pageIndex, int pageSize, out long recordCount, object[] ParamsList = null, bool ReadOnlyDataSource = true)
        {
            int     SI = pageIndex * pageSize - pageSize + 1;
            int     EI = pageIndex * pageSize;
            DataSet ds = new DataSet();

            if (string.IsNullOrEmpty(sqlCols) || sqlCols == "*")
            {
                sqlCols = "ID,Title,Site,Description,BlockCode,YearVal,MonthVal,DayVal,IsDel,CreateTime";
            }
            StringBuilder sql = new StringBuilder("WITH PST(RN," + sqlCols + ") AS");

            sql.Append("(");
            sql.Append("SELECT ROW_NUMBER() OVER(ORDER BY ").Append(sqlSort).Append(") RN,").Append(sqlCols).Append(" ");
            sql.Append("FROM NBlock_Trace(NOLOCK)");
            if (!string.IsNullOrEmpty(sqlWhere))
            {
                sql.Append(" WHERE ").Append(sqlWhere);
            }
            sql.Append(")");
            sql.Append("SELECT RN,").Append(sqlCols).Append(" FROM PST WHERE RN BETWEEN @SI AND @EI");
            object[] NewParamsList;
            if (ParamsList != null)
            {
                NewParamsList = new object[ParamsList.Length + 2];
                for (int i = 0; i < ParamsList.Length; i++)
                {
                    NewParamsList[i] = ParamsList[i];
                }
                NewParamsList[ParamsList.Length]     = SI;
                NewParamsList[ParamsList.Length + 1] = EI;
            }
            else
            {
                NewParamsList    = new object[2];
                NewParamsList[0] = SI;
                NewParamsList[1] = EI;
            }
            if (!string.IsNullOrEmpty(sqlWhere))
            {
                sql.Append(";SELECT COUNT(1) FROM NBlock_Trace(NOLOCK) WHERE ").Append(sqlWhere);
            }
            else
            {
                sql.Append(";SELECT COUNT(1) FROM NBlock_Trace(NOLOCK)");
            }
            SqlCommand cmd = BuildCommand(sql.ToString(), NewParamsList);

            ds = new Trans.Db.DBUtility.DBHelper(ReadOnlyDataSource).ExecDataSet(cmd);
            if (ds != null && ds.Tables.Count > 1 && ds.Tables[1].Rows.Count > 0)
            {
                recordCount = Convert.ToInt64(ds.Tables[1].Rows[0][0]);
            }
            else
            {
                recordCount = 0;
            }
            if (ds != null && ds.Tables.Count > 1)
            {
                return(ds.Tables[0]);
            }
            else
            {
                return(new DataTable());
            }
        }
Exemple #8
0
        /// <summary>
        /// 插入数据,返回自增列ID
        /// </summary>
        /// <returns></returns>
        public static bool Add(Trans.Db.Model.NBlock_Trace NBlock_Trace_obj, out Int64 ID)
        {
            ID = 0;
            SqlCommand    cmd        = new SqlCommand();
            StringBuilder cols       = new StringBuilder();
            StringBuilder parameters = new StringBuilder();
            string        sql        = "INSERT INTO NBlock_Trace({0}) values({1});SELECT @@IDENTITY;";

            if (cols.Length > 0)
            {
                cols.Append(",");
                parameters.Append(",");
            }
            cols.Append("[Title]");
            parameters.Append("@Title");
            if (!string.IsNullOrEmpty(NBlock_Trace_obj.Title))
            {
                cmd.Parameters.AddWithValue("@Title", NBlock_Trace_obj.Title);
            }
            else
            {
                cmd.Parameters.AddWithValue("@Title", "");
            }
            if (cols.Length > 0)
            {
                cols.Append(",");
                parameters.Append(",");
            }
            cols.Append("[Site]");
            parameters.Append("@Site");
            if (!string.IsNullOrEmpty(NBlock_Trace_obj.Site))
            {
                cmd.Parameters.AddWithValue("@Site", NBlock_Trace_obj.Site);
            }
            else
            {
                cmd.Parameters.AddWithValue("@Site", "");
            }
            if (cols.Length > 0)
            {
                cols.Append(",");
                parameters.Append(",");
            }
            cols.Append("[Description]");
            parameters.Append("@Description");
            if (!string.IsNullOrEmpty(NBlock_Trace_obj.Description))
            {
                cmd.Parameters.AddWithValue("@Description", NBlock_Trace_obj.Description);
            }
            else
            {
                cmd.Parameters.AddWithValue("@Description", "");
            }
            if (cols.Length > 0)
            {
                cols.Append(",");
                parameters.Append(",");
            }
            cols.Append("[BlockCode]");
            parameters.Append("@BlockCode");
            if (!string.IsNullOrEmpty(NBlock_Trace_obj.BlockCode))
            {
                cmd.Parameters.AddWithValue("@BlockCode", NBlock_Trace_obj.BlockCode);
            }
            else
            {
                cmd.Parameters.AddWithValue("@BlockCode", "");
            }
            if (cols.Length > 0)
            {
                cols.Append(",");
                parameters.Append(",");
            }
            cols.Append("[YearVal]");
            parameters.Append("@YearVal");
            if (!string.IsNullOrEmpty(NBlock_Trace_obj.YearVal))
            {
                cmd.Parameters.AddWithValue("@YearVal", NBlock_Trace_obj.YearVal);
            }
            else
            {
                cmd.Parameters.AddWithValue("@YearVal", "");
            }
            if (cols.Length > 0)
            {
                cols.Append(",");
                parameters.Append(",");
            }
            cols.Append("[MonthVal]");
            parameters.Append("@MonthVal");
            if (!string.IsNullOrEmpty(NBlock_Trace_obj.MonthVal))
            {
                cmd.Parameters.AddWithValue("@MonthVal", NBlock_Trace_obj.MonthVal);
            }
            else
            {
                cmd.Parameters.AddWithValue("@MonthVal", "");
            }
            if (cols.Length > 0)
            {
                cols.Append(",");
                parameters.Append(",");
            }
            cols.Append("[DayVal]");
            parameters.Append("@DayVal");
            if (!string.IsNullOrEmpty(NBlock_Trace_obj.DayVal))
            {
                cmd.Parameters.AddWithValue("@DayVal", NBlock_Trace_obj.DayVal);
            }
            else
            {
                cmd.Parameters.AddWithValue("@DayVal", "");
            }
            if (cols.Length > 0)
            {
                cols.Append(",");
                parameters.Append(",");
            }
            cols.Append("[IsDel]");
            parameters.Append("@IsDel");
            cmd.Parameters.AddWithValue("@IsDel", NBlock_Trace_obj.IsDel);
            if (cols.Length > 0)
            {
                cols.Append(",");
                parameters.Append(",");
            }
            cols.Append("[CreateTime]");
            parameters.Append("@CreateTime");
            if (NBlock_Trace_obj.CreateTime == null || NBlock_Trace_obj.CreateTime == DateTime.MinValue)
            {
                cmd.Parameters.AddWithValue("@CreateTime", DateTime.Now);
            }
            else
            {
                cmd.Parameters.AddWithValue("@CreateTime", NBlock_Trace_obj.CreateTime);
            }
            sql             = string.Format(sql, cols.ToString(), parameters.ToString());
            cmd.CommandText = sql;
            bool b = true;

            try
            {
                object idobj = new Trans.Db.DBUtility.DBHelper(false).ExecScalar(cmd);
                ID = Convert.ToInt64(idobj);
                if (ID == 0)
                {
                    b = false;
                }
            }
            catch { b = false; }
            return(b);
        }
Exemple #9
0
        /// <summary>
        /// 插入数据,返回自增列ID
        /// </summary>
        /// <returns></returns>
        public static bool Add(Trans.Db.Model.NUser_Info NUser_Info_obj, out Int32 UserId)
        {
            UserId = 0;
            SqlCommand    cmd        = new SqlCommand();
            StringBuilder cols       = new StringBuilder();
            StringBuilder parameters = new StringBuilder();
            string        sql        = "INSERT INTO NUser_Info({0}) values({1});SELECT @@IDENTITY;";

            if (!string.IsNullOrEmpty(NUser_Info_obj.UserName))
            {
                if (cols.Length > 0)
                {
                    cols.Append(",");
                    parameters.Append(",");
                }
                cols.Append("[UserName]");
                parameters.Append("@UserName");
                cmd.Parameters.AddWithValue("@UserName", NUser_Info_obj.UserName);
            }
            if (cols.Length > 0)
            {
                cols.Append(",");
                parameters.Append(",");
            }
            cols.Append("[Password]");
            parameters.Append("@Password");
            if (!string.IsNullOrEmpty(NUser_Info_obj.Password))
            {
                cmd.Parameters.AddWithValue("@Password", NUser_Info_obj.Password);
            }
            else
            {
                cmd.Parameters.AddWithValue("@Password", "");
            }
            if (cols.Length > 0)
            {
                cols.Append(",");
                parameters.Append(",");
            }
            cols.Append("[RefUserId]");
            parameters.Append("@RefUserId");
            cmd.Parameters.AddWithValue("@RefUserId", NUser_Info_obj.RefUserId);
            if (cols.Length > 0)
            {
                cols.Append(",");
                parameters.Append(",");
            }
            cols.Append("[Status]");
            parameters.Append("@Status");
            cmd.Parameters.AddWithValue("@Status", NUser_Info_obj.Status);
            if (cols.Length > 0)
            {
                cols.Append(",");
                parameters.Append(",");
            }
            cols.Append("[IsDel]");
            parameters.Append("@IsDel");
            cmd.Parameters.AddWithValue("@IsDel", NUser_Info_obj.IsDel);
            if (cols.Length > 0)
            {
                cols.Append(",");
                parameters.Append(",");
            }
            cols.Append("[CreateTime]");
            parameters.Append("@CreateTime");
            if (NUser_Info_obj.CreateTime == null || NUser_Info_obj.CreateTime == DateTime.MinValue)
            {
                cmd.Parameters.AddWithValue("@CreateTime", DateTime.Now);
            }
            else
            {
                cmd.Parameters.AddWithValue("@CreateTime", NUser_Info_obj.CreateTime);
            }
            sql             = string.Format(sql, cols.ToString(), parameters.ToString());
            cmd.CommandText = sql;
            bool b = true;

            try
            {
                object idobj = new Trans.Db.DBUtility.DBHelper(false).ExecScalar(cmd);
                UserId = Convert.ToInt32(idobj);
                if (UserId == 0)
                {
                    b = false;
                }
            }
            catch { b = false; }
            return(b);
        }
Exemple #10
0
        /// <summary>
        /// 插入数据
        /// </summary>
        /// <returns></returns>
        public static bool insert(Trans.Db.Model.NUser_Info NUser_Info_obj)
        {
            SqlCommand    cmd        = new SqlCommand();
            StringBuilder cols       = new StringBuilder();
            StringBuilder parameters = new StringBuilder();
            string        sql        = "INSERT INTO NUser_Info({0}) values({1})";

            if (!string.IsNullOrEmpty(NUser_Info_obj.UserName))
            {
                if (cols.Length > 0)
                {
                    cols.Append(",");
                    parameters.Append(",");
                }
                cols.Append("[UserName]");
                parameters.Append("@UserName");
                cmd.Parameters.AddWithValue("@UserName", NUser_Info_obj.UserName);
            }
            if (cols.Length > 0)
            {
                cols.Append(",");
                parameters.Append(",");
            }
            cols.Append("[Password]");
            parameters.Append("@Password");
            if (!string.IsNullOrEmpty(NUser_Info_obj.Password))
            {
                cmd.Parameters.AddWithValue("@Password", NUser_Info_obj.Password);
            }
            else
            {
                cmd.Parameters.AddWithValue("@Password", "");
            }
            if (cols.Length > 0)
            {
                cols.Append(",");
                parameters.Append(",");
            }
            cols.Append("[RefUserId]");
            parameters.Append("@RefUserId");
            cmd.Parameters.AddWithValue("@RefUserId", NUser_Info_obj.RefUserId);
            if (cols.Length > 0)
            {
                cols.Append(",");
                parameters.Append(",");
            }
            cols.Append("[Status]");
            parameters.Append("@Status");
            cmd.Parameters.AddWithValue("@Status", NUser_Info_obj.Status);
            if (cols.Length > 0)
            {
                cols.Append(",");
                parameters.Append(",");
            }
            cols.Append("[IsDel]");
            parameters.Append("@IsDel");
            cmd.Parameters.AddWithValue("@IsDel", NUser_Info_obj.IsDel);
            if (cols.Length > 0)
            {
                cols.Append(",");
                parameters.Append(",");
            }
            cols.Append("[CreateTime]");
            parameters.Append("@CreateTime");
            if (NUser_Info_obj.CreateTime == null || NUser_Info_obj.CreateTime == DateTime.MinValue)
            {
                cmd.Parameters.AddWithValue("@CreateTime", DateTime.Now);
            }
            else
            {
                cmd.Parameters.AddWithValue("@CreateTime", NUser_Info_obj.CreateTime);
            }
            sql             = string.Format(sql, cols.ToString(), parameters.ToString());
            cmd.CommandText = sql;
            bool b = true;

            try
            {
                int QueryCount = new Trans.Db.DBUtility.DBHelper(false).ExecNonQuery(cmd);
                if (QueryCount < 1)
                {
                    b = false;
                }
            }
            catch { b = false; }
            return(b);
        }
Exemple #11
0
        /// <summary>
        /// 插入数据,返回自增列ID
        /// </summary>
        /// <returns></returns>
        public static bool Add(Trans.Db.Model.NUser_Log NUser_Log_obj, out Int64 LogId)
        {
            LogId = 0;
            SqlCommand    cmd        = new SqlCommand();
            StringBuilder cols       = new StringBuilder();
            StringBuilder parameters = new StringBuilder();
            string        sql        = "INSERT INTO NUser_Log({0}) values({1});SELECT @@IDENTITY;";

            if (cols.Length > 0)
            {
                cols.Append(",");
                parameters.Append(",");
            }
            cols.Append("[UserId]");
            parameters.Append("@UserId");
            cmd.Parameters.AddWithValue("@UserId", NUser_Log_obj.UserId);
            if (cols.Length > 0)
            {
                cols.Append(",");
                parameters.Append(",");
            }
            cols.Append("[Action]");
            parameters.Append("@Action");
            if (!string.IsNullOrEmpty(NUser_Log_obj.Action))
            {
                cmd.Parameters.AddWithValue("@Action", NUser_Log_obj.Action);
            }
            else
            {
                cmd.Parameters.AddWithValue("@Action", "");
            }
            if (cols.Length > 0)
            {
                cols.Append(",");
                parameters.Append(",");
            }
            cols.Append("[Content]");
            parameters.Append("@Content");
            if (!string.IsNullOrEmpty(NUser_Log_obj.Content))
            {
                cmd.Parameters.AddWithValue("@Content", NUser_Log_obj.Content);
            }
            else
            {
                cmd.Parameters.AddWithValue("@Content", "");
            }
            if (cols.Length > 0)
            {
                cols.Append(",");
                parameters.Append(",");
            }
            cols.Append("[IsDel]");
            parameters.Append("@IsDel");
            cmd.Parameters.AddWithValue("@IsDel", NUser_Log_obj.IsDel);
            if (cols.Length > 0)
            {
                cols.Append(",");
                parameters.Append(",");
            }
            cols.Append("[CreateTime]");
            parameters.Append("@CreateTime");
            if (NUser_Log_obj.CreateTime == null || NUser_Log_obj.CreateTime == DateTime.MinValue)
            {
                cmd.Parameters.AddWithValue("@CreateTime", DateTime.Now);
            }
            else
            {
                cmd.Parameters.AddWithValue("@CreateTime", NUser_Log_obj.CreateTime);
            }
            sql             = string.Format(sql, cols.ToString(), parameters.ToString());
            cmd.CommandText = sql;
            bool b = true;

            try
            {
                object idobj = new Trans.Db.DBUtility.DBHelper(false).ExecScalar(cmd);
                LogId = Convert.ToInt64(idobj);
                if (LogId == 0)
                {
                    b = false;
                }
            }
            catch { b = false; }
            return(b);
        }
Exemple #12
0
        /// <summary>
        /// 插入数据,返回自增列ID
        /// </summary>
        /// <returns></returns>
        public static bool Add(Trans.Db.Model.NUser_AuthDetail NUser_AuthDetail_obj, out Int32 ID)
        {
            ID = 0;
            SqlCommand    cmd        = new SqlCommand();
            StringBuilder cols       = new StringBuilder();
            StringBuilder parameters = new StringBuilder();
            string        sql        = "INSERT INTO NUser_AuthDetail({0}) values({1});SELECT @@IDENTITY;";

            if (cols.Length > 0)
            {
                cols.Append(",");
                parameters.Append(",");
            }
            cols.Append("[UserID]");
            parameters.Append("@UserID");
            cmd.Parameters.AddWithValue("@UserID", NUser_AuthDetail_obj.UserID);
            if (cols.Length > 0)
            {
                cols.Append(",");
                parameters.Append(",");
            }
            cols.Append("[DetailName]");
            parameters.Append("@DetailName");
            if (!string.IsNullOrEmpty(NUser_AuthDetail_obj.DetailName))
            {
                cmd.Parameters.AddWithValue("@DetailName", NUser_AuthDetail_obj.DetailName);
            }
            else
            {
                cmd.Parameters.AddWithValue("@DetailName", "");
            }
            if (cols.Length > 0)
            {
                cols.Append(",");
                parameters.Append(",");
            }
            cols.Append("[AllowList]");
            parameters.Append("@AllowList");
            cmd.Parameters.AddWithValue("@AllowList", NUser_AuthDetail_obj.AllowList);
            if (cols.Length > 0)
            {
                cols.Append(",");
                parameters.Append(",");
            }
            cols.Append("[AllowSync]");
            parameters.Append("@AllowSync");
            cmd.Parameters.AddWithValue("@AllowSync", NUser_AuthDetail_obj.AllowSync);
            if (cols.Length > 0)
            {
                cols.Append(",");
                parameters.Append(",");
            }
            cols.Append("[AllowRoll]");
            parameters.Append("@AllowRoll");
            cmd.Parameters.AddWithValue("@AllowRoll", NUser_AuthDetail_obj.AllowRoll);
            if (cols.Length > 0)
            {
                cols.Append(",");
                parameters.Append(",");
            }
            cols.Append("[SiteName]");
            parameters.Append("@SiteName");
            if (!string.IsNullOrEmpty(NUser_AuthDetail_obj.SiteName))
            {
                cmd.Parameters.AddWithValue("@SiteName", NUser_AuthDetail_obj.SiteName);
            }
            else
            {
                cmd.Parameters.AddWithValue("@SiteName", "");
            }
            if (cols.Length > 0)
            {
                cols.Append(",");
                parameters.Append(",");
            }
            cols.Append("[IsDir]");
            parameters.Append("@IsDir");
            cmd.Parameters.AddWithValue("@IsDir", NUser_AuthDetail_obj.IsDir);
            if (cols.Length > 0)
            {
                cols.Append(",");
                parameters.Append(",");
            }
            cols.Append("[IsDel]");
            parameters.Append("@IsDel");
            cmd.Parameters.AddWithValue("@IsDel", NUser_AuthDetail_obj.IsDel);
            if (cols.Length > 0)
            {
                cols.Append(",");
                parameters.Append(",");
            }
            cols.Append("[CreateTime]");
            parameters.Append("@CreateTime");
            if (NUser_AuthDetail_obj.CreateTime == null || NUser_AuthDetail_obj.CreateTime == DateTime.MinValue)
            {
                cmd.Parameters.AddWithValue("@CreateTime", DateTime.Now);
            }
            else
            {
                cmd.Parameters.AddWithValue("@CreateTime", NUser_AuthDetail_obj.CreateTime);
            }
            sql             = string.Format(sql, cols.ToString(), parameters.ToString());
            cmd.CommandText = sql;
            bool b = true;

            try
            {
                object idobj = new Trans.Db.DBUtility.DBHelper(false).ExecScalar(cmd);
                ID = Convert.ToInt32(idobj);
                if (ID == 0)
                {
                    b = false;
                }
            }
            catch { b = false; }
            return(b);
        }
Exemple #13
0
        /// <summary>
        /// 插入数据
        /// </summary>
        /// <returns></returns>
        public static bool insert(Trans.Db.Model.NUser_AuthDetail NUser_AuthDetail_obj)
        {
            SqlCommand    cmd        = new SqlCommand();
            StringBuilder cols       = new StringBuilder();
            StringBuilder parameters = new StringBuilder();
            string        sql        = "INSERT INTO NUser_AuthDetail({0}) values({1})";

            if (cols.Length > 0)
            {
                cols.Append(",");
                parameters.Append(",");
            }
            cols.Append("[UserID]");
            parameters.Append("@UserID");
            cmd.Parameters.AddWithValue("@UserID", NUser_AuthDetail_obj.UserID);
            if (cols.Length > 0)
            {
                cols.Append(",");
                parameters.Append(",");
            }
            cols.Append("[DetailName]");
            parameters.Append("@DetailName");
            if (!string.IsNullOrEmpty(NUser_AuthDetail_obj.DetailName))
            {
                cmd.Parameters.AddWithValue("@DetailName", NUser_AuthDetail_obj.DetailName);
            }
            else
            {
                cmd.Parameters.AddWithValue("@DetailName", "");
            }
            if (cols.Length > 0)
            {
                cols.Append(",");
                parameters.Append(",");
            }
            cols.Append("[AllowList]");
            parameters.Append("@AllowList");
            cmd.Parameters.AddWithValue("@AllowList", NUser_AuthDetail_obj.AllowList);
            if (cols.Length > 0)
            {
                cols.Append(",");
                parameters.Append(",");
            }
            cols.Append("[AllowSync]");
            parameters.Append("@AllowSync");
            cmd.Parameters.AddWithValue("@AllowSync", NUser_AuthDetail_obj.AllowSync);
            if (cols.Length > 0)
            {
                cols.Append(",");
                parameters.Append(",");
            }
            cols.Append("[AllowRoll]");
            parameters.Append("@AllowRoll");
            cmd.Parameters.AddWithValue("@AllowRoll", NUser_AuthDetail_obj.AllowRoll);
            if (cols.Length > 0)
            {
                cols.Append(",");
                parameters.Append(",");
            }
            cols.Append("[SiteName]");
            parameters.Append("@SiteName");
            if (!string.IsNullOrEmpty(NUser_AuthDetail_obj.SiteName))
            {
                cmd.Parameters.AddWithValue("@SiteName", NUser_AuthDetail_obj.SiteName);
            }
            else
            {
                cmd.Parameters.AddWithValue("@SiteName", "");
            }
            if (cols.Length > 0)
            {
                cols.Append(",");
                parameters.Append(",");
            }
            cols.Append("[IsDir]");
            parameters.Append("@IsDir");
            cmd.Parameters.AddWithValue("@IsDir", NUser_AuthDetail_obj.IsDir);
            if (cols.Length > 0)
            {
                cols.Append(",");
                parameters.Append(",");
            }
            cols.Append("[IsDel]");
            parameters.Append("@IsDel");
            cmd.Parameters.AddWithValue("@IsDel", NUser_AuthDetail_obj.IsDel);
            if (cols.Length > 0)
            {
                cols.Append(",");
                parameters.Append(",");
            }
            cols.Append("[CreateTime]");
            parameters.Append("@CreateTime");
            if (NUser_AuthDetail_obj.CreateTime == null || NUser_AuthDetail_obj.CreateTime == DateTime.MinValue)
            {
                cmd.Parameters.AddWithValue("@CreateTime", DateTime.Now);
            }
            else
            {
                cmd.Parameters.AddWithValue("@CreateTime", NUser_AuthDetail_obj.CreateTime);
            }
            sql             = string.Format(sql, cols.ToString(), parameters.ToString());
            cmd.CommandText = sql;
            bool b = true;

            try
            {
                int QueryCount = new Trans.Db.DBUtility.DBHelper(false).ExecNonQuery(cmd);
                if (QueryCount < 1)
                {
                    b = false;
                }
            }
            catch { b = false; }
            return(b);
        }
Exemple #14
0
        /// <summary>
        /// 插入数据,返回自增列ID
        /// </summary>
        /// <returns></returns>
        public static bool Add(Trans.Db.Model.NBlock_Task NBlock_Task_obj, out Int64 ID)
        {
            ID = 0;
            SqlCommand    cmd        = new SqlCommand();
            StringBuilder cols       = new StringBuilder();
            StringBuilder parameters = new StringBuilder();
            string        sql        = "INSERT INTO NBlock_Task({0}) values({1});SELECT @@IDENTITY;";

            if (cols.Length > 0)
            {
                cols.Append(",");
                parameters.Append(",");
            }
            cols.Append("[BlockCode]");
            parameters.Append("@BlockCode");
            if (!string.IsNullOrEmpty(NBlock_Task_obj.BlockCode))
            {
                cmd.Parameters.AddWithValue("@BlockCode", NBlock_Task_obj.BlockCode);
            }
            else
            {
                cmd.Parameters.AddWithValue("@BlockCode", "");
            }
            if (cols.Length > 0)
            {
                cols.Append(",");
                parameters.Append(",");
            }
            cols.Append("[FilePath]");
            parameters.Append("@FilePath");
            if (!string.IsNullOrEmpty(NBlock_Task_obj.FilePath))
            {
                cmd.Parameters.AddWithValue("@FilePath", NBlock_Task_obj.FilePath);
            }
            else
            {
                cmd.Parameters.AddWithValue("@FilePath", "");
            }
            if (cols.Length > 0)
            {
                cols.Append(",");
                parameters.Append(",");
            }
            cols.Append("[Status]");
            parameters.Append("@Status");
            cmd.Parameters.AddWithValue("@Status", NBlock_Task_obj.Status);
            if (cols.Length > 0)
            {
                cols.Append(",");
                parameters.Append(",");
            }
            cols.Append("[UploadLog]");
            parameters.Append("@UploadLog");
            if (!string.IsNullOrEmpty(NBlock_Task_obj.UploadLog))
            {
                cmd.Parameters.AddWithValue("@UploadLog", NBlock_Task_obj.UploadLog);
            }
            else
            {
                cmd.Parameters.AddWithValue("@UploadLog", "");
            }
            if (cols.Length > 0)
            {
                cols.Append(",");
                parameters.Append(",");
            }
            cols.Append("[CoverStatus]");
            parameters.Append("@CoverStatus");
            if (!string.IsNullOrEmpty(NBlock_Task_obj.CoverStatus))
            {
                cmd.Parameters.AddWithValue("@CoverStatus", NBlock_Task_obj.CoverStatus);
            }
            else
            {
                cmd.Parameters.AddWithValue("@CoverStatus", "");
            }
            if (cols.Length > 0)
            {
                cols.Append(",");
                parameters.Append(",");
            }
            cols.Append("[ErrorServer]");
            parameters.Append("@ErrorServer");
            if (!string.IsNullOrEmpty(NBlock_Task_obj.ErrorServer))
            {
                cmd.Parameters.AddWithValue("@ErrorServer", NBlock_Task_obj.ErrorServer);
            }
            else
            {
                cmd.Parameters.AddWithValue("@ErrorServer", "");
            }
            if (cols.Length > 0)
            {
                cols.Append(",");
                parameters.Append(",");
            }
            cols.Append("[IsDel]");
            parameters.Append("@IsDel");
            cmd.Parameters.AddWithValue("@IsDel", NBlock_Task_obj.IsDel);
            if (cols.Length > 0)
            {
                cols.Append(",");
                parameters.Append(",");
            }
            cols.Append("[CreateTime]");
            parameters.Append("@CreateTime");
            if (NBlock_Task_obj.CreateTime == null || NBlock_Task_obj.CreateTime == DateTime.MinValue)
            {
                cmd.Parameters.AddWithValue("@CreateTime", DateTime.Now);
            }
            else
            {
                cmd.Parameters.AddWithValue("@CreateTime", NBlock_Task_obj.CreateTime);
            }
            sql             = string.Format(sql, cols.ToString(), parameters.ToString());
            cmd.CommandText = sql;
            bool b = true;

            try
            {
                object idobj = new Trans.Db.DBUtility.DBHelper(false).ExecScalar(cmd);
                ID = Convert.ToInt64(idobj);
                if (ID == 0)
                {
                    b = false;
                }
            }
            catch { b = false; }
            return(b);
        }