Beispiel #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        String dbLocation = Server.MapPath(Path.Combine("~/App_Data/", Constants.DB_NAME));

        db = new MenuDbManager(dbLocation);
        db.Connect();
        updateMenuItems();
    }
Beispiel #2
0
    public void CreateServer(string firstname, string lastname, int age, char sex)
    {
        MenuDbManager db = new MenuDbManager(DBManager.defaultDbLocation);

        db.Connect();
        db.InsertServer(firstname, lastname, age, sex);
        db.Close();
        serverList.Add(new Server(firstname, lastname, age, sex));
    }
Beispiel #3
0
    public void CreateMenuItem(string itemName, string type, double price, double cost)
    {
        MenuDbManager db = new MenuDbManager(DBManager.defaultDbLocation);

        db.Connect();
        db.InsertMenu(itemName, type, price, cost);
        db.Close();
        this.itemList = new List <MenuItem>();
        LoadMenuItems();
    }
Beispiel #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        this.Page.ViewStateMode = System.Web.UI.ViewStateMode.Enabled;
        db = new MenuDbManager(DBManager.defaultDbLocation);
        db.Connect();

        if (!IsPostBack)
        {
            GetServerList();
            menuItemsList.DataSource = GetMenuItems();
            menuItemsList.DataBind();
        }

        if (ViewState[Constants.Items] == null)
        {
            ViewState[Constants.Items] = new Dictionary <MenuItem, int>();
        }
    }
Beispiel #5
0
    public void CreateOrder(int serverId, DateTime?saleDate, string mealType, List <KeyValuePair <int, int> > itemId_Amount)
    {
        MenuDbManager db = new MenuDbManager(DBManager.defaultDbLocation);

        db.Connect();

        OleDbDataReader reader    = db.Execute("select max(GROUP_ID) from [Order]");
        bool            hasValues = reader.Read() && !reader.IsDBNull(0);
        //if Order table is empty, id = 0, else = max + 1
        int groupId = hasValues ? Convert.ToInt16(reader[0]) + 1 : 0;

        db.InsertOrder(groupId, serverId, saleDate.ToString(), mealType);
        foreach (var k in itemId_Amount)
        {
            db.InsertOrderItem(groupId, k.Key, k.Value);
        }
        db.Close();
        this.orderList = new List <Order>();
        LoadOrders();
    }
Beispiel #6
0
    public void FillChart2()
    {
        MenuDbManager db = new MenuDbManager(DBManager.defaultDbLocation);

        db.Connect();
        DataTable table = new DataTable();

        table.Load(db.Execute("select ITEM_NAME, (PRICE-COST) as PROFIT from Menu"));

        var tableFilter = from t in table.AsEnumerable()
                          where Convert.ToInt16(t["PROFIT"]) > 2
                          select t;

        DataTable table2 = tableFilter.CopyToDataTable();

        chart2.Series[0].XValueMember  = "ITEM_NAME";
        chart2.Series[0].YValueMembers = "PROFIT";
        chart2.DataSource = table2;
        chart2.DataBind();
    }
Beispiel #7
0
    public void LoadMenuItems()
    {
        MenuDbManager db = new MenuDbManager(DBManager.defaultDbLocation);

        db.Connect();

        dataTable = db.GetTable(MenuDbManager.Table.MENU);

        foreach (DataRow row in dataTable.Rows)
        {
            MenuItem item = new MenuItem();
            item.id       = Convert.ToInt16(row["ID"]);
            item.itemName = row["ITEM_NAME"].ToString();
            item.type     = row["TYPE"].ToString();
            item.price    = Convert.ToDouble(row["PRICE"]);
            item.cost     = Convert.ToDouble(row["COST"]);
            itemList.Add(item);
        }
        db.Close();
    }
Beispiel #8
0
    public void LoadServers()
    {
        MenuDbManager db = new MenuDbManager(DBManager.defaultDbLocation);

        db.Connect();
        dataTable = db.GetTable(MenuDbManager.Table.SERVER);
        // Load all Servers into Session Variable
        foreach (DataRow r in dataTable.Rows)
        {
            Server server = new Server();
            server.id        = Convert.ToInt16(r["ID"]);
            server.firstname = r["FIRST_NAME"].ToString();
            server.lastname  = r["LAST_NAME"].ToString();
            server.age       = Convert.ToInt16(r["AGE"]);
            server.sex       = Convert.ToChar(r["SEX"]);
            serverList.Add(server);
        }

        db.Close();
    }
Beispiel #9
0
    public void LoadOrders()
    {
        String        dbLocation = HostingEnvironment.MapPath(System.IO.Path.Combine("~/App_Data/", Constants.DB_NAME));
        MenuDbManager db         = new MenuDbManager(DBManager.defaultDbLocation);

        db.Connect();

        orderDataTable = db.GetTable(MenuDbManager.Table.ORDERS);
        // Load all MenuItems into Session Variable
        foreach (DataRow row in orderDataTable.Rows)
        {
            Order order = new Order();
            order.groupId  = Convert.ToInt16(row["GROUP_ID"]);
            order.serverId = Convert.ToInt16(row["SERVER_ID"]);
            order.mealType = row["MEAL_TYPE"].ToString();
            orderList.Add(order);
        }

        List <OrderItem> orderItems = new List <OrderItem>();

        orderItemDataTable = db.GetTable(MenuDbManager.Table.ORDER_ITEM);
        foreach (DataRow row in orderItemDataTable.Rows)
        {
            OrderItem item = new OrderItem();
            item.groupId = Convert.ToInt16(row["GROUP_ID"]);
            item.itemId  = Convert.ToInt16(row["ITEM_ID"]);
            item.amount  = Convert.ToInt16(row["AMOUNT"]);
            orderItems.Add(item);
        }

        foreach (Order o in this.orderList)
        {
            var results = orderItems.FindAll(i => i.groupId == o.groupId);
            o.orderItems = results;
        }
        db.Close();
    }