public VendingMachine(string filePath)
 {
     using (StreamReader sr = new StreamReader(filePath))
     {
         while (!sr.EndOfStream)
         {
             string line = sr.ReadLine();
             Slot   slot = new Slot(line);
             SlotDictionary.Add(slot.Location, slot);
             ItemsSold.Add(slot.SlotItem, 0);
         }
     }
 }
Esempio n. 2
0
        private void BindDataTable()
        {
            SqlCommand objCmd = new SqlCommand();

            objCmd.Connection  = con;
            objCmd.CommandText = "select * from DineINOrder INNER JOIN orderDetails ON DineINOrder.orderID = orderDetails.orderID WHERE DineINOrder.restaurantID='" + Session["restaurantID"] + "' ORDER BY DineINOrder.orderID";
            objCmd.CommandType = CommandType.Text;
            DataSet        objDS = new DataSet();
            SqlDataAdapter objDA = new SqlDataAdapter();

            objDA.SelectCommand = objCmd;
            con.Open();
            objDA.Fill(objDS);
            con.Close();
            ItemsSold.DataSource = objDS;
            ItemsSold.DataBind();
        }
        //public void dropdownList()
        //{
        //    const string dbConnectionString = @"Data Source=DATABAIST;Database=ksingh31;Integrated Security=true";
        //    SqlConnection dbConnection = new SqlConnection();
        //    dbConnection.ConnectionString = dbConnectionString;
        //    dbConnection.Open();
        //    SqlCommand getItemCmd = new SqlCommand();
        //    getItemCmd.Connection = dbConnection;
        //    getItemCmd.CommandType = CommandType.StoredProcedure;
        //    getItemCmd.CommandText = "GetCustomers";
        //    SqlDataAdapter da = new SqlDataAdapter(getItemCmd);

        //    DataSet custC = new DataSet();
        //    da.Fill(custC);
        //    CustomerIDList.DataSource = custC;
        //    CustomerIDList.DataTextField = "CustomerName";
        //    CustomerIDList.DataValueField = "CustomerID";
        //    CustomerIDList.DataBind();
        //    CustomerIDList.Items.Insert(0, new ListItem("-- Select Customer --", "0"));
        //    dbConnection.Close();
        //}

        protected void GoToSalePage_Click(object sender, EventArgs e)
        {
            int                saleNumber = int.Parse(SaleNumberTextBox.Text);
            string             sName      = SalepersonTextBox.Text;
            double             sSubTotal  = Convert.ToDouble(subTotalTextBox.Text);
            double             sgst       = Convert.ToDouble(gstTextBox.Text);
            double             sTotal     = Convert.ToDouble(totalTextBox.Text);
            var                list       = new List <ItemsSold>();
            TableRowCollection t          = CartTable.Rows;

            foreach (TableRow r in t)
            {
                ItemsSold item1 = new ItemsSold();
                item1.ItemCode   = (r.Cells[0].Text).ToString();
                item1.SaleNumber = saleNumber;
                item1.Quantity   = int.Parse(r.Cells[1].Text);
                item1.ItemTotal  = Convert.ToDouble(r.Cells[2].Text);
                list.Add(item1);
            }
            BAIS3150CodeSampleHandler RequestDirector = new BAIS3150CodeSampleHandler();

            try
            {
                bool Confirmation = RequestDirector.AddSale(saleNumber, sName, sSubTotal, sgst, sTotal, list);
                if (Confirmation)
                {
                    MessageLabel.Text = "<i>Sale Created successfully</i>";
                }
                else
                {
                    MessageLabel.Text = "<i style='color: red;'>Sale was NOT successful</i>";
                }
            }
            catch (Exception ex)
            {
                MessageLabel.Text = "<i style='color: red;'>Create Sale was NOT successful</i>";
                Console.WriteLine(ex.Message);
            }
        }
 //ID Number Section - - - - - - - - - - - - - - - -
 //Method OrderID
 public string OrderID()
 {
     return(OrderInitiated.ToShortDateString() + ClientID.ToString() + DateDue.ToShortDateString() + ItemsSold.ToString());
 }//end Method OrderID
        }         //end Property DateDue



        public override string ToString()
        {
            return("Order Type:\t\t" + OrderType() + "OrderID: \t\t" + OrderID().ToString() + "\n" + "ClientID: \t\t" + ClientID.ToString() + "\n" + "Completed Status\t\t" + OrderStatus() + "TAX:\t\t" + TaxSales.ToString() + "\n" + "Items Sold:\t\t" + ItemsSold.ToString() + "\n" + "Unit Cost:\t\t" + ItemUnitCost.ToString() + "\n" + "Remaining Balance:\t\t" + OrderBalance().ToString());
        } //end method ToString Override
        }    //end PaymentReceived

        //Method String ItemList
        //public StringBuilder ItemList()
        //{
        //    foreach (ItemBase item in Checkout())
        //        return "TYPE:\t\t" + item.ItemType + "\n \t\t" + item.NameOfItem + "\n \t\t" + item.UnitPrice + "\n \t\t" + item.SizeItem + "\n \t\t" + item.VendorName
        //            + "\n \t\t" + item.ItemDescription;
        //}



        public override string ToString()
        {
            return("Order Type:\t\t" + this.OrderType().ToString() + "\nOrderID:\t\t" + this.OrderID().ToString() + "\nClientID:\t\t" + this.ClientID +
                   "\nOrder Status\t\t" + this.OrderStatus() + "\n\nTAX:\t\t" + this.TaxSales.ToString() + "\n" + "Items Sold:\t\t" + ItemsSold.ToString() + "\n" +
                   "Unit Cost:\t\t" + this.ItemUnitCost.ToString() + "\n" + "Remaining Balance:\t\t" + this.OrderRemainingBalance().ToString()
                   /*Lists*/);
        }//end method ToString Override