Exemple #1
0
        private void exit_Click(object sender, EventArgs e)
        {
            Sales_Page g = new Sales_Page();

            g.Show();
            this.Hide();
        }
Exemple #2
0
        private void Sales_Receipt_FormClosed(object sender, FormClosedEventArgs e)
        {
            Sales_Page g = new Sales_Page();

            g.Show();
            this.Hide();
        }
Exemple #3
0
        private void back_button_Click(object sender, EventArgs e)
        {
            if (cust_name_input.Text == string.Empty && total_text.Text == string.Empty)
            {
                Sales_Page g = new Sales_Page();
                g.Show();
                this.Hide();
            }
            else
            {
                switch (MessageBox.Show("Are you sure you want to leave? \nChanges you have made will not be saved.", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Information))
                {
                case DialogResult.Yes:
                    Homepage g = new Homepage();
                    g.Show();
                    this.Hide();
                    break;

                case DialogResult.No:

                    break;
                }
            }
        }
Exemple #4
0
        private void create_button_Click(object sender, EventArgs e)
        {
            if (cust_name_input.Text == String.Empty)
            {
                MessageBox.Show("Please Input Customer Name", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (selected_sales_item_view.Rows.Count == 0)
            {
                MessageBox.Show("Please Input Item/s", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (cust_name_input.Items.Contains(cust_name_input.Text) == false)
            {
                MessageBox.Show("Customer name not valid. Please select from the list.");
                cust_name_input.Text = string.Empty;
            }
            else
            {
                switch (MessageBox.Show("Are you sure you want to proceed with the Check-out?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Information))
                {
                case DialogResult.Yes:
                    Conn.Open();
                    string format = "yyyy-MM-dd HH:mm:ss";
                    string query2 = "insert into stock_order(stock_order_id, " +
                                    "cust_id_stock_order_fk, stock_order_date, total_amount_stock_order) VALUES " +
                                    "('" + Convert.ToInt32(sales_id.Text) + "','" +
                                    "" + Convert.ToInt32(cust_id.Text) + "','" +
                                    "" + date_input.Value.ToString(format) + "','" +
                                    "" + Convert.ToDouble(total_text.Text) + "')";
                    main.CUD_Statement(query2);

                    countrow2 = sales_item_view.Rows.Count;
                    for (int a = 0; a < countrow2; a++)
                    {
                        MySqlCommand cmd2 = new MySqlCommand("update inventory set inventory_quantity=@invq where item_id_inventory_fk=@item_id", Conn);
                        cmd2.Parameters.AddWithValue("@invq", sales_item_view.Rows[a].Cells[5].Value);
                        cmd2.Parameters.AddWithValue("@item_id", sales_item_view.Rows[a].Cells[0].Value);
                        cmd2.ExecuteNonQuery();
                    }

                    int countrow3 = selected_sales_item_view.Rows.Count;
                    for (int i = 0; i < countrow3; i++)
                    {
                        MySqlCommand cmd = new MySqlCommand("INSERT INTO stock_order_details(stock_order_item_quantity,stock_order_id_fk, item_id_stock_order_fk, total_stock_order_details) VALUES (@sqty,@stockidfk,@itemidfk, @total)", Conn);

                        cmd.Parameters.AddWithValue("@sqty", selected_sales_item_view.Rows[i].Cells[2].Value);
                        cmd.Parameters.AddWithValue("@stockidfk", selected_sales_item_view.Rows[i].Cells[5].Value);
                        cmd.Parameters.AddWithValue("@itemidfk", selected_sales_item_view.Rows[i].Cells[6].Value);
                        cmd.Parameters.AddWithValue("@total", selected_sales_item_view.Rows[i].Cells[3].Value); cmd.ExecuteNonQuery();

                        MySqlCommand cmd2 = new MySqlCommand("INSERT INTO stock_out_details(stock_out_quantity, stock_out_type, item_id_stock_out_fk) VALUES (@sqty,'Sales',@itemidfk)", Conn);

                        cmd2.Parameters.AddWithValue("@sqty", selected_sales_item_view.Rows[i].Cells[2].Value);
                        cmd2.Parameters.AddWithValue("@itemidfk", selected_sales_item_view.Rows[i].Cells[6].Value);
                        cmd2.ExecuteNonQuery();
                    }


                    Conn.Close();

                    // messagebox for yes and no if sure about transaction
                    // show list of all items bought
                    switch (MessageBox.Show("Transaction Created! Would you like to print the Receipt?", "Sales", MessageBoxButtons.YesNo, MessageBoxIcon.Information))
                    {
                    case DialogResult.Yes:
                        salid = Convert.ToString(sales_id.Text);
                        new Sales_Receipt(salid).ShowDialog();
                        break;

                    case DialogResult.No:

                        Sales_Page k = new Sales_Page();
                        k.Show();
                        this.Hide();
                        break;
                    }

                    break;

                case DialogResult.No:
                    break;
                }
            }
        }