public string setDeallocationTable(int tableID) { string client = SqlProcessor.selectTable(tableID).Client; setDeallocation(client, tableID); return(XmlProcessor.xmlTablesStatusBuilder(SqlProcessor.selectAllTables())); }
public string setDeallocationClient(string dni) { int tableID = SqlProcessor.selectTable(dni).Id; setDeallocation(dni, tableID); return(XmlProcessor.xmlTablesStatusBuilder(SqlProcessor.selectAllTables())); }
public string getBill(int tableID, bool _short) { if (_short) { return(XmlProcessor.xmlShortBillBuilder(generateBill(tableID))); } string xmlBill = SqlProcessor.selectBillTable(tableID); // busca la factura no pagada de la mesa 'tableID' if (!xmlBill.Equals("")) { return(xmlBill); // si la hay, la devuelve } Bill bill = generateBill(tableID); // si no, la calcula xmlBill = SqlProcessor.selectBill(bill.Id); // mira si está con las facturas pagadas if (!xmlBill.Equals("")) { return(xmlBill); // si la encuentra, la devuelve } xmlBill = XmlProcessor.xmlBillBuilder(bill); // si no, genera el xml if (bill.Total > 0) // Para evitar almacenar basura { SqlProcessor.insertBill(bill, xmlBill); // y lo almacena con el resto de facturas SqlProcessor.increaseNBill(); // incrementa el número de serie de las facturas } return(xmlBill); // y devuelve el xml de la factura calculada }
public string setAllocationTable(string dni, int tableID, int guests) { int appearances = SqlProcessor.selectClient(dni).Appearances; SqlProcessor.updateClient(dni, 1, ++appearances); // status (cliente) == 1 (sentado) SqlProcessor.updateTable(tableID, 0, dni, guests); // status (mesa) == 0 (ocupada) return(XmlProcessor.xmlTablesStatusBuilder(SqlProcessor.selectAllTables())); }
public void saveRoom(string name, string xml) { Room room = SqlProcessor.selectRoom(name); if (!room.Name.Equals("")) { SqlProcessor.deleteRoom(name); } SqlProcessor.insertRoom(XmlProcessor.xmlAddRoomDecoder(xml)); }
public string addNewOrder(string xml) { List <Order> orders = XmlProcessor.xmlOrdersDecoder(xml); foreach (Order order in orders) { SqlProcessor.insertOrder(order); } recalculateTablesStatus(); // recalcula el nuevo estado de las mesas del restaurante return(XmlProcessor.xmlTablesStatusBuilder(SqlProcessor.selectAllTables())); }
public string getRestaurant() { List <Object> loo = new List <Object>(); Company company = SqlProcessor.selectRestaurant(); loo.Add(company); loo.Add(SqlProcessor.selectAddress(company.NIF)); loo.Add(SqlProcessor.selectIVA()); loo.Add(SqlProcessor.selectDiscount()); loo.Add(SqlProcessor.selectDiscountedVisit()); return(XmlProcessor.xmlRestaurantDataBuilder(loo)); }
public string getRecommendation(string client) { string restaurant = SqlProcessor.selectRestaurant().Name; List <HistoricalOrder> clientHistory = SqlProcessor.selectHistoricalOrders(client); // selecciona el historial de pedidos del cliente List <Product> products = SqlProcessor.selectAllProducts(false); // selecciona sólo los productos visibles int appearances = SqlProcessor.selectClient(client).Appearances; double discount = SqlProcessor.selectDiscount(); int discountedV = SqlProcessor.selectDiscountedVisit(); Recommendation rec = Recommender.generateRecommendation(products, clientHistory, restaurant, appearances, discount, discountedV); return(XmlProcessor.xmlRecommendationBuilder(rec)); }
public void saveRestaurant(string xml) { List <Object> info = XmlProcessor.xmlRestaurantDecoder(xml); Company c = (Company)info[0]; Address a = (Address)info[1]; double iva = (Double)info[2]; double discount = (Double)info[3]; int discountedVisit = (Int32)info[4]; SqlProcessor.insertRestaurant(c, SqlProcessor.selectNBill(), iva, discount, discountedVisit, SqlProcessor.selectRestaurantRoom()); SqlProcessor.insertAddress(c.NIF, a); }
public void saveProductsList(string xml) { List <Product> products = XmlProcessor.xmlProductsDecoder(xml); if (products.Count > 0) { SqlProcessor.truncateProducts(); } foreach (Product product in products) { SqlProcessor.insertProduct(product); } }
public string payBill(int billID, int type) { int tableID = SqlProcessor.selectTableBill(billID); string client = SqlProcessor.selectTable(tableID).Client; foreach (Order o in SqlProcessor.selectTableOrders(tableID, false)) { SqlProcessor.updateOrder(o.Id, -3, 3, -3); } SqlProcessor.updateClient(client, 2, -3); SqlProcessor.updateTable(tableID, 3, "", -3); SqlProcessor.updateBillStatus(billID, type); return(XmlProcessor.xmlTablesStatusBuilder(SqlProcessor.selectAllTables())); }
public string getCurrentRoom() { string name = SqlProcessor.selectRestaurantRoom(); if (!name.Equals("none") && !name.Equals("")) { Room room = SqlProcessor.selectRoom(name); List <Room> rooms = new List <Room>(); if (!room.Name.Equals("")) { rooms.Add(room); } return(XmlProcessor.xmlRoomsBuilder(rooms)); } return(""); }
public void resetJourney(string room) { SqlProcessor.truncateTables(); // se eliminan las mesas existentes en la BD List <Table> tables = XmlProcessor.xmlRoomTablesDecoder(SqlProcessor.selectRoom(room).Xml); // se cargan las mesas del comedor elegido foreach (Table table in tables) // se inicializan las mesas y se guardan en la BD { table.Status = -1; table.Client = ""; table.Guests = 0; SqlProcessor.insertTable(table); } SqlProcessor.truncateOrders(); // se eliminan todos los pedidos existentes en la BD SqlProcessor.deleteUnpaidBills(); // se eliminan las facturas generadas pero no pagadas SqlProcessor.deleteAnonymousClients(); // se eliminan los clientes anónimos (no usan NFC) SqlProcessor.resetClientsStatus(); // se cambia el estado de los demás clientes a 0 ('no está en el restaurante') }
public int getClientStatus(string xmlClient) { List <Object> clientData = XmlProcessor.xmlClientDecoder(xmlClient); Client client = SqlProcessor.selectClient(((Client)clientData[0]).Dni); if (client.Name == null) // si el cliente no existe, se crea { SqlProcessor.insertClient(new Client(((Client)clientData[0]).Dni, ((Client)clientData[0]).Name, ((Client)clientData[0]).Surname, 0, 0)); // se almacenan los datos personales SqlProcessor.insertAddress(((Client)clientData[0]).Dni, (Address)clientData[1]); // y se almacena la dirección return(-1); // indica primer acceso de un cliente } else { return(client.Status); } }
public string getClientsHistory() { return(XmlProcessor.xmlHistoryBuilder(SqlProcessor.selectHistoricalOrders(""))); }
public string getTablesStatus() { return(XmlProcessor.xmlTablesStatusBuilder(SqlProcessor.selectAllTables())); }
public string getClients() { return(XmlProcessor.xmlClientsDataBuilder(SqlProcessor.selectClients())); }
public string setOrderTable(int orderID, int tableID) { SqlProcessor.updateOrder(orderID, -3, -3, tableID); // -3 no modifica el argumento recalculateTablesStatus(); // recalcula el nuevo estado de las mesas del restaurante return(XmlProcessor.xmlTablesStatusBuilder(SqlProcessor.selectAllTables())); }
public string getRooms() { return(XmlProcessor.xmlRoomsBuilder(SqlProcessor.selectAllRooms())); }
public string getTableStatus(int tableID) { string dni = SqlProcessor.selectTable(tableID).Client; return(XmlProcessor.xmlTableStatusBuilder(SqlProcessor.selectTable(tableID), SqlProcessor.selectClient(dni), SqlProcessor.selectTableOrders(tableID, true))); }
public string getOrdersStatus() { return(XmlProcessor.xmlOrdersStatusBuilder(SqlProcessor.selectAllOrders())); }
public string getHOrders(int amount, bool ascending) { return(XmlProcessor.xmlHistoryBuilder(SqlProcessor.selectHOrders(amount, ascending))); }
public string getBills(int amount, bool ascending) { return(XmlProcessor.xmlBillsBuilder(SqlProcessor.selectBills(amount, ascending))); }
public string getProducts(bool nonVisible) { return(XmlProcessor.xmlProductsBuilder(SqlProcessor.selectAllProducts(nonVisible))); }
public string getClient(string dni) { return(XmlProcessor.xmlClientDataBuilder(SqlProcessor.selectClient(dni), SqlProcessor.selectAddress(dni))); }