Ejemplo n.º 1
0
 /// <summary>
 /// Yacht adatok frissitése az adatbázisba
 /// </summary>
 /// <param name="UpdateYacht"></param>
 public void MysqlUpdateYacht(Yacht UpdateYacht)
 {
     try
     {
         string query = "UPDATE enYacht SET name = ?name, producer = ?producer, image = ?image, seats = ?seats, hire = ?hire, busy = ?busy, daly_price = ?daly_price, width = ?width, lenght = ?lenght, dive = ?dive, speed = ?speed, port_id = ?port_id WHERE yacht_id = ?yacht_id;";
         Globals.connect.Open();
         using (MySqlCommand cmd = new MySqlCommand(query, Globals.connect))
         {
             cmd.Parameters.Add("?yacht_id", MySqlDbType.Int16).Value   = UpdateYacht.id;
             cmd.Parameters.Add("?name", MySqlDbType.VarChar).Value     = UpdateYacht.nev;
             cmd.Parameters.Add("?producer", MySqlDbType.VarChar).Value = UpdateYacht.gyarto;
             if (UpdateYacht.kep != null)
             {
                 cmd.Parameters.Add("?image", MySqlDbType.LongBlob).Value = MysqlGeneral.ImageToByte(UpdateYacht.kep);
             }
             else
             {
                 cmd.Parameters.Add("?image", MySqlDbType.LongBlob).Value = DBNull.Value;
             }
             cmd.Parameters.Add("?seats", MySqlDbType.Int16).Value      = UpdateYacht.ferohely;
             cmd.Parameters.Add("?hire", MySqlDbType.Bit).Value         = UpdateYacht.berelheto;
             cmd.Parameters.Add("?busy", MySqlDbType.Bit).Value         = UpdateYacht.blfoglalt;
             cmd.Parameters.Add("?daly_price", MySqlDbType.Int16).Value = UpdateYacht.napi_ar;
             cmd.Parameters.Add("?width", MySqlDbType.Float).Value      = UpdateYacht.szeles;
             cmd.Parameters.Add("?lenght", MySqlDbType.Float).Value     = UpdateYacht.hossz;
             cmd.Parameters.Add("?dive", MySqlDbType.Float).Value       = UpdateYacht.merules;
             cmd.Parameters.Add("?speed", MySqlDbType.Int16).Value      = UpdateYacht.sebesseg;
             cmd.Parameters.Add("?port_id", MySqlDbType.Int16).Value    = UpdateYacht.kikoto_id;
             cmd.ExecuteNonQuery();
         }
     }
     catch (MySqlException e)
     {
         Globals.log = "Sikertelen módosítás!";
         MessageBox.Show(e.ToString(), e.ToString(), MessageBoxButton.OK);
     }
     finally
     {
         Globals.connect.Close();
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Felhasználói rekord frissitése
 /// </summary>
 /// <param name="UpdateUser">A frissteni kivánt felhasználó</param>
 public void MysqlUpdateUser(Felhasznalo UpdateUser)
 {
     try
     {
         string query = "UPDATE enYacht_Club_Tag SET nickname = ?nickname, last_name = ?last_name, first_name = ?first_name, birthday = ?birthday, zip_code = ?zip_code, address = ?address, country = ?country, image = ?image WHERE member_id = ?member_id;";
         Globals.connect.Open();
         using (MySqlCommand cmd = new MySqlCommand(query, Globals.connect))
         {
             cmd.Parameters.Add("?nickname", MySqlDbType.VarChar).Value   = UpdateUser.nickname;
             cmd.Parameters.Add("?last_name", MySqlDbType.VarChar).Value  = UpdateUser.kereszt_nev;
             cmd.Parameters.Add("?first_name", MySqlDbType.VarChar).Value = UpdateUser.veztek_nev;
             cmd.Parameters.Add("?birthday", MySqlDbType.DateTime).Value  = UpdateUser.szuletesdt;
             cmd.Parameters.Add("?zip_code", MySqlDbType.Int16).Value     = UpdateUser.iranyitoszm;
             cmd.Parameters.Add("?address", MySqlDbType.VarChar).Value    = UpdateUser.lakcim;
             cmd.Parameters.Add("?country", MySqlDbType.VarChar).Value    = UpdateUser.orszag;
             if (MysqlGeneral.ImageToByte(UpdateUser.kep) != null)
             {
                 cmd.Parameters.Add("?image", MySqlDbType.LongBlob).Value = MysqlGeneral.ImageToByte(UpdateUser.kep);
             }
             else
             {
                 cmd.Parameters.Add("?image", MySqlDbType.LongBlob).Value = DBNull.Value;
             }
             cmd.Parameters.Add("?member_id", MySqlDbType.Int16).Value = UpdateUser.member_id;
             cmd.ExecuteNonQuery();
         }
     }
     catch (Exception)
     {
         Globals.log = "Sikertelen módosítás!";
     }
     finally
     {
         Globals.connect.Close();
     }
 }