Ejemplo n.º 1
0
        public PlayerGravelRequsetRecordInfo[] GetLastDayPlayerGravelRequsetRecords(MyDateTime date, int userID)
        {
            MySqlConnection myconn = null;
            MySqlCommand    mycmd  = null;

            try
            {
                myconn = MyDBHelper.Instance.CreateConnection();
                mycmd  = myconn.CreateCommand();

                string sqlInnerSelect = " select * from  playergravelrequsetrecordinfo ";
                string sqlWhere       = " where ";
                if (userID > 0)
                {
                    sqlWhere += " UserID=@userID and ";
                }
                sqlWhere += " @beginDate <= RequestDate and RequestDate < @endDate ";
                string sqlText = "SELECT r.*, s.UserName FROM (" + sqlInnerSelect + sqlWhere + ") r left join playersimpleinfo s on r.UserID = s.id ";
                mycmd.CommandText = sqlText;
                mycmd.Parameters.AddWithValue("@beginDate", new DateTime(date.Year, date.Month, date.Day, 0, 0, 0));
                mycmd.Parameters.AddWithValue("@endDate", new DateTime(date.Year, date.Month, date.Day + 1, 0, 0, 0));
                mycmd.Parameters.AddWithValue("@userID", userID);

                DataTable        table   = new DataTable();
                MySqlDataAdapter adapter = new MySqlDataAdapter(mycmd);
                adapter.Fill(table);

                var lists = MetaDBAdapter <PlayerGravelRequsetRecordInfo> .GetPlayerGravelRequsetRecordInfoFromDataTable(table);

                table.Clear();
                table.Dispose();
                adapter.Dispose();
                return(lists);
            }
            finally
            {
                if (mycmd != null)
                {
                    mycmd.Dispose();
                }
                if (myconn != null)
                {
                    myconn.Close();
                    myconn.Dispose();
                }
            }
        }
Ejemplo n.º 2
0
        public PlayerGravelRequsetRecordInfo GetLastDayPlayerGravelRequsetRecord(int userID)
        {
            MySqlConnection myconn = null;
            MySqlCommand    mycmd  = null;

            try
            {
                myconn = MyDBHelper.Instance.CreateConnection();
                mycmd  = myconn.CreateCommand();

                string sqlInnerSelect = " select * from  playergravelrequsetrecordinfo where UserID=@userID order by id desc limit 1 ";
                string sqlText        = "SELECT r.*, s.UserName FROM (" + sqlInnerSelect + ") r left join playersimpleinfo s on r.UserID = s.id ";
                mycmd.CommandText = sqlText;
                mycmd.Parameters.AddWithValue("@userID", userID);

                DataTable        table   = new DataTable();
                MySqlDataAdapter adapter = new MySqlDataAdapter(mycmd);
                adapter.Fill(table);

                var records = MetaDBAdapter <PlayerGravelRequsetRecordInfo> .GetPlayerGravelRequsetRecordInfoFromDataTable(table);

                table.Clear();
                table.Dispose();
                adapter.Dispose();
                if (records == null || records.Length == 0)
                {
                    return(null);
                }

                return(records[0]);
            }
            finally
            {
                if (mycmd != null)
                {
                    mycmd.Dispose();
                }
                if (myconn != null)
                {
                    myconn.Close();
                    myconn.Dispose();
                }
            }
        }