Esempio n. 1
0
 partial void DeleteSALES_ORDER(SALES_ORDER instance);
Esempio n. 2
0
 partial void UpdateSALES_ORDER(SALES_ORDER instance);
Esempio n. 3
0
 private void detach_SALES_ORDERs(SALES_ORDER entity)
 {
     this.SendPropertyChanging();
     entity.CUSTOMER = null;
 }
Esempio n. 4
0
 partial void InsertSALES_ORDER(SALES_ORDER instance);
Esempio n. 5
0
        private void completePurchaseBtn_Click(object sender, RoutedEventArgs e)
        {
            if (allowed == true)
            {
                if (wasChecked)
                {
                    try
                    {
                        int  salesOrderID = int.Parse(ordersDrpDown.SelectedItem.ToString());
                        long upc          = long.Parse(upcDrpDown.SelectedItem.ToString());
                        int  qty          = int.Parse(qty_txt.Text);

                        dbConnection.usp_addASalesOrderItem(salesOrderID, upc, qty);
                        Decimal itemCost     = dbConnection.ITEMs.Where(i => i.upc == upc).Select(i => i.unitPrice).FirstOrDefault();
                        Decimal purchaseCost = itemCost * qty;

                        cust.balance += purchaseCost;

                        dbConnection.SubmitChanges();
                        MessageBox.Show("Item added to purchase");
                    }
                    catch (NullReferenceException ex)
                    {
                        MessageBox.Show("Please fill out all fields");
                    }

                    catch (SqlException sqle)
                    {
                        MessageBox.Show("Looks like you already have this item in your order or the item is out of stock");
                    }
                }
                else
                {
                    try
                    {
                        long upc = long.Parse(upcDrpDown.SelectedItem.ToString());
                        int  qty = int.Parse(qty_txt.Text);


                        SALES_ORDER newOrder = new SALES_ORDER();
                        newOrder.cashierId = 3;
                        newOrder.custId    = customerID;
                        newOrder.minPurchaseForDiscount = 15;
                        dbConnection.SALES_ORDERs.InsertOnSubmit(newOrder);
                        dbConnection.SubmitChanges();

                        int orderID = newOrder.salesOrderID;

                        dbConnection.usp_addASalesOrderItem(orderID, upc, qty);

                        Decimal itemCost     = dbConnection.ITEMs.Where(i => i.upc == upc).Select(i => i.unitPrice).FirstOrDefault();
                        Decimal purchaseCost = itemCost * qty;

                        cust.balance += purchaseCost;

                        dbConnection.SubmitChanges();
                    }
                    catch (NullReferenceException ex)
                    {
                        MessageBox.Show("Please fill out all fields");
                    }

                    catch (SqlException sqle)
                    {
                        MessageBox.Show("Something went wrong");
                    }
                }
            }
            else
            {
                MessageBox.Show("Please pay your balance");
            }
        }