public List <Rohware> GetRohwaren() { var rohwarenList = new List <Rohware>(); try { OpenDB(); com = con.CreateCommand(); com.CommandText = "SELECT * FROM tbl_roh;"; var reader = com.ExecuteReader(); while (reader.Read()) { var rohware = new Rohware( reader.GetInt32(0), !reader.IsDBNull(1) ? reader.GetString(1) : "", // Bezeichnung !reader.IsDBNull(2) ? reader.GetString(2) : "" // Einheit ); rohwarenList.Add(rohware); } } catch (Exception ex) { MessageBox.Show("GR: " + ex.Message); } finally { CloseDB(); } return(rohwarenList); }
private void btn_rohHinzufuegen_Click(object sender, EventArgs e) { var rohware = new Rohware(-1, tbx_rohBezeichnung.Text, tbx_rohEinheit.Text); db.AddRohware(rohware); GetLists(); PopulateLbxRohwaren(); if (lbx_fertigwaren.SelectedIndex > -1) { PopulateDgvStueckliste(); } }
private void btn_rohAktualisieren_Click(object sender, EventArgs e) { if (lbx_rohwaren.SelectedIndex > -1) { var rohware = new Rohware(Convert.ToInt32(tbx_rohArtNr.Text), tbx_rohBezeichnung.Text, tbx_rohEinheit.Text); db.UpdateRohware(rohware); GetLists(); PopulateLbxRohwaren(); if (lbx_fertigwaren.SelectedIndex > -1) { PopulateDgvStueckliste(); } } }
public void UpdateRohware(Rohware rohware) { try { OpenDB(); com = con.CreateCommand(); com.CommandText = String.Format("UPDATE tbl_roh SET roh_bezeichnung = '{0}', roh_einheit = '{1}' WHERE roh_id = {2};", rohware.Bezeichnung, rohware.Einheit, rohware.ArtNr.ToString()); com.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show("UR: " + ex.Message); } finally { CloseDB(); } }
public void AddRohware(Rohware rohware) { try { OpenDB(); com = con.CreateCommand(); com.CommandText = String.Format("INSERT INTO tbl_roh VALUES (null, '{0}', '{1}');", rohware.Bezeichnung, rohware.Einheit); com.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show("AR: " + ex.Message); } finally { CloseDB(); } }