public bool AddOsztaly(Osztaly osztaly) { bool success = false; MySqlCommand command = new MySqlCommand(); MySqlConnection connection = getConnection(); command.CommandText = "AddOsztaly"; command.CommandType = System.Data.CommandType.StoredProcedure; MySqlParameter pname = new MySqlParameter() { ParameterName = "pname", Value = osztaly.Name, Direction = System.Data.ParameterDirection.Input, DbType = System.Data.DbType.String }; command.Connection = connection; command.Parameters.Add(pname); try { OpenConnection(connection); success = command.ExecuteNonQuery() == 0 ? false : true; } catch (Exception e) { Logger.Log(e.Message); } finally { CloseConnection(connection); } return(success); }
private void ferohelyValt_Click(object sender, RoutedEventArgs e) { Osztaly selectedDept = (Osztaly)osztalyLista.SelectedItems[0]; UserControlok.OsztalyModositas osztalyMod = new UserControlok.OsztalyModositas(selectedDept.id, true); if (osztalyMod.ShowDialog() == true) { OsztalyokFrissitese(); ferohelyValt.Visibility = Visibility.Hidden; torlesOsztaly.Visibility = Visibility.Hidden; } }
internal bool ModifyDolgozo(Dolgozo dolgozo, Osztaly group) { bool siker = false; MySqlCommand command = new MySqlCommand(); MySqlConnection connection = getConnection(); command.CommandType = System.Data.CommandType.StoredProcedure; command.CommandText = "ModifyDolgozo"; command.Connection = connection; MySqlParameter ujnev = new MySqlParameter() { ParameterName = "newname", DbType = System.Data.DbType.String, Direction = System.Data.ParameterDirection.Input, Value = dolgozo.Name }; MySqlParameter groupid = new MySqlParameter() { ParameterName = "gid", DbType = System.Data.DbType.Int32, Direction = System.Data.ParameterDirection.Input, Value = group.Id }; MySqlParameter did = new MySqlParameter() { ParameterName = "did", DbType = System.Data.DbType.Int32, Direction = System.Data.ParameterDirection.Input, Value = dolgozo.Id }; command.Parameters.Add(ujnev); command.Parameters.Add(groupid); command.Parameters.Add(did); try { OpenConnection(connection); siker = command.ExecuteNonQuery() == 0 ? false : true; } catch (Exception e) { Logger.Log(e.Message); } finally { CloseConnection(connection); } return(siker); }
public bool RemoveOsztaly(Osztaly osztaly) { bool success = false; MySqlCommand command = new MySqlCommand(); MySqlConnection connection = getConnection(); command.Connection = connection; command.CommandType = System.Data.CommandType.StoredProcedure; command.CommandText = "RemoveOsztaly"; MySqlParameter pid = new MySqlParameter() { ParameterName = "delid", Value = osztaly.Id, Direction = System.Data.ParameterDirection.Input, DbType = System.Data.DbType.Int32 }; MySqlParameter eredmeny = new MySqlParameter() { Direction = System.Data.ParameterDirection.ReturnValue, ParameterName = "eredmeny", DbType = System.Data.DbType.Int32 }; command.Parameters.Add(pid); command.Parameters.Add(eredmeny); try { OpenConnection(connection); command.ExecuteNonQuery(); //1 ha törölte 0 ha van még rajta ember int isDeleted = int.Parse(eredmeny.Value.ToString()); if (isDeleted == 1) { success = true; } } catch (Exception e) { Logger.Log(e.Message); } finally { CloseConnection(connection); } return(success); }
public bool AddDolgozo(string newName, Osztaly group) { bool success = false; MySqlCommand command = new MySqlCommand(); MySqlConnection connection = getConnection(); command.Connection = connection; command.CommandType = System.Data.CommandType.StoredProcedure; command.CommandText = "AddDolgozo"; MySqlParameter name = new MySqlParameter() { Value = newName, DbType = System.Data.DbType.String, Direction = System.Data.ParameterDirection.Input, ParameterName = "newname" }; MySqlParameter csid = new MySqlParameter() { Value = group.Id, DbType = System.Data.DbType.Int32, Direction = System.Data.ParameterDirection.Input, ParameterName = "csid" }; command.Parameters.Add(name); command.Parameters.Add(csid); try { OpenConnection(connection); success = command.ExecuteNonQuery() == 0?false:true; } catch (Exception e) { Logger.Log(e.Message); } finally { CloseConnection(connection); } return(success); }
private void torlesOsztaly_Click(object sender, RoutedEventArgs e) { Osztaly selectedDept = (Osztaly)osztalyLista.SelectedItems[0]; MessageBoxResult valasz = System.Windows.MessageBox.Show("Biztosan törlöd?", "", System.Windows.MessageBoxButton.OKCancel); if (valasz == MessageBoxResult.OK) { var x = from akt in Adatbazis.AdatBazis.DataBase.Osztalyok where selectedDept.id == akt.Id select akt; foreach (var item in x) { Adatbazis.AdatBazis.DataBase.Osztalyok.Remove(item); } MessageBox.Show("Osztály törölve."); Adatbazis.AdatBazis.DataBase.SaveChanges(); OsztalyokFrissitese(); osztalyokMenuGomb_Click(sender, e); } }
static void Main(string[] args) { Osztaly o = new Osztaly(); }
public AddAndModifyOsztalyViewModel(Osztaly Osztaly) { ButtonText = "Módosítás"; this.Osztaly = Osztaly; this.NewName = Osztaly.Name; }