Exemple #1
0
        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);
        }
Exemple #2
0
        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();
            }
        }
Exemple #3
0
 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();
         }
     }
 }
Exemple #4
0
        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();
            }
        }
Exemple #5
0
        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();
            }
        }