Beispiel #1
0
        private async void button1_Click(object sender, EventArgs e)
        {
            if (((customer_name_textbox.Text != "") && customer_phoneno_textbox.Text != ""))
            {
                Connect.exec("UPDATE Invoice SET Invoice_Date = Now() WHERE Invoice_No = " + getVar.invoice_no + ";");
                Connect.exec("UPDATE Invoice SET Customer_ID = '1' WHERE Invoice_No = " + getVar.invoice_no + ";");
                Connect.exec("UPDATE Invoice SET Customer_Name = '" + customer_name_textbox.Text + "' WHERE Invoice_No = " + getVar.invoice_no + ";");
                Connect.exec("UPDATE Invoice SET Total_amount = " + total_textbox.Text + " WHERE Invoice_No = " + getVar.invoice_no + ";");

                Connect.exec("UPDATE Invoice SET Cus_Phoneno = '" + customer_phoneno_textbox.Text + "' WHERE Invoice_No = " + getVar.invoice_no + ";");

                Connect.exec("UPDATE Invoice SET Pay_Status = True WHERE Invoice_No = " + getVar.invoice_no + ";");

                paystatus.Text     = "Contacting to the card company";
                progressBar1.Value = 50;
                await Task.Delay(2000);

                paystatus.Text     = "Payment complete";
                progressBar1.Value = 100;
                Invoice report = new Invoice();
                report.Show();
            }
            else
            {
                MessageBox.Show("Please fill in all the information!");
            }
        }
Beispiel #2
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (Product_name.Text == "" || price.Text == "" || dimension.Text == "" || reorderinglevel.Text == "" || shelf_loc.Text == "" ||
         discount_tb.Text == "" || quantity.Text == "" || category.Text == "" || description.Text == "" || subCategory.Text == "")
     {
         MessageBox.Show("Please input all field!");
     }
     else
     {
         String catID = "";
         Table = Connect.query("SELECT Category_ID from Category WHERE Category_Name = '" + category.Text + "'");
         catID = Table.Rows[0][0].ToString();
         Connect.exec("INSERT INTO Product( Product_ID, Product_Name,Product_Price,Discounts ) VALUES ('" + product_id.Text + "','" + Product_name.Text + "','" + price.Text + "','" + discount_tb.Text + "')");
         Connect.exec("INSERT INTO Stock(Product_ID, Category_ID,Quantity,Reordering_level,Shelf_location,Description,Dimension) VALUES ('" + product_id.Text + "','" + catID + "','" + quantity.Text + "', '" + reorderinglevel.Text + "','" + shelf_loc.Text + "', '" + description.Text + "', '" + dimension.Text + "')");
         MessageBox.Show("Add successful");
         Product_name.Text    = "";
         price.Text           = "";
         dimension.Text       = "";
         reorderinglevel.Text = "";
         shelf_loc.Text       = "";
         discount_tb.Text     = "";
         quantity.Text        = "";
         description.Text     = "";
         Table           = Connect.query("SELECT max(Product_ID)+1 from Product WHERE Deleted = False;");
         product_id.Text = Table.Rows[0][0].ToString();
     }
 }
Beispiel #3
0
        private void delete_button_Click(object sender, EventArgs e)
        {
            DialogResult result1 = MessageBox.Show("Are you sure you want to delete this item?",
                                                   "Warning",
                                                   MessageBoxButtons.YesNo,
                                                   MessageBoxIcon.Warning);

            if (result1 == DialogResult.Yes)
            {
                Connect.exec("UPDATE Product SET Deleted=True WHERE Product.Product_ID = " + product_IDTextBox.Text + ";");
                Close();
            }
        }
Beispiel #4
0
 private void confirm_button_Click(object sender, EventArgs e)
 {
     Connect.exec("UPDATE Product SET Product_Name='" + product_NameTextBox.Text + "' ,Discounts= '" + discountsTextBox.Text + "',Product_Price= '" + product_PriceTextBox.Text + "' WHERE Product_ID = " + product_IDTextBox.Text + ";");
     Connect.exec("UPDATE Stock SET Quantity='" + quantity_textbox.Text + "',Reordering_level= '" + reordering_levelTextBox.Text + "',Shelf_location = '" + shelf_locationTextBox.Text + "',Description= '" + descriptionRichTextBox.Text + "',Dimension= '" + dimensionTextBox.Text + "' WHERE Product_ID = " + product_IDTextBox.Text + ";");
     MessageBox.Show("Update Success!");
 }
Beispiel #5
0
        private void button3_Click(object sender, EventArgs e)
        {
            if (orderqty_textbox.Text != "" && quantity_textbox.Text != "" && (Int32.Parse(quantity_textbox.Text) >= Int32.Parse(orderqty_textbox.Text)))
            {
                Table_Temp        = Connect.query("SELECT max(Invoice_No) FROM Invoice WHERE (Pay_Status=False AND Using_Status=True);");
                getVar.invoice_no = Table_Temp.Rows[0][0].ToString();
                Table_Temp        = Connect.query("SELECT max(Invoice_No)+1 FROM Invoice WHERE (Pay_Status=True AND Using_Status=True);");
                string old_invoice_no = Table_Temp.Rows[0][0].ToString();
                if (getVar.invoice_no == "" && old_invoice_no == "")
                {
                    getVar.invoice_no     = "1";
                    quantity_textbox.Text = (Int32.Parse(quantity_textbox.Text) - Int32.Parse(orderqty_textbox.Text)).ToString();

                    Connect.exec("INSERT INTO Invoice(Invoice_No,Store_ID,Using_Status) VALUES ('" + getVar.invoice_no.ToString() + "','" + getVar.storeID.ToString() + "',True)");

                    Connect.exec("INSERT INTO Product_Invoice( Invoice_No,Product_ID,Quantity,Deposit ) VALUES ('" + getVar.invoice_no.ToString() + "','" + product_IDTextBox.Text + "','" + orderqty_textbox.Text + "','" + product_PriceTextBox.Text + "')");

                    Connect.exec("UPDATE Stock SET Quantity='" + quantity_textbox.Text + "' WHERE Product_ID = " + product_IDTextBox.Text + ";");
                    MessageBox.Show("Add order complete!");
                }
                else if ((old_invoice_no.ToString() == "") && (getVar.invoice_no == "1"))
                {
                    quantity_textbox.Text = (Int32.Parse(quantity_textbox.Text) - Int32.Parse(orderqty_textbox.Text)).ToString();

                    Table_Temp = Connect.query("SELECT Quantity FROM Product_Invoice WHERE (Invoice_No = " + getVar.invoice_no.ToString() + " AND Product_ID= " + product_IDTextBox.Text + ");");
                    if (!(Table_Temp.Rows.Count == 0))
                    {
                        int temp = Int32.Parse(Table_Temp.Rows[0][0].ToString()) + Int32.Parse(orderqty_textbox.Value.ToString());



                        Connect.exec("UPDATE Product_invoice SET Quantity='" + temp + "' WHERE Product_ID = " + product_IDTextBox.Text + ";");

                        Connect.exec("UPDATE Stock SET Quantity='" + quantity_textbox.Text + "' WHERE Product_ID = " + product_IDTextBox.Text + ";");
                        MessageBox.Show("Add order complete!");
                    }
                    else
                    { //duplocate
                        Connect.exec("INSERT INTO Product_invoice(Quantity,Product_ID,Invoice_No,Deposit) VALUES('" + orderqty_textbox.Value.ToString() + "','" + product_IDTextBox.Text + "','" + getVar.invoice_no.ToString() + "','" + product_PriceTextBox.Text + "')");

                        Connect.exec("UPDATE Stock SET Quantity='" + quantity_textbox.Text + "' WHERE Product_ID = " + product_IDTextBox.Text + ";");
                        MessageBox.Show("Add order complete!");
                    }
                }

                else if ((getVar.invoice_no != "") && (old_invoice_no.ToString() != ""))
                {
                    Table_Temp = Connect.query("SELECT Quantity FROM Product_Invoice WHERE (Invoice_No = " + getVar.invoice_no.ToString() + " AND Product_ID= " + product_IDTextBox.Text + ");");
                    if (!(Table_Temp.Rows.Count == 0))
                    {
                        int temp = Int32.Parse(Table_Temp.Rows[0][0].ToString()) + Int32.Parse(orderqty_textbox.Value.ToString());



                        Connect.exec("UPDATE Product_invoice SET Quantity='" + temp + "' WHERE Product_ID = " + product_IDTextBox.Text + ";");

                        Connect.exec("UPDATE Stock SET Quantity='" + quantity_textbox.Text + "' WHERE Product_ID = " + product_IDTextBox.Text + ";");
                        MessageBox.Show("Add order complete!");
                    }
                    else
                    {
                        Connect.exec("INSERT INTO Product_invoice(Quantity,Product_ID,Invoice_No,Deposit) VALUES('" + orderqty_textbox.Value.ToString() + "','" + product_IDTextBox.Text + "','" + old_invoice_no.ToString() + "','" + product_PriceTextBox.Text + "')");

                        Connect.exec("UPDATE Stock SET Quantity='" + quantity_textbox.Text + "' WHERE Product_ID = " + product_IDTextBox.Text + ";");
                        MessageBox.Show("Add order complete!");
                    }
                }
                else
                {
                    Connect.exec("INSERT INTO Invoice(Invoice_No,Store_ID,Using_Status) VALUES ('" + old_invoice_no + "','" + getVar.storeID.ToString() + "',True)");

                    Connect.exec("INSERT INTO Product_Invoice( Product_ID,Quantity,Deposit,Invoice_No ) VALUES ('" + product_IDTextBox.Text + "','" + orderqty_textbox.Text + "','" + product_PriceTextBox.Text + "','" + old_invoice_no.ToString() + "')");

                    Connect.exec("UPDATE Stock SET Quantity='" + quantity_textbox.Text + "' WHERE Product_ID = " + product_IDTextBox.Text + ";");
                    Table_Temp = Connect.query("SELECT Quantity FROM Product_Invoice WHERE (Invoice_No = " + old_invoice_no.ToString() + " AND Product_ID= " + product_IDTextBox.Text + ");");
                    int temp = Int32.Parse(Table_Temp.Rows[0][0].ToString()) + Int32.Parse(orderqty_textbox.Value.ToString());

                    Connect.exec("UPDATE Product_invoice SET Quantity='" + temp + "' WHERE Product_ID = " + product_IDTextBox.Text + ";");
                    MessageBox.Show("Add order complete!");
                }
            }
            else if ((Int32.Parse(orderqty_textbox.Text) < 0))
            {
                MessageBox.Show("Please input postive number!");
            }
            else if (quantity_textbox.Text.ToString() == "")
            {
                MessageBox.Show("Please select item");
            }
            else if ((Int32.Parse(quantity_textbox.Text) < Int32.Parse(orderqty_textbox.Text)))
            {
                MessageBox.Show("Not enough stock!");
            }
            Table = Connect.query("SELECT Product.Product_ID AS [Product ID], Product.Product_Name AS [Product Name], Product.Product_Price AS [Price], Product.Discounts AS [Discount], Stock.Category_ID AS [Category], Stock.Quantity AS [Quantity], Stock.Reordering_level AS [Reordering level], Stock.Shelf_location AS [Shelf Location], Stock.Description, Stock.Dimension from Product left join Stock on Product.Product_ID = Stock.Product_ID WHERE Deleted = False;");
            dataGridView1.DataSource = Table;
        }