Beispiel #1
0
 private Placering(int id, string hylde, string plads, Vare vare)
 {
     this.id    = id;
     this.hylde = hylde;
     this.plads = plads;
     this.vare  = vare;
 }
Beispiel #2
0
        //Adds an ITEM in to the database look in "Firma" class under Addvare Method for more info
        static private void AddData(Firma P)
        {
            Console.Clear();
            Console.WriteLine(" _______________________________ ");
            Console.WriteLine("| Navn:                         |");
            Console.WriteLine("| Pris:                         |");
            Console.WriteLine("| Antal:                        |");
            Console.WriteLine("|_______________________________|");
            Console.SetCursorPosition(8, 1);
            string varenavn = Console.ReadLine();

            Console.SetCursorPosition(8, 2);
            string prisstr = Console.ReadLine();
            double pris    = Double.Parse(prisstr);

            Console.SetCursorPosition(9, 3);
            int antal = Convert.ToInt32(Console.ReadLine());

            Console.SetCursorPosition(0, 5);
            Vare V = new Vare(varenavn, pris, antal);

            P.AddVare(V);
            Console.WriteLine("Succesfully Inserted Item into Database");
            Console.Write("Press any key to continue...");
            Console.ReadLine();
            Menu(P);
        }
Beispiel #3
0
        //Adds an ITEM to the database using the Insert method in SQLconnection
        //Tries to replace , with . in the price because if there is a , in the database it cannot display the , in the Console
        //Also we can't write . to begin with because the convert to double removes the . from the variable
        public void AddVare(Vare P)
        {
            varer.Add(P);
            string pris  = P.Pris.ToString().Replace(",", ".");
            string query = $"INSERT INTO Vare (navn, pris, stock) VALUES ('{P.Navn}','{pris}','{P.Antal}')";

            Insert(query);
        }
Beispiel #4
0
        public Placering Get(int id)
        {
            DataTable dataTable      = new DataTable();
            string    placeringQuery = $"SELECT * FROM Placering WHERE id = {id}";

            dataTable = Select(placeringQuery);
            foreach (DataRow row in dataTable.Rows)
            {
                return(new Placering(Convert.ToInt32(row.ItemArray[0]), row.ItemArray[1].ToString(), row.ItemArray[2].ToString(), Vare.Get(Convert.ToInt32(row.ItemArray[3]))));
            }
            return(null);
        }
Beispiel #5
0
 public Placering(string hylde, string plads, Vare vare)
 {
     this.hylde = hylde;
     this.plads = plads;
     this.vare  = vare;
 }