Exemplo n.º 1
0
        public static UserInfo get(double id)
        {
            UserInfo        value = new UserInfo();
            MySqlDataReader rs    = Sql.ExecuteReader("select id,uname,status,createdate,updatedate,email,mobile,phone,icon,filteringIP,sex,classId,cash from m_admin where  id=@id", new MySqlParameter[] { new MySqlParameter("id", id) });

            if (rs.Read())
            {
                value.id          = rs.GetDouble(0);
                value.username    = rs[1].ToString();
                value.classId     = rs.GetDouble(11);
                value.status      = rs.GetInt32(2);
                value.createdate  = rs.GetDateTime(3);
                value.updatedate  = rs.GetDateTime(4);
                value.email       = rs[5] + "";
                value.mobile      = rs[6] + "";
                value.phone       = rs[7] + "";
                value.icon        = rs[8] + "";
                value.filteringIP = rs[9] + "";
                value.sex         = rs.IsDBNull(10) ? true : rs.GetBoolean(10);
                value.cash        = rs.IsDBNull(12) ? 0 : rs.GetInt32(12);
            }
            rs.Close();
            if (value.id < 1)
            {
                return(null);
            }
            rs = Sql.ExecuteReader("select roleId from admin_role where  userId=@id", new MySqlParameter[] { new MySqlParameter("id", id) });
            string roleId = "";

            while (rs.Read())
            {
                if (roleId != "")
                {
                    roleId += ",";
                }
                roleId    += rs.GetDouble(0);
                value.role = roleId;
            }
            rs.Close();
            return(value);
        }
 private RegionSettings ToRegionSettings(MySqlDataReader reader) => new RegionSettings
 {
     BlockTerraform      = reader.GetBool("BlockTerraform"),
     BlockFly            = reader.GetBool("BlockFly"),
     AllowDamage         = reader.GetBool("AllowDamage"),
     RestrictPushing     = reader.GetBool("RestrictPushing"),
     AllowLandResell     = reader.GetBool("AllowLandResell"),
     AllowLandJoinDivide = reader.GetBool("AllowLandJoinDivide"),
     BlockShowInSearch   = reader.GetBool("BlockShowInSearch"),
     AgentLimit          = reader.GetInt32("AgentLimit"),
     ObjectBonus         = reader.GetDouble("ObjectBonus"),
     DisableScripts      = reader.GetBool("DisableScripts"),
     DisableCollisions   = reader.GetBool("DisableCollisions"),
     BlockFlyOver        = reader.GetBool("BlockFlyOver"),
     Sandbox             = reader.GetBool("Sandbox"),
     TerrainTexture1     = reader.GetUUID("TerrainTexture1"),
     TerrainTexture2     = reader.GetUUID("TerrainTexture2"),
     TerrainTexture3     = reader.GetUUID("TerrainTexture3"),
     TerrainTexture4     = reader.GetUUID("TerrainTexture4"),
     TelehubObject       = reader.GetUUID("TelehubObject"),
     Elevation1NW        = reader.GetDouble("Elevation1NW"),
     Elevation2NW        = reader.GetDouble("Elevation2NW"),
     Elevation1NE        = reader.GetDouble("Elevation1NE"),
     Elevation2NE        = reader.GetDouble("Elevation2NE"),
     Elevation1SE        = reader.GetDouble("Elevation1SE"),
     Elevation2SE        = reader.GetDouble("Elevation2SE"),
     Elevation1SW        = reader.GetDouble("Elevation1SW"),
     Elevation2SW        = reader.GetDouble("Elevation2SW"),
     WaterHeight         = reader.GetDouble("WaterHeight"),
     TerrainRaiseLimit   = reader.GetDouble("TerrainRaiseLimit"),
     TerrainLowerLimit   = reader.GetDouble("TerrainLowerLimit"),
     SunPosition         = reader.GetDouble("SunPosition"),
     IsSunFixed          = reader.GetBoolean("IsSunFixed"),
     UseEstateSun        = reader.GetBool("UseEstateSun"),
     BlockDwell          = reader.GetBool("BlockDwell"),
     ResetHomeOnTeleport = reader.GetBool("ResetHomeOnTeleport"),
     AllowLandmark       = reader.GetBool("AllowLandmark"),
     AllowDirectTeleport = reader.GetBool("AllowDirectTeleport"),
     MaxBasePrims        = reader.GetInt32("MaxBasePrims"),
     WalkableCoefficientsSerialization = reader.GetBytes("WalkableCoefficientsData")
 };
Exemplo n.º 3
0
        // If Not the teacher wants to log in
        private void StudentLogin()
        {
            if (cc.IfLogin())
            {
                try
                {
                    _command             = new MySqlCommand();
                    _command.Connection  = cc.connection;
                    _command.CommandText = "SELECT tanulo.id, tanulo.nev, tanulo.kurzus_id, tanulo.felh, tanulo.jelszo, tanulo.tema, tanulo.telsz, tanulo.email, tanulo.belephet FROM tanulo WHERE tanulo.felh = '" + TxtUsername.Text + "' AND tanulo.jelszo = '" + pass.Coding(TxtPassword.Text) + "' ";

                    _command.ExecuteNonQuery();
                    _reader = _command.ExecuteReader();
                    _reader.Read();
                    if (_reader.HasRows)
                    {
                        if (_reader.GetBoolean(8))
                        {
                            new Student(new User(_reader.GetInt32(0), _reader.GetString(1), _reader.GetInt32(2), _reader.GetString(3), _reader.GetString(4), _reader.GetString(5), _reader.GetString(6), _reader.GetString(7)), this).Show();
                            Hide();
                        }
                        else
                        {
                            LblLoginError.Text += "A felhasználód jelenleg nem elérhető! \n";
                        }
                    }
                    else
                    {
                        LblLoginError.Text += "Érvénytelen adatok! \n";
                    }
                    _reader.Close();
                }
                catch (MySqlException ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    cc.connection.Close();
                }
            }
        }
Exemplo n.º 4
0
        public ShoppingCart GetShoppingCart(string userName)
        {
            try {
                ShoppingCart          ans = new ShoppingCart();
                string                sql = " SELECT * FROM UserCart where userName = '******';";
                LinkedList <UserCart> ucs = new LinkedList <UserCart>();

                MySqlCommand cmd = new MySqlCommand(sql, con);

                con.Open();

                MySqlDataReader reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    int     saleId             = reader.GetInt32("saleId");
                    int     amount             = reader.GetInt32("amount");
                    double  offer              = reader.GetDouble("offer");
                    Boolean couponActivated    = reader.GetBoolean("couponActivated");
                    double  price              = reader.GetDouble("price");
                    double  priceAfterDiscount = reader.GetDouble("priceAfterDiscount");

                    UserCart uc = new UserCart(userName, saleId, amount);
                    uc.Offer              = offer;
                    uc.CouponActivated    = couponActivated;
                    uc.Price              = price;
                    uc.PriceAfterDiscount = priceAfterDiscount;

                    ucs.AddLast(uc);
                }
                con.Close();
                ans.products = ucs;

                return(ans);
            }
            catch (Exception e)
            {
                con.Close();
                throw new Exception("DB ERROR");
            }
        }
Exemplo n.º 5
0
        public override LinkedList <User> Get()
        {
            try
            {
                string            sql   = " SELECT * FROM User";
                LinkedList <User> users = new LinkedList <User>();
                MySqlCommand      cmd   = new MySqlCommand(sql, con);
                con.Open();
                MySqlDataReader reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    int     state    = reader.GetInt32("state");
                    string  userName = reader.GetString("userName");
                    string  password = reader.GetString("password");
                    Boolean isActive = reader.GetBoolean("isActive");
                    User    u        = new User(userName, password);
                    u.setIsActive(isActive);
                    if (state == 2)
                    {
                        u.setState(new LogedIn());
                    }
                    else if (state == 3)
                    {
                        u.setState(new Admin());
                    }
                    users.AddLast(u);
                }
                con.Close();
                foreach (User u in users)
                {
                    u.shoppingCart = GetShoppingCart(u.userName);
                }
                return(users);
            }
            catch (Exception e)
            {
                con.Close();
                throw new Exception("DB ERROR");
            }
        }
Exemplo n.º 6
0
        private List <Product> search()
        {
            List <Product> list = new List <Product>();

            connection = new MySqlConnection(connString);
            try
            {
                connection.Open();
                command    = new MySqlCommand(sql, connection);
                dataReader = command.ExecuteReader();
                while (dataReader.Read())
                {
                    Product pro = new Product();
                    pro.ID                = dataReader.GetInt32(0);
                    pro.BusinessPlanId    = dataReader.GetInt32(1);
                    pro.ProductType       = dataReader.GetBoolean(2);
                    pro.Name              = dataReader.GetString(3);
                    pro.Directed_to       = dataReader.GetString(4);
                    pro.Innovation_factor = dataReader.GetString(5);
                    pro.Technology        = dataReader.GetString(6);
                    pro.License           = dataReader.GetString(7);
                    pro.Competition       = dataReader.GetString(8);
                    pro.Price             = dataReader.GetInt32(9);
                    pro.Description       = dataReader.GetString(10);
                    pro.Copyright         = dataReader.GetString(11);
                    pro.ProductCost       = dataReader.GetInt32(12);
                    pro.NumProduct        = dataReader.GetInt32(13);
                    pro.PercentageIncome  = dataReader.GetInt32(14);
                    list.Add(pro);
                }
                dataReader.Close();
                command.Dispose();
                connection.Close();
            }
            catch (Exception ex)
            {
                return(null);
            }

            return(list);
        }
Exemplo n.º 7
0
        public List <Categoria> GetCategoria()
        {
            List <Categoria> list = new List <Categoria>();

            try
            {
                db.Open();
                string       consulta = "sp_EliminarProducto";
                MySqlCommand comm     = new MySqlCommand(consulta, db);

                comm.CommandType = CommandType.StoredProcedure;

                comm.Parameters.AddWithValue("@_id", "");

                MySqlDataReader rd = comm.ExecuteReader();
                if (rd.HasRows)
                {
                    while (rd.Read())
                    {
                        list.Add(new Categoria
                        {
                            Id           = rd.GetInt32(0),
                            StrCategoria = rd.GetString(1),
                            BitEstatus   = rd.GetBoolean(4)
                        });
                    }
                }
                else
                {
                    throw new Exception("No hay registros");
                }

                db.Close();
            }
            catch (Exception ex)
            {
                throw new Exception("Error", ex);
            }
            db.Close();
            return(list);
        }
Exemplo n.º 8
0
        public List <Task> GetAll(int ID)
        {
            List <Task> tasks = new List <Task>();

            Dictionary <string, string> parameters = new Dictionary <string, string>
            {
                { "@id", ID.ToString() }
            };

            MySqlDataReader dataReader = mySQLConnector.GetData("SELECT * FROM tasks WHERE section_id = @id", parameters);

            if (dataReader.HasRows)
            {
                while (dataReader.Read())
                {
                    int      id               = dataReader.IsDBNull(0) ? 0 : dataReader.GetInt16("id");
                    int      parent_task_id   = dataReader.IsDBNull(1) ? 0 : dataReader.GetInt16("parent_task_id");
                    int      requires_task_id = dataReader.IsDBNull(2) ? 0 : dataReader.GetInt16("requires_task_id");
                    int      section_id       = dataReader.IsDBNull(3) ? 0 : dataReader.GetInt16("section_id");
                    int      user_id          = dataReader.IsDBNull(4) ? 0 : dataReader.GetInt16("user_id");
                    string   name             = dataReader.IsDBNull(5) ? "" : dataReader.GetString("name");
                    string   description      = dataReader.IsDBNull(6) ? "" : dataReader.GetString("description");
                    DateTime start_date       = (DateTime)dataReader.GetMySqlDateTime("start_date");
                    DateTime due_date         = (DateTime)dataReader.GetMySqlDateTime("due_date");
                    bool     completed        = dataReader.IsDBNull(9) ? false : dataReader.GetBoolean("completed");
                    Double   estimated_time   = dataReader.IsDBNull(9) ? 0.0 : dataReader.GetDouble("estimated_time");
                    int      priority         = dataReader.IsDBNull(10) ? 0 : dataReader.GetInt16("priority");
                    DateTime created_at       = (DateTime)dataReader.GetMySqlDateTime("created_at");

                    Task parentTask   = parent_task_id == 0 ? null : this.Read(parent_task_id);
                    Task requiredTask = requires_task_id == 0 ? null : this.Read(requires_task_id);

                    Task task = new Task(id, parentTask, requiredTask, new UserDAO().Read(user_id), section_id, name, description, estimated_time, priority, completed, start_date, due_date, created_at);

                    tasks.Add(task);
                }
            }
            mySQLConnector.CloseConnections(dataReader);

            return(tasks);
        }
Exemplo n.º 9
0
        public menuPrincipal(string user)
        {
            InitializeComponent();
            MySqlCommand    sql2   = new MySqlCommand(String.Format("Select * from Usuarios where Nick_Name='" + user + "'"), ConectarServidor.conexion());
            MySqlDataReader reader = sql2.ExecuteReader();

            if (reader.Read() == true)
            {
                btRentar.Enabled          = reader.GetBoolean(4);
                btCotizacion.Enabled      = reader.GetBoolean(5);
                btRegistro.Enabled        = reader.GetBoolean(6);
                btBusqueda.Enabled        = reader.GetBoolean(7);
                btDevoluciones.Enabled    = reader.GetBoolean(8);
                btRegistroUsuario.Enabled = reader.GetBoolean(9);
                btConfiguracion.Enabled   = reader.GetBoolean(10);
                this.user = user;
            }
            reader.Close();
        }
Exemplo n.º 10
0
        public List <TodoItem> Index()
        {
            string cs = @"server=localhost;userid=root;password='';database=todos;";

            using var con = new MySqlConnection(cs);
            con.Open();
            var stm = "SELECT * FROM todotabell ORDER BY Id ASC";
            var cmd = new MySqlCommand(stm, con);

            using MySqlDataReader rdr = cmd.ExecuteReader();
            TodoItem.TodoLista.Clear();
            while (rdr.Read())
            {
                TodoItem Todo = new TodoItem {
                    Id = rdr.GetInt32(0), Name = rdr.GetString(1), IsComplete = rdr.GetBoolean(2)
                };
                TodoItem.TodoLista.Add(Todo);
            }

            return(TodoItem.TodoLista);
        }
        /// <summary>
        /// Provides the ability to search for students using their uid.
        /// </summary>
        /// <param name="uid">Should be the FOB uid used to search for the student.</param>
        /// <returns>
        /// True = they're alive and well. False = check their pulse.
        /// </returns>
        public Student FindStudentByUID(uint uid)
        {
            MySqlDataReader reader = db.Query($"SELECT * FROM students WHERE uid={uid}");
            Student         result = null;

            if (reader != null && reader.HasRows)
            {
                reader.Read();
                result = new Student(reader.GetUInt32("id"),
                                     reader.GetUInt32("uid"),
                                     reader.GetUInt32("oasisid"),
                                     reader.GetString("firstname"),
                                     reader.GetString("lastname"),
                                     reader.GetUInt16("finishyear"),
                                     reader.GetBoolean("active"));
            }

            reader.Close();
            db.CloseConnection();
            return(result);
        }
Exemplo n.º 12
0
        // Return all ListItems for a given list
        public List <ListItem> GetAllItemsForList(int listId)
        {
            List <ListItem> results = new List <ListItem>();
            string          sql     = $"SELECT ItemId, Text, Completed FROM ListItems WHERE ListId = {listId};";

            using (MySqlCommand cmd = new MySqlCommand(sql, Connection))
            {
                MySqlDataReader rdr = cmd.ExecuteReader();

                while (rdr.Read())
                {
                    ListItem item = new ListItem(
                        rdr.GetInt32("ItemId"),
                        rdr.GetString("Text"),
                        rdr.GetBoolean("Completed"));
                    results.Add(item);
                }
            }

            return(results);
        }
        /// <summary>
        /// Muestra si un usuario es administrador
        /// </summary>
        /// <param name="email">Email o nombre de usuario, del usuario a chequear</param>
        /// <returns>True si es administrador, false si no lo es</returns>
        public static bool GetAdmin(string email)
        {
            bool         resultado = false;
            MySqlCommand command   = new MySqlCommand("SELECT usuario.Administrador FROM usuario WHERE Email=@email");

            command.Parameters.AddWithValue("@email", email);
            MySqlDataReader reader = Database.ExecuteQuery(command);

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    if (reader.GetBoolean(0))
                    {
                        resultado = true;
                    }
                }
            }
            reader.Close();
            return(resultado);
        }
Exemplo n.º 14
0
        public static bool CanPlayerLogin(string email, string password)
        {
            MySqlDataReader reader = Program.database.GetData("SELECT baned FROM Users WHERE email='" + email + "' AND password='******'");

            if (reader.HasRows)
            {
                reader.Read();
                if (reader.GetBoolean("baned"))
                {
                    reader.Close();
                    return(false);
                }
                else
                {
                    reader.Close();
                    return(true);
                }
            }
            reader.Close();
            return(false);
        }
Exemplo n.º 15
0
        private List <Receipt_Food> retrieveOrderFood()
        {
            List <Receipt_Food> orderFood = new List <Receipt_Food>();

            cnn = new MySqlConnection(connectionString);
            cnn.Open();

            String sql = "SELECT * from receipt_food WHERE receiptid = '" + Id + "'";;

            MySqlCommand    cmd        = new MySqlCommand(sql, cnn);
            MySqlDataReader dataReader = cmd.ExecuteReader();

            while (dataReader.Read())
            {
                orderFood.Add(new Receipt_Food(dataReader.GetInt32(0), dataReader.GetInt32(1),
                                               dataReader.GetString(2), dataReader.GetDecimal(3), dataReader.GetInt32(4),
                                               dataReader.GetBoolean(5)));
            }

            return(orderFood);
        }
Exemplo n.º 16
0
        public Uposlenik VratiUposlenika(int brojClanskeKarte)
        {
            try
            {
                MySqlCommand dataCommand = new MySqlCommand();
                dataCommand.Connection  = dataConnection;
                dataCommand.CommandText = "SELECT * FROM clanovi_biblioteke, uposlenici WHERE uposlenici_uposlenikID = uposlenikID AND brojClanskeKarte = " + brojClanskeKarte + ";";
                MySqlDataReader dataReader = dataCommand.ExecuteReader();

                dataReader.Read();
                Uposlenik u = new Uposlenik(dataReader.GetString(1), dataReader.GetString(2), dataReader.GetString(3), dataReader.GetString(4), dataReader.GetString(5), dataReader.GetString(6), dataReader.GetDateTime(7), dataReader.GetString(14), dataReader.GetString(15));
                u.BrojIznajmljenihKnjiga = dataReader.GetInt32(9);
                u.Zaduzen = dataReader.GetBoolean(10);
                dataReader.Close();
                return(u);
            }
            catch (MySqlException izuzetak)
            {
                throw new Exception(izuzetak.Message);
            }
        }
Exemplo n.º 17
0
        public static List <WordFilterData> ReadSwearWords()
        {
            List <WordFilterData> result = new List <WordFilterData>();

            using (DatabaseConnection dbClient = Alias.Server.DatabaseManager.GetConnection())
            {
                using (MySqlDataReader Reader = dbClient.DataReader("SELECT `word`, `bannable` FROM `wordfilter`"))
                {
                    while (Reader.Read())
                    {
                        WordFilterData data = new WordFilterData
                        {
                            Phrase   = Reader.GetString("Word"),
                            Bannable = Reader.GetBoolean("bannable")
                        };
                        result.Add(data);
                    }
                }
            }
            return(result);
        }
Exemplo n.º 18
0
        // Lookup Existing Customer
        public int LookupCustomer()
        {
            string lookupCustomerQuery = $"SELECT customerName, active, addressId FROM customer WHERE customerId = { _customerID };";
            int    customerAddress     = 0;

            dbCon.Open();

            MySqlCommand    lookupCustomerCommand = new MySqlCommand(lookupCustomerQuery, dbCon);
            MySqlDataReader lookupCustomerReader  = lookupCustomerCommand.ExecuteReader();

            if (lookupCustomerReader.Read())
            {
                _customerName   = lookupCustomerReader.GetString(0);
                _isActive       = lookupCustomerReader.GetBoolean(1);
                customerAddress = lookupCustomerReader.GetInt32(2);
            }

            dbCon.Close();

            return(customerAddress);
        }
Exemplo n.º 19
0
        public Student VratiStudenta(int brojClanskeKarte)
        {
            try
            {
                MySqlCommand dataCommand = new MySqlCommand();
                dataCommand.Connection  = dataConnection;
                dataCommand.CommandText = "SELECT * FROM clanovi_biblioteke, studenti WHERE studenti_studentID = studentID AND brojClanskeKarte = " + brojClanskeKarte + ";";
                MySqlDataReader dataReader = dataCommand.ExecuteReader();

                dataReader.Read();
                Student s = new Student(dataReader.GetString(1), dataReader.GetString(2), dataReader.GetString(3), dataReader.GetString(4), dataReader.GetString(5), dataReader.GetString(6), dataReader.GetDateTime(7), dataReader.GetInt32(13), dataReader.GetString(14), dataReader.GetInt32(15));
                s.BrojIznajmljenihKnjiga = dataReader.GetInt32(9);
                s.Zaduzen = dataReader.GetBoolean(10);
                dataReader.Close();
                return(s);
            }
            catch (MySqlException izuzetak)
            {
                throw new Exception(izuzetak.Message);
            }
        }
Exemplo n.º 20
0
 private bool ReadBuilding(MySqlDataReader reader, out BuildingSaveData result)
 {
     if (reader.Read())
     {
         result                 = new BuildingSaveData();
         result.Id              = reader.GetString(0);
         result.ParentId        = reader.GetString(1);
         result.EntityId        = reader.GetInt32(2);
         result.CurrentHp       = reader.GetInt32(3);
         result.RemainsLifeTime = reader.GetFloat(4);
         result.IsLocked        = reader.GetBoolean(5);
         result.LockPassword    = reader.GetString(6);
         result.CreatorId       = reader.GetString(7);
         result.CreatorName     = reader.GetString(8);
         result.Position        = new Vector3(reader.GetFloat(9), reader.GetFloat(10), reader.GetFloat(11));
         result.Rotation        = Quaternion.Euler(reader.GetFloat(12), reader.GetFloat(13), reader.GetFloat(14));
         return(true);
     }
     result = new BuildingSaveData();
     return(false);
 }
Exemplo n.º 21
0
        static public List <Entidades.Seccion> buscarSeccionPorLote(string lote)
        {
            List <Entidades.Seccion> secciones = new List <Entidades.Seccion>();

            Conexion.OpenConnection();
            string query;

            Entidades.Seccion b = new Entidades.Seccion();

            query = "Select * from seccion where idLote = @lote";
            MySqlCommand comando = new MySqlCommand(query, Conexion.Connection);

            comando.Parameters.AddWithValue("@lote", lote);
            comando.Prepare();
            MySqlDataReader reader = comando.ExecuteReader();

            while (reader.Read())
            {
                b                 = new Entidades.Seccion();
                b.IdSeccion       = reader.GetString("idSeccion");
                b.IdLote          = reader.GetString("idLote");
                b.IdBloque        = reader.GetString("idBloque");
                b.Area            = reader.GetDouble("area");
                b.Posicion        = reader.GetInt32("posicion");
                b.NumPlantas      = reader.GetInt32("numPlantas");
                b.PosX            = reader.GetInt32("posX");
                b.PosY            = reader.GetInt32("posY");
                b.FechaSiembra    = reader.GetDateTime("fechaSiembra");
                b.FechaInicial    = reader.GetDateTime("fechaInicial");
                b.FechaProgramada = reader.GetDateTime("fechaProgramada");
                b.Detalle         = reader.GetString("detalle");
                b.GrupoForza      = reader.GetString("grupoForza");
                b.Paquete         = reader.GetString("idPaquete");
                b.Bloqueo         = reader.GetBoolean("bloqueo");
                secciones.Add(b);
            }
            //retorna valores nulos en caso de no encontrar coincidencias
            Conexion.CloseConnection();
            return(secciones);
        }
Exemplo n.º 22
0
        public IP CheckIp(string ip)
        {
            IP           ret = null;
            MySqlCommand cmd = CreateQuery();

            cmd.CommandText = "SELECT * FROM ips WHERE ip=@ip;";
            cmd.Parameters.AddWithValue("@ip", ip);
            bool foundIp = false;

            using (MySqlDataReader rdr = cmd.ExecuteReader())
            {
                if (rdr.HasRows)
                {
                    foundIp = true;
                    rdr.Read();
                    ret = new IP
                    {
                        Address = rdr.GetString("ip"),
                        Banned  = rdr.GetBoolean("banned"),
                        Gifts   = Utils.FromCommaSepString16(rdr.GetString("gifts")).ToList()
                    };
                }
            }
            if (!foundIp)
            {
                cmd             = CreateQuery();
                cmd.CommandText = @"INSERT INTO ips(ip, banned, gifts) VALUES (@ip, @banned, @gifts)";
                cmd.Parameters.AddWithValue("@ip", ip);
                cmd.Parameters.AddWithValue("@banned", 0);
                cmd.Parameters.AddWithValue("@gifts", "");
                cmd.ExecuteNonQuery();
                ret = new IP
                {
                    Address = ip,
                    Banned  = false,
                    Gifts   = new List <short>()
                };
            }
            return(ret);
        }
Exemplo n.º 23
0
        //______________________________________________________
        //ajouter les informations dans le bouton + stocker les infos pour la fenetres infos supplémentaires
        public void Ajouter_dans_boutons(int id, Button btn_matin, Button btn_aprem, DateTime date, int num_tab)
        {
            try
            {
                connexion.Open();
                MySqlCommand cmd1 = new MySqlCommand("SELECT * FROM emploi WHERE ID_Groupe ='" + id + "' AND Date_Seance='" + date.ToShortDateString() + "';", connexion);
                using (MySqlDataReader Reader1 = cmd1.ExecuteReader())
                {
                    while (Reader1.Read())
                    {
                        string Libelle_Cours = Reader1.GetString("Libelle_Cours");
                        int    couleur       = Reader1.GetInt32("Couleur_Cours");
                        bool   debut_seance  = Reader1.GetBoolean("Debut_Seance");

                        if (debut_seance == true)
                        {
                            btn_matin.Text      = Libelle_Cours;
                            btn_matin.BackColor = System.Drawing.Color.FromArgb(couleur);
                            notes[num_tab]      = Reader1.GetString("Note_Seance");
                            profs[num_tab]      = Reader1.GetString("Prenom") + " " + Reader1.GetString("Nom");
                            ids_seance[num_tab] = Reader1.GetInt32("ID_Seance");
                        }
                        else
                        {
                            btn_aprem.Text          = Libelle_Cours;
                            btn_aprem.BackColor     = System.Drawing.Color.FromArgb(couleur);
                            notes[num_tab + 1]      = Reader1.GetString("Note_Seance");
                            profs[num_tab + 1]      = Reader1.GetString("Prenom") + " " + Reader1.GetString("Nom");
                            ids_seance[num_tab + 1] = Reader1.GetInt32("ID_Seance");
                        }
                    }
                    Reader1.Close();
                }
                connexion.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erreur pendant l'execution de la méthode Ajouter dans boutons pour l'emploi du temps " + ex.ToString());
            }
        }
Exemplo n.º 24
0
        public static PyObject DBColumnToPyObject(int index, ref MySqlDataReader reader)
        {
            Type type = reader.GetFieldType(index);

            switch (type.Name)
            {
            case "String":
                return(new PyString(reader.IsDBNull(index) == true ? "" : reader.GetString(index)));

            case "UInt32":
            case "Int32":
            case "UInt16":
            case "Int16":
            case "SByte":
            case "Byte":
                return(new PyInt(reader.IsDBNull(index) == true ? 0 : reader.GetInt32(index)));

            case "UInt64":
            case "Int64":
                return(new PyLongLong(reader.IsDBNull(index) == true ? 0 : reader.GetInt64(index)));

            case "Byte[]":
                return(new PyBuffer(reader.IsDBNull(index) == true ? new byte[0] : (byte[])reader.GetValue(index)));

            case "Double":
                return(new PyFloat(reader.IsDBNull(index) == true ? 0.0 : reader.GetDouble(index)));

            case "Decimal":
                return(new PyFloat(reader.IsDBNull(index) == true ? 0.0 : (double)reader.GetDecimal(index)));

            case "Boolean":
                return(new PyBool(reader.IsDBNull(index) == true ? false : reader.GetBoolean(index)));

            default:
                Log.Error("Database", "Unhandled MySQL type " + type.Name);
                break;
            }

            return(null);
        }
Exemplo n.º 25
0
        public Bug getBugById(int id)
        {
            String sql = "SELECT b.id,b.name,b.package_name,b.class,b.method,b.line_start,b.line_end,b.status,b.date,b.image,b.code,u.username,p.title FROM tbl_bug AS b,tbl_project AS p,tbl_user AS u WHERE b.project_id=p.id AND b.user_id=u.id AND b.id=@id";

            try
            {
                conn.Open();
                MySqlCommand sqlCommand = new MySqlCommand(sql, conn);
                sqlCommand.Parameters.AddWithValue("@id", id);
                MySqlDataReader result = sqlCommand.ExecuteReader();
                while (result.Read())
                {
                    bug              = new Bug();
                    bug.Id           = result.GetInt32(result.GetOrdinal("id"));
                    bug.BugName      = result.GetString(result.GetOrdinal("name"));
                    bug.PackageName  = result.GetString(result.GetOrdinal("package_name"));
                    bug.ClassName    = result.GetString(result.GetOrdinal("class"));
                    bug.MethodName   = result.GetString(result.GetOrdinal("method"));
                    bug.LineStart    = result.GetInt32(result.GetOrdinal("line_start"));
                    bug.LineEnd      = result.GetInt32(result.GetOrdinal("line_end"));
                    bug.BugAddedDate = result.GetDateTime(result.GetOrdinal("date"));
                    bug.Status       = result.GetBoolean(result.GetOrdinal("status"));
                    bug.BugAuthor    = result.GetString(result.GetOrdinal("username"));
                    bug.ProjectName  = result.GetString(result.GetOrdinal("title"));
                    bug.CodeBlock    = result.GetString(result.GetOrdinal("code"));
                    byte[] img = (byte[])(result[result.GetOrdinal("image")]);
                    bug.Image = img;

                    return(bug);
                    //  project.Id = result.GetInt32(result.GetOrdinal("id"));
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(" project bug" + e.Message);
            }


            return(null);
        }
Exemplo n.º 26
0
        public Tables Get(Database database)
        {
            Tables tables     = new Tables(database);
            double tableCount = GetTablesCount(database);
            double tableIndex = 0;

            using (MySqlConnection conn = new MySqlConnection(connectioString))
            {
                database.Name = conn.Database;
                using (MySqlCommand command = new MySqlCommand("select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, ENGINE, VERSION, ROW_FORMAT, TABLE_ROWS, AVG_ROW_LENGTH, DATA_LENGTH, MAX_DATA_LENGTH, INDEX_LENGTH, DATA_FREE, IFNULL(AUTO_INCREMENT,0) AS AUTO_INCREMENT, CREATE_TIME, UPDATE_TIME, CHECK_TIME, TABLE_COLLATION, IFNULL(CHECKSUM,0) AS CHECKSUM, CREATE_OPTIONS, TABLE_COMMENT FROM Information_schema.tables WHERE TABLE_SCHEMA = '" + database.Name + "' ORDER BY TABLE_NAME", conn))
                {
                    conn.Open();
                    using (MySqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            Table table = new Table(database);
                            table.Id            = (int)tableIndex;
                            table.Name          = reader["TABLE_NAME"].ToString();
                            table.AutoIncrement = reader.GetInt32("AUTO_INCREMENT");
                            table.CheckSum      = reader.GetBoolean("CHECKSUM");
                            table.Collation     = reader["TABLE_COLLATION"].ToString();
                            table.Comments      = reader["TABLE_COMMENT"].ToString();
                            table.CreateOptions = reader["CREATE_OPTIONS"].ToString();
                            table.Engine        = reader["ENGINE"].ToString();
                            table.Constraints   = (new GenerateConstraint(connectioString, tableFilter)).Get(table); /*Primero debe ir las constraints*/
                            table.Columns       = GetColumnsDatabase(table);
                            table.Triggers      = GetTriggers(table);
                            //table.Indexes = (new GenerateIndex(connectioString,tableFilter)).Get(table);
                            tables.Add(table);
                            tableIndex++;
                            OnTableProgress(this, new ProgressEventArgs((tableIndex / tableCount) * 100));
                        }
                    }
                }
            }
            //tables.Sort();
            tables.ToSQL();
            return(tables);
        }
Exemplo n.º 27
0
        public System()
        {
            conn = DBUtils.GetDBConnection();
            try
            {
                conn.Open();
                Console.WriteLine("[MySQL] Verbindung erfolgreich!");
            }
            catch (Exception e)
            {
                Console.WriteLine("[MySQL] Verbindung fehlgeschlagen!");
                Console.WriteLine(e.Message);
            }
            try
            {
                Thread Socket = new Thread(new ThreadStart(new SocketHandler().Handler)); //Start Console Handler
                Socket.Start();

                List <int>      startServer = new List <int>();
                MySqlDataReader data        = DBUtils.ExecuteCommand(conn, "SELECT * FROM `server`");
                while (data.Read())
                {
                    int id = data.GetInt32(0);
                    if (data.GetBoolean(6))
                    {
                        startServer.Add(id);
                        //new Thread(() => StartServer(id)).Start();
                    }
                }
                data.Close();
                foreach (int id in startServer)
                {
                    StartServer(id);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Exemplo n.º 28
0
        //Validate username and password
        protected void login_Authenticate(object sender, AuthenticateEventArgs e)
        {
            using (SHA256CryptoServiceProvider encrypt = new SHA256CryptoServiceProvider())
            {
                byte [] username = Encoding.Unicode.GetBytes(login.UserName.Trim());
                byte [] password = Encoding.Unicode.GetBytes(login.Password.Trim());

                byte [] usernameHash = encrypt.ComputeHash(username);
                byte [] passwordHash = encrypt.ComputeHash(password);

                using (MySqlConnection database = new MySqlConnection(CONNECTION_STRING))
                {
                    database.Open();

                    using (MySqlCommand select = new MySqlCommand("Select * from users where username = @usernameHash and password = @passwordHash", database))
                    {
                        select.Parameters.AddWithValue("@usernameHash", usernameHash);
                        select.Parameters.AddWithValue("@passwordHash", passwordHash);

                        using (MySqlDataReader reader = select.ExecuteReader())
                        {
                            reader.Read();

                            //If we have a result we are authenticated
                            if (reader.HasRows)
                            {
                                e.Authenticated = true;

                                Session ["user"] = new User(reader.GetUInt64("id"), reader.GetBoolean("is_admin"), reader.GetString("firstname"), reader.GetString("lastname"), reader.GetDateTime("dob"), reader.GetString("country"), reader.GetString("phone"));
                                Response.Redirect("Default.aspx");
                            }
                            else
                            {
                                e.Authenticated = false;
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 29
0
        public clsVehiculoTransporte CargaVehiculoTransporte(Int32 Codigo)
        {
            clsVehiculoTransporte veh = null;

            try
            {
                con.conectarBD();
                cmd = new MySqlCommand("MuestraVehiculoTransporte", con.conector);
                cmd.Parameters.AddWithValue("codveh", Codigo);
                cmd.CommandType = CommandType.StoredProcedure;
                dr = cmd.ExecuteReader();
                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        veh = new clsVehiculoTransporte();
                        veh.CodVehiculoTransporte = Convert.ToInt32(dr.GetDecimal(0));
                        veh.Placa                 = dr.GetString(1);
                        veh.CodMarca              = Convert.ToInt32(dr.GetDecimal(2));
                        veh.Marca                 = dr.GetString(3);
                        veh.CodModelo             = Convert.ToInt32(dr.GetDecimal(4));
                        veh.Modelo                = dr.GetString(5);
                        veh.Año                   = Convert.ToInt32(dr.GetDecimal(6));
                        veh.ConstanciaInscripcion = dr.GetString(7);
                        veh.Estado                = dr.GetBoolean(8);
                        veh.CodUser               = Convert.ToInt32(dr.GetDecimal(9));
                        veh.FechaRegistro         = dr.GetDateTime(10);// capturo la fecha
                        veh.Soat                  = dr.GetString(11);
                        veh.ConfVehicular         = dr.GetString(12);
                        veh.MTC                   = dr.GetString(13);
                    }
                }
                return(veh);
            }
            catch (MySqlException ex)
            {
                throw ex;
            }
            finally { con.conector.Dispose(); cmd.Dispose(); con.desconectarBD(); }
        }
Exemplo n.º 30
0
        public List <Item> GetItems()
        {
            MySqlConnection conn = DB.Connection();

            conn.Open();
            MySqlCommand cmd = conn.CreateCommand() as MySqlCommand;

            cmd.CommandText = @"SELECT items.* FROM pcs
              JOIN inventory ON (pcs.id = inventory.pcs)
              JOIN items ON (inventory.items = items.id)
              WHERE pcs.id = @PCId;";

            MySqlParameter pcIdParameter = new MySqlParameter();

            pcIdParameter.ParameterName = "@PCId";
            pcIdParameter.Value         = _id;
            cmd.Parameters.Add(pcIdParameter);

            MySqlDataReader rdr   = cmd.ExecuteReader() as MySqlDataReader;
            List <Item>     items = new List <Item> {
            };

            while (rdr.Read())
            {
                int itemId = rdr.GetInt32(0);
                // int pcId = rdr.GetInt32(1);
                string itemName    = rdr.GetString(1);
                string itemType    = rdr.GetString(2);
                string itemSpecial = rdr.GetString(3);
                bool   itemMagic   = rdr.GetBoolean(4);
                Item   newItem     = Item.Find(itemId);
                items.Add(newItem);
            }
            conn.Close();
            if (conn != null)
            {
                conn.Dispose();
            }
            return(items);
        }