Exemplo n.º 1
0
Arquivo: RMS.cs Projeto: jeem200/RMS
        private void placeOrderPaymentMethodCardFinishBtn_Click(object sender, EventArgs e)
        {
            billprint();
            if (placeOrderIdLabel.Text.ToString().CompareTo("") != 0)
            {
                try
                {
                    if (placeOrderCardType.Text.ToString().CompareTo("") != 0 && placeOrderCardNo.Text.ToString().CompareTo("") != 0)
                    {
                        if (Convert.ToDouble(placeOrderCardNo.Text.ToString()) < 0)
                        {
                            MetroFramework.MetroMessageBox.Show(this, "Wrong Input: Negative Values Not Allowed");
                        }
                        else
                        {
                            double              cardNo             = Convert.ToDouble(placeOrderCardNo.Text.ToString());
                            String              cardType           = placeOrderCardType.Text.ToString();
                            DateTime            dtValue            = DateTime.Now;
                            string              orderDate          = dtValue.ToString("yyyy-MM-dd");
                            string              orderTime          = dtValue.ToString("HH:mm:ss");
                            OrderInfoDataAccess orderOb            = new OrderInfoDataAccess();
                            double              discountOrderTotal = orderTotal - discount;
                            string              query = "update orderinfo set orderdate='" + orderDate + "', ordertime='" + orderTime + "', ordertotal=" + discountOrderTotal + ", discount=" + discount + ", vattotal=" + vatTotal + ", nettotal=" + netTotal + ", paymentmethod='" + placeOrderPaymentMethodCbox.Text.ToString() + "', cardtype='" + cardType + "', cardnum=" + cardNo + ",status='TRUE' where id=" + Convert.ToInt32(placeOrderIdLabel.Text.ToString());
                            orderOb.addOrderDetails(query);
                            MetroFramework.MetroMessageBox.Show(this, "Order Details Updated To Database Successfully");
                            placeOrderPaymentMethodCashFinishBtn.Hide();
                            placeOrderPaymentMethodCardFinishBtn.Hide();
                            placeOrderAddItemBtn.Hide();
                            placeOrderCancelResetBtn.Text       = "New Order";
                            placeOrder_discountTbox.ReadOnly    = true;
                            placeOrderCashPaidTbox.ReadOnly     = true;
                            placeOrderCardNo.ReadOnly           = true;
                            placeOrderCardType.Enabled          = false;
                            placeOrderPaymentMethodCbox.Enabled = false;
                        }
                    }



                    else
                    {
                        MetroFramework.MetroMessageBox.Show(this, "Error: Input Can't be Blank");
                    }
                }

                catch (FormatException)
                {
                    MetroFramework.MetroMessageBox.Show(this, "Error: Wrong Input");
                }

                catch (Exception exc)
                {
                    MetroFramework.MetroMessageBox.Show(this, exc.ToString());
                }
            }
            else
            {
                MetroFramework.MetroMessageBox.Show(this, "Error: No Item Is Ordered Yet");
            }
        }
Exemplo n.º 2
0
Arquivo: RMS.cs Projeto: jeem200/RMS
        private void placeOrderAddItemBtn_Click(object sender, EventArgs e)
        {
            if (placeOrderItemNameCbox.Text.ToString().CompareTo("") != 0)
            {
                try
                {
                    ItemDataAccess      itemOb  = new ItemDataAccess();
                    OrderInfoDataAccess orderOb = new OrderInfoDataAccess();
                    string itemName             = placeOrderItemNameCbox.Text.ToString();
                    double itemUnitPrice        = itemOb.getItemUnitPrice(itemName);
                    int    qty = Convert.ToInt32(placeOrderQtyUpDown.Value);
                    int    orderId;

                    if (placeOrderIdLabel.Text.ToString().CompareTo("") == 0)
                    {
                        string sql = "Insert into ORDERINFO (ID,STATUS) VALUES(order_orderid_seq.NEXTVAL,'FALSE')";
                        orderOb.addOrderDetails(sql);
                        orderId = orderOb.getCurrentOrderId();
                        placeOrderIdLabel.Text       = Convert.ToString(orderId);
                        placeOrder_orderTotal.Text   = "0.0";
                        placeOrder_vatTotal.Text     = "0.0";
                        placeOrder_netTotal.Text     = "0.0";
                        placeOrder_discountTbox.Text = "0.0";
                    }
                    orderId = Convert.ToInt32(placeOrderIdLabel.Text.ToString());
                    string addOrderdItemSql = "Insert into ORDEREDITEM VALUES(" + orderId + "," + qty + "," + itemUnitPrice + ",'" + itemName + "')";
                    orderOb.addOrderDetails(addOrderdItemSql);


                    string           connStr = "Data Source=localhost; User Id= Tokee; Password=12345";
                    OracleConnection conn    = new OracleConnection(connStr);

                    string orderedItemListSql = "select ITEMNAME, ITEMUNITPRICE, ITEMQTY from ORDEREDITEM where ORDERID =" + orderId + "";


                    OracleDataAdapter adapter = new OracleDataAdapter(orderedItemListSql, conn);
                    DataTable         dt      = new DataTable();
                    adapter.Fill(dt);
                    placeOrderItemList.DataSource = dt;


                    orderTotal = orderTotal + (itemUnitPrice * qty);
                    vatTotal   = orderTotal * 0.15;
                    netTotal   = orderTotal + vatTotal;
                    placeOrder_orderTotal.Text = Convert.ToString(orderTotal);
                    placeOrder_vatTotal.Text   = Convert.ToString(vatTotal);
                    placeOrder_netTotal.Text   = Convert.ToString(netTotal);

                    placeOrderItemNameCbox.Items.Clear();
                    placeOrderItemCategoryCbox.Items.Clear();
                    itemCategoryComboboxFill();
                    itemListCategoryComboboxDefaultSelect();
                    placeOrderQtyUpDown.Value = placeOrderQtyUpDown.Minimum;
                }

                catch (Exception exc)
                {
                    MetroFramework.MetroMessageBox.Show(this, exc.ToString());
                }
            }
            else
            {
                MetroFramework.MetroMessageBox.Show(this, "No Item Selected");
            }
        }