Esempio n. 1
0
File: merge.cs Progetto: GB616/merge
        private static void compareValues(ArrayList dataFile1, ArrayList dataFile2)
        {
            ArrayList tmp      = new ArrayList();
            float     flag     = -1;
            ArrayList indexTab = new ArrayList();
            IComparer comp     = new myComparer();

            foreach (DataCustomer data1 in dataFile1)
            {
                foreach (DataCustomer data2 in dataFile2)
                {
                    if (data1.getCustomer() == data2.getCustomer() && data1.getProduct() == data2.getProduct())
                    {
                        DataCustomer tmpData = new DataCustomer(data1);
                        indexTab.Add(dataFile2.IndexOf(data2));

                        if (data2.getPrice() != flag)
                        {
                            tmpData.setPrice((float)data2.getPrice());
                        }
                        if (data2.getAmount() != flag)
                        {
                            tmpData.setAmount(data2.getAmount());
                        }
                        if ((float)data2.getQuantity() != flag)
                        {
                            tmpData.setQuantity(data2.getQuantity());
                        }
                        if ((float)data2.getInvoice() != flag)
                        {
                            tmpData.setInvoice(data2.getInvoice());
                        }
                        if (data2.getCost() != flag)
                        {
                            tmpData.setCost(data2.getCost());
                        }
                        tmp.Add(tmpData);
                    }
                }
            }

            removeFromArrayAtInexes(dataFile2, indexTab);

            dataFile1.Clear();
            addArrayList(dataFile1, tmp);
            addArrayList(dataFile1, dataFile2);
            dataFile1.Sort(comp);
        }
Esempio n. 2
0
File: merge.cs Progetto: GB616/merge
        private static void selectFunction(string field, string value, DataCustomer data)
        {
            int precision = 10;

            switch (field)
            {
            case "Customer":
                data.setCustomer(value.Trim());
                break;

            case "Product":
                data.setProduct(value.Trim());
                break;

            case "Price":
                data.setPrice(roundDigits(value, precision));
                break;

            case "Quantity":
                data.setQuantity(Int32.Parse(value));
                break;

            case "Cost":
                data.setCost(roundDigits(value, precision));
                break;

            case "Total Amount":
                data.setAmount(roundDigits(value, precision));
                break;

            case "Invoice Number":
                data.setInvoice(Int32.Parse(value));
                break;

            default:
                Console.WriteLine("Unknown field");
                break;
            }
        }