Пример #1
0
        public static Patient LoadPatient(uint PatientId)
        {
            Patient patient = null;

            using (var cmd = new MySqlCommand(MySqlCommandType.SELECT).Select("patient").Where("PatientId", PatientId))
                using (var reader = new MySqlReader(cmd))
                {
                    if (reader.Read())
                    {
                        patient = new Patient(reader.ReadInt32("PatientId"),
                                              reader.ReadInt32("Age"),
                                              (Gender)reader.ReadByte("Gender"),
                                              reader.ReadString("PatientName"),
                                              reader.ReadString("PhoneNumber"),
                                              reader.ReadString("Address"));
                    }
                }
            if (patient != null)
            {
                using (var cmd = new MySqlCommand(MySqlCommandType.SELECT).Select("history").Where("PatientId", PatientId))
                    using (var reader = new MySqlReader(cmd))
                    {
                        while (reader.Read())
                        {
                            patient.insertNewHistory($"[{DateTime.FromBinary(reader.ReadInt64("Date"))}] ==> {reader.ReadString("History")}");
                        }
                    }
            }
            return(patient);
        }
Пример #2
0
 public AccountTable(string username)
 {
     if (username == null)
     {
         return;
     }
     this.Username = username;
     this.Password = "";
     this.IP       = "";
     this.State    = Enums.AccountState.Default;
     this.EntityID = 0;
     using (var cmd = new MySqlCommand(MySqlCommandType.SELECT).Select("accounts").Where("Username", username))
         using (var reader = new MySqlReader(cmd))
         {
             if (reader.Read())
             {
                 exists        = true;
                 this.Password = reader.ReadString("Password");
                 this.IP       = reader.ReadString("Ip");
                 this.EntityID = reader.ReadUInt32("EntityID");
                 this.State    = (Enums.AccountState)reader.ReadInt32("State");
                 using (var cmd2 = new MySqlCommand(MySqlCommandType.SELECT).Select("characters").Where("UID", EntityID))
                     using (var reader2 = new MySqlReader(cmd2))
                     {
                         if (reader2.Read())
                         {
                             Name = reader2.ReadString("Name");
                             Rank = (ushort)Entity.RankExperiences.Where(i => i.Value >= reader2.ReadUInt32("Experience")).FirstOrDefault().Key;
                             byte[] Battles = reader2.ReadBlob("Battles");
                             var    battles = new List <Battle>();
                             if (Battles.Length > 0)
                             {
                                 using (var stream = new System.IO.MemoryStream(Battles))
                                     using (var rdr = new System.IO.BinaryReader(stream))
                                     {
                                         int count = rdr.ReadInt32();
                                         for (int i = 0; i < count; i++)
                                         {
                                             Battle battle = new Battle
                                             {
                                                 GameMode = (Enums.GameMode)rdr.ReadByte(),
                                                 Won      = rdr.ReadBoolean(),
                                                 Kills    = rdr.ReadUInt16(),
                                                 Deaths   = rdr.ReadUInt16()
                                             };
                                             battles.Add(battle);
                                         }
                                     }
                             }
                             TotalDeaths = (uint)battles.Sum(i => i.Deaths);
                             TotalKills  = (uint)battles.Sum(i => i.Kills);
                         }
                     }
             }
         }
 }
        public static Reservation LoadReservation(uint ReservationId)
        {
            Reservation reservation = null;

            using (var cmd = new MySqlCommand(MySqlCommandType.SELECT).Select("reservation").Where("ReservationId", ReservationId))
                using (var reader = new MySqlReader(cmd))
                {
                    if (reader.Read())
                    {
                        reservation = new Reservation(reader.ReadInt32("PatientId"),
                                                      reader.ReadInt32("ReservationId"),
                                                      reader.ReadString("DoctorId"),
                                                      reader.ReadString("ClinicId"),
                                                      reader.ReadString("AccountantId"),
                                                      DateTime.FromBinary(reader.ReadInt64("ReservationDate"))
                                                      );
                    }
                }
            return(reservation);
        }