コード例 #1
0
ファイル: pointOfSale.cs プロジェクト: Tolcrow/Point-of-Sale
        /**
         * \brief <b>orderPaid_Click</b> - refunds a paid order
         * \details refunds a paid order and modifies the products inventory levels
         * \param object sender - reference to the object that raised the event.  not used
         * \param EventArgs e - contains event data,  not used
         * \return none
         */
        private void orderRefund_Click(object sender, EventArgs e)
        {
            Int32  selectedRow  = searchGridView.Rows.GetFirstRow(DataGridViewElementStates.Selected);
            string ID           = searchGridView.Rows[selectedRow].Cells[0].Value.ToString();
            string getOrderLine = string.Format("select * from orderLine where orderID = {0};", ID);

            DataTable ds = submitQuerry(getOrderLine);

            string cmd = string.Format("UPDATE orderLine SET quantity = 0 WHERE orderID = {0};", ID);

            cmd += string.Format("UPDATE _order SET _status = \"RFND\" WHERE orderID = {0};", ID);

            for (int i = 0; i < ds.Rows.Count; i++)
            {
                // update of quantity of products in the database
                cmd += string.Format("UPDATE products SET quantity = (quantity + {0}) WHERE ProductID = '{1}';",
                                     ds.Rows[i].Field <int>("quantity").ToString(), ds.Rows[i].Field <int>("ProductID").ToString());
            }
            cmd += string.Format("select * from _order where orderID = {0};", ID);
            searchGridView.DataSource = submitQuerry(cmd);

            salesRecord sr = new salesRecord(createSalesRecord(Int32.Parse(ID)));

            sr.ShowDialog();
        }
コード例 #2
0
ファイル: pointOfSale.cs プロジェクト: Tolcrow/Point-of-Sale
        /**
         * \brief <b>orderPaid_Click</b> - change an order from pending to paid
         * \details change an order from pending to paid
         * \param object sender - reference to the object that raised the event.  not used
         * \param EventArgs e - contains event data,  not used
         * \return none
         */
        private void orderPaid_Click(object sender, EventArgs e)
        {
            Int32  selectedRow = updateOrder("PAID");
            string ID          = searchGridView.Rows[selectedRow].Cells[0].Value.ToString();
            // get all the product that are in this order so I can update their quantity levels
            string    getOrderLine = string.Format("select * from orderLine where orderID = {0};", ID);
            DataTable ds           = submitQuerry(getOrderLine);

            string cmd = string.Empty;

            for (int i = 0; i < ds.Rows.Count; i++)
            {
                // update of quantity of products in the database
                cmd = string.Format("UPDATE products SET quantity = (quantity - {0}) where ProductID = '{1}';",
                                    ds.Rows[i].Field <int>("quantity").ToString(), ds.Rows[i].Field <int>("ProductID").ToString());
            }
            submitQuerry(cmd);

            salesRecord sr = new salesRecord(createSalesRecord(Int32.Parse(ID)));

            sr.ShowDialog();
        }
コード例 #3
0
ファイル: pointOfSale.cs プロジェクト: Tolcrow/Point-of-Sale
        /**
         * \brief <b>completeOrder_Click</b> - completes an order
         * \details completes an order and adds it to the database.  If the order is a paid order then the inventory levels are modified.
         * \param object sender - reference to the object that raised the event.  not used
         * \param EventArgs e - contains event data,  not used
         * \return none
         */
        private void completeOrder_Click(object sender, EventArgs e)
        {
            // if order status is set to paid
            if (newOrderPaymentStatusComboBox.SelectedIndex == 0)
            {
                for (int i = 0; i < orderGrid.RowCount; i++)
                {
                    order += string.Format("UPDATE products SET quantity = (quantity - {0}) where ProductID = '{1}';",
                                           orderGrid.Rows[i].Cells["quantityColumn"].Value.ToString(), orderGrid.Rows[i].Cells["productIDColumn"].Value.ToString());
                }
            }
            order += string.Format("SELECT orderID FROM _order WHERE customerID = {0} ORDER BY orderID DESC LIMIT 1;", newOrderCustomerIDTextBox.Text);
            DataTable orderID = submitQuerry(order);

            salesRecord sr = new salesRecord(createSalesRecord(orderID.Rows[0].Field <int>("orderID")));

            sr.ShowDialog();

            order = string.Empty;
            orderGrid.Rows.Clear();

            newOrderCustomerIDTextBox.Text = string.Empty;
            newOrderQuantityTextBox.Text   = string.Empty;

            newOrderCustomerIDTextBox.Enabled     = true;
            newOrderDateTimePicker.Enabled        = true;
            newOrderPaymentStatusComboBox.Enabled = true;
            newOrderBranchComboBox.Enabled        = true;
            orderNew.Enabled = true;

            newOrderProductComboBox.Enabled = false;
            newOrderQuantityTextBox.Enabled = false;
            OrderItemNew.Enabled            = false;
            cancelOrder.Enabled             = false;
            completeOrder.Enabled           = false;
        }