public static bool CheckIfBlocked(string uid, out DateTime? dt, out bool resetAttemptCounter) { List<AccessDenied> adList = new Database().GetAllAccessDenied(); resetAttemptCounter = false; foreach (AccessDenied ad in adList) { if (ad.MachineID == uid) { dt = ad.BlockedUntil; if (dt > DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc)) { resetAttemptCounter = false; return true; } new Database().Delete(Database.TableName.AccessDenied, (int)ad.BlockedID); resetAttemptCounter = true; } } dt = new DateTime(); return false; }
private void pnlTable_Click(object sender, EventArgs e) { if (tbxAmountOfPersons_tpOrderCreation.Text != String.Empty) { Panel pnlSender = (Panel)sender; int currentTableID = 0; currentTableID = TableLayout.GetTableID(pnlSender.Name); Table tb = new Database().GetTable(Convert.ToUInt64(currentTableID)); try { if (this.clients[Convert.ToInt32(this.tables[currentTableID].clientID)].FirstName == String.Empty) { MessageBox.Show("Table Already in use", "In use", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification); return; } } catch (Exception ex) { } if (tbxTableID_tpOrderCreation.Text.Contains(" " + currentTableID.ToString() + ",") || tbxTableID_tpOrderCreation.Text.Contains(", " + currentTableID.ToString()) || (tbxTableID_tpOrderCreation.Text.Contains(currentTableID.ToString()) && (tbxTableID_tpOrderCreation.Text.Length == currentTableID.ToString().Length)) && !tbxTableID_tpOrderCreation.Text.Contains(",")) { return; } this.tbxTableID_tpOrderCreation.Text += (this.tbxTableID_tpOrderCreation.Text == String.Empty) ? currentTableID.ToString() : ", " + currentTableID.ToString().ToString(); } else { MessageBox.Show("Add the amount of accompanies first."); } }
private void plnSearchName_MouseClick(object sender, MouseEventArgs e) { string name = tbxSearchName.Text; List<Client> ResultingClients = new List<Client>(); ResultingClients = new Database().GetClientListByName(name); this.lbxClientList.Items.Clear(); foreach (Client cl in ResultingClients) { this.lbxClientList.Items.Add(cl.ToString()); } if (this.lbxClientList.Items.Count == 0) { this.lbxClientList.Items.Add("Failed to Find any results."); } this.lbxClientList.Items.Add(""); this.lbxClientList.Items.Add("/.. - Return to Full List"); }
private Panel DisplayMenuItems() { int defaultSkipHeight = 10; // 10 px; int defaultSkipWidth = 4; int currentHeight = 4; int currentIndexOf = 0; List<Menu> MenuItems = new Database().GetAllMenus(); Panel pnl = new Panel(); pnl.AutoScroll = false; pnl.AutoSize = true; pnl.Width = 2000; pnl.Height = 1000; foreach (Menu m in MenuItems) { int currentWidth = 4; Label lblItemID = new Label(); Label lblItemName = new Label(); Label lblItemPrice = new Label(); TextBox tbxAmmount = new TextBox(); Button btnRemove = new Button(); Button btnAdd = new Button(); lblItemID.Name = String.Format("lblItemID{0}", currentIndexOf.ToString()); lblItemName.Name = "lblItemName" + currentIndexOf.ToString(); lblItemPrice.Name = "lblItemPrice" + currentIndexOf.ToString(); tbxAmmount.Name = "tbxAmmount" + currentIndexOf.ToString(); btnRemove.Name = "btnRemove" + currentIndexOf.ToString(); btnAdd.Name = "btnAdd" + currentIndexOf.ToString(); lblItemID.Enabled = true; lblItemName.Enabled = true; lblItemPrice.Enabled = true; tbxAmmount.Enabled = true; btnRemove.Enabled = true; btnAdd.Enabled = true; lblItemID.AutoSize = true; lblItemName.AutoSize = true; lblItemPrice.AutoSize = true; tbxAmmount.AutoSize = true; btnRemove.AutoSize = true; btnAdd.AutoSize = true; lblItemID.Text = m.MenuID.Value.ToString(); lblItemName.Text = m.Entree + "\n" + m.MainCourse + "\n" + m.Dessert; lblItemPrice.Text = m.Price.ToString(); tbxAmmount.Text = "0"; btnRemove.Text = "-"; btnAdd.Text = "+"; lblItemID.Location = new Point(currentWidth, currentHeight); currentWidth += defaultSkipWidth + lblItemID.Width; lblItemName.Location = new Point(currentWidth, currentHeight); currentWidth += defaultSkipWidth + lblItemName.Width; lblItemPrice.Location = new Point(currentWidth, currentHeight); currentWidth += defaultSkipWidth + lblItemPrice.Width; tbxAmmount.Location = new Point(currentWidth, currentHeight); currentWidth += defaultSkipWidth + tbxAmmount.Width; btnRemove.Location = new Point(currentWidth, currentHeight); currentWidth += defaultSkipWidth + btnAdd.Width; btnAdd.Location = new Point(currentWidth, currentHeight); btnRemove.Click += new System.EventHandler(this.btnMenuItemsRemove_Click); btnAdd.Click += new System.EventHandler(this.btnMenuItemsAdd_Click); pnl.Controls.Add(lblItemID); pnl.Controls.Add(lblItemName); pnl.Controls.Add(lblItemPrice); pnl.Controls.Add(tbxAmmount); pnl.Controls.Add(btnRemove); pnl.Controls.Add(btnAdd); currentIndexOf++; currentHeight += lblItemName.Size.Height + defaultSkipHeight; } pnl.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; pnl.Update(); return pnl; }
private void CreateTableLayoutData() { tables.Clear(); List<TableOrder> tbo = new Database().GetAllTableOrders(); List<Table> tbs = new Database().GetAllTables(); for (int i = 0; i < tbs.Count; i++) { TableStatus tableStatus = TableStatus.Empty; string clientID = String.Empty; for (int j = 0; j < tbo.Count; j++) { if (tbo[j].TableID == tbs[i].TableID) { Order o = new Database().GetOrder((ulong)tbo[j].OrderID); if (o.Payed == true) tableStatus = TableStatus.Empty; else { if (o.StartDateTime > DateTime.Now) tableStatus = TableStatus.NotOnTime; else { if (o.Seated == true) tableStatus = TableStatus.OnTime; else tableStatus = TableStatus.Ordered; } } clientID = new Database().GetOrder((ulong)tbo[j].OrderID).ClientID.ToString(); } } tables.Add(new TableLayout((int)tbs[i].TableID, clientID, tableStatus)); } this.ShowTables(); }
public abstract bool Insert(Database.TableName tableName, string[] values);
public abstract bool Delete(Database.TableName tableName, int id);
public abstract bool Update(Database.TableName tableName, string[] argsCol, string[] argsVal, int id);
private void CheckForAdminControl() { try { List<User> userList = new Database().GetAllUsers(); foreach (User u in userList) { if (u.Username == "Admin") { llblAdminLogin.Enabled = true; llblAdminLogin.Text = "Admin Login(enter password)."; } } } catch { return; } }
private void FillData(int id) { if (id != -1) { Client cl = new Database().GetClient((ulong)id); this.tbxFirstName.Text = cl.FirstName; this.tbxFirstName.Enabled = false; this.tbxLastName.Text = cl.LastName; this.tbxLastName.Enabled = false; this.tbxAddress.Text = cl.Address; this.tbxPostalCode.Text = cl.PostalCode; this.tbxCity.Text = cl.City; this.tbxPhoneNumber.Text = cl.PhoneNumber; this.tbxEmail.Text = cl.Email; } }