Esempio n. 1
0
        public static List <Nadal> GetNadalValues(OleDbConnection connection)
        {
            string query =
                "SELECT * FROM Nadalad";
            OleDbCommand    command = new OleDbCommand(query, connection);
            OleDbDataReader reader  = command.ExecuteReader();

            List <Nadal> nadalad = new List <Nadal>();

            while (reader.Read())
            {
                Toode toode = new Toode();
                toode.TooteID = Convert.ToInt32(reader["TooteID"]);
                toode.Hind    = reader["Hind"].ToString();
                int nadalNumber = Convert.ToInt32(reader["Nadal"]);
                int nadalIndex  = DoesNadalExist(nadalad, nadalNumber);
                if (nadalIndex == -1)
                {
                    Nadal nadal = new Nadal();
                    nadal.NadalNumber = nadalNumber;
                    nadal.AddToode(toode);
                    nadalad.Add(nadal);
                }
                else
                {
                    nadalad[nadalIndex].AddToode(toode);
                }
            }
            return(nadalad);
        }
Esempio n. 2
0
        public static void InsertToDatabase(Toode item, OleDbConnection connection)
        {
            item.TooteKirjeldus = item.TooteKirjeldus.Replace("'", "''");

            string query =
                "INSERT INTO Hinnakiri (TooteGrupp, Tootja, Toode, Hind) " +
                $"VALUES ('{item.TooteGrupp}', '{item.Tootja}', '{item.TooteKirjeldus}', '{item.Hind}')";

            OleDbCommand command = new OleDbCommand(query, connection);

            command.ExecuteNonQuery();
        }
Esempio n. 3
0
        private List <string> GetDifference(Nadal nadal1, Nadal nadal2)
        {
            List <string> differences   = new List <string>();
            List <int>    checkedIDlist = new List <int>();

            for (int i = 0; i < nadal1.Tooted.Count; i++)
            {
                Toode toode1 = nadal1.Tooted[i];
                Toode toode2 = nadal2.Tooted.Find(j => j.TooteID == toode1.TooteID);

                //If there is not equilevant to toode1, its new or deleted
                if (toode2 == null)
                {
                    differences.Add($"{nadal1.NadalNumber}.nadalal oli toode {toode1.TooteID} mida polnud {nadal2.NadalNumber}.nadalal");
                }
                else if (toode2.Hind != toode1.Hind)
                {
                    differences.Add($"{nadal1.NadalNumber}.nadal = {toode1.TooteID} = {toode1.Hind} EUR | {nadal2.NadalNumber}.nadalal = {toode2.TooteID} = {toode2.Hind} EUR");
                }
                checkedIDlist.Add(toode1.TooteID);
            }
            for (int i = 0; i < nadal2.Tooted.Count; i++)
            {
                Toode toode1 = nadal2.Tooted[i];
                Toode toode2 = nadal1.Tooted.Find(j => j.TooteID == toode1.TooteID);

                //If already checked previously then continue;
                if (checkedIDlist.Contains(toode1.TooteID))
                {
                    continue;
                }
                //If there is not equilevant to toode1, its new or deleted
                if (toode2 == null)
                {
                    differences.Add($"{nadal2.NadalNumber}.nadalal oli toode {toode1.TooteID} mida polnud {nadal1.NadalNumber}.nadalal");
                }
                else if (toode2.Hind != toode1.Hind)
                {
                    differences.Add($"{nadal2.NadalNumber}.nadal = {toode1.TooteID} = {toode1.Hind} EUR | {nadal1.NadalNumber}.nadalal = {toode2.TooteID} = {toode2.Hind} EUR");
                }
                checkedIDlist.Add(toode1.TooteID);
            }
            JO_Lbl_DifferenceCount.Text = differences.Count.ToString();

            return(differences);
        }
Esempio n. 4
0
 public void AddToode(Toode toode)
 {
     Tooted.Add(toode);
 }