private void DeleteLine(int a_line) { try{ int start_index = ProdukteBox.GetFirstCharIndexFromLine(a_line); int count = ProdukteBox.Lines[a_line].Length; // Eat new line chars if (a_line < ProdukteBox.Lines.Length - 1) { count += ProdukteBox.GetFirstCharIndexFromLine(a_line + 1) - ((start_index + count - 1) + 1); } string lastPart = ProdukteBox.Lines[a_line].Split('-').Last(); if (lastPart != null) { IDErrorLabel.Visible = false; lastPart = lastPart.Remove(lastPart.Length - 1); price -= float.Parse(lastPart, System.Globalization.CultureInfo.InvariantCulture); updatePreis(); ProdukteBox.Text = ProdukteBox.Text.Remove(start_index, count); ProdukteBox.Refresh(); IDErrorLabel.Visible = false; } else { IDErrorLabel.Visible = true; } } catch { IDErrorLabel.Visible = true; } }
private void addProd(string name, string preis, float fpreis) { id += 1; produkte.Add(new Tuple <string, int>(name, id)); price += fpreis; preisListe.Add(fpreis); updatePreis(); string leer; if (id >= 10) { leer = " "; } else { leer = " "; } ProdukteBox.AppendText("\r\n " + id + "." + leer + name + " - " + preis); ProdukteBox.ScrollToCaret(); ProdukteBox.Refresh(); }