Пример #1
0
 private void SetAttParams(MySqlCommand cmd, OnLineUserLogPo obj)
 {
     cmd.Parameters.AddWithValue(OnLineUserLogDbo.CmdParam.USERNAME, 253).Value = obj.USERNAME;
     cmd.Parameters.AddWithValue(OnLineUserLogDbo.CmdParam.WS_IP, 253).Value    = obj.WS_IP;
     cmd.Parameters.AddWithValue(OnLineUserLogDbo.CmdParam.WS_MAC, 253).Value   = obj.WS_MAC;
     cmd.Parameters.AddWithValue(OnLineUserLogDbo.CmdParam.CREATED, 12).Value   = obj.CREATED;
 }
Пример #2
0
        public bool Insert(MySqlConnection conn, MySqlTransaction trans, OnLineUserLogPo obj)
        {
            string text = string.Concat(new string[]
            {
                "INSERT INTO ",
                this.TABLE_NAME,
                " (",
                this.SQL_INSERT_COLUMNS,
                ") VALUES (",
                this.SQL_INSERT_VALUES,
                ")"
            });
            MySqlCommand mySqlCommand = new MySqlCommand(text, conn, trans);

            this.SetKeyParams(mySqlCommand, obj);
            this.SetAttParams(mySqlCommand, obj);
            bool result;

            try
            {
                result = (mySqlCommand.ExecuteNonQuery() > 0);
            }
            catch (MySqlException ex)
            {
                throw new Exception(ex.Message);
            }
            catch (Exception ex2)
            {
                throw new Exception(ex2.Message);
            }
            return(result);
        }
Пример #3
0
        public bool Delete(OnLineUserLogPo obj)
        {
            string          text       = " DELETE FROM " + this.TABLE_NAME + this.SQL_WHERE_KEYS;
            MySqlConnection connection = DBOHelper.GetConnection();

            DBOHelper.OpenConnection(connection);
            MySqlCommand mySqlCommand = new MySqlCommand(text, connection);

            this.SetKeyParams(mySqlCommand, obj);
            bool result;

            try
            {
                result = (mySqlCommand.ExecuteNonQuery() > 0);
            }
            catch (MySqlException ex)
            {
                throw new Exception(ex.Message);
            }
            catch (Exception ex2)
            {
                throw new Exception(ex2.Message);
            }
            finally
            {
                DBOHelper.CloseConnection(connection);
            }
            return(result);
        }
Пример #4
0
        public bool Update(MySqlConnection conn, MySqlTransaction trans, OnLineUserLogPo obj)
        {
            string text = string.Concat(new string[]
            {
                "UPDATE ",
                this.TABLE_NAME,
                " SET ",
                this.SQL_UPDATE_FIELD,
                this.SQL_WHERE_KEYS
            });
            MySqlCommand mySqlCommand = new MySqlCommand(text, conn, trans);

            this.SetKeyParams(mySqlCommand, obj);
            this.SetAttParams(mySqlCommand, obj);
            bool result;

            try
            {
                result = (mySqlCommand.ExecuteNonQuery() > 0);
            }
            catch (MySqlException ex)
            {
                throw new Exception(ex.Message);
            }
            catch (Exception ex2)
            {
                throw new Exception(ex2.Message);
            }
            return(result);
        }
Пример #5
0
        public static bool DeleteObj(OnLineUserLog ou)
        {
            OnLineUserLogDbo dbo = new OnLineUserLogDbo();
            OnLineUserLogPo  po  = new OnLineUserLogPo();

            po.USERID   = ou.UserId;
            po.USERNAME = ou.UserName;
            po.WS_IP    = ou.WS_IP;
            po.WS_MAC   = ou.WS_MAC;
            po.CREATED  = ou.Created;

            return(dbo.Delete(po));
        }
Пример #6
0
        public static bool UpdateObj(OnLineUserLog ou)
        {
            OnLineUserLogDbo dbo = new OnLineUserLogDbo();
            OnLineUserLogPo  po  = new OnLineUserLogPo();

            po.USERID   = ou.UserId;
            po.USERNAME = ou.UserName;
            po.WS_IP    = ou.WS_IP;
            po.WS_MAC   = ou.WS_MAC;
            po.CREATED  = DateTime.Now;

            return(dbo.Update(po));
        }
Пример #7
0
        public bool Insert(OnLineUserLogPo obj)
        {
            MySqlConnection connection = DBOHelper.GetConnection();

            DBOHelper.OpenConnection(connection);
            string text = string.Concat(new string[]
            {
                "INSERT INTO ",
                this.TABLE_NAME,
                " (",
                this.SQL_INSERT_COLUMNS,
                ") VALUES (",
                this.SQL_INSERT_VALUES,
                ")"
            });
            MySqlCommand mySqlCommand = new MySqlCommand(text, connection);

            this.SetKeyParams(mySqlCommand, obj);
            this.SetAttParams(mySqlCommand, obj);
            bool result;

            try
            {
                result = (mySqlCommand.ExecuteNonQuery() > 0);
            }
            catch (MySqlException ex)
            {
                throw new Exception(ex.Message);
            }
            catch (Exception ex2)
            {
                throw new Exception(ex2.Message);
            }
            finally
            {
                DBOHelper.CloseConnection(connection);
            }
            return(result);
        }
Пример #8
0
        public bool Delete(MySqlConnection conn, MySqlTransaction trans, OnLineUserLogPo obj)
        {
            string       text         = " DELETE FROM " + this.TABLE_NAME + this.SQL_WHERE_KEYS;
            MySqlCommand mySqlCommand = new MySqlCommand(text, conn, trans);

            this.SetKeyParams(mySqlCommand, obj);
            bool result;

            try
            {
                result = (mySqlCommand.ExecuteNonQuery() > 0);
            }
            catch (MySqlException ex)
            {
                throw new Exception(ex.Message);
            }
            catch (Exception ex2)
            {
                throw new Exception(ex2.Message);
            }
            return(result);
        }
Пример #9
0
        public bool Update(OnLineUserLogPo obj)
        {
            MySqlConnection connection = DBOHelper.GetConnection();

            DBOHelper.OpenConnection(connection);
            string text = string.Concat(new string[]
            {
                "UPDATE ",
                this.TABLE_NAME,
                " SET ",
                this.SQL_UPDATE_FIELD,
                this.SQL_WHERE_KEYS
            });
            MySqlCommand mySqlCommand = new MySqlCommand(text, connection);

            this.SetKeyParams(mySqlCommand, obj);
            this.SetAttParams(mySqlCommand, obj);
            bool result;

            try
            {
                result = (mySqlCommand.ExecuteNonQuery() > 0);
            }
            catch (MySqlException ex)
            {
                throw new Exception(ex.Message);
            }
            catch (Exception ex2)
            {
                throw new Exception(ex2.Message);
            }
            finally
            {
                DBOHelper.CloseConnection(connection);
            }
            return(result);
        }
Пример #10
0
 private void SetKeyParams(MySqlCommand cmd, OnLineUserLogPo obj)
 {
     cmd.Parameters.AddWithValue(OnLineUserLogDbo.CmdParam.USERID, 3).Value = obj.USERID;
 }