private void btnCreareCont_Click(object sender, RoutedEventArgs e) { CategoriiProdus cp = new CategoriiProdus(categorieTextBox.Text); try { if (CategoriiProdusBLL.findCategorie(cp) == null) { if (cp.Categorie.ToString().Length > 0) { CategoriiProdusBLL.insertCategorie(cp); listaProduseWindow.populateComboBox(); MessageBox.Show("Categoria a fost introdusa cu succes!"); this.Close(); } else { MessageBox.Show("Camp vid!"); } } else { MessageBox.Show("Aceasta categorie exista deja!"); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public static List <Object> createListOfObjects(string query, string tip) { List <Object> list = new List <Object>(); MySqlConnection conn = ConnectionFactory.getConnection(); cmd.Connection = conn; cmd.CommandText = query; try { conn.Open(); MySqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { Object o = null; if (tip == "Cont") { o = new Cont(Convert.ToString(rdr["username"]), Convert.ToString(rdr["pass"]), Convert.ToChar(rdr["rol"])); } else if (tip == "CategoriiProdus") { o = new CategoriiProdus(Convert.ToString(rdr["categorie"])); } else if (tip == "Client") { o = new Client(Convert.ToInt32(rdr["idClient"]), Convert.ToString(rdr["username"]), Convert.ToString(rdr["nume"]), Convert.ToString(rdr["prenume"]), Convert.ToString(rdr["cnp"]), Convert.ToString(rdr["adresaLivrare"]), Convert.ToString(rdr["nrTelefon"]), Convert.ToString(rdr["email"]), Convert.ToChar(rdr["eClientLoial"])); } else if (tip == "Comanda") { o = new Comanda(Convert.ToInt32(rdr["idComanda"]), Convert.ToInt32(rdr["idClient"]), Convert.ToString(rdr["dataComanda"]), Convert.ToDouble(rdr["pretTotal"]), Convert.ToString(rdr["modalitatePlata"])); } else if (tip == "DetaliiComanda") { o = new DetaliiComanda(Convert.ToInt32(rdr["idComanda"]), Convert.ToString(rdr["numeProdus"]), Convert.ToDouble(rdr["pret"]), Convert.ToInt32(rdr["cantitate"])); } else if (tip == "Produs") { o = new Produs(Convert.ToInt32(rdr["idProdus"]), Convert.ToString(rdr["categorie"]), Convert.ToString(rdr["nume"]), Convert.ToString(rdr["descriere"]), Convert.ToInt32(rdr["gramaj"]), Convert.ToDouble(rdr["pret"])); } list.Add(o); } rdr.Close(); } catch (Exception ex) { System.Windows.MessageBox.Show(ex.ToString()); } finally { ConnectionFactory.close(conn); } return(list); }
public static Object select(Object obj, string tip) { Object o = null; MySqlConnection conn = ConnectionFactory.getConnection(); cmd.Connection = conn; cmd.CommandText = selectQuery(obj, tip); try { //System.Windows.MessageBox.Show(cmd.CommandText.ToString()); conn.Open(); MySqlDataReader rdr = cmd.ExecuteReader(); if (rdr.Read()) { //System.Windows.MessageBox.Show(rdr["username"].ToString() + ", " + rdr["pass"].ToString() + ", " + rdr["rol"].ToString()); if (tip == "Cont") { o = new Cont(Convert.ToString(rdr["username"]), Convert.ToString(rdr["pass"]), Convert.ToChar(rdr["rol"])); } else if (tip == "CategoriiProdus") { o = new CategoriiProdus(Convert.ToString(rdr["categorie"])); } rdr.Close(); } } catch (Exception e) { System.Windows.MessageBox.Show(e.ToString()); } finally { ConnectionFactory.close(conn); } return(o); }
public static CategoriiProdus findCategorie(CategoriiProdus obj) { return((CategoriiProdus)(ReflectionDAO.select(obj, "CategoriiProdus"))); }
public static void insertCategorie(CategoriiProdus obj) { ReflectionDAO.insert(obj, "CategoriiProdus"); }