public List <Tuoterivi> haeKaikki()
        {
            try {
                using (MySqlConnection yhteys = new MySqlConnection(this.YhteysAsetukset)) {
                    yhteys.Open();

                    string SqlLause = "SELECT * FROM tuoteluettelo";

                    MySqlDataReader tulokset = new MySqlCommand(SqlLause, yhteys).ExecuteReader();

                    List <Tuoterivi> apulista = new List <Tuoterivi>();

                    while (tulokset.Read())
                    {
                        Tuoterivi apu = new Tuoterivi();

                        apu.id             = tulokset.GetInt32("id");
                        apu.vari           = tulokset.GetString("vari");
                        apu.koko           = tulokset.GetString("koko");
                        apu.hinta          = tulokset.GetFloat("hinta");
                        apu.varastotilanne = tulokset.GetInt32("varastotilanne");
                        apu.kuva           = tulokset.GetInt32("kuva");
                        apulista.Add(apu);
                    }

                    return(apulista);
                }
            } catch (Exception e) {
                throw new Exception("Tietojen hakemisessa tietokannasta tapahtui virhe", e);
            }
        }
예제 #2
0
        public List <Triangle> ReadAllTriangles()
        {
            var reader = new MySqlCommand(@"SELECT * FROM triangles",
                                          Connection).ExecuteReader();
            var results = new List <Triangle>();

            while (reader.Read())
            {
                results.Add(new Triangle(new Point(reader.GetFloat("ax"),
                                                   reader.GetFloat("ay"), reader.GetFloat("az")),
                                         new Point(reader.GetFloat("bx"), reader.GetFloat("by"),
                                                   reader.GetFloat("bz")),
                                         new Point(reader.GetFloat("cx"), reader.GetFloat("cy"),
                                                   reader.GetFloat("cz"))));
            }

            return(results);
        }
예제 #3
0
        private void FetchData()
        {
            try
            {
                var    S = new StatystykaSQL();
                string SqlString;
                SqlString  = S.SelectObsada(Settings.Default.IdSchool.ToString(), Settings.Default.SchoolYear, rbOkres.Tag.ToString() == "S"?EndOfSemester:EndOfSchoolYear);
                SqlString += S.SelectLiczbaOcen(Settings.Default.IdSchool.ToString(), Settings.Default.SchoolYear, rbOkres.Tag.ToString());
                SqlString += S.SelectStanKlasy(Settings.Default.IdSchool.ToString(), Settings.Default.SchoolYear, rbOkres.Tag.ToString() == "S" ? EndOfSemester : EndOfSchoolYear);
                SqlString += S.SelectStanKlasyWirtualnej(Settings.Default.IdSchool.ToString(), Settings.Default.SchoolYear, rbOkres.Tag.ToString() == "S" ? EndOfSemester : EndOfSchoolYear);
                SqlString += S.CountGroupMember(Settings.Default.IdSchool.ToString(), Settings.Default.SchoolYear);

                using (var R = new MySqlCommand(SqlString, conn).ExecuteReader())
                {
                    lstObsada.Clear();
                    while (R.Read())
                    {
                        lstObsada.Add(new SubjectStaff {
                            Class = new StaffUnit {
                                ID = R.GetInt32("Klasa"), Nazwa = R.GetString("Nazwa_Klasy")
                            },
                            Subject = new SubjectUnit {
                                ID = R.GetInt32("IdPrzedmiot"), Nazwa = R.GetString("Przedmiot"), IdSzkolaPrzedmiot = R.GetInt32("IdSzkolaPrzedmiot")
                            },
                            Teacher = new StaffUnit {
                                ID = R.GetInt32("IdNauczyciel"), Nazwa = R.GetString("Nauczyciel")
                            }, IsVirtual = R.GetBoolean("Virtual")
                        }
                                      );
                    }
                    R.NextResult();

                    lstLiczbaOcen.Clear();
                    while (R.Read())
                    {
                        lstLiczbaOcen.Add(new ScoreInfo {
                            ScoreCount = R.GetInt32("LiczbaOcen"), ScoreWeight = (int)R.GetFloat("Waga"), ClassID = R.GetInt32("Klasa"), SubjectID = R.GetInt32("IdPrzedmiot"), TeacherID = R.GetInt32("Nauczyciel")
                        });
                    }
                    R.NextResult();

                    lstLiczbaUczniow.Clear();
                    while (R.Read())
                    {
                        lstLiczbaUczniow.Add(new StudentCount {
                            ClassID = R.GetInt32("Klasa"), Count = R.GetInt32("StanKlasy")
                        });
                    }
                    R.NextResult();

                    lstLiczbaUczniowNI.Clear();
                    while (R.Read())
                    {
                        lstLiczbaUczniowNI.Add(new VirtualStudentCount {
                            ClassID = R.GetInt32("Klasa"), Count = R.GetInt32("StanKlasy"), SubjectID = R.GetInt32("IdPrzedmiot"), VirtualClassID = R.GetInt32("KlasaWirtualna")
                        });
                    }
                    R.NextResult();

                    lstLiczbaUczniowGrupa.Clear();
                    while (R.Read())
                    {
                        lstLiczbaUczniowGrupa.Add(new SubjectGroupCount {
                            ClassID = R.GetInt32("Klasa"), Count = R.GetInt32("StanGrupy"), SubjectID = R.GetInt32("IdPrzedmiot"), SubjectIdBySchool = R.GetInt32("IdSzkolaPrzedmiot")
                        });
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #4
0
            internal static Dictionary <string, object> Get(int CharacterID)
            {
                Dictionary <string, object> CharacterData = new Dictionary <string, object>();

                MySqlDataReader ResultReader;

                ResultReader = new MySqlCommand($"select * FROM usercharacter WHERE UserCharacterID = {CharacterID}")
                {
                    Connection = Connection
                }.ExecuteReader();

                ResultReader.Read();

                CharacterData.Add("CharacterID", ResultReader.GetInt64(0));
                CharacterData.Add("Name", ResultReader.GetString(2)); //The 0 here is an Ordinal
                CharacterData.Add("GuildID", ResultReader.GetInt64(3));
                CharacterData.Add("Credits", ResultReader.GetInt64(4));
                CharacterData.Add("LastInInstanceID", ResultReader.GetInt16(5));
                CharacterData.Add("LastInInstance", ResultReader.GetInt64(6));
                CharacterData.Add("PositionX", ResultReader.GetFloat(7));
                CharacterData.Add("PositionY", ResultReader.GetFloat(8));
                CharacterData.Add("Deleted", ResultReader.GetBoolean(10));

                ResultReader.Close();

                ResultReader = new MySqlCommand($"select * FROM usercharacterxp WHERE UserCharacterID = {CharacterID}")
                {
                    Connection = Connection
                }.ExecuteReader();

                ResultReader.Read();
                CharacterData.Add("MageXP", ResultReader.GetInt64(1));
                CharacterData.Add("HealerXP", ResultReader.GetInt64(2));
                CharacterData.Add("AttackerXP", ResultReader.GetInt64(3));
                CharacterData.Add("TankXP", ResultReader.GetInt64(4));
                CharacterData.Add("WoodcuttingXP", ResultReader.GetInt64(5));
                CharacterData.Add("CombatXP", ResultReader.GetInt64(6));

                ResultReader.Close();

                ResultReader = new MySqlCommand($"select * FROM usercharacteroutfit WHERE CharacterID = {CharacterID} AND IsEquipped = 1")
                {
                    Connection = Connection
                }.ExecuteReader();

                ResultReader.Read();
                CharacterData.Add("HeadIndex", ResultReader.GetInt16(3));
                CharacterData.Add("HeadColor", ResultReader.GetString(4));
                CharacterData.Add("HairIndex", ResultReader.GetInt16(5));
                CharacterData.Add("HairColor", ResultReader.GetString(6));
                CharacterData.Add("EyesIndex", ResultReader.GetInt16(7));
                CharacterData.Add("EyesColor", ResultReader.GetString(8));
                CharacterData.Add("TorsoIndex", ResultReader.GetInt16(9));
                CharacterData.Add("TorsoColor", ResultReader.GetString(10));
                CharacterData.Add("ArmsIndex", ResultReader.GetInt16(11));
                CharacterData.Add("ArmsColor", ResultReader.GetString(12));
                CharacterData.Add("HandsIndex", ResultReader.GetInt16(13));
                CharacterData.Add("HandsColor", ResultReader.GetString(14));
                CharacterData.Add("LegsIndex", ResultReader.GetInt16(15));
                CharacterData.Add("LegsColor", ResultReader.GetString(16));
                CharacterData.Add("FeetIndex", ResultReader.GetInt16(17));
                CharacterData.Add("FeetColor", ResultReader.GetString(18));

                ResultReader.Close();

                return(CharacterData);
            }