Example #1
0
        private void HandleItemNoConflict(Product prodToAdd)
        {
            char   append     = 'a';
            String tempItemNo = prodToAdd.ItemNo + append++;

            List <Product> prods = ProductDatabase.SearchProductsByItemNoOneWildCard(prodToAdd.ItemNo);

            for (int i = 0; i < prods.Count; i++)
            {
                if (prods[i].ItemNo == tempItemNo)
                {
                    if (prods[i].ItemDesc == prodToAdd.ItemDesc)
                    {
                        prodToAdd.ItemNo   = tempItemNo;
                        prodToAdd.ItemDesc = InsertEscape(prodToAdd.ItemDesc);
                        ProductDatabase.EditProduct(prodToAdd.ItemNo, prodToAdd.ItemNo, prodToAdd.ItemDesc, prodToAdd.PerCarton, prodToAdd.Location, prodToAdd.Cost, prodToAdd.SellPrice, prodToAdd.UPC);
                        return;
                    }
                    else
                    {
                        tempItemNo = prodToAdd.ItemNo + append++;
                    }
                }
            }
            prodToAdd.ItemNo   = tempItemNo;
            prodToAdd.ItemDesc = InsertEscape(prodToAdd.ItemDesc);
            ProductDatabase.AddProduct(prodToAdd.ItemNo, prodToAdd.ItemDesc, prodToAdd.PerCarton, prodToAdd.Location, prodToAdd.Cost, prodToAdd.SellPrice, prodToAdd.UPC);
        }
Example #2
0
 private static void SeedToys(int num)
 {
     for (int i = 1; i < num; i++)
     {
         ProductDatabase.AddProduct("A" + i, "desc" + i, i, "A" + i, i, i, i);
     }
     for (int i = 1; i < num; i++)
     {
         ProductDatabase.AddProduct("B" + i, "desc" + i, i, "B" + i, i, i, i);
     }
 }
Example #3
0
        static void SeedData()
        {
            ProvinceTaxDatabase.AddProvinceTax("ON1", 7, 5);
            ProvinceTaxDatabase.AddProvinceTax("ON2", 0, 5);
            ProvinceTaxDatabase.AddProvinceTax("BC1", 7, 12);
            ProvinceTaxDatabase.AddProvinceTax("BC2", 0, 5);
            ProvinceTaxDatabase.AddProvinceTax("BC3", 7, 5);
            ProvinceTaxDatabase.AddProvinceTax("AB1", 7, 5);


            ProductDatabase.AddProduct("12121", "Bouncy Ball", 1, "TSBK", 1.70, 2.50, 3242343, "may7");
            ProductDatabase.AddProduct("34523", "PlayDough", 6, "TS", 3.90, 4.99, 3453453, "discontinued");
            ProductDatabase.AddProduct("78666", "U-Fidget", 15, "TS", 1.25, 2.00, 5645334, "discontinued");
            ProductDatabase.AddProduct("34513", "Kaleidoscope", 20, "TS", 5.50, 6.50, 6433423, "jn9");
            ProductDatabase.AddProduct("89798", "PlayDough", 8, "TS", 1.20, 2.50, 2565443, "discontinued");
            ProductDatabase.AddProduct("45323", "Sidewalk Chalk", 12, "TS00", 5.50, 7.00, 4534634);
            ProductDatabase.AddProduct("89675", "Rubber Duck", 5, "TSD", 1.90, 2.20, 9678565);
            ProductDatabase.AddProduct("34921", "Baseball", 20, "TS2", 3.00, 3.50, 3527657);
            ProductDatabase.AddProduct("90243", "SuperSoaker", 1, "TS3", 10.50, 12.50, 7687432);
            ProductDatabase.AddProduct("43424", "Diving Sub", 10, "TS1", 3.50, 4.00, 1787424);
            ProductDatabase.AddProduct("42131", "Geo Twister", 4, "TS1", 1.50, 2.00, 2437583);
            ProductDatabase.AddProduct("14513", "Chicken Flingers", 16, "TS1", 8.50, 10.00, 5898275);
            ProductDatabase.AddProduct("24235", "Stunt Flyer", 18, "TS1", 4.00, 4.50, 4980240);



            CustomerDatabase.AddCustomer("Splash Toys", "", "*****@*****.**", "1201 Main st, Vancouver, BC  V6G9K7", "1201 Main st, Vancouver, BC  V6G9K7", "Nicole", "6047990643", "net30", "fedex", "BC2", "Kyle");
            CustomerDatabase.AddCustomer("Kaboodles", "", "*****@*****.**", "5601 Broadway st, Vancouver, BC  L6G9K7", "5601 Broadway st, Vancouver, BC  L6G9K7", "Ben", "6047342643", "credit", "canpar", "BC3", "Jake");
            CustomerDatabase.AddCustomer("Childrens Hospital", "Gift Shop", "*****@*****.**", "8901 Cambie st, Vancouver, BC  H7J9K0", "8901 Cambie st, Vancouver, BC  H7J9K0", "Sammy", "6045690643", "net30", "canpar", "BC1", "Kyle");
            CustomerDatabase.AddCustomer("Science World Edmonton", "Gift Shop", "*****@*****.**", "4745 Main st, Edmonton, AB  K7G5F4", "4745 Main st, Edmonton, AB  K7G5F4", "Julie", "6047670643", "net30", "canpar", "AB1", "Mike");

            int custID;

            custID = CustomerDatabase.GetStoreID("Splash Toys", "1201 Main st, Vancouver, BC  V6G9K7");
            InvoiceDatabase.AddInvoice(custID, "2312343", "", "", 0, 0, 0, 0, 1);
            InvoiceDatabase.UpdateBackorderSpecialNotes(custID, "monday only not friday");
            InvoiceContentsDatabase.AddInvoiceContent(1, "12121", 10, "2 Red");
            InvoiceContentsDatabase.AddInvoiceContent(1, "24235", 8, "");
            InvoiceContentsDatabase.AddInvoiceContent(1, "89675", 12, "1 Pink");
            InvoiceContentsDatabase.AddInvoiceContent(1, "90243", 2, "");
            InvoiceContentsDatabase.AddInvoiceContent(1, "43424", 5, "");

            custID = CustomerDatabase.GetStoreID("Kaboodles", "5601 Broadway st, Vancouver, BC  L6G9K7");
            InvoiceDatabase.AddInvoice(custID, "2312343", "", "", 0, 0, 0, 0, 2);
            InvoiceContentsDatabase.AddInvoiceContent(2, "45323", 10, "3 blue");
            InvoiceContentsDatabase.AddInvoiceContent(2, "34523", 8, "");
            InvoiceContentsDatabase.AddInvoiceContent(2, "34513", 12, "1 Pink");
            InvoiceContentsDatabase.AddInvoiceContent(2, "89798", 2, "");
            InvoiceContentsDatabase.AddInvoiceContent(2, "42131", 5, "");
        }
Example #4
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            Product prod = new Product("", "", 0, "", 0, 0, 0);
            int     tempCart;
            Int64   tempUPC;
            float   tempCost, tempPrice;
            //Workbook ex = Workbook.Load(file);
            Worksheet worksheet    = ex.Worksheets[0];
            int       maxRow       = worksheet.Cells.Rows.Count;
            double    readProgress = 100d / maxRow;

            for (int row = 0; row < maxRow; ++row)
            {
                if (backgroundWorker1.CancellationPending == true)
                {
                    e.Cancel = true;
                    break;
                }
                String errmsg = String.Empty;

                if (worksheet.Cells[row, 1].Value != null && worksheet.Cells[row, 1].Value.ToString().Length < 20)
                {
                    prod.ItemNo = worksheet.Cells[row, 1].Value.ToString();
                }
                else
                {
                    errmsg += (worksheet.Cells[row, 1].Value != null ? "Item number too long: " + worksheet.Cells[row, 1].Value
                        : "No Item Number detected") + " / ";
                }


                if (worksheet.Cells[row, 3].Value != null && worksheet.Cells[row, 3].Value.ToString().Length < 20)
                {
                    prod.Location = worksheet.Cells[row, 3].Value.ToString();
                }
                else
                {
                    errmsg += (worksheet.Cells[row, 3].Value != null ? "Item Location too long: " + worksheet.Cells[row, 3].Value
                        : "No Item Location detected") + " / ";
                }

                if (worksheet.Cells[row, 4].Value != null && worksheet.Cells[row, 4].Value.ToString().Length < 100)
                {
                    prod.ItemDesc = worksheet.Cells[row, 4].Value.ToString();
                }
                else
                {
                    errmsg += (worksheet.Cells[row, 4].Value != null ? "Item Description too long: " + worksheet.Cells[row, 4].Value
                        : "No Item Description detected") + " / ";
                }


                if (worksheet.Cells[row, 5].Value != null && Int32.TryParse(worksheet.Cells[row, 5].Value.ToString(), out tempCart))
                {
                    prod.PerCarton = tempCart;
                }
                else
                {
                    //errmsg += (worksheet.Cells[row, 4].Value != null ? "Invalid Carton: " + worksheet.Cells[row, 4].Value
                    //    : "No Carton detected") + " / ";
                    prod.PerCarton = 1;
                }

                prod.Cost = 0;

                /*
                 * if (worksheet.Cells[row, 11].Value != null && Single.TryParse(worksheet.Cells[row, 11].Value.ToString(), out tempCost))
                 * {
                 *  prod.Cost = tempCost;
                 * }
                 * else
                 * {
                 *  errmsg += (worksheet.Cells[row, 11].Value != null ? "Invalid Cost: " + worksheet.Cells[row, 11].Value
                 *      : "No Cost detected") + " / ";
                 * }
                 */

                if (worksheet.Cells[row, 13].Value != null && Single.TryParse(worksheet.Cells[row, 13].Value.ToString(), out tempPrice))
                {
                    prod.SellPrice = tempPrice;
                }
                else
                {
                    errmsg += (worksheet.Cells[row, 13].Value != null ? "Invalid Price: " + worksheet.Cells[row, 13].Value
                        : "No Price detected") + " / ";
                }

                if (worksheet.Cells[row, 10].Value != null && Int64.TryParse(worksheet.Cells[row, 10].Value.ToString(), out tempUPC))
                {
                    prod.UPC = tempUPC;
                }
                else
                {
                    prod.UPC = 0;
                }

                if (worksheet.Cells[row, 15].Value != null && worksheet.Cells[row, 15].Value.ToString().Length < 100)
                {
                    prod.SpecialNotes = worksheet.Cells[row, 15].Value.ToString();
                }
                else
                {
                    prod.SpecialNotes = String.Empty;
                }

                if (errmsg.Length != 0)
                {
                    errmsg = errmsg.Insert(0, "Error on spreadsheet row " + (row + 1) + ": ");
                    errors.Add(errmsg);
                    continue;
                }
                Product prodInDB = ProductDatabase.SearchProductByItemNo(prod.ItemNo);
                if (prodInDB == null)
                {
                    prod.ItemDesc = InsertEscape(prod.ItemDesc);
                    ProductDatabase.AddProduct(prod.ItemNo, prod.ItemDesc, prod.PerCarton, prod.Location, prod.Cost, prod.SellPrice, prod.UPC, prod.SpecialNotes);
                }
                else
                {
                    prod.ItemDesc = InsertEscape(prod.ItemDesc);
                    ProductDatabase.EditProduct(prod.ItemNo, prod.ItemNo, prodInDB.ItemDesc, prod.PerCarton, prod.Location, prod.Cost, prod.SellPrice, prod.UPC, prod.SpecialNotes);

                    /*
                     * if (prodInDB.ItemDesc == prod.ItemDesc)
                     * {
                     *  prod.ItemDesc = InsertEscape(prod.ItemDesc);
                     *  ProductDatabase.EditProduct(prod.ItemNo, prod.ItemNo, prod.ItemDesc, prod.PerCarton, prod.Location, prod.Cost, prod.SellPrice, prod.UPC);
                     * }
                     * else
                     * {
                     *  HandleItemNoConflict(prod);
                     * }*/
                }
                backgroundWorker1.ReportProgress((int)(readProgress * row));
            }
        }
Example #5
0
        private void submit_button_Click(object sender, EventArgs e)
        {
            Boolean allValid  = true;
            Boolean editValid = true;

            itemNo   = itemNumber_textBox.Text;
            itemDesc = itemDescription_textBox.Text;
            Int32.TryParse(cartonPack_textBox.Text, out perCarton);
            location = warehouseLoc_textBox.Text;
            Int64.TryParse(upc_textBox.Text, out upc);
            specNotes = specNote_textBox.Text;
            if (!editMode)
            {
                if (!validItemNumber(itemNo))
                {
                    allValid = false;
                    itemNumber_textBox.BackColor = Color.Red;
                }
                else
                {
                    itemNumber_textBox.BackColor = Color.White;
                }
            }
            if (itemDesc.Length == 0)
            {
                allValid  = false;
                editValid = false;
                itemDescription_textBox.BackColor = Color.Red;
            }
            else
            {
                itemDescription_textBox.BackColor = Color.White;
            }

            if (!Int32.TryParse(cartonPack_textBox.Text, out perCarton))
            {
                allValid  = false;
                editValid = false;
                cartonPack_textBox.BackColor = Color.Red;
            }
            else
            {
                cartonPack_textBox.BackColor = Color.White;
            }

            if (location.Length == 0)
            {
                allValid  = false;
                editValid = false;
                warehouseLoc_textBox.BackColor = Color.Red;
            }
            else
            {
                warehouseLoc_textBox.BackColor = Color.White;
            }

            if (!Double.TryParse(cost_textBox.Text, out cost))
            {
                allValid  = false;
                editValid = false;
                cost_textBox.BackColor = Color.Red;
            }
            else
            {
                cost_textBox.BackColor = Color.White;
            }

            if (!Double.TryParse(sellingPrice_textBox.Text, out sellPrice))
            {
                allValid  = false;
                editValid = false;
                sellingPrice_textBox.BackColor = Color.Red;
            }
            else
            {
                sellingPrice_textBox.BackColor = Color.White;
            }

            if (editMode == false && allValid)
            {
                ProductDatabase.AddProduct(itemNo, itemDesc, perCarton, location, cost, sellPrice, upc, specNotes);
                if (replacedItemNo != null)
                {
                    ProductDatabase.DeleteProductByItemNo(replacedItemNo);
                }
                DialogResult = DialogResult.OK;
                this.Close();
            }
            else if (editMode && editValid)
            {
                ProductDatabase.EditProduct(replacedItemNo, itemNo, itemDesc, perCarton, location, cost, sellPrice, upc, specNotes);
                DialogResult = DialogResult.OK;
                this.Close();
            }
        }