Esempio n. 1
0
        private void ProductList_UpdateRow(int rowIndex, String itemNo)
        {
            Product prod = ProductDatabase.SearchProductByItemNo(itemNo);

            productList.Items.RemoveAt(rowIndex);
            productList.Items.Insert(rowIndex, new ListViewItem(new String[] { prod.ItemNo, prod.ItemDesc, prod.PerCarton.ToString(), prod.Location, prod.Cost.ToString("0.00"), prod.SellPrice.ToString("0.00"), prod.UPC.ToString(), prod.SpecialNotes }));
        }
Esempio n. 2
0
        public ViewProduct()
        {
            InitializeComponent();
            AddButtons();
            productList.Size     = new Size(900, 500);
            productList.Location = new Point(50, 100);

            productList.Columns.Add("Item Number", 80, HorizontalAlignment.Left);
            productList.Columns.Add("Description", 275, HorizontalAlignment.Left);
            productList.Columns.Add("Carton Pack", -2, HorizontalAlignment.Left);
            productList.Columns.Add("Warehouse Location", -2, HorizontalAlignment.Left);
            productList.Columns.Add("Cost", 80, HorizontalAlignment.Left);
            productList.Columns.Add("Selling Price", 80, HorizontalAlignment.Left);
            productList.Columns.Add("UPC", -2, HorizontalAlignment.Left);
            productList.Columns.Add("Special Note", -2, HorizontalAlignment.Left);

            productList.GridLines     = true;
            productList.Scrollable    = true;
            productList.FullRowSelect = true;
            productList.View          = System.Windows.Forms.View.Details;
            productList.DoubleClick  += ProductList_DoubleClick;

            this.Controls.Add(productList);

            List <Product> list = ProductDatabase.SearchProductsByItemNo("");

            foreach (Product p in list)
            {
                productList.Items.Add(new ListViewItem(new String[] { p.ItemNo, p.ItemDesc, p.PerCarton.ToString(), p.Location, p.Cost.ToString("0.00"), p.SellPrice.ToString("0.00"), p.UPC.ToString(), p.SpecialNotes }));
            }
        }
Esempio n. 3
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);
        }
Esempio n. 4
0
        private void Qty_TextChanged(object sender, EventArgs e)
        {
            TextBox t       = (TextBox)sender;
            Product product = ProductDatabase.SearchProductByItemNo(this.panel1.Controls["itemNumber" + t.AccessibleName].Text);

            if (product != null && this.panel1.Controls["qty" + t.AccessibleName].Text.Length > 0)
            {
                if (this.panel1.Controls["qty" + t.AccessibleName].Text.Length == 1 && this.panel1.Controls["qty" + t.AccessibleName].Text == "-")
                {
                    return;
                }
                else
                {
                    this.panel1.Controls["amount" + t.AccessibleName].Text = (Single.Parse(this.panel1.Controls["qty" + t.AccessibleName].Text) * product.SellPrice).ToString("0.00");
                }
            }
            if (Int32.Parse(t.AccessibleName) == i)
            {
                AddItemBoxes();
            }

            if (this.panel1.Controls["itemNumber" + t.AccessibleName].Text.Length == 0 && this.panel1.Controls["qty" + t.AccessibleName].Text.Length == 0)
            {
                this.panel1.Controls["loc" + t.AccessibleName].Text          = "";
                this.panel1.Controls["desc" + t.AccessibleName].Text         = "";
                this.panel1.Controls["carton" + t.AccessibleName].Text       = "";
                this.panel1.Controls["cost" + t.AccessibleName].Text         = "";
                this.panel1.Controls["amount" + t.AccessibleName].Text       = "";
                this.panel1.Controls["specialNotes" + t.AccessibleName].Text = "";
            }
        }
Esempio n. 5
0
        public Invoice(int invoiceID)
        {
            // WholeSale Company Information
            CompanyName        = "Great West Wholesale LTD";
            CompanyAddress     = "1670 PANDORA ST. VANCOUVER, BC V5L 1L6";
            CompanyPhoneNumber = "604-255-9588";
            CompanyFax         = "604-255-9589";
            CompanyTollFree    = "1-800-901-9588";
            GSTNo = "R102186178";

            Items = new List <Product>();


            MySqlConnection conn = new MySqlConnection(LoginInfo.LoginCreds);

            try
            {
                conn.Open();
                MySqlCommand    cmd;
                MySqlDataReader rdr;
                String          sql;

                sql = "SELECT * FROM Invoices WHERE InvoiceID = " + invoiceID + ";";
                cmd = new MySqlCommand(sql, conn);
                rdr = cmd.ExecuteReader();

                if (rdr.HasRows)
                {
                    rdr.Read();

                    InvoiceID = Int32.Parse(rdr[0].ToString());

                    customer = CustomerDatabase.SearchCustomersByID(Int32.Parse(rdr[1].ToString()));

                    PurchaseOrder = rdr[2].ToString();



                    List <InvoiceContentInfo> items = InvoiceContentsDatabase.GetInvoiceContents(InvoiceID);
                    Product temp;
                    for (int i = 0; i < items.Count; i++)
                    {
                        temp = ProductDatabase.SearchProductByItemNo(items[i].ItemNo);
                        temp.SpecialNotes          = items[i].SpecialNotes;
                        temp.Quantity              = items[i].Quantity;
                        temp.BackOrder             = items[i].Backorder;
                        temp.BackOrderSpecialNotes = items[i].BackOrderSpecialNotes;
                        Items.Add(temp);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }

            conn.Close();
        }
Esempio n. 6
0
        private Boolean isUniqueItemNo(String itemNo)
        {
            Product result = ProductDatabase.SearchProductByItemNo(itemNo);

            if (result != null)
            {
                return(false);
            }
            return(true);
        }
Esempio n. 7
0
 public ExcelReadWindow(Workbook excelFile)
 {
     InitializeComponent();
     ex = excelFile;
     ProductDatabase.DeleteAllProducts();
     errors = new List <String>();
     backgroundWorker1.WorkerReportsProgress      = true;
     backgroundWorker1.WorkerSupportsCancellation = true;
     backgroundWorker1.RunWorkerAsync();
 }
Esempio n. 8
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);
     }
 }
Esempio n. 9
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, "");
        }
Esempio n. 10
0
        private void ItemNumber_LostFocus(object sender, EventArgs e)
        {
            ComboBox c = (ComboBox)sender;

            if (c.Items.Count == 0)
            {
                return;
            }
            Product product = ProductDatabase.SearchProductByItemNo(c.Text);

            if (product != null)
            {
                this.panel1.Controls["loc" + c.AccessibleName].Text          = product.Location;
                this.panel1.Controls["desc" + c.AccessibleName].Text         = product.ItemDesc;
                this.panel1.Controls["carton" + c.AccessibleName].Text       = product.PerCarton.ToString();
                this.panel1.Controls["cost" + c.AccessibleName].Text         = product.SellPrice.ToString("0.00");
                this.panel1.Controls["specialNotes" + c.AccessibleName].Text = product.SpecialNotes;

                if (this.panel1.Controls["qty" + c.AccessibleName].Text.Length > 0)
                {
                    if (this.panel1.Controls["qty" + c.AccessibleName].Text.Length == 1 && this.panel1.Controls["qty" + c.AccessibleName].Text == "-")
                    {
                        return;
                    }
                    else
                    {
                        this.panel1.Controls["amount" + c.AccessibleName].Text = (Single.Parse(this.panel1.Controls["qty" + c.AccessibleName].Text) * product.SellPrice).ToString("0.00");
                    }
                }
            }

            if (Int32.Parse(c.AccessibleName) == i)
            {
                AddItemBoxes();
            }

            //qty and itemNo empty
            if (this.panel1.Controls["itemNumber" + c.AccessibleName].Text.Length == 0 && this.panel1.Controls["qty" + c.AccessibleName].Text.Length == 0)
            {
                this.panel1.Controls["loc" + c.AccessibleName].Text    = "";
                this.panel1.Controls["desc" + c.AccessibleName].Text   = "";
                this.panel1.Controls["carton" + c.AccessibleName].Text = "";
                this.panel1.Controls["cost" + c.AccessibleName].Text   = "";
                this.panel1.Controls["amount" + c.AccessibleName].Text = "";
            }
        }
Esempio n. 11
0
 private void itemNumber_textBox_TextChanged(object sender, EventArgs e)
 {
     if (editMode == false)
     {
         if (ProductDatabase.SearchProductByItemNo(itemNumber_textBox.Text) != null)
         {
             itemNumber_textBox.BackColor = Color.Red;
         }
         else
         {
             itemNumber_textBox.BackColor = Color.White;
         }
     }
     else
     {
         itemNumber_textBox.BackColor = Color.White;
     }
 }
Esempio n. 12
0
        private void C_TextUpdated(object sender, EventArgs e)
        {
            ComboBox c = (ComboBox)sender;

            c.DroppedDown = true;

            c.Items.Clear();
            c.SelectionLength = 0;

            c.SelectionStart = c.Text.Length;

            List <Product> productList = ProductDatabase.SearchProductsByItemNo(c.Text);

            Object[] arr = new Object[productList.Count];
            for (int j = 0; j < productList.Count; j++)
            {
                arr[j] = productList[j].ItemNo;
            }
            c.Items.AddRange(arr);
        }
Esempio n. 13
0
 private void DeleteProduct_Click(object sender, EventArgs e)
 {
     if (productList.SelectedItems.Count > 0)
     {
         var confirmResult = MessageBox.Show("Are you sure you want to Delete these item(s)?",
                                             "Confirm Delete!!",
                                             MessageBoxButtons.YesNo);
         if (confirmResult == DialogResult.Yes)
         {
             foreach (ListViewItem l in productList.SelectedItems)
             {
                 ProductDatabase.DeleteProductByItemNo(l.SubItems[0].Text);
             }
             RefreshView();
         }
         else
         {
             // If 'No', do something here.
         }
     }
 }
Esempio n. 14
0
        private void RefreshView()
        {
            foreach (ListViewItem lvItem in productList.Items)
            {
                productList.Items.Remove(lvItem);
            }
            List <Product> list;

            if (productTextBox.Text.Length == 0)
            {
                list = ProductDatabase.SearchProductsByItemNo("");
            }
            else
            {
                list = ProductDatabase.SearchProductsByItemNo(productTextBox.Text);
                list.AddRange(ProductDatabase.SearchProductsByDesc(productTextBox.Text));
            }
            foreach (Product p in list)
            {
                productList.Items.Add(new ListViewItem(new String[] { p.ItemNo, p.ItemDesc, p.PerCarton.ToString(), p.Location, p.Cost.ToString("0.00"), p.SellPrice.ToString("0.00"), p.UPC.ToString(), p.SpecialNotes }));
            }
        }
Esempio n. 15
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));
            }
        }
Esempio n. 16
0
        private void AddItemBoxes()
        {
            for (int i = 0; i < invoiceContentsList.Count; i++)
            {
                Product p = ProductDatabase.SearchProductByItemNo(invoiceContentsList[i].ItemNo);

                TextBox qty = new TextBox();
                qty.Location       = new Point(0, 0 + i * 25);
                qty.Size           = new Size(30, 25);
                qty.Name           = "qty" + i;
                qty.Text           = (invoiceContentsList[i].Quantity).ToString();
                qty.ReadOnly       = true;
                qty.Enter         += Desc_Enter;
                qty.AccessibleName = "" + i;
                panel1.Controls.Add(qty);

                TextBox itemNumber = new TextBox();
                itemNumber.Location       = new Point(50, 0 + i * 25);
                itemNumber.Size           = new Size(100, 25);
                itemNumber.Text           = invoiceContentsList[i].ItemNo;
                itemNumber.ReadOnly       = true;
                itemNumber.Name           = "itemNumber" + i;
                itemNumber.Enter         += Desc_Enter;
                itemNumber.AccessibleName = "" + i;
                panel1.Controls.Add(itemNumber);

                TextBox loc = new TextBox();
                loc.Location       = new Point(170, 0 + i * 25);
                loc.Size           = new Size(50, 25);
                loc.Text           = p.Location;
                loc.ReadOnly       = true;
                loc.Enter         += Desc_Enter;
                loc.Name           = "loc" + i;
                loc.AccessibleName = "" + i;
                panel1.Controls.Add(loc);

                TextBox desc = new TextBox();
                desc.Location       = new Point(240, 0 + i * 25);
                desc.Size           = new Size(200, 25);
                desc.Text           = p.ItemDesc;
                desc.ReadOnly       = true;
                desc.Enter         += Desc_Enter;
                desc.Name           = "desc" + i;
                desc.AccessibleName = "" + i;
                panel1.Controls.Add(desc);

                TextBox cartonPack = new TextBox();
                cartonPack.Location       = new Point(460, 0 + i * 25);
                cartonPack.Size           = new Size(30, 25);
                cartonPack.Text           = p.PerCarton.ToString();
                cartonPack.ReadOnly       = true;
                cartonPack.Enter         += Desc_Enter;
                cartonPack.Name           = "carton" + i;
                cartonPack.AccessibleName = "" + i;
                panel1.Controls.Add(cartonPack);

                TextBox cost = new TextBox();
                cost.Location       = new Point(510, 0 + i * 25);
                cost.Size           = new Size(50, 25);
                cost.Text           = p.Cost.ToString("0.00");
                cost.ReadOnly       = true;
                cost.Enter         += Desc_Enter;
                cost.Name           = "cost" + i;
                cost.AccessibleName = "" + i;
                panel1.Controls.Add(cost);

                TextBox amount = new TextBox();
                amount.Location       = new Point(580, 0 + i * 25);
                amount.Size           = new Size(50, 25);
                amount.Text           = (Single.Parse(this.panel1.Controls["qty" + i].Text) * p.Cost).ToString("0.00");
                amount.ReadOnly       = true;
                amount.Enter         += Desc_Enter;
                amount.Name           = "amount" + i;
                amount.AccessibleName = "" + i;
                amount.TextChanged   += Amount_TextChanged;
                panel1.Controls.Add(amount);

                TextBox specialNotes = new TextBox();
                specialNotes.Location       = new Point(640, 0 + i * 25);
                specialNotes.Size           = new Size(140, 25);
                specialNotes.Text           = invoiceContentsList[i].SpecialNotes;
                specialNotes.Name           = "specialNotes" + i;
                specialNotes.AccessibleName = "" + i;
                specialNotes.ReadOnly       = true;
                panel1.Controls.Add(specialNotes);

                if (invoiceContentsList[i].Backorder > 0)
                {
                    TextBox backorder = new TextBox();
                    backorder.Location       = new Point(790, 0 + i * 25);
                    backorder.Size           = new Size(30, 25);
                    backorder.Name           = "backorder" + i;
                    backorder.AccessibleName = "" + i;
                    backorder.Text           = invoiceContentsList[i].Backorder.ToString();
                    backorder.TextChanged   += Backorder_TextChanged;
                    backorder.ReadOnly       = true;
                    panel1.Controls.Add(backorder);

                    TextBox backorderNotes = new TextBox();
                    backorderNotes.Location       = new Point(830, 0 + i * 25);
                    backorderNotes.Size           = new Size(50, 25);
                    backorderNotes.Name           = "backorderNotes" + i;
                    backorderNotes.AccessibleName = "" + i;
                    backorderNotes.ReadOnly       = true;
                    panel1.Controls.Add(backorderNotes);
                }
            }
        }
Esempio n. 17
0
        public Invoice(int invoiceID)
        {
            // WholeSale Company Information
            CompanyName        = "Great West Wholesale LTD";
            CompanyAddress     = "1670 PANDORA ST. VANCOUVER, BC V5L 1L6";
            CompanyPhoneNumber = "604-255-9588";
            CompanyFax         = "604-255-9589";
            CompanyTollFree    = "1-800-901-9588";
            GSTNo = "R102186178";

            Items = new List <Product>();
            String pswd    = "password";
            String user    = "******";
            String connStr = "server=localhost;user="******";database=GWW;port=3306;password="******"SELECT * FROM Invoices WHERE InvoiceID = " + invoiceID + ";";
                cmd = new MySqlCommand(sql, conn);
                rdr = cmd.ExecuteReader();

                //InvoiceID | StoreID | PurchaseOrder | SpecialNotes | InvoiceNo | SubTotal | Gst | Pst | NetTotal | Stage |

                if (rdr.HasRows)
                {
                    rdr.Read();

                    InvoiceID = Int32.Parse(rdr[0].ToString());

                    customer = CustomerDatabase.SearchCustomersByID(Int32.Parse(rdr[1].ToString()));

                    CustomerName          = customer.StoreName;
                    CustomerContact       = customer.StoreContact;
                    CustomerAddress       = customer.ShippingAddress;
                    CustomerPhone         = customer.PhoneNumber;
                    CustomerTerms         = customer.PaymentTerms;
                    CustomerShippingTerms = customer.ShippingInstructions;

                    PurchaseOrder = rdr[2].ToString();

                    SpecialNotes = rdr[3].ToString();

                    BackorderNotes = rdr[4].ToString();
                    InvoiceNo      = rdr[5].ToString();
                    SubTotal       = Single.Parse(rdr[6].ToString());

                    Gst      = Single.Parse(rdr[7].ToString());
                    Pst      = Single.Parse(rdr[8].ToString());
                    NetTotal = Single.Parse(rdr[9].ToString());
                    freight  = Single.Parse(rdr[10].ToString());
                    Stage    = Int32.Parse(rdr[11].ToString());

                    List <InvoiceContentInfo> items = InvoiceContentsDatabase.GetInvoiceContents(InvoiceID);
                    Product temp;
                    for (int i = 0; i < items.Count; i++)
                    {
                        temp = ProductDatabase.SearchProductByItemNo(items[i].ItemNo);
                        temp.SpecialNotes          = items[i].SpecialNotes;
                        temp.Quantity              = items[i].Quantity;
                        temp.BackOrder             = items[i].Backorder;
                        temp.BackOrderSpecialNotes = items[i].BackOrderSpecialNotes;
                        Items.Add(temp);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }

            conn.Close();
        }
Esempio n. 18
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();
            }
        }