├── .gitignore ├── FastFoodPOS.sln ├── FastFoodPOS ├── App.config ├── Components │ ├── AlertNotification.Designer.cs │ ├── AlertNotification.cs │ ├── AlertNotification.resx │ ├── OrderItemComponent.Designer.cs │ ├── OrderItemComponent.cs │ ├── OrderItemComponent.resx │ ├── ProductCardComponent.Designer.cs │ ├── ProductCardComponent.cs │ ├── ProductCardComponent.resx │ ├── ProductCardComponent1.Designer.cs │ ├── ProductCardComponent1.cs │ ├── ProductCardComponent1.resx │ ├── ReceiptTemplate.cs │ ├── UserCardComponent.Designer.cs │ ├── UserCardComponent.cs │ ├── UserCardComponent.resx │ └── Validator.cs ├── DatabaseUtil │ ├── Database.cs │ ├── DatabaseMSAccessProvider.cs │ ├── DatabaseMySQLProvider.cs │ └── DatabaseProvider.cs ├── Dialog │ ├── BackupDialogBox.Designer.cs │ ├── BackupDialogBox.cs │ ├── BackupDialogBox.resx │ ├── ConfirmDialogBox.Designer.cs │ ├── ConfirmDialogBox.cs │ ├── ConfirmDialogBox.resx │ ├── HelpDialogBox.Designer.cs │ ├── HelpDialogBox.cs │ └── HelpDialogBox.resx ├── ErrorHandler │ └── Level1Exception.cs ├── FastFoodPOS.csproj ├── FastFoodPOS.csproj.user ├── Forms │ ├── AdminForms │ │ ├── FormActivityLog.Designer.cs │ │ ├── FormActivityLog.cs │ │ ├── FormActivityLog.resx │ │ ├── FormAddProduct.Designer.cs │ │ ├── FormAddProduct.cs │ │ ├── FormAddProduct.resx │ │ ├── FormAddUser.Designer.cs │ │ ├── FormAddUser.cs │ │ ├── FormAddUser.resx │ │ ├── FormChangePassword.Designer.cs │ │ ├── FormChangePassword.cs │ │ ├── FormChangePassword.resx │ │ ├── FormDashboard.Designer.cs │ │ ├── FormDashboard.cs │ │ ├── FormDashboard.resx │ │ ├── FormManageProducts.Designer.cs │ │ ├── FormManageProducts.cs │ │ ├── FormManageProducts.resx │ │ ├── FormProductArchive.Designer.cs │ │ ├── FormProductArchive.cs │ │ ├── FormProductArchive.resx │ │ ├── FormSalesReport.Designer.cs │ │ ├── FormSalesReport.cs │ │ ├── FormSalesReport.resx │ │ ├── FormTransactions.Designer.cs │ │ ├── FormTransactions.cs │ │ ├── FormTransactions.resx │ │ ├── FormUpdateCurrentUser.Designer.cs │ │ ├── FormUpdateCurrentUser.cs │ │ ├── FormUpdateCurrentUser.resx │ │ ├── FormUpdateProduct.Designer.cs │ │ ├── FormUpdateProduct.cs │ │ ├── FormUpdateProduct.resx │ │ ├── FormUpdateUser.Designer.cs │ │ ├── FormUpdateUser.cs │ │ ├── FormUpdateUser.resx │ │ ├── FormUsers.Designer.cs │ │ ├── FormUsers.cs │ │ ├── FormUsers.resx │ │ ├── FormUsersArchive.Designer.cs │ │ ├── FormUsersArchive.cs │ │ ├── FormUsersArchive.resx │ │ └── IKeepable.cs │ ├── BaseForm.cs │ ├── CashierForms │ │ ├── FormPOS.Designer.cs │ │ ├── FormPOS.cs │ │ ├── FormPOS.resx │ │ ├── FormUpdatePassword.Designer.cs │ │ ├── FormUpdatePassword.cs │ │ ├── FormUpdatePassword.resx │ │ ├── ProcessOrder.Designer.cs │ │ ├── ProcessOrder.cs │ │ └── ProcessOrder.resx │ ├── FormAdminLogin.Designer.cs │ ├── FormAdminLogin.cs │ ├── FormAdminLogin.resx │ ├── FormAdminPanel.Designer.cs │ ├── FormAdminPanel.cs │ ├── FormAdminPanel.resx │ ├── FormCashierPanel.Designer.cs │ ├── FormCashierPanel.cs │ ├── FormCashierPanel.resx │ ├── FormLoading.Designer.cs │ ├── FormLoading.cs │ ├── FormLoading.resx │ ├── FormRegistration.Designer.cs │ ├── FormRegistration.cs │ └── FormRegistration.resx ├── MainForm.Designer.cs ├── MainForm.cs ├── MainForm.resx ├── Models │ ├── Log.cs │ ├── Order.cs │ ├── Product.cs │ ├── Sale.cs │ ├── Transaction.cs │ └── User.cs ├── Program.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings ├── Resources │ ├── FastFoodDatabase.accdb │ ├── archive_gray.png │ ├── archive_white.png │ ├── burger.png │ ├── burger_soda_black.png │ ├── burger_soda_gray.png │ ├── burger_soda_plus_gray.png │ ├── burger_soda_plus_white.png │ ├── burger_soda_white.png │ ├── check.png │ ├── email.png │ ├── error-white.png │ ├── glass.png │ ├── hide.png │ ├── home_gray.png │ ├── home_white.png │ ├── icecream.png │ ├── icon_placeholder.png │ ├── info.png │ ├── key.png │ ├── mcdonalds.png │ ├── product_default.png │ ├── question_circle_gray.png │ ├── receipt_gray.png │ ├── receipt_white.png │ ├── sales_gray.png │ ├── sales_white.png │ ├── search_gray.png │ ├── show.png │ ├── sign_out_gray.png │ ├── sign_out_right_white.png │ ├── soup.png │ ├── unavailable.png │ ├── user_default.png │ ├── users_gray.png │ └── users_white.png ├── Util.cs └── mcdonalds.ico ├── LICENSE.md ├── README.md └── lib ├── ClosedXML.dll ├── DocumentFormat.OpenXml.dll ├── ExcelNumberFormat.dll ├── Guna.UI2.dll ├── LiveCharts.WinForms.dll ├── LiveCharts.Wpf.dll ├── LiveCharts.dll └── MySql.Data.dll /.gitignore: -------------------------------------------------------------------------------- 1 | FastFoodPOS.v11.suo 2 | Thumbs.db 3 | Assets/ 4 | FastFoodPOS/bin/Debug/* 5 | FastFoodPOS/bin/Release/* 6 | FastFoodPOS/bin/x86/* 7 | FastFoodPOS/bin/x64/* 8 | FastFoodPOS/obj/* 9 | FastFoodPOS/Resources/Thumbs.db -------------------------------------------------------------------------------- /FastFoodPOS.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Express 2012 for Windows Desktop 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FastFoodPOS", "FastFoodPOS\FastFoodPOS.csproj", "{24DAF629-492B-47C1-A1A2-43BBB242DB26}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|32bit = Debug|32bit 9 | Debug|64bit = Debug|64bit 10 | Debug|AnyCPU = Debug|AnyCPU 11 | Release|32bit = Release|32bit 12 | Release|64bit = Release|64bit 13 | Release|AnyCPU = Release|AnyCPU 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {24DAF629-492B-47C1-A1A2-43BBB242DB26}.Debug|32bit.ActiveCfg = Debug|x86 17 | {24DAF629-492B-47C1-A1A2-43BBB242DB26}.Debug|32bit.Build.0 = Debug|x86 18 | {24DAF629-492B-47C1-A1A2-43BBB242DB26}.Debug|64bit.ActiveCfg = Debug|x64 19 | {24DAF629-492B-47C1-A1A2-43BBB242DB26}.Debug|64bit.Build.0 = Debug|x64 20 | {24DAF629-492B-47C1-A1A2-43BBB242DB26}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU 21 | {24DAF629-492B-47C1-A1A2-43BBB242DB26}.Debug|AnyCPU.Build.0 = Debug|Any CPU 22 | {24DAF629-492B-47C1-A1A2-43BBB242DB26}.Release|32bit.ActiveCfg = Release|Any CPU 23 | {24DAF629-492B-47C1-A1A2-43BBB242DB26}.Release|64bit.ActiveCfg = Release|Any CPU 24 | {24DAF629-492B-47C1-A1A2-43BBB242DB26}.Release|AnyCPU.ActiveCfg = Release|Any CPU 25 | {24DAF629-492B-47C1-A1A2-43BBB242DB26}.Release|AnyCPU.Build.0 = Release|Any CPU 26 | EndGlobalSection 27 | GlobalSection(SolutionProperties) = preSolution 28 | HideSolutionNode = FALSE 29 | EndGlobalSection 30 | EndGlobal 31 | -------------------------------------------------------------------------------- /FastFoodPOS/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 |
6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | CREATE TABLE IF NOT EXISTS `orders` ( 57 | `id` int(11) NOT NULL AUTO_INCREMENT, 58 | `product_id` int(11) NOT NULL, 59 | `transaction_id` varchar(256) NOT NULL, 60 | `quantity` int(11) NOT NULL, 61 | `price` decimal(10,2) NOT NULL, 62 | PRIMARY KEY(id) 63 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; 64 | 65 | 66 | CREATE TABLE IF NOT EXISTS `products` ( 67 | `id` int(11) NOT NULL AUTO_INCREMENT, 68 | `name` varchar(256) NOT NULL, 69 | `category` varchar(256) NOT NULL, 70 | `price` decimal(10,2) NOT NULL, 71 | `is_available` tinyint(1) NOT NULL, 72 | `image` varchar(256) NOT NULL, 73 | `is_deleted` tinyint(1) NOT NULL DEFAULT '0', 74 | PRIMARY KEY(id) 75 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; 76 | 77 | 78 | CREATE TABLE IF NOT EXISTS `transactions` ( 79 | `id` varchar(256) NOT NULL, 80 | `user_id` int(11) NOT NULL, 81 | `date_created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, 82 | `cash` decimal(10,2) NOT NULL, 83 | PRIMARY KEY(id) 84 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; 85 | 86 | 87 | CREATE TABLE IF NOT EXISTS `users` ( 88 | `id` int(11) NOT NULL AUTO_INCREMENT, 89 | `fullname` varchar(256) NOT NULL, 90 | `email` varchar(256) NOT NULL, 91 | `role` varchar(256) NOT NULL, 92 | `password` varchar(256) NOT NULL, 93 | `image` varchar(256) NOT NULL, 94 | `is_deleted` tinyint(1) NOT NULL DEFAULT '0', 95 | PRIMARY KEY(id) 96 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; 97 | 98 | 99 | CREATE OR REPLACE VIEW `OrderTotal` AS 100 | SELECT transaction_id, SUM(price*quantity) AS total, Sum(quantity) AS orders 101 | FROM orders 102 | GROUP BY transaction_id; 103 | 104 | 105 | CREATE OR REPLACE VIEW `TransactionsView` AS 106 | SELECT transactions.*, OrderTotal.total, OrderTotal.orders 107 | FROM transactions INNER JOIN OrderTotal ON transactions.id=OrderTotal.transaction_id; 108 | 109 | 110 | CREATE OR REPLACE VIEW `SalesView` AS 111 | SELECT Sum(TransactionsView.total) AS Sale, date_created AS day, Sum(TransactionsView.orders) AS total_order, Count(TransactionsView.id) AS total_customer 112 | FROM TransactionsView 113 | GROUP BY day 114 | ORDER BY day; 115 | 116 | 117 | 118 | 119 | 120 | 121 | -------------------------------------------------------------------------------- /FastFoodPOS/Components/AlertNotification.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace FastFoodPOS.Components 2 | { 3 | partial class AlertNotification 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.components = new System.ComponentModel.Container(); 32 | this.timer1 = new System.Windows.Forms.Timer(this.components); 33 | this.guna2Panel1 = new Guna.UI2.WinForms.Guna2Panel(); 34 | this.Label1 = new System.Windows.Forms.Label(); 35 | this.pictureBox1 = new System.Windows.Forms.PictureBox(); 36 | this.guna2Panel1.SuspendLayout(); 37 | ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); 38 | this.SuspendLayout(); 39 | // 40 | // timer1 41 | // 42 | this.timer1.Interval = 1; 43 | this.timer1.Tick += new System.EventHandler(this.timer1_Tick); 44 | // 45 | // guna2Panel1 46 | // 47 | this.guna2Panel1.Controls.Add(this.Label1); 48 | this.guna2Panel1.Controls.Add(this.pictureBox1); 49 | this.guna2Panel1.CustomBorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(50)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); 50 | this.guna2Panel1.CustomBorderThickness = new System.Windows.Forms.Padding(10, 0, 0, 0); 51 | this.guna2Panel1.Dock = System.Windows.Forms.DockStyle.Fill; 52 | this.guna2Panel1.FillColor = System.Drawing.Color.White; 53 | this.guna2Panel1.Location = new System.Drawing.Point(0, 0); 54 | this.guna2Panel1.Name = "guna2Panel1"; 55 | this.guna2Panel1.ShadowDecoration.Parent = this.guna2Panel1; 56 | this.guna2Panel1.Size = new System.Drawing.Size(380, 70); 57 | this.guna2Panel1.TabIndex = 0; 58 | // 59 | // Label1 60 | // 61 | this.Label1.BackColor = System.Drawing.Color.Transparent; 62 | this.Label1.Font = new System.Drawing.Font("Segoe UI", 12F); 63 | this.Label1.ForeColor = System.Drawing.Color.White; 64 | this.Label1.Location = new System.Drawing.Point(68, 9); 65 | this.Label1.MaximumSize = new System.Drawing.Size(300, 50); 66 | this.Label1.Name = "Label1"; 67 | this.Label1.Size = new System.Drawing.Size(300, 50); 68 | this.Label1.TabIndex = 3; 69 | this.Label1.Text = "Success"; 70 | this.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; 71 | // 72 | // pictureBox1 73 | // 74 | this.pictureBox1.BackColor = System.Drawing.Color.Transparent; 75 | this.pictureBox1.Location = new System.Drawing.Point(26, 19); 76 | this.pictureBox1.Name = "pictureBox1"; 77 | this.pictureBox1.Size = new System.Drawing.Size(30, 30); 78 | this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; 79 | this.pictureBox1.TabIndex = 0; 80 | this.pictureBox1.TabStop = false; 81 | // 82 | // AlertNotification 83 | // 84 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 85 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 86 | this.ClientSize = new System.Drawing.Size(380, 70); 87 | this.Controls.Add(this.guna2Panel1); 88 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; 89 | this.Name = "AlertNotification"; 90 | this.ShowInTaskbar = false; 91 | this.Text = "AlertNotification"; 92 | this.guna2Panel1.ResumeLayout(false); 93 | ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); 94 | this.ResumeLayout(false); 95 | 96 | } 97 | 98 | #endregion 99 | 100 | private System.Windows.Forms.Timer timer1; 101 | private Guna.UI2.WinForms.Guna2Panel guna2Panel1; 102 | private System.Windows.Forms.PictureBox pictureBox1; 103 | internal System.Windows.Forms.Label Label1; 104 | } 105 | } -------------------------------------------------------------------------------- /FastFoodPOS/Components/AlertNotification.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | 11 | namespace FastFoodPOS.Components 12 | { 13 | public partial class AlertNotification : Form 14 | { 15 | 16 | private static List OpenForms = new List(); 17 | Action action; 18 | 19 | public enum AlertType 20 | { 21 | SUCCESS, 22 | WARNING, 23 | ERROR, 24 | INFO 25 | } 26 | 27 | enum Action 28 | { 29 | WAIT, 30 | START, 31 | CLOSE 32 | } 33 | 34 | int x, y; 35 | 36 | public AlertNotification(string message, AlertType type) 37 | { 38 | InitializeComponent(); 39 | string fname; 40 | Opacity = 0; 41 | StartPosition = FormStartPosition.Manual; 42 | for (int i = 1; i <= 10; i++) 43 | { 44 | fname = "alert" + i; 45 | var alert = OpenForms.FirstOrDefault((forms) => forms.Name == fname); 46 | if (alert == null) 47 | { 48 | Name = fname; 49 | x = Screen.PrimaryScreen.WorkingArea.Width - Width + 15; 50 | y = Screen.PrimaryScreen.WorkingArea.Height - Height * i - 5 * i; 51 | Location = new Point(x, y); 52 | OpenForms.Add(this); 53 | break; 54 | } 55 | } 56 | x = Screen.PrimaryScreen.WorkingArea.Width - Width - 5; 57 | 58 | switch (type) 59 | { 60 | case AlertType.SUCCESS: 61 | pictureBox1.Image = Properties.Resources.check; 62 | guna2Panel1.FillColor = Color.FromArgb(82, 152, 114); 63 | break; 64 | case AlertType.WARNING: 65 | pictureBox1.Image = Properties.Resources.error_white; 66 | guna2Panel1.FillColor = Color.FromArgb(255, 164, 91); 67 | break; 68 | case AlertType.ERROR: 69 | pictureBox1.Image = Properties.Resources.error_white; 70 | guna2Panel1.FillColor = Color.FromArgb(255, 70, 70); 71 | break; 72 | case AlertType.INFO: 73 | pictureBox1.Image = Properties.Resources.info; 74 | guna2Panel1.FillColor = Color.FromArgb(71, 169, 248); 75 | break; 76 | } 77 | 78 | Label1.Text = message; 79 | 80 | } 81 | 82 | 83 | public void showAlert() 84 | { 85 | action = Action.START; 86 | TopMost = true; 87 | Show(); 88 | timer1.Start(); 89 | } 90 | 91 | public static void ShowAlertMessage(string message, AlertType type) 92 | { 93 | var alert = (new AlertNotification(message, type)); 94 | alert.showAlert(); 95 | } 96 | 97 | private void timer1_Tick(object sender, EventArgs e) 98 | { 99 | switch (action) 100 | { 101 | case Action.START: 102 | timer1.Interval = 1; 103 | Opacity += 0.1; 104 | if (x < Location.X) 105 | { 106 | Left -= 1; 107 | } 108 | else 109 | { 110 | if (Opacity == 1) 111 | { 112 | action = Action.WAIT; 113 | } 114 | } 115 | break; 116 | case Action.WAIT: 117 | timer1.Interval = 3000; 118 | action = Action.CLOSE; 119 | break; 120 | case Action.CLOSE: 121 | timer1.Interval = 1; 122 | Opacity -= 0.1; 123 | Left += 1; 124 | if (Opacity == 0) 125 | { 126 | OpenForms.Remove(this); 127 | Dispose(); 128 | } 129 | break; 130 | } 131 | } 132 | } 133 | } 134 | -------------------------------------------------------------------------------- /FastFoodPOS/Components/OrderItemComponent.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Drawing; 5 | using System.Data; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | using FastFoodPOS.Models; 11 | 12 | namespace FastFoodPOS.Components 13 | { 14 | partial class OrderItemComponent : UserControl 15 | { 16 | 17 | public Order _Order; 18 | 19 | private BindingList Orders; 20 | 21 | public event EventHandler OnOrderIncrement; 22 | 23 | public OrderItemComponent(BindingList Orders, Order order) 24 | { 25 | InitializeComponent(); 26 | Dock = DockStyle.Top; 27 | _Order = order; 28 | this.Orders = Orders; 29 | LabelName.Text = order.GetProduct().Name; 30 | } 31 | 32 | public void UpdateData() 33 | { 34 | LabelQuantity.Text = _Order.Quantity.ToString(); 35 | LabelSubtotal.Text = _Order.Subtotal.ToString() + "PHP"; 36 | } 37 | 38 | private void ButtonAdd_Click(object sender, EventArgs e) 39 | { 40 | if (OnOrderIncrement != null) OnOrderIncrement(1, this); 41 | /* 42 | _Order.Quantity++; 43 | Orders.ResetBindings(); 44 | */ 45 | } 46 | 47 | private void ButtonMinus_Click(object sender, EventArgs e) 48 | { 49 | if (OnOrderIncrement != null) OnOrderIncrement(-1, this); 50 | } 51 | 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /FastFoodPOS/Components/OrderItemComponent.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /FastFoodPOS/Components/ProductCardComponent.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Drawing; 5 | using System.Data; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | using FastFoodPOS.Models; 11 | using FastFoodPOS.Forms; 12 | using FastFoodPOS.Forms.AdminForms; 13 | 14 | namespace FastFoodPOS.Components 15 | { 16 | partial class ProductCardComponent : UserControl 17 | { 18 | public Product product; 19 | 20 | [Browsable(true)] 21 | [Category("Action")] 22 | public event EventHandler ButtonUpdateClick; 23 | 24 | [Browsable(true)] 25 | [Category("Action")] 26 | public event EventHandler ButtonRemoveClick; 27 | 28 | public ProductCardComponent(Product product) 29 | { 30 | InitializeComponent(); 31 | this.product = product; 32 | UpdateData(); 33 | } 34 | 35 | public void UpdateData() 36 | { 37 | PictureProductImage.ImageLocation = product.Image; 38 | LabelProductName.Text = product.Name; 39 | LabelPrice.Text = product.Price + "PHP"; 40 | 41 | if (product.IsAvailable) 42 | { 43 | ButtonSetAvailability.FillColor = Color.FromArgb(179, 15, 25); 44 | ButtonSetAvailability.Text = "Availability: Available"; 45 | } 46 | else 47 | { 48 | ButtonSetAvailability.FillColor = Color.Gray; 49 | ButtonSetAvailability.Text = "Availability: Not Available"; 50 | } 51 | } 52 | 53 | private void ButtonUpdate_Click(object sender, EventArgs e) 54 | { 55 | if (this.ButtonUpdateClick != null) 56 | { 57 | this.ButtonUpdateClick(sender, this); 58 | } 59 | } 60 | 61 | private void ButtonSetAvailability_Click(object sender, EventArgs e) 62 | { 63 | DialogResult result = ShowConfirmDialog(); 64 | if (result == DialogResult.Yes) 65 | { 66 | if (product.IsAvailable) Log.AddLog("Set product[" + product.Id + "] to Unavailable"); 67 | else Log.AddLog("Set product[" + product.Id + "] to Available"); 68 | product.ToggleAvailability(); 69 | AlertNotification.ShowAlertMessage("Product updated successfully", AlertNotification.AlertType.SUCCESS); 70 | UpdateData(); 71 | } 72 | } 73 | 74 | private DialogResult ShowConfirmDialog() 75 | { 76 | return Dialog.ConfirmDialogBox.ShowDialog( 77 | product.IsAvailable 78 | ? "Are you sure to make this product Unavailable" 79 | : "Are you sure to make this product Available"); 80 | } 81 | 82 | private void ButtonRemove_Click(object sender, EventArgs e) 83 | { 84 | if (this.ButtonRemoveClick != null) 85 | { 86 | this.ButtonRemoveClick(sender, this); 87 | } 88 | } 89 | 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /FastFoodPOS/Components/ProductCardComponent.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /FastFoodPOS/Components/ProductCardComponent1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Drawing; 5 | using System.Data; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | using FastFoodPOS.Models; 11 | using FastFoodPOS.Forms; 12 | 13 | namespace FastFoodPOS.Components 14 | { 15 | partial class ProductCardComponent1 : UserControl 16 | { 17 | Product product; 18 | 19 | public event EventHandler ButtonAddProductClick; 20 | 21 | public ProductCardComponent1(Product product) 22 | { 23 | InitializeComponent(); 24 | this.product = product; 25 | 26 | ButtonAddProduct.Visible = product.IsAvailable; 27 | ButtonUnavailable.Visible = !product.IsAvailable; 28 | 29 | } 30 | 31 | private void ButtonAddProduct_Click(object sender, EventArgs e) 32 | { 33 | if (ButtonAddProductClick != null) ButtonAddProductClick(sender, product); 34 | } 35 | 36 | private void ProductCardComponent1_Load(object sender, EventArgs e) 37 | { 38 | LabelName.Text = product.Name; 39 | LabelPrice.Text = product.Price + "PHP"; 40 | PictureProductImage.ImageLocation = product.Image; 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /FastFoodPOS/Components/ProductCardComponent1.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /FastFoodPOS/Components/ReceiptTemplate.cs: -------------------------------------------------------------------------------- 1 | using FastFoodPOS.Models; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace FastFoodPOS.Components 9 | { 10 | class ReceiptTemplate 11 | { 12 | 13 | public static string GetReceipt(Transaction transaction) 14 | { 15 | return GenerateReceiptTemplate() 16 | .Replace("", GetOrderRows(transaction)) 17 | .Replace("", transaction.Total.ToString() + "PHP") 18 | .Replace("", transaction.Cash.ToString() + "PHP") 19 | .Replace("", transaction.Change.ToString() + "PHP") 20 | .Replace("", transaction.Id) 21 | .Replace("", transaction.GetCashier().Fullname) 22 | .Replace("", transaction.Date.ToString()); 23 | } 24 | 25 | static string GetOrderRows(Transaction transaction) 26 | { 27 | string result = ""; 28 | transaction.GetOrders().ForEach((Order item) => { 29 | result += ""; 30 | result += "" + item.GetProduct().Name + ""; 31 | result += "x " + item.Quantity + ""; 32 | result += "" + item.Subtotal + "PHP"; 33 | result += ""; 34 | }); 35 | return result; 36 | } 37 | 38 | private static string GenerateReceiptTemplate() 39 | { 40 | return 41 | @" 42 |
43 | WcDonalds
44 | wcdonalds@gmail.com 45 |
46 |

47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 |
Product NameQuantitySubtotal
59 |
60 |
---------------------------------------
61 |
62 | 63 | Total:
64 | Cash:
65 | Change:
66 |
67 | Transaction ID: #
68 | Cashier:
69 | Date:
70 | 71 |
72 |
---------------------------------------
73 |
74 | 75 |
Thanks for visiting WcDonalds
76 | "; 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /FastFoodPOS/Components/UserCardComponent.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Drawing; 5 | using System.Data; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | using FastFoodPOS.Models; 11 | using FastFoodPOS.Forms; 12 | using FastFoodPOS.Forms.AdminForms; 13 | 14 | namespace FastFoodPOS.Components 15 | { 16 | partial class UserCardComponent : UserControl 17 | { 18 | User user; 19 | 20 | public event EventHandler OnUpdateButton_Click; 21 | public event EventHandler OnRemoveButton_Click; 22 | public event EventHandler OnActivityLogButton_Click; 23 | 24 | public UserCardComponent(User user) 25 | { 26 | InitializeComponent(); 27 | 28 | this.user = user; 29 | 30 | LabelNameRole.Text = user.Fullname + " (" + user.Role + ")"; 31 | LabelEmail.Text = user.Email; 32 | PictureImage.Image = Util.GetImageFromFile(user.Image); 33 | 34 | BackColor = Color.Transparent; 35 | Dock = DockStyle.Top; 36 | 37 | foreach (Control control in Controls) 38 | { 39 | control.MouseEnter += this.UserCardComponent_MouseHover; 40 | control.MouseLeave += this.UserCardComponent_MouseLeave; 41 | } 42 | 43 | } 44 | 45 | private void UserCardComponent_MouseHover(object sender, EventArgs e) 46 | { 47 | BackColor = SystemColors.Control; 48 | } 49 | 50 | private void UserCardComponent_MouseLeave(object sender, EventArgs e) 51 | { 52 | BackColor = Color.Transparent; 53 | } 54 | 55 | private void ButtonUpdate_Click(object sender, EventArgs e) 56 | { 57 | if (OnUpdateButton_Click != null) 58 | { 59 | OnUpdateButton_Click(this, user); 60 | } 61 | } 62 | 63 | private void ButtonRemove_Click(object sender, EventArgs e) 64 | { 65 | if (OnRemoveButton_Click != null) 66 | { 67 | OnRemoveButton_Click(this, user); 68 | } 69 | } 70 | 71 | private void ButtonActivityLogs_Click(object sender, EventArgs e) 72 | { 73 | if (OnActivityLogButton_Click != null) 74 | { 75 | OnActivityLogButton_Click(this, user); 76 | } 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /FastFoodPOS/Components/Validator.cs: -------------------------------------------------------------------------------- 1 | using FastFoodPOS.DatabaseUtil; 2 | using FastFoodPOS.Models; 3 | using Guna.UI2.WinForms; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Drawing; 7 | using System.Linq; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | 11 | namespace FastFoodPOS.Components 12 | { 13 | class Validator 14 | { 15 | private Color default_border_color; 16 | private Guna2TextBox control; 17 | private Label error_message; 18 | private string name; 19 | private string rules; 20 | private bool is_valid = false; 21 | 22 | public Guna2TextBox compare_control { get; set; } 23 | public string unique_ignore { get; set; } 24 | 25 | public Validator(Guna2TextBox control, Label error_message, string name, string rules) 26 | { 27 | this.control = control; 28 | this.default_border_color = control.BorderColor; 29 | this.error_message = error_message; 30 | this.name = name; 31 | this.rules = rules; 32 | this.control.Leave += control_LostFocus; 33 | ResetStyle(); 34 | } 35 | 36 | void control_LostFocus(object sender, EventArgs e) 37 | { 38 | Validate(); 39 | } 40 | 41 | public void Validate() 42 | { 43 | ResetStyle(); 44 | is_valid = true; 45 | string text = control.Text.Trim(); 46 | string[] rules = this.rules.Split('|'); 47 | foreach(string ruleString in rules) 48 | { 49 | 50 | string[] rule = ruleString.Split(':'); 51 | string ruleBody = rule[0]; 52 | string ruleParam = rule.Length > 1 ? rule[1] : ""; 53 | 54 | if(ruleBody.Equals("required") && text.Length == 0) { 55 | is_valid = false; 56 | control.BorderColor = Color.Red; 57 | error_message.Text = "The " + name + " field is required"; 58 | break; 59 | } 60 | else if (ruleBody.Equals("min") && text.Length < Int32.Parse(ruleParam)) 61 | { 62 | is_valid = false; 63 | control.BorderColor = Color.Red; 64 | error_message.Text = "The " + name + " field must have atleast " + ruleParam + " characters"; 65 | break; 66 | } 67 | else if (ruleBody.Equals("email") && !Util.IsEmail(text)) 68 | { 69 | is_valid = false; 70 | control.BorderColor = Color.Red; 71 | error_message.Text = "The " + name + " field must be a valid email"; 72 | break; 73 | } 74 | else if (ruleBody.Equals("unique") && !isUnique(text, ruleParam.Split(','))) 75 | { 76 | is_valid = false; 77 | control.BorderColor = Color.Red; 78 | error_message.Text = "The " + name + " already exists"; 79 | break; 80 | } 81 | else if (ruleBody.Equals("compare") && !text.Equals(compare_control.Text)) 82 | { 83 | is_valid = false; 84 | control.BorderColor = Color.Red; 85 | error_message.Text = "The " + name + " field does not match"; 86 | break; 87 | } 88 | else if (ruleBody.Equals("name") && !isValidName(text)) 89 | { 90 | is_valid = false; 91 | control.BorderColor = Color.Red; 92 | error_message.Text = "The "+ name + " field must not contain numbers and symbols"; 93 | break; 94 | } 95 | } 96 | } 97 | 98 | public bool isUnique(string text, string[] ruleParams) 99 | { 100 | bool result = true; 101 | string table = ruleParams[0]; 102 | string column = ruleParams[1]; 103 | if (unique_ignore != control.Text && Database.IsExist(table, column, text.Trim())) 104 | result = false; 105 | return result; 106 | } 107 | 108 | public bool isValidName(string name) 109 | { 110 | bool result = true; 111 | foreach(char val in name.ToCharArray()){ 112 | if (!char.IsLetter(val) && val != ' ' && val != '-') 113 | {//The name must not contain symbos except [space] and [hypen] 114 | result = false; 115 | break; 116 | } 117 | if(char.IsNumber(val)) { //the name must not contains a number 118 | result = false; 119 | break; 120 | } 121 | } 122 | return result; 123 | } 124 | 125 | public void Reset() 126 | { 127 | ResetStyle(); 128 | } 129 | 130 | public bool IsValid() 131 | { 132 | Validate(); 133 | return is_valid; 134 | } 135 | 136 | void ResetStyle() 137 | { 138 | error_message.Text = ""; 139 | control.BorderColor = default_border_color; 140 | } 141 | 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /FastFoodPOS/DatabaseUtil/Database.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Data.Common; 4 | using System.Data.OleDb; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace FastFoodPOS.DatabaseUtil 10 | { 11 | class Database 12 | { 13 | private static DatabaseProvider Provider = null; 14 | 15 | public static DbConnection GetConnection() 16 | { 17 | return GetProvider().GetConnection(); 18 | } 19 | 20 | 21 | public static DbCommand CreateCommand(string query) 22 | { 23 | return GetProvider().CreateCommand(query); 24 | } 25 | 26 | public static DatabaseProvider GetProvider() 27 | { 28 | if (Provider == null) 29 | { 30 | if (Util.GetConfig("DbProvider") == "MSACCESS") 31 | { 32 | Provider = new DatabaseMSAccessProvider(); 33 | } 34 | else if (Util.GetConfig("DbProvider") == "MYSQL") 35 | { 36 | Provider = new DatabaseMySQLProvider(); 37 | } 38 | } 39 | return Provider; 40 | } 41 | 42 | public static void BindParameters(DbCommand cmd, params object[] parameters) 43 | { 44 | GetProvider().BindParameters(cmd, parameters); 45 | } 46 | 47 | public static bool IsExist(string table, string column, object value) 48 | { 49 | return GetProvider().IsExist(table, column, value); 50 | } 51 | 52 | public static bool IsValidConnection() 53 | { 54 | try 55 | { 56 | GetConnection().Open(); 57 | GetConnection().Close(); 58 | return true; 59 | } 60 | catch (Exception e) 61 | { 62 | Console.WriteLine(e); 63 | return false; 64 | } 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /FastFoodPOS/DatabaseUtil/DatabaseMSAccessProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Data.Common; 3 | using System.Data.OleDb; 4 | 5 | namespace FastFoodPOS.DatabaseUtil 6 | { 7 | class DatabaseMSAccessProvider : DatabaseProvider 8 | { 9 | private OleDbConnection connection = null; 10 | public override DbConnection GetConnection() 11 | { 12 | if (connection == null) 13 | { 14 | connection = new OleDbConnection(GetConnectionString()); 15 | } 16 | return connection; 17 | } 18 | 19 | private static string GetConnectionString() 20 | { 21 | return Util.GetConfig("ConnectionString") + ";Jet OLEDB:Database Password=" + Util.GetConfig("Password"); 22 | } 23 | 24 | public override DbCommand CreateCommand(string query) 25 | { 26 | return new OleDbCommand(query, GetConnection() as OleDbConnection); 27 | } 28 | 29 | public override void BindParameters(DbCommand _cmd, params object[] parameters) 30 | { 31 | OleDbCommand cmd = _cmd as OleDbCommand; 32 | cmd.Parameters.Clear(); 33 | for (int i = 0; i < parameters.Length; i++) 34 | { 35 | cmd.Parameters.AddWithValue("@p" + (i+1), parameters[i]); 36 | } 37 | } 38 | 39 | public override bool IsExist(string table, string column, object value) 40 | { 41 | bool result = false; 42 | using(var cmd = CreateCommand("SELECT COUNT(*) FROM " + table + " WHERE " + column + " = ?")) 43 | { 44 | BindParameters(cmd, value); 45 | GetConnection().Open(); 46 | result = int.Parse(cmd.ExecuteScalar().ToString()) > 0; 47 | GetConnection().Close(); 48 | } 49 | return result; 50 | } 51 | 52 | public override string FormatShortDate(DateTime day) 53 | { 54 | return day.ToShortDateString(); 55 | } 56 | 57 | 58 | public override string FormatDateTime(DateTime date) 59 | { 60 | return date.ToString(); 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /FastFoodPOS/DatabaseUtil/DatabaseMySQLProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using MySql.Data.MySqlClient; 3 | using System.Data.Common; 4 | 5 | namespace FastFoodPOS.DatabaseUtil 6 | { 7 | class DatabaseMySQLProvider : DatabaseProvider 8 | { 9 | 10 | private MySqlConnection connection = null; 11 | 12 | public override DbConnection GetConnection() 13 | { 14 | if (connection == null) 15 | { 16 | string host = Util.GetConfig("host"); 17 | string user = Util.GetConfig("user"); 18 | string pass = Util.GetConfig("pass"); 19 | string db = Util.GetConfig("db"); 20 | string connection_strng = "SERVER=" + host + ";DATABASE=" + db + ";UID=" + user + ";PASSWORD=" + pass + ";"; 21 | connection = new MySqlConnection(connection_strng); 22 | } 23 | return connection; 24 | } 25 | 26 | public override DbCommand CreateCommand(string query) 27 | { 28 | return new MySqlCommand(query, GetConnection() as MySqlConnection); 29 | } 30 | 31 | public override void BindParameters(DbCommand _cmd, params object[] parameters) 32 | { 33 | MySqlCommand cmd = _cmd as MySqlCommand; 34 | cmd.Parameters.Clear(); 35 | cmd.Parameters.Clear(); 36 | for (int i = 0; i < parameters.Length; i++) 37 | { 38 | cmd.Parameters.AddWithValue("@p" + (i+1), parameters[i]); 39 | } 40 | } 41 | 42 | public override bool IsExist(string table, string column, object value) 43 | { 44 | bool result = false; 45 | using (var cmd = CreateCommand("SELECT COUNT(*) FROM " + table + " WHERE " + column + " = ?")) 46 | { 47 | BindParameters(cmd, value); 48 | GetConnection().Open(); 49 | result = int.Parse(cmd.ExecuteScalar().ToString()) > 0; 50 | GetConnection().Close(); 51 | } 52 | return result; 53 | } 54 | 55 | public override void ImportTables() 56 | { 57 | using (var cmd = CreateCommand(Properties.Settings.Default.MySQLTables)) 58 | { 59 | GetConnection().Open(); 60 | cmd.ExecuteNonQuery(); 61 | GetConnection().Close(); 62 | } 63 | } 64 | 65 | public override string FormatShortDate(DateTime day) 66 | { 67 | return day.ToString("yyyy-MM-dd"); 68 | } 69 | 70 | public override string QUERY_SALES_BETWEEN_1{ 71 | get{ return "SELECT * FROM SalesView WHERE day BETWEEN CAST('@@from' AS DATE) AND CAST('@@to' AS DATE)"; } 72 | } 73 | 74 | public override string FormatDateTime(DateTime date) 75 | { 76 | return date.ToString("YYYY-MM-DD HH:MM:SS"); 77 | } 78 | 79 | public override string QUERY_GET_TRANSACTIONS{ 80 | get { return "SELECT * FROM `TransactionsView` WHERE DATE(`date_created`)=@p1"; } 81 | } 82 | 83 | public override string QUERY_GENERATE_TRANSACTION_ID { 84 | get { return "SELECT COUNT(*) FROM `transactions` WHERE DATE(`date_created`)=DATE(NOW())"; } 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /FastFoodPOS/DatabaseUtil/DatabaseProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Data.Common; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace FastFoodPOS.DatabaseUtil 9 | { 10 | abstract class DatabaseProvider 11 | { 12 | public abstract DbConnection GetConnection(); 13 | public abstract DbCommand CreateCommand(string query); 14 | public abstract void BindParameters(DbCommand _cmd, params object[] parameters); 15 | public abstract bool IsExist(string table, string column, object value); 16 | public abstract string FormatShortDate(DateTime day); 17 | public abstract string FormatDateTime(DateTime date); 18 | 19 | public virtual void ImportTables() { } 20 | 21 | public virtual string QUERY_SALES_BETWEEN_1{ 22 | get{ return "SELECT * FROM SalesView WHERE day BETWEEN #@@from# AND #@@to#"; } 23 | } 24 | 25 | public virtual string QUERY_GET_TRANSACTIONS { 26 | get { return "SELECT * FROM `TransactionsView` WHERE FIX(`date_created`)=@p1"; } 27 | } 28 | 29 | public virtual string QUERY_GENERATE_TRANSACTION_ID { 30 | get { return "SELECT COUNT(*) FROM `transactions` WHERE FIX(`date_created`)=FIX(NOW())"; } 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /FastFoodPOS/Dialog/BackupDialogBox.cs: -------------------------------------------------------------------------------- 1 | using ClosedXML.Excel; 2 | using FastFoodPOS.Models; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.ComponentModel; 6 | using System.Data; 7 | using System.Drawing; 8 | using System.IO; 9 | using System.Linq; 10 | using System.Text; 11 | using System.Threading.Tasks; 12 | using System.Windows.Forms; 13 | 14 | namespace FastFoodPOS.Dialog 15 | { 16 | public partial class BackupDialogBox : Form 17 | { 18 | 19 | 20 | public BackupDialogBox() 21 | { 22 | InitializeComponent(); 23 | guna2ShadowForm1.SetShadowForm(this); 24 | 25 | } 26 | 27 | private void BtnStart_Click(object sender, EventArgs e) 28 | { 29 | panelButton.Visible = false; 30 | panelLoading.Visible = true; 31 | backgroundWorker1.RunWorkerAsync(); 32 | } 33 | 34 | private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) 35 | { 36 | 37 | DataTable usersTable, productsTable, transactionsTable, ordersTable; 38 | 39 | usersTable = new DataTable(); 40 | usersTable.Columns.Add("id"); 41 | usersTable.Columns.Add("fullname"); 42 | usersTable.Columns.Add("email"); 43 | usersTable.Columns.Add("password"); 44 | usersTable.Columns.Add("role"); 45 | usersTable.Columns.Add("is_deleted"); 46 | 47 | productsTable = new DataTable(); 48 | productsTable.Columns.Add("id"); 49 | productsTable.Columns.Add("name"); 50 | productsTable.Columns.Add("category"); 51 | productsTable.Columns.Add("price"); 52 | productsTable.Columns.Add("is_available"); 53 | productsTable.Columns.Add("is_deleted"); 54 | 55 | transactionsTable = new DataTable(); 56 | transactionsTable.Columns.Add("id"); 57 | transactionsTable.Columns.Add("user_id"); 58 | transactionsTable.Columns.Add("date_created"); 59 | transactionsTable.Columns.Add("cash"); 60 | 61 | ordersTable = new DataTable(); 62 | ordersTable.Columns.Add("id"); 63 | ordersTable.Columns.Add("product_id"); 64 | ordersTable.Columns.Add("transaction_id"); 65 | ordersTable.Columns.Add("quantity"); 66 | ordersTable.Columns.Add("price"); 67 | 68 | List users = User.GetAll(true); 69 | List transactions = Transaction.GetAllTransactions(); 70 | List orders = Order.GetAll(); 71 | List products = new List(); 72 | products.AddRange(Product.GetAllProducts()); 73 | products.AddRange(Product.GetAllDeleted()); 74 | 75 | users.ForEach(user => usersTable.Rows.Add(user.Id, user.Fullname,user.Email, user.Password ,user.Role, user.IsDeleted)); 76 | transactions.ForEach(transaction => transactionsTable.Rows.Add(transaction.Id, transaction.CashierId, transaction.Date, transaction.Cash)); 77 | orders.ForEach(order => ordersTable.Rows.Add(order.Id, order.ProductId, order.TransactionId, order.Quantity, order.Price)); 78 | products.ForEach(product => productsTable.Rows.Add(product.Id, product.Name, product.Category, product.Price, product.IsAvailable, product.IsDeleted)); 79 | 80 | string filename = GetFileName(); 81 | //string filenamedb = filename + ".accdb"; 82 | 83 | XLWorkbook wb = new XLWorkbook(); 84 | wb.Worksheets.Add(usersTable, "users"); 85 | wb.Worksheets.Add(productsTable, "products"); 86 | wb.Worksheets.Add(transactionsTable, "transactions"); 87 | wb.Worksheets.Add(ordersTable, "orders"); 88 | wb.SaveAs(filename); 89 | 90 | e.Result = filename; 91 | } 92 | 93 | 94 | string GetFileName() 95 | { 96 | string name = DateTime.Now.ToString("yyyy_MM_dd_hhmmss") + ".xlsx"; 97 | if (!Directory.Exists("backup")) Directory.CreateDirectory("backup"); 98 | return Path.Combine("backup", name); 99 | } 100 | 101 | private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) 102 | { 103 | panelLoading.Visible = false; 104 | panelSuccess.Visible = true; 105 | lblFilename.Text = e.Result.ToString(); 106 | } 107 | 108 | private void ButtonNo_Click(object sender, EventArgs e) 109 | { 110 | Close(); 111 | } 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /FastFoodPOS/Dialog/ConfirmDialogBox.cs: -------------------------------------------------------------------------------- 1 | using Guna.UI2.WinForms; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.ComponentModel; 5 | using System.Data; 6 | using System.Drawing; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | using System.Windows.Forms; 11 | 12 | namespace FastFoodPOS.Dialog 13 | { 14 | public partial class ConfirmDialogBox : Form 15 | { 16 | public ConfirmDialogBox(string text) 17 | { 18 | InitializeComponent(); 19 | guna2ShadowForm1.SetShadowForm(this); 20 | label2.Text = text; 21 | } 22 | 23 | private void ButtonYes_Click(object sender, EventArgs e) 24 | { 25 | DialogResult = DialogResult.Yes; 26 | Dispose(); 27 | } 28 | 29 | private void ButtonNo_Click(object sender, EventArgs e) 30 | { 31 | DialogResult = DialogResult.No; 32 | Dispose(); 33 | } 34 | 35 | public static DialogResult ShowDialog(string text) 36 | { 37 | return (new ConfirmDialogBox(text)).ShowDialog(); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /FastFoodPOS/Dialog/HelpDialogBox.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | 11 | namespace FastFoodPOS.Dialog 12 | { 13 | public partial class HelpDialogBox : Form 14 | { 15 | public HelpDialogBox() 16 | { 17 | InitializeComponent(); 18 | guna2ShadowForm1.SetShadowForm(this); 19 | } 20 | 21 | public static void ShowHelpDialog() 22 | { 23 | HelpDialogBox x = new HelpDialogBox(); 24 | x.ShowDialog(); 25 | } 26 | 27 | private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 28 | { 29 | System.Diagnostics.Process.Start(linkLabel1.Text); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /FastFoodPOS/ErrorHandler/Level1Exception.cs: -------------------------------------------------------------------------------- 1 | using FastFoodPOS.Components; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows.Forms; 8 | 9 | namespace FastFoodPOS.ErrorHandler 10 | { 11 | class Level1Exception : Exception 12 | { 13 | public Level1Exception(string message) : base(message) 14 | { 15 | } 16 | 17 | public void DisplayMessage() 18 | { 19 | //MessageBox.Show(Message); 20 | AlertNotification.ShowAlertMessage(Message, AlertNotification.AlertType.ERROR); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /FastFoodPOS/FastFoodPOS.csproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | publish\ 5 | 6 | 7 | 8 | 9 | 10 | en-US 11 | false 12 | 13 | -------------------------------------------------------------------------------- /FastFoodPOS/Forms/AdminForms/FormActivityLog.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Drawing; 5 | using System.Data; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | using FastFoodPOS.Models; 11 | 12 | namespace FastFoodPOS.Forms.AdminForms 13 | { 14 | partial class FormActivityLog : UserControl 15 | { 16 | public FormActivityLog(User user) 17 | { 18 | InitializeComponent(); 19 | var logs = Log.GetLogs(user); 20 | logs.ForEach(log => 21 | { 22 | DataGridViewLogs.Rows.Add( 23 | log.date_created.ToString(), 24 | user.Fullname, 25 | log.activity 26 | ); 27 | }); 28 | if (logs.Count == 0) 29 | { 30 | DataGridViewLogs.Rows.Add( 31 | "", "There is no activity made by this user", "" 32 | ); 33 | } 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /FastFoodPOS/Forms/AdminForms/FormAddProduct.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Drawing; 5 | using System.Data; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | using FastFoodPOS.Models; 11 | using FastFoodPOS.Components; 12 | 13 | namespace FastFoodPOS.Forms.AdminForms 14 | { 15 | public partial class FormAddProduct : UserControl 16 | { 17 | List validators; 18 | string category; 19 | public FormAddProduct(string from) 20 | { 21 | InitializeComponent(); 22 | PictureProductImage.ImageLocation = Product.DEFAULT_IMAGE_PATH; 23 | 24 | category = from; 25 | 26 | ComboBoxType.Text = category; 27 | 28 | validators = new List(); 29 | validators.Add(new Validator(TextName, LabelName, "Name", "required")); 30 | 31 | } 32 | 33 | private void ButtonSave_Click(object sender, EventArgs e) 34 | { 35 | if(IsValid()){ 36 | Product nProduct = new Product 37 | { 38 | Name = TextName.Text, 39 | Category = ComboBoxType.Text, 40 | Price = TextPrice.Value, 41 | IsAvailable = ToggleAvailability.Checked, 42 | Image = PictureProductImage.ImageLocation 43 | }; 44 | nProduct.Save(); 45 | category = ComboBoxType.Text; 46 | Log.AddLog("Add new product name " + TextName.Text); 47 | AlertNotification.ShowAlertMessage("Product added Successfully", AlertNotification.AlertType.SUCCESS); 48 | LinkBack_LinkClicked(null, null); 49 | } 50 | } 51 | 52 | private bool IsValid() 53 | { 54 | return validators.All((validator) => validator.IsValid()); 55 | } 56 | 57 | private void ButtonChangeImage_Click(object sender, EventArgs e) 58 | { 59 | if (OpenFileDialogChangeImage.ShowDialog() == DialogResult.OK) 60 | { 61 | PictureProductImage.ImageLocation = OpenFileDialogChangeImage.FileName; 62 | } 63 | } 64 | 65 | private void ButtonReset_Click(object sender, EventArgs e) 66 | { 67 | PictureProductImage.ImageLocation = Product.DEFAULT_IMAGE_PATH; 68 | TextName.Text = ""; 69 | ComboBoxType.SelectedIndex = 0; 70 | ToggleAvailability.Checked = true; 71 | TextPrice.Text = ""; 72 | validators.ForEach((validator) => validator.Reset()); 73 | } 74 | 75 | private void TextPrice_Leave(object sender, EventArgs e) 76 | { 77 | if (TextPrice.Text.Length == 0) 78 | { 79 | TextPrice.Text = "0"; 80 | } 81 | } 82 | 83 | private void FormAddProduct_Load(object sender, EventArgs e) 84 | { 85 | ParentForm.AcceptButton = ButtonSave; 86 | } 87 | 88 | private void LinkBack_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 89 | { 90 | FormAdminPanel.GetInstance().LoadFormControl(new FormManageProducts(category)); 91 | } 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /FastFoodPOS/Forms/AdminForms/FormAddUser.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Drawing; 5 | using System.Data; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | using FastFoodPOS.Models; 11 | using FastFoodPOS.ErrorHandler; 12 | using FastFoodPOS.Components; 13 | 14 | namespace FastFoodPOS.Forms.AdminForms 15 | { 16 | public partial class FormAddUser : UserControl 17 | { 18 | 19 | List validators; 20 | 21 | public FormAddUser() 22 | { 23 | InitializeComponent(); 24 | PictureUserImage.ImageLocation = User.DEFAULT_IMAGE_PATH; 25 | validators = new List(); 26 | validators.Add(new Validator(TextName, LabelName, "Name", "required|min:5|name")); 27 | validators.Add(new Validator(TextEmail, LabelEmail, "Email", "required|email|unique:users,email")); 28 | validators.Add(new Validator(TextPassword, LabelPassword, "Password", "required|min:8")); 29 | validators.Add(new Validator(TextConfirmPassword, LabelConfirmPassword, "Confirm Password", "required|min:8|compare"){ compare_control = TextPassword}); 30 | } 31 | 32 | private void ButtonBack_Click(object sender, EventArgs e) 33 | { 34 | FormAdminPanel.GetInstance().LoadFormControl(new FormUsers()); 35 | } 36 | 37 | private void ButtonChangeImage_Click(object sender, EventArgs e) 38 | { 39 | if (OpenFileDialogChangeImage.ShowDialog() == DialogResult.OK) 40 | { 41 | PictureUserImage.ImageLocation = OpenFileDialogChangeImage.FileName; 42 | } 43 | } 44 | 45 | private void ButtonSave_Click(object sender, EventArgs e) 46 | { 47 | try 48 | { 49 | if (validators.Count((validator) => validator.IsValid()) == validators.Count) 50 | { 51 | var user = new User 52 | { 53 | Fullname = TextName.Text, 54 | Email = TextEmail.Text, 55 | Role = ComboBoxRole.Text, 56 | Password = Util.GetHashSHA256(TextPassword.Text), 57 | Image = PictureUserImage.ImageLocation 58 | }; 59 | user.Save(); 60 | MessageBox.Show("User added successfully"); 61 | ButtonBack.PerformClick(); 62 | } 63 | } 64 | catch (Level1Exception ex) 65 | { 66 | ex.DisplayMessage(); 67 | } 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /FastFoodPOS/Forms/AdminForms/FormChangePassword.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Drawing; 5 | using System.Data; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | using FastFoodPOS.Components; 11 | using FastFoodPOS.Models; 12 | 13 | namespace FastFoodPOS.Forms.AdminForms 14 | { 15 | public partial class FormChangePassword : UserControl 16 | { 17 | 18 | List validators = new List(); 19 | User user; 20 | 21 | public FormChangePassword() 22 | { 23 | InitializeComponent(); 24 | 25 | user = User.CurrentUser; 26 | 27 | validators.Add(new Validator(TextNewPassword, LabelNewPassword, "New Password", "required|min:8")); 28 | validators.Add(new Validator(TextConfirmPassword, LabelConfirmPassword, "Confirm Password", "required|min:8|compare") { compare_control = TextNewPassword }); 29 | validators.Add(new Validator(TextOldPassword, LabelOldPassword, "Old Password", "required|min:8")); 30 | 31 | } 32 | 33 | 34 | private void LinkBack_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 35 | { 36 | FormAdminPanel.GetInstance().LoadFormControl(new FormUpdateCurrentUser(user)); 37 | } 38 | 39 | private void ButtonSave_Click(object sender, EventArgs e) 40 | { 41 | if (validators.Count == validators.Count(validator => validator.IsValid())) 42 | { 43 | if (user.Password.Equals(Util.GetHashSHA256(TextOldPassword.Text))) 44 | { 45 | User clone = user.Clone(); 46 | clone.Password = Util.GetHashSHA256(TextNewPassword.Text.Trim()); 47 | clone.Update(); 48 | 49 | user.Password = clone.Password; 50 | 51 | AlertNotification.ShowAlertMessage("Password updated successfully", AlertNotification.AlertType.SUCCESS); 52 | LinkBack_LinkClicked(null, null); 53 | } 54 | else 55 | { 56 | AlertNotification.ShowAlertMessage("Wrong Password", AlertNotification.AlertType.ERROR); 57 | } 58 | } 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /FastFoodPOS/Forms/AdminForms/FormDashboard.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Drawing; 5 | using System.Data; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | using FastFoodPOS.Models; 11 | using LiveCharts; 12 | using LiveCharts.Wpf; 13 | 14 | namespace FastFoodPOS.Forms.AdminForms 15 | { 16 | public partial class FormDashboard : UserControl 17 | { 18 | List sales; 19 | public FormDashboard() 20 | { 21 | InitializeComponent(); 22 | RefreshWeekSales(); 23 | RefreshCardData(); 24 | } 25 | 26 | private void RefreshCardData() 27 | { 28 | Sale today_sale = sales.FirstOrDefault((sale) => sale.Date.Date.Equals(DateTime.Now.Date)); 29 | if (today_sale == null) today_sale = Sale.GetSale(DateTime.Now); 30 | LabelOrderCount.Text = today_sale.OrderCount.ToString(); 31 | LabelTotalSales.Text = today_sale.Value.ToString() + "PHP"; 32 | LabelCustomerCount.Text = today_sale.CustomerCount.ToString(); 33 | } 34 | 35 | private void RefreshWeekSales() 36 | { 37 | CartesianChartWeekSales.Series.Clear(); 38 | sales = Sale.GetSalesFromLastWeek(); 39 | SeriesCollection series = new SeriesCollection(); 40 | List values = new List(); 41 | DateTime today = DateTime.Now; 42 | for (int i = 6; i >= 0; i--) 43 | { 44 | decimal value = 0; 45 | Sale iSale = sales.FirstOrDefault((sale) => sale.Date.Date.Equals(today.AddDays(-i).Date)); 46 | if (iSale != null) value = iSale.Value; 47 | values.Add(value); 48 | } 49 | series.Add(new LineSeries() 50 | { 51 | Title = "Total Sales", 52 | Values = new ChartValues(values) 53 | }); 54 | CartesianChartWeekSales.Series = series; 55 | } 56 | 57 | private void FormDashboard_Load(object sender, EventArgs e) 58 | { 59 | /** 60 | * the chart turns into black and why 61 | * and this fixed it. 62 | * I don't understand why 63 | */ 64 | CartesianChartWeekSales.Visible = false; 65 | CartesianChartWeekSales.Visible = true; 66 | 67 | CartesianChartWeekSales.AxisX.ToString(); 68 | CartesianChartWeekSales.AxisX.Add(new LiveCharts.Wpf.Axis 69 | { 70 | Title = "Days", 71 | Labels = Sale.GetDaysLabelFromLastWeek() 72 | }); 73 | CartesianChartWeekSales.AxisY.Add(new LiveCharts.Wpf.Axis 74 | { 75 | Title = "Sales", 76 | LabelFormatter = value => value.ToString() + "PHP" 77 | }); 78 | } 79 | 80 | private void BtnBackupData_Click(object sender, EventArgs e) 81 | { 82 | (new Dialog.BackupDialogBox()).ShowDialog(); 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /FastFoodPOS/Forms/AdminForms/FormManageProducts.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Drawing; 5 | using System.Data; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | using FastFoodPOS.Models; 11 | using FastFoodPOS.Components; 12 | using Guna.UI2.WinForms; 13 | 14 | namespace FastFoodPOS.Forms.AdminForms 15 | { 16 | partial class FormManageProducts : UserControl, IKeepable 17 | { 18 | List AllProducts; 19 | Button submit; 20 | string selected = "Food"; 21 | 22 | public FormManageProducts() 23 | { 24 | init(); 25 | } 26 | 27 | public FormManageProducts(string selected) 28 | { 29 | this.selected = selected; 30 | init(); 31 | } 32 | 33 | void init() 34 | { 35 | InitializeComponent(); 36 | submit = new Button(); 37 | submit.Click += ButtonSearch_Click; 38 | AllProducts = Product.GetAllProducts(); 39 | loadSelected(); 40 | } 41 | 42 | void loadSelected() 43 | { 44 | foreach (Guna2Button control in ButtonsMenu.Controls) 45 | { 46 | if (control.Tag.ToString() == selected) 47 | { 48 | control.PerformClick(); 49 | break; 50 | } 51 | } 52 | } 53 | 54 | private void ButtonFilter_Click(object sender, EventArgs e) 55 | { 56 | 57 | TextSearch.Text = ""; 58 | 59 | flowLayoutPanel1.Visible = false; 60 | DisposePanelContent(); 61 | Guna2Button button = (Guna2Button)sender; 62 | 63 | selected = button.Tag.ToString(); 64 | 65 | AllProducts.ForEach((Product product) => 66 | { 67 | if (product.Category.Equals(button.Tag)) 68 | { 69 | AddProductComponent(product); 70 | } 71 | }); 72 | flowLayoutPanel1.Visible = true; 73 | } 74 | 75 | void pcc_ButtonRemoveClick(object sender, ProductCardComponent e) 76 | { 77 | DialogResult result = Dialog.ConfirmDialogBox.ShowDialog("Are you sure to remove this product?"); 78 | if (result == DialogResult.Yes) 79 | { 80 | e.product.Remove(); 81 | AlertNotification.ShowAlertMessage("Product removed successfully", AlertNotification.AlertType.SUCCESS); 82 | AllProducts.Remove(e.product); 83 | e.Dispose(); 84 | } 85 | } 86 | 87 | void pcc_ButtonUpdateClick(object sender, ProductCardComponent e) 88 | { 89 | FormAdminPanel.GetInstance().LoadFormControl(new FormUpdateProduct(e)); 90 | } 91 | 92 | 93 | private void DisposePanelContent() 94 | { 95 | while (flowLayoutPanel1.Controls.Count >= 1) 96 | { 97 | flowLayoutPanel1.Controls[0].Dispose(); 98 | } 99 | } 100 | 101 | 102 | public bool ShouldKeepForm { get; set; } 103 | 104 | public void OnMounted() 105 | { 106 | ParentForm.AcceptButton = submit; 107 | } 108 | 109 | public void OnUnMounted(ref UserControl next) 110 | { 111 | 112 | } 113 | 114 | private void panel1_MouseEnter(object sender, EventArgs e) 115 | { 116 | flowLayoutPanel1.Focus(); 117 | } 118 | 119 | private void ButtonSearch_Click(object sender, EventArgs e) 120 | { 121 | if (TextSearch.Text == "") return; 122 | 123 | foreach (Guna2Button menu in ButtonsMenu.Controls) 124 | menu.Checked = false; 125 | 126 | flowLayoutPanel1.SuspendLayout(); 127 | DisposePanelContent(); 128 | var result = SearchResult(); 129 | result.ForEach((product) => AddProductComponent(product)); 130 | flowLayoutPanel1.ResumeLayout(); 131 | 132 | AlertNotification.ShowAlertMessage(result.Count + " items found", AlertNotification.AlertType.INFO); 133 | 134 | } 135 | 136 | private void AddProductComponent(Product product) 137 | { 138 | ProductCardComponent pcc = new ProductCardComponent(product); 139 | pcc.ButtonUpdateClick += pcc_ButtonUpdateClick; 140 | pcc.ButtonRemoveClick += pcc_ButtonRemoveClick; 141 | flowLayoutPanel1.Controls.Add(pcc); 142 | } 143 | 144 | private List SearchResult() 145 | { 146 | List result = AllProducts.FindAll((product) => product.ContainsAnd(TextSearch.Text)); 147 | if (result.Count == 0) 148 | result = AllProducts.FindAll((product) => product.ContainsOr(TextSearch.Text)); 149 | if (result.Count >= 16) 150 | result.RemoveRange(15, result.Count - 15); 151 | return result; 152 | } 153 | 154 | private void ButtonAddProduct_Click(object sender, EventArgs e) 155 | { 156 | FormAdminPanel.GetInstance().LoadFormControl(new FormAddProduct(selected)); 157 | } 158 | } 159 | } 160 | -------------------------------------------------------------------------------- /FastFoodPOS/Forms/AdminForms/FormProductArchive.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Drawing; 5 | using System.Data; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | using FastFoodPOS.Models; 11 | 12 | namespace FastFoodPOS.Forms.AdminForms 13 | { 14 | public partial class FormProductArchive : UserControl 15 | { 16 | List deleted; 17 | 18 | public FormProductArchive() 19 | { 20 | InitializeComponent(); 21 | RefreshData(); 22 | } 23 | 24 | private void RefreshData() 25 | { 26 | deleted = Product.GetAllDeleted(); 27 | DataGridViewProducts.Rows.Clear(); 28 | deleted.ForEach(item => 29 | { 30 | DataGridViewProducts.Rows.Add( 31 | item.Id, 32 | item.Name, 33 | item.Category, 34 | item.Price 35 | ); 36 | }); 37 | if(deleted.Count == 0) DataGridViewProducts.Rows.Add("No deleted products"); 38 | } 39 | 40 | private void DataGridViewProducts_CellDoubleClick(object sender, DataGridViewCellEventArgs e) 41 | { 42 | if (deleted.Count == 0) return; 43 | Product selected = deleted[e.RowIndex]; 44 | DialogResult result = Dialog.ConfirmDialogBox.ShowDialog("Are you sure to recover this product " + selected.Name); 45 | if (result == DialogResult.Yes) 46 | { 47 | selected.Recover(); 48 | MessageBox.Show("Product recovered successfully"); 49 | RefreshData(); 50 | } 51 | } 52 | 53 | private void LinkUserArchive_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 54 | { 55 | FormAdminPanel.GetInstance().LoadFormControl(new FormUsersArchive()); 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /FastFoodPOS/Forms/AdminForms/FormSalesReport.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Drawing; 5 | using System.Data; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | using LiveCharts; 11 | using FastFoodPOS.Models; 12 | using LiveCharts.Wpf; 13 | 14 | namespace FastFoodPOS.Forms.AdminForms 15 | { 16 | public partial class FormSalesReport : UserControl 17 | { 18 | public FormSalesReport() 19 | { 20 | InitializeComponent(); 21 | 22 | DateTimeStart.MaxDate = DateTime.Now.Date; 23 | DateTimeEnd.MaxDate = DateTime.Now.Date; 24 | DateTimeEnd.Value = DateTime.Now.Date; 25 | 26 | DateTimeStart.ValueChanged += this.DateTimeRange_ValueChanged; 27 | DateTimeEnd.ValueChanged += this.DateTimeRange_ValueChanged; 28 | 29 | DateTimeStart.Value = DateTime.Now.AddDays(-6).Date; 30 | } 31 | 32 | private void FormSalesReport_Load(object sender, EventArgs e) 33 | { 34 | CartesianChartSales.Visible = false; 35 | CartesianChartSales.Visible = true; 36 | 37 | CartesianChartSales.AxisY.Add(new LiveCharts.Wpf.Axis{ 38 | Title = "Sales", 39 | LabelFormatter = value => value.ToString() + "PHP" 40 | }); 41 | } 42 | 43 | private void DateTimeRange_ValueChanged(object sender, EventArgs e) 44 | { 45 | DateTimeStart.MaxDate = DateTimeEnd.Value; 46 | DateTimeEnd.MinDate = DateTimeStart.Value; 47 | 48 | CartesianChartSales.Series.Clear(); 49 | CartesianChartSales.AxisX.Clear(); 50 | 51 | CartesianChartSales.AxisX.Add(new LiveCharts.Wpf.Axis{ 52 | Title = "Date", 53 | Labels = Sale.GetDaysLabel(DateTimeStart.Value, DateTimeEnd.Value) 54 | }); 55 | 56 | List sales = Sale.GetSalesBetween(DateTimeStart.Value, DateTimeEnd.Value); 57 | List values = new List(); 58 | DateTime i = DateTimeStart.Value.Date; 59 | while (!i.Equals(DateTimeEnd.Value.AddDays(1).Date)) 60 | { 61 | decimal value = 0; 62 | Sale sale = sales.FirstOrDefault((isale) => isale.Date.Equals(i)); 63 | if (sale != null) value = sale.Value; 64 | values.Add(value); 65 | i = i.AddDays(1); 66 | } 67 | 68 | CartesianChartSales.Series.Add(new LineSeries { 69 | Title = "Sales", 70 | Values = new ChartValues(values) 71 | }); 72 | } 73 | 74 | private void BtnBackupData_Click(object sender, EventArgs e) 75 | { 76 | 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /FastFoodPOS/Forms/AdminForms/FormSalesReport.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /FastFoodPOS/Forms/AdminForms/FormTransactions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Windows.Forms; 4 | using FastFoodPOS.Models; 5 | 6 | namespace FastFoodPOS.Forms.AdminForms 7 | { 8 | public partial class FormTransactions : UserControl 9 | { 10 | Dictionary Users; 11 | public FormTransactions() 12 | { 13 | InitializeComponent(); 14 | Users = new Dictionary(); 15 | User.GetAll(true).ForEach((User user) => Users.Add(user.Id, user)); 16 | DateTimeSpecifier.MaxDate = DateTime.Now; 17 | DateTimeSpecifier.Value = DateTimeSpecifier.MaxDate; 18 | } 19 | 20 | void RefreshTransactions(DateTime date) 21 | { 22 | var Transactions = Transaction.GetTransactions(date); 23 | DataGridViewTransaction.Rows.Clear(); 24 | Transactions.ForEach((Transaction transaction) => 25 | { 26 | DataGridViewTransaction.Rows.Add( 27 | "#" + transaction.Id, 28 | transaction.Date.ToShortTimeString(), 29 | Users[transaction.CashierId].Fullname, 30 | transaction.Total + "PHP" 31 | ); 32 | }); 33 | if (Transactions.Count == 0) 34 | { 35 | DataGridViewTransaction.Rows.Add("There is no transaction on the selected date"); 36 | } 37 | } 38 | 39 | private void DateTimeSpecifier_ValueChanged(object sender, EventArgs e) 40 | { 41 | RefreshTransactions(DateTimeSpecifier.Value); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /FastFoodPOS/Forms/AdminForms/FormUpdateCurrentUser.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Drawing; 5 | using System.Data; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | using FastFoodPOS.Components; 11 | using FastFoodPOS.Models; 12 | 13 | namespace FastFoodPOS.Forms.AdminForms 14 | { 15 | partial class FormUpdateCurrentUser : UserControl 16 | { 17 | List validators; 18 | User uuser; 19 | 20 | public event EventHandler OnUpdate_Success; 21 | 22 | public FormUpdateCurrentUser(User uuser) 23 | { 24 | InitializeComponent(); 25 | this.uuser = uuser; 26 | validators = new List(); 27 | validators.Add(new Validator(TextName, LabelName, "Name", "required|min:5|name")); 28 | validators.Add(new Validator(TextEmail, LabelEmail, "Email", "required|email|unique:users,email") { unique_ignore = uuser.Email }); 29 | Reset(); 30 | } 31 | 32 | void Reset() 33 | { 34 | PictureUserImage.ImageLocation = uuser.Image; 35 | TextName.Text = uuser.Fullname; 36 | TextEmail.Text = uuser.Email; 37 | validators.ForEach((validator) => validator.Reset()); 38 | 39 | if (User.CurrentUser.Role == "SubAdministrator") 40 | { 41 | TextName.Enabled = false; 42 | TextEmail.Enabled = false; 43 | } 44 | 45 | } 46 | 47 | private void ButtonSave_Click(object sender, EventArgs e) 48 | { 49 | if (validators.Count((validator) => validator.IsValid()) == validators.Count) 50 | { 51 | User updated = uuser.Clone(); 52 | updated.Fullname = TextName.Text; 53 | updated.Email = TextEmail.Text; 54 | updated.newImage = PictureUserImage.ImageLocation; 55 | updated.Update(); 56 | MessageBox.Show("Updated Successfully"); 57 | 58 | if (uuser.Image != PictureUserImage.ImageLocation) Log.AddLog("Changed Profile picture"); 59 | 60 | if (OnUpdate_Success != null) 61 | { 62 | OnUpdate_Success(this, updated); 63 | } 64 | } 65 | } 66 | 67 | private void ButtonChangeImage_Click(object sender, EventArgs e) 68 | { 69 | if (OpenFileDialogChangeImage.ShowDialog() == DialogResult.OK) 70 | { 71 | PictureUserImage.ImageLocation = OpenFileDialogChangeImage.FileName; 72 | } 73 | } 74 | 75 | private void ButtonReset_Click(object sender, EventArgs e) 76 | { 77 | Reset(); 78 | } 79 | 80 | private void ButtonChangePassword_Click(object sender, EventArgs e) 81 | { 82 | FormAdminPanel.GetInstance().LoadFormControl(new FormChangePassword()); 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /FastFoodPOS/Forms/AdminForms/FormUpdateProduct.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Drawing; 5 | using System.Data; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | using FastFoodPOS.Models; 11 | using FastFoodPOS.Components; 12 | 13 | namespace FastFoodPOS.Forms.AdminForms 14 | { 15 | partial class FormUpdateProduct : UserControl, IKeepable 16 | { 17 | ProductCardComponent pcc; 18 | Product product; 19 | Validator NameValidator; 20 | string category; 21 | public FormUpdateProduct(ProductCardComponent pcc) 22 | { 23 | InitializeComponent(); 24 | this.pcc = pcc; 25 | this.product = pcc.product; 26 | this.category = pcc.product.Category; 27 | NameValidator = new Validator(TextName, LabelName, "Name", "required"); 28 | ResetData(); 29 | } 30 | 31 | void ResetData() 32 | { 33 | PictureProductImage.ImageLocation = product.Image; 34 | TextName.Text = product.Name; 35 | ComboBoxType.Text = product.Category; 36 | TextPrice.Text = product.Price.ToString(); 37 | NameValidator.Reset(); 38 | } 39 | 40 | private void ButtonBack_Click(object sender, EventArgs e) 41 | { 42 | FormAdminPanel.GetInstance().LoadFormControl(new FormManageProducts(category)); 43 | } 44 | 45 | private void ButtonReset_Click(object sender, EventArgs e) 46 | { 47 | ResetData(); 48 | } 49 | 50 | private void ButtonSave_Click(object sender, EventArgs e) 51 | { 52 | if(NameValidator.IsValid()) 53 | { 54 | Product uProduct = product.Clone(); 55 | uProduct.Name = TextName.Text; 56 | uProduct.Category = ComboBoxType.Text; 57 | uProduct.Price = TextPrice.Value; 58 | uProduct.newImage = PictureProductImage.ImageLocation; 59 | uProduct.Update(); 60 | product.Copy(uProduct); 61 | 62 | Log.AddLog("Make changes to product["+uProduct.Id+"]"); 63 | 64 | AlertNotification.ShowAlertMessage("Product updated successfully", AlertNotification.AlertType.SUCCESS); 65 | 66 | category = ComboBoxType.Text; 67 | 68 | ButtonBack.PerformClick(); 69 | } 70 | } 71 | 72 | private void ButtonChangeImage_Click(object sender, EventArgs e) 73 | { 74 | if (OpenFileDialogChangeImage.ShowDialog() == DialogResult.OK) 75 | { 76 | PictureProductImage.ImageLocation = OpenFileDialogChangeImage.FileName; 77 | } 78 | } 79 | 80 | public bool ShouldKeepForm { get; set; } 81 | 82 | public void OnMounted() 83 | { 84 | 85 | } 86 | 87 | public void OnUnMounted(ref UserControl next) 88 | { 89 | 90 | } 91 | 92 | private void TextPrice_Leave(object sender, EventArgs e) 93 | { 94 | if (TextPrice.Text.Length == 0) 95 | { 96 | TextPrice.Text = "0"; 97 | TextPrice.Value = 0; 98 | } 99 | } 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /FastFoodPOS/Forms/AdminForms/FormUpdateUser.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Drawing; 5 | using System.Data; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | using FastFoodPOS.Models; 11 | using FastFoodPOS.Components; 12 | 13 | namespace FastFoodPOS.Forms.AdminForms 14 | { 15 | partial class FormUpdateUser : UserControl 16 | { 17 | User user; 18 | List validators = new List(); 19 | 20 | public FormUpdateUser(User user) 21 | { 22 | InitializeComponent(); 23 | this.user = user; 24 | validators.Add(new Validator(TextName, LabelName, "Name", "required|min:5|name")); 25 | validators.Add(new Validator(TextEmail, LabelEmail, "Email", "required|email|unique:users,email") { unique_ignore = user.Email }); 26 | AutoFillData(); 27 | } 28 | 29 | private void AutoFillData() 30 | { 31 | PictureUserImage.ImageLocation = user.Image; 32 | TextName.Text = user.Fullname; 33 | TextEmail.Text = user.Email; 34 | } 35 | 36 | private void LinkBack_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 37 | { 38 | FormAdminPanel.GetInstance().LoadFormControl(new FormUsers()); 39 | } 40 | 41 | private void ButtonReset_Click(object sender, EventArgs e) 42 | { 43 | AutoFillData(); 44 | validators.ForEach(validator => validator.Reset()); 45 | } 46 | 47 | private void ButtonSave_Click(object sender, EventArgs e) 48 | { 49 | if (validators.Count((validator) => validator.IsValid()) == validators.Count) 50 | { 51 | User updated = user.Clone(); 52 | updated.Fullname = TextName.Text; 53 | updated.Email = TextEmail.Text; 54 | updated.newImage = PictureUserImage.ImageLocation; 55 | updated.Update(); 56 | MessageBox.Show("User Updated Successfully"); 57 | LinkBack_LinkClicked(this, null); 58 | } 59 | } 60 | 61 | private void ButtonChangeImage_Click(object sender, EventArgs e) 62 | { 63 | if (OpenFileDialogChangeImage.ShowDialog() == DialogResult.OK) 64 | { 65 | PictureUserImage.ImageLocation = OpenFileDialogChangeImage.FileName; 66 | } 67 | } 68 | 69 | private void ButtonChangePassword_Click(object sender, EventArgs e) 70 | { 71 | 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /FastFoodPOS/Forms/AdminForms/FormUsers.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace FastFoodPOS.Forms.AdminForms 2 | { 3 | partial class FormUsers 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Component Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.label1 = new System.Windows.Forms.Label(); 32 | this.ButtonAddUser = new Guna.UI2.WinForms.Guna2Button(); 33 | this.guna2Panel1 = new Guna.UI2.WinForms.Guna2Panel(); 34 | this.PanelUsers = new System.Windows.Forms.Panel(); 35 | this.guna2Panel1.SuspendLayout(); 36 | this.SuspendLayout(); 37 | // 38 | // label1 39 | // 40 | this.label1.AutoSize = true; 41 | this.label1.Font = new System.Drawing.Font("Segoe UI", 16F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 42 | this.label1.Location = new System.Drawing.Point(30, 30); 43 | this.label1.Name = "label1"; 44 | this.label1.Size = new System.Drawing.Size(129, 30); 45 | this.label1.TabIndex = 2; 46 | this.label1.Text = "List of Users"; 47 | // 48 | // ButtonAddUser 49 | // 50 | this.ButtonAddUser.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); 51 | this.ButtonAddUser.CheckedState.Parent = this.ButtonAddUser; 52 | this.ButtonAddUser.CustomImages.Parent = this.ButtonAddUser; 53 | this.ButtonAddUser.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(179)))), ((int)(((byte)(15)))), ((int)(((byte)(25))))); 54 | this.ButtonAddUser.Font = new System.Drawing.Font("Segoe UI", 10F); 55 | this.ButtonAddUser.ForeColor = System.Drawing.Color.White; 56 | this.ButtonAddUser.HoverState.Parent = this.ButtonAddUser; 57 | this.ButtonAddUser.Location = new System.Drawing.Point(35, 457); 58 | this.ButtonAddUser.Name = "ButtonAddUser"; 59 | this.ButtonAddUser.ShadowDecoration.Parent = this.ButtonAddUser; 60 | this.ButtonAddUser.Size = new System.Drawing.Size(180, 45); 61 | this.ButtonAddUser.TabIndex = 8; 62 | this.ButtonAddUser.Text = "Add New User"; 63 | this.ButtonAddUser.Click += new System.EventHandler(this.ButtonAddUser_Click); 64 | // 65 | // guna2Panel1 66 | // 67 | this.guna2Panel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 68 | | System.Windows.Forms.AnchorStyles.Left) 69 | | System.Windows.Forms.AnchorStyles.Right))); 70 | this.guna2Panel1.AutoScroll = true; 71 | this.guna2Panel1.BorderColor = System.Drawing.Color.Silver; 72 | this.guna2Panel1.BorderThickness = 1; 73 | this.guna2Panel1.Controls.Add(this.PanelUsers); 74 | this.guna2Panel1.Location = new System.Drawing.Point(35, 74); 75 | this.guna2Panel1.Name = "guna2Panel1"; 76 | this.guna2Panel1.ShadowDecoration.Parent = this.guna2Panel1; 77 | this.guna2Panel1.Size = new System.Drawing.Size(652, 365); 78 | this.guna2Panel1.TabIndex = 9; 79 | // 80 | // PanelUsers 81 | // 82 | this.PanelUsers.AutoSize = true; 83 | this.PanelUsers.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; 84 | this.PanelUsers.BackColor = System.Drawing.Color.Transparent; 85 | this.PanelUsers.Dock = System.Windows.Forms.DockStyle.Top; 86 | this.PanelUsers.Location = new System.Drawing.Point(0, 0); 87 | this.PanelUsers.MinimumSize = new System.Drawing.Size(625, 0); 88 | this.PanelUsers.Name = "PanelUsers"; 89 | this.PanelUsers.Size = new System.Drawing.Size(652, 0); 90 | this.PanelUsers.TabIndex = 0; 91 | // 92 | // FormUsers 93 | // 94 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 95 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 96 | this.BackColor = System.Drawing.Color.White; 97 | this.Controls.Add(this.guna2Panel1); 98 | this.Controls.Add(this.ButtonAddUser); 99 | this.Controls.Add(this.label1); 100 | this.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 101 | this.Name = "FormUsers"; 102 | this.Size = new System.Drawing.Size(731, 528); 103 | this.guna2Panel1.ResumeLayout(false); 104 | this.guna2Panel1.PerformLayout(); 105 | this.ResumeLayout(false); 106 | this.PerformLayout(); 107 | 108 | } 109 | 110 | #endregion 111 | 112 | private System.Windows.Forms.Label label1; 113 | private Guna.UI2.WinForms.Guna2Button ButtonAddUser; 114 | private Guna.UI2.WinForms.Guna2Panel guna2Panel1; 115 | private System.Windows.Forms.Panel PanelUsers; 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /FastFoodPOS/Forms/AdminForms/FormUsers.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Drawing; 5 | using System.Data; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | using FastFoodPOS.Models; 11 | using FastFoodPOS.Components; 12 | 13 | namespace FastFoodPOS.Forms.AdminForms 14 | { 15 | public partial class FormUsers : UserControl 16 | { 17 | List AllUsers; 18 | public FormUsers() 19 | { 20 | InitializeComponent(); 21 | RefreshUser(); 22 | } 23 | 24 | void RefreshUser() 25 | { 26 | AllUsers = User.GetAll(); 27 | PanelUsers.Controls.Clear(); 28 | AllUsers.ForEach((User user) => 29 | { 30 | if (user.Id != User.CurrentUser.Id) 31 | { 32 | var user_component = new UserCardComponent(user); 33 | user_component.OnUpdateButton_Click += component_OnUpdateButton_Click; 34 | user_component.OnRemoveButton_Click += user_component_OnRemoveButton_Click; 35 | user_component.OnActivityLogButton_Click += user_component_OnActivityLogButton_Click; 36 | PanelUsers.Controls.Add(user_component); 37 | } 38 | }); 39 | } 40 | 41 | void user_component_OnActivityLogButton_Click(object sender, User e) 42 | { 43 | FormAdminPanel.GetInstance().LoadFormControl(new FormActivityLog(e)); 44 | } 45 | 46 | void user_component_OnRemoveButton_Click(object sender, User e) 47 | { 48 | DialogResult result = Dialog.ConfirmDialogBox.ShowDialog("Are you sure to remove " + e.Fullname); 49 | if (result == DialogResult.Yes) 50 | { 51 | e.Remove(); 52 | MessageBox.Show("User successfully removed"); 53 | RefreshUser(); 54 | } 55 | } 56 | 57 | void component_OnUpdateButton_Click(object sender, User e) 58 | { 59 | FormAdminPanel.GetInstance().LoadFormControl(new FormUpdateUser(e)); 60 | } 61 | 62 | private void ButtonAddUser_Click(object sender, EventArgs e) 63 | { 64 | FormAdminPanel.GetInstance().LoadFormControl(new FormAddUser()); 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /FastFoodPOS/Forms/AdminForms/FormUsers.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /FastFoodPOS/Forms/AdminForms/FormUsersArchive.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Drawing; 5 | using System.Data; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | using FastFoodPOS.Models; 11 | 12 | namespace FastFoodPOS.Forms.AdminForms 13 | { 14 | public partial class FormUsersArchive : UserControl 15 | { 16 | List deleted; 17 | 18 | public FormUsersArchive() 19 | { 20 | InitializeComponent(); 21 | RefreshData(); 22 | } 23 | 24 | private void RefreshData() 25 | { 26 | deleted = User.GetAllDeleted(); 27 | DataGridViewUsers.Rows.Clear(); 28 | deleted.ForEach(user => 29 | { 30 | DataGridViewUsers.Rows.Add( 31 | user.Id, 32 | user.Fullname, 33 | user.Email, 34 | user.Role 35 | ); 36 | }); 37 | if (deleted.Count == 0) DataGridViewUsers.Rows.Add("No deleted users"); 38 | } 39 | 40 | private void LinkProductArchive_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 41 | { 42 | FormAdminPanel.GetInstance().LoadFormControl(new FormProductArchive()); 43 | } 44 | 45 | private void DataGridViewUsers_CellDoubleClick(object sender, DataGridViewCellEventArgs e) 46 | { 47 | if (deleted.Count == 0) return; 48 | User selected = deleted[e.RowIndex]; 49 | DialogResult result = Dialog.ConfirmDialogBox.ShowDialog("Are you sure to recover this user " + selected.Fullname); 50 | if (result == DialogResult.Yes) 51 | { 52 | selected.Recover(); 53 | MessageBox.Show("User recovered successfully"); 54 | RefreshData(); 55 | } 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /FastFoodPOS/Forms/AdminForms/IKeepable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows.Forms; 7 | 8 | namespace FastFoodPOS.Forms.AdminForms 9 | { 10 | interface IKeepable 11 | { 12 | bool ShouldKeepForm { get; set; } 13 | void OnMounted(); 14 | void OnUnMounted(ref UserControl next); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /FastFoodPOS/Forms/BaseForm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows.Forms; 7 | 8 | namespace FastFoodPOS.Forms 9 | { 10 | public class BaseForm : UserControl 11 | { 12 | public virtual bool IsFullScreen() 13 | { 14 | return true; 15 | } 16 | 17 | public virtual void OnLoad() { } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /FastFoodPOS/Forms/CashierForms/FormPOS.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /FastFoodPOS/Forms/CashierForms/FormUpdatePassword.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Drawing; 5 | using System.Data; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | using FastFoodPOS.Models; 11 | using FastFoodPOS.Components; 12 | 13 | namespace FastFoodPOS.Forms.CashierForms 14 | { 15 | partial class FormUpdatePassword : BaseForm 16 | { 17 | List validators = new List(); 18 | User user; 19 | 20 | public FormUpdatePassword(User user) 21 | { 22 | InitializeComponent(); 23 | this.user = user; 24 | 25 | validators.Add(new Validator(TextNewPassword, LabelNewPassword, "New Password", "required|min:8")); 26 | validators.Add(new Validator(TextConfirmPassword, LabelConfirmPassword, "Confirm Password", "required|min:8|compare") { compare_control = TextNewPassword }); 27 | validators.Add(new Validator(TextOldPassword, LabelOldPassword, "Old Password", "required|min:8")); 28 | 29 | } 30 | 31 | public override void OnLoad() 32 | { 33 | ParentForm.AcceptButton = ButtonSave; 34 | } 35 | 36 | private void ButtonSave_Click(object sender, EventArgs e) 37 | { 38 | if (validators.Count == validators.Count(validator => validator.IsValid())) 39 | { 40 | if (user.Password.Equals(Util.GetHashSHA256(TextOldPassword.Text))) 41 | { 42 | User updated = user.Clone(); 43 | updated.Password = Util.GetHashSHA256(TextNewPassword.Text.Trim()); 44 | updated.Update(); 45 | 46 | user.Password = updated.Password; 47 | 48 | AlertNotification.ShowAlertMessage("Password updated successfully", AlertNotification.AlertType.SUCCESS); 49 | 50 | linkLabel1_LinkClicked(null, null); 51 | } 52 | else 53 | { 54 | AlertNotification.ShowAlertMessage("Wrong Password", AlertNotification.AlertType.ERROR); 55 | } 56 | } 57 | } 58 | 59 | private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 60 | { 61 | FormCashierPanel.LoadControl(new FormPOS(user)); 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /FastFoodPOS/Forms/CashierForms/ProcessOrder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Drawing; 5 | using System.Data; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | using FastFoodPOS.Components; 11 | using FastFoodPOS.Models; 12 | using System.Drawing.Printing; 13 | 14 | namespace FastFoodPOS.Forms.CashierForms 15 | { 16 | partial class ProcessOrder : UserControl 17 | { 18 | Form formDialog; 19 | Transaction transaction; 20 | 21 | public ProcessOrder(Transaction transaction) 22 | { 23 | InitializeComponent(); 24 | this.transaction = transaction; 25 | Dock = DockStyle.Fill; 26 | } 27 | 28 | private void ButtonClose_Click(object sender, EventArgs e) 29 | { 30 | formDialog.Dispose(); 31 | } 32 | 33 | public void ShowDialog() 34 | { 35 | formDialog = new Form(); 36 | formDialog.Size = Size; 37 | formDialog.Controls.Add(this); 38 | formDialog.ShowInTaskbar = false; 39 | formDialog.FormBorderStyle = FormBorderStyle.None; 40 | formDialog.StartPosition = FormStartPosition.CenterScreen; 41 | guna2HtmlLabel1.Text = ReceiptTemplate.GetReceipt(transaction); 42 | formDialog.ShowDialog(); 43 | 44 | } 45 | 46 | private void ButtonPrint_Click(object sender, EventArgs e) 47 | { 48 | PrintForm printForm1 = new PrintForm(this); 49 | printForm1.Show(); 50 | } 51 | 52 | class PrintForm : Form 53 | { 54 | 55 | PrintPreviewDialog printDialog1; 56 | PrintDocument printDocument1; 57 | ProcessOrder parent; 58 | Point oldPosition; 59 | Guna.UI2.WinForms.Guna2HtmlLabel content; 60 | 61 | public PrintForm(ProcessOrder parent) 62 | { 63 | content = parent.guna2HtmlLabel1; 64 | 65 | this.parent = parent; 66 | this.oldPosition = new Point(content.Location.X, content.Location.Y); 67 | 68 | this.BackColor = Color.White; 69 | ShowInTaskbar = false; 70 | FormBorderStyle = FormBorderStyle.None; 71 | StartPosition = FormStartPosition.CenterScreen; 72 | Size = new Size(content.Size.Width + 15, content.Size.Height + 30); 73 | Controls.Add(content); 74 | content.Location = new Point(15, 15); 75 | 76 | printDialog1 = new PrintPreviewDialog(); 77 | printDocument1 = new PrintDocument(); 78 | 79 | printDialog1.Document = printDocument1; 80 | printDocument1.PrintPage += printDocument1_PrintPage; 81 | 82 | this.Load += PrintForm_Load; 83 | 84 | //printDialog1.ShowDialog(); 85 | } 86 | 87 | void PrintForm_Load(object sender, EventArgs e) 88 | { 89 | printDialog1.ShowDialog(); 90 | 91 | parent.guna2Panel1.Controls.Add(content); 92 | 93 | content.Location = oldPosition; 94 | 95 | Dispose(); 96 | 97 | } 98 | 99 | void printDocument1_PrintPage(object sender, PrintPageEventArgs e) 100 | { 101 | Bitmap img = new Bitmap(this.Size.Width, this.Size.Height); 102 | this.DrawToBitmap(img, this.DisplayRectangle); 103 | e.Graphics.DrawImage(img, new Point(100, 100)); 104 | } 105 | } 106 | 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /FastFoodPOS/Forms/CashierForms/ProcessOrder.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /FastFoodPOS/Forms/FormAdminLogin.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Drawing; 5 | using System.Data; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | using FastFoodPOS.Models; 11 | using FastFoodPOS.ErrorHandler; 12 | using FastFoodPOS.Components; 13 | using FastFoodPOS.Forms.CashierForms; 14 | 15 | namespace FastFoodPOS.Forms 16 | { 17 | public partial class FormAdminLogin : BaseForm 18 | { 19 | public override bool IsFullScreen() 20 | { 21 | return false; 22 | } 23 | 24 | public FormAdminLogin() 25 | { 26 | InitializeComponent(); 27 | } 28 | 29 | public override void OnLoad() 30 | { 31 | TextEmail.Focus(); 32 | ParentForm.AcceptButton = ButtonLogin; 33 | } 34 | 35 | private void ButtonLogin_Click(object sender, EventArgs e) 36 | { 37 | try 38 | { 39 | User loggedIn = User.Login(TextEmail.Text, TextPassword.Text); 40 | AlertNotification.ShowAlertMessage("Logged in successfully", AlertNotification.AlertType.SUCCESS); 41 | if (loggedIn.Role.Equals("Cashier")){ 42 | MainForm.LoadForm(new FormCashierPanel(loggedIn)); 43 | }else 44 | MainForm.LoadForm(new FormAdminPanel(loggedIn)); 45 | 46 | } 47 | catch (Level1Exception ex) 48 | { 49 | ex.DisplayMessage(); 50 | TextEmail.Focus(); 51 | } 52 | } 53 | 54 | private void VisibilityToggler_Click(object sender, EventArgs e) 55 | { 56 | TextPassword.UseSystemPasswordChar = !TextPassword.UseSystemPasswordChar; 57 | } 58 | 59 | private void ButtonHelp_Click(object sender, EventArgs e) 60 | { 61 | Dialog.HelpDialogBox.ShowHelpDialog(); 62 | } 63 | 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /FastFoodPOS/Forms/FormAdminPanel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Drawing; 5 | using System.Data; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | using FastFoodPOS.Forms.AdminForms; 11 | using Guna.UI2.WinForms; 12 | using FastFoodPOS.Models; 13 | 14 | namespace FastFoodPOS.Forms 15 | { 16 | partial class FormAdminPanel : BaseForm 17 | { 18 | User LoggedInUser = null; 19 | 20 | private static FormAdminPanel Instance; 21 | 22 | public static FormAdminPanel GetInstance() 23 | { 24 | return Instance; 25 | } 26 | 27 | public FormAdminPanel(User _LoggedInUser) 28 | { 29 | InitializeComponent(); 30 | 31 | Instance = this; 32 | LoggedInUser = _LoggedInUser; 33 | 34 | 35 | } 36 | 37 | public override void OnLoad() 38 | { 39 | Reset(); 40 | 41 | ButtonDashboard.PerformClick(); 42 | } 43 | 44 | private void Reset() 45 | { 46 | PictureUserImage.Image = Util.GetImageFromFile(LoggedInUser.Image); 47 | LabelUserName.Text = LoggedInUser.Fullname; 48 | LabelUserRole.Text = LoggedInUser.Role; 49 | 50 | if (LoggedInUser.Role == "SubAdministrator") 51 | { 52 | ButtonUsers.Visible = false; 53 | ButtonArchives.Visible = false; 54 | } 55 | 56 | } 57 | 58 | private void ButtonMenu_Click(object sender, EventArgs e) 59 | { 60 | Guna2Button ButtonMenu = (Guna2Button)sender; 61 | 62 | switch (Convert.ToInt16(ButtonMenu.Tag)) 63 | { 64 | case 1: 65 | LoadFormControl(new FormDashboard()); 66 | break; 67 | case 3: 68 | LoadFormControl(new FormManageProducts()); 69 | break; 70 | case 4: 71 | LoadFormControl(new FormTransactions()); 72 | break; 73 | case 5: 74 | LoadFormControl(new FormSalesReport()); 75 | break; 76 | case 6: 77 | LoadFormControl(new FormUsers()); 78 | break; 79 | case 7: 80 | LoadFormControl(new FormProductArchive()); 81 | break; 82 | } 83 | 84 | } 85 | 86 | public void LoadFormControl(UserControl uc) 87 | { 88 | ParentForm.AcceptButton = null; 89 | DisposeAdminForm(ref uc); 90 | 91 | IKeepable ucKeepable = uc as IKeepable; 92 | 93 | uc.Dock = DockStyle.Fill; 94 | panel5.Controls.Add(uc); 95 | 96 | if (ucKeepable != null) ((IKeepable)uc).OnMounted(); 97 | } 98 | 99 | private void DisposeAdminForm(ref UserControl next) 100 | { 101 | while (panel5.Controls.Count >= 1) 102 | { 103 | IKeepable ucToRemove = panel5.Controls[0] as IKeepable; 104 | if (ucToRemove != null) 105 | { 106 | ucToRemove.OnUnMounted(ref next); 107 | if (ucToRemove.ShouldKeepForm) 108 | panel5.Controls.RemoveAt(0); 109 | else 110 | panel5.Controls[0].Dispose(); 111 | } 112 | else 113 | { 114 | panel5.Controls[0].Dispose(); 115 | } 116 | } 117 | } 118 | 119 | private void ButtonLogout_Click(object sender, EventArgs e) 120 | { 121 | if(Dialog.ConfirmDialogBox.ShowDialog("Are you sure to logout?") == DialogResult.Yes) 122 | MainForm.LoadForm(new FormAdminLogin()); 123 | } 124 | 125 | private void ButtonUpdateInfo_Click(object sender, EventArgs e) 126 | { 127 | FormUpdateCurrentUser fuu = new FormUpdateCurrentUser(LoggedInUser); 128 | fuu.OnUpdate_Success += fuu_OnUpdate_Success; 129 | LoadFormControl(fuu); 130 | foreach (Guna2Button btn in ButtonsMenuPanel.Controls) 131 | { 132 | if (btn.Checked) btn.Checked = false; 133 | } 134 | } 135 | 136 | void fuu_OnUpdate_Success(object sender, User e) 137 | { 138 | this.LoggedInUser = e; 139 | User.CurrentUser = e; 140 | Reset(); 141 | ButtonDashboard.PerformClick(); 142 | } 143 | 144 | } 145 | } 146 | -------------------------------------------------------------------------------- /FastFoodPOS/Forms/FormAdminPanel.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /FastFoodPOS/Forms/FormCashierPanel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Drawing; 5 | using System.Data; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | using FastFoodPOS.Models; 11 | using FastFoodPOS.Forms.CashierForms; 12 | 13 | namespace FastFoodPOS.Forms 14 | { 15 | partial class FormCashierPanel : BaseForm 16 | { 17 | User cashier; 18 | 19 | static FormCashierPanel Instance; 20 | 21 | public FormCashierPanel(User loggedin) 22 | { 23 | InitializeComponent(); 24 | 25 | Instance = this; 26 | 27 | this.cashier = loggedin; 28 | LinkLabelName.Text = cashier.Fullname; 29 | PictureUserImage.Image = Util.GetImageFromFile(loggedin.Image); 30 | 31 | LoadControl(new FormPOS(loggedin)); 32 | 33 | } 34 | 35 | private void ButtonLogout_Click(object sender, EventArgs e) 36 | { 37 | if (Dialog.ConfirmDialogBox.ShowDialog("Are you sure to logout?") == DialogResult.Yes) 38 | MainForm.LoadForm(new FormAdminLogin()); 39 | } 40 | 41 | public static void LoadControl(BaseForm form) 42 | { 43 | Instance.panel2.Controls.Clear(); 44 | GC.Collect(); 45 | form.Dock = DockStyle.Fill; 46 | Instance.panel2.Controls.Add(form); 47 | } 48 | 49 | private void LinkLabelName_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 50 | { 51 | LoadControl(new FormUpdatePassword(cashier)); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /FastFoodPOS/Forms/FormCashierPanel.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /FastFoodPOS/Forms/FormLoading.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Drawing; 5 | using System.Data; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | 11 | namespace FastFoodPOS.Forms 12 | { 13 | public partial class FormLoading : BaseForm 14 | { 15 | 16 | enum Result 17 | { 18 | SUCCESS, 19 | INVALID_DATABASE_VERION, 20 | WRONG_PASSWORD, 21 | DATABASE_ERROR, 22 | NO_USER 23 | } 24 | 25 | public override void OnLoad() 26 | { 27 | backgroundWorker1.RunWorkerAsync(); 28 | } 29 | 30 | public override bool IsFullScreen() 31 | { 32 | return false; 33 | } 34 | 35 | public FormLoading() 36 | { 37 | InitializeComponent(); 38 | } 39 | 40 | private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) 41 | { 42 | System.Threading.Thread.Sleep(2500); //delay a little bit 43 | 44 | try 45 | { 46 | DatabaseUtil.Database.GetConnection().Open(); 47 | DatabaseUtil.Database.GetConnection().Close(); 48 | 49 | //Import tables 50 | DatabaseUtil.Database.GetProvider().ImportTables(); 51 | 52 | if (Models.User.HasAdminUser()) 53 | { 54 | //Cache Data 55 | Models.User.GetAll(); 56 | Models.Product.GetAllProducts(); 57 | e.Result = Result.SUCCESS; 58 | } 59 | else 60 | { 61 | e.Result = Result.NO_USER; 62 | } 63 | } 64 | catch (System.InvalidOperationException ex) 65 | { 66 | e.Result = Result.INVALID_DATABASE_VERION; 67 | } 68 | catch (System.Data.OleDb.OleDbException ex) 69 | { 70 | if (ex.Message.Equals("Not a valid password.")) 71 | { 72 | e.Result = Result.WRONG_PASSWORD; 73 | } 74 | else 75 | { 76 | e.Result = Result.DATABASE_ERROR; 77 | } 78 | } 79 | 80 | //////Check database 81 | ////if (DatabaseUtil.Database.IsValidConnection()) 82 | ////{ 83 | //// if (Models.User.HasAdminUser()) 84 | //// { 85 | //// //Cache Data 86 | //// Models.User.GetAll(); 87 | //// Models.Product.GetAllProducts(); 88 | //// e.Result = Result.SUCCESS; 89 | //// } 90 | //// else 91 | //// { 92 | //// e.Result = Result.NO_USER; 93 | //// } 94 | ////} 95 | ////else 96 | ////{ 97 | //// e.Result = Result.DATABASE_ERROR; 98 | ////} 99 | } 100 | 101 | private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) 102 | { 103 | guna2WinProgressIndicator1.Visible = false; 104 | switch ((Result)e.Result) 105 | { 106 | case Result.SUCCESS: 107 | MainForm.LoadForm(new FormAdminLogin()); 108 | break; 109 | case Result.NO_USER: 110 | MainForm.LoadForm(new FormRegistration()); 111 | break; 112 | case Result.INVALID_DATABASE_VERION: 113 | MessageBox.Show("Please try the other variant or install Microsoft Access 2010 redistributable"); 114 | Application.Exit(); 115 | break; 116 | case Result.WRONG_PASSWORD: 117 | MessageBox.Show("Wrong Password!"); 118 | MessageBox.Show("Contact me here at my email lenard.mangayayam@gmail.com" + Environment.NewLine + "to get the password"); 119 | Application.Exit(); 120 | break; 121 | case Result.DATABASE_ERROR: 122 | MessageBox.Show("Oops!! Theres a problem while connecting to the database."); 123 | Application.Exit(); 124 | break; 125 | } 126 | } 127 | 128 | 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /FastFoodPOS/Forms/FormRegistration.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Drawing; 5 | using System.Data; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | using FastFoodPOS.Components; 11 | using FastFoodPOS.Models; 12 | 13 | namespace FastFoodPOS.Forms 14 | { 15 | public partial class FormRegistration : BaseForm 16 | { 17 | 18 | List validators = new List(); 19 | 20 | public override bool IsFullScreen() 21 | { 22 | return false; 23 | } 24 | 25 | public override void OnLoad() 26 | { 27 | ParentForm.AcceptButton = BtnSubmit; 28 | } 29 | 30 | public FormRegistration() 31 | { 32 | InitializeComponent(); 33 | validators.Add(new Validator(TextName, LabelNameError, "Name", "required|name|min:5")); 34 | validators.Add(new Validator(TextEmail, LabelEmailError, "Email", "required|email|unique:users,email")); 35 | validators.Add(new Validator(TextPassword, LabelPasswordError, "Password", "required|min:8")); 36 | validators.Add(new Validator(TextConfirmPassword, LabelConfirmPasswordError, "Confirm Password", "required|min:8|compare") { compare_control = TextPassword }); 37 | } 38 | 39 | private void BtnSubmit_Click(object sender, EventArgs e) 40 | { 41 | if (validators.Count == validators.Count(validator => validator.IsValid())) 42 | { 43 | User new_user = new User(); 44 | new_user.Fullname = TextName.Text.Trim(); 45 | new_user.Email = TextEmail.Text.Trim(); 46 | new_user.Password = Util.GetHashSHA256(TextPassword.Text.Trim()); 47 | new_user.Role = "Administrator"; 48 | new_user.Save(); 49 | 50 | AlertNotification.ShowAlertMessage("Registered Successfully", AlertNotification.AlertType.SUCCESS); 51 | 52 | MainForm.LoadForm(new FormAdminLogin()); 53 | } 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /FastFoodPOS/Forms/FormRegistration.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /FastFoodPOS/MainForm.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace FastFoodPOS 2 | { 3 | partial class MainForm 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.components = new System.ComponentModel.Container(); 32 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm)); 33 | this.guna2ShadowForm1 = new Guna.UI2.WinForms.Guna2ShadowForm(this.components); 34 | this.SuspendLayout(); 35 | // 36 | // MainForm 37 | // 38 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 39 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 40 | this.ClientSize = new System.Drawing.Size(284, 261); 41 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; 42 | this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); 43 | this.Name = "MainForm"; 44 | this.Text = "Form1"; 45 | this.ResumeLayout(false); 46 | 47 | } 48 | 49 | #endregion 50 | 51 | private Guna.UI2.WinForms.Guna2ShadowForm guna2ShadowForm1; 52 | } 53 | } 54 | 55 | -------------------------------------------------------------------------------- /FastFoodPOS/MainForm.cs: -------------------------------------------------------------------------------- 1 | using FastFoodPOS.Forms; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.ComponentModel; 5 | using System.Data; 6 | using System.Drawing; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | using System.Windows.Forms; 11 | 12 | namespace FastFoodPOS 13 | { 14 | public partial class MainForm : Form 15 | { 16 | 17 | private static MainForm Instance; 18 | 19 | public MainForm() 20 | { 21 | InitializeComponent(); 22 | Instance = this; 23 | 24 | MaximumSize = Screen.FromControl(this).WorkingArea.Size; 25 | FormBorderStyle = FormBorderStyle.None; 26 | 27 | guna2ShadowForm1.SetShadowForm(this); 28 | 29 | LoadForm(new FormLoading()); 30 | } 31 | 32 | public static void LoadForm(BaseForm form) 33 | { 34 | Instance.AcceptButton = null; 35 | DisposeContent(); 36 | if (form.IsFullScreen()) 37 | { 38 | Instance.WindowState = FormWindowState.Maximized; 39 | } 40 | else 41 | { 42 | Instance.WindowState = FormWindowState.Normal; 43 | Instance.Size = form.Size; 44 | Instance.CenterToScreen(); 45 | } 46 | form.Dock = DockStyle.Fill; 47 | Instance.Controls.Add(form); 48 | form.OnLoad(); 49 | } 50 | 51 | private static void DisposeContent() 52 | { 53 | while (Instance.Controls.Count >= 1) 54 | { 55 | Instance.Controls[0].Dispose(); 56 | } 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /FastFoodPOS/Models/Log.cs: -------------------------------------------------------------------------------- 1 | using FastFoodPOS.DatabaseUtil; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace FastFoodPOS.Models 9 | { 10 | class Log 11 | { 12 | User user; 13 | public int user_id { get; set; } 14 | public DateTime date_created{ get; set; } 15 | public string activity { get; set; } 16 | 17 | public Log(User user) 18 | { 19 | this.user = user; 20 | } 21 | 22 | public User GetUser() 23 | { 24 | if (user == null) 25 | user = User.Find(user_id); 26 | return user; 27 | } 28 | 29 | public static void AddLog(string activity) 30 | { 31 | if (User.CurrentUser.Role == "Administrator") return; 32 | using (var cmd = Database.CreateCommand("INSERT INTO `logs`(`user_id`, `activity`, `date_created`) VALUES (?,?,?)")) 33 | { 34 | Database.BindParameters(cmd, User.CurrentUser.Id, activity, Database.GetProvider().FormatDateTime(DateTime.Now)); 35 | Database.GetConnection().Open(); 36 | cmd.ExecuteNonQuery(); 37 | Database.GetConnection().Close(); 38 | } 39 | } 40 | 41 | public static List GetLogs(User user) 42 | { 43 | var result = new List(); 44 | using (var cmd = Database.CreateCommand("SELECT `activity`, `date_created` FROM `logs` WHERE `user_id`=? ORDER BY `date_created` DESC")) 45 | { 46 | Database.BindParameters(cmd, user.Id); 47 | Database.GetConnection().Open(); 48 | using (var reader = cmd.ExecuteReader()) 49 | { 50 | while (reader.Read()) 51 | { 52 | result.Add(new Log(user) { 53 | activity = reader.GetString(0), 54 | date_created = reader.GetDateTime(1) 55 | }); 56 | } 57 | } 58 | Database.GetConnection().Close(); 59 | } 60 | return result; 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /FastFoodPOS/Models/Order.cs: -------------------------------------------------------------------------------- 1 | using FastFoodPOS.DatabaseUtil; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Data.Common; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace FastFoodPOS.Models 10 | { 11 | class Order 12 | { 13 | public int Id { get; set; } 14 | public int ProductId { get; set; } 15 | public string TransactionId { get; set; } 16 | public int Quantity { get; set; } 17 | public decimal Price { get; set; } 18 | 19 | public decimal Subtotal { 20 | get{ 21 | return Quantity * Price; 22 | } 23 | } 24 | 25 | Product product = null; 26 | 27 | public Order(Product product) 28 | { 29 | this.product = product; 30 | this.ProductId = product.Id; 31 | this.Quantity = 1; 32 | this.Price = product.Price; 33 | } 34 | 35 | public Order() 36 | { 37 | // TODO: Complete member initialization 38 | } 39 | 40 | public void Save(string transaction_id) 41 | { 42 | using (var cmd = Database.CreateCommand("INSERT INTO `orders`(`product_id`, `transaction_id`, `quantity`, `price`) VALUES (@p1, @p2, @p3, @p4)")) 43 | { 44 | Database.BindParameters(cmd, ProductId, transaction_id, Quantity, Price); 45 | Database.GetConnection().Open(); 46 | cmd.ExecuteNonQuery(); 47 | Database.GetConnection().Close(); 48 | } 49 | } 50 | 51 | public Product GetProduct() 52 | { 53 | if (product == null) 54 | { 55 | product = Product.Find(Id); 56 | } 57 | return product; 58 | } 59 | 60 | public static List GetAll() 61 | { 62 | var result = new List(); 63 | using (var cmd = Database.CreateCommand("SELECT * FROM `orders`")) 64 | { 65 | Database.GetConnection().Open(); 66 | using (var reader = cmd.ExecuteReader()) 67 | { 68 | while (reader.Read()) 69 | result.Add(ConvertReaderToOrder(reader)); 70 | } 71 | Database.GetConnection().Close(); 72 | } 73 | return result; 74 | } 75 | 76 | public static List GetAll(string id) 77 | { 78 | var result = new List(); 79 | using (var cmd = Database.CreateCommand("SELECT * FROM `orders` WHERE `transaction_id`=@p1")) 80 | { 81 | Database.BindParameters(cmd, id); 82 | Database.GetConnection().Open(); 83 | using (var reader = cmd.ExecuteReader()) 84 | { 85 | while (reader.Read()) 86 | result.Add(ConvertReaderToOrder(reader)); 87 | } 88 | Database.GetConnection().Close(); 89 | } 90 | return result; 91 | } 92 | 93 | private static Order ConvertReaderToOrder(DbDataReader reader) 94 | { 95 | var result = new Order 96 | { 97 | Id = reader.GetInt32(0), 98 | ProductId = reader.GetInt16(1), 99 | TransactionId = reader.GetString(2), 100 | Quantity = reader.GetInt16(3), 101 | Price = reader.GetDecimal(4) 102 | }; 103 | return result; 104 | } 105 | 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /FastFoodPOS/Models/Sale.cs: -------------------------------------------------------------------------------- 1 | using FastFoodPOS.DatabaseUtil; 2 | using FastFoodPOS.ErrorHandler; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Data.Common; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | 10 | namespace FastFoodPOS.Models 11 | { 12 | class Sale 13 | { 14 | public decimal Value { get; set; } 15 | public int OrderCount { get; set; } 16 | public int CustomerCount { get; set; } 17 | public DateTime Date { get; set; } 18 | 19 | public static List GetSalesBetween(DateTime from, DateTime to) 20 | { 21 | List result = new List(); 22 | using (var cmd = Database.CreateCommand(Database.GetProvider().QUERY_SALES_BETWEEN_1)) 23 | { 24 | //BindParams not working 25 | //idk why 26 | cmd.CommandText = cmd.CommandText.Replace("@@from", Database.GetProvider().FormatShortDate(from.AddDays(-1))); 27 | cmd.CommandText = cmd.CommandText.Replace("@@to", Database.GetProvider().FormatShortDate(to.AddDays(1))); 28 | Database.GetConnection().Open(); 29 | 30 | using (var reader = cmd.ExecuteReader()) 31 | { 32 | while (reader.Read()) 33 | { 34 | result.Add(new Sale 35 | { 36 | Value = reader.GetDecimal(0), 37 | Date = reader.GetDateTime(1), 38 | OrderCount = reader.GetInt16(2), 39 | CustomerCount = reader.GetInt32(3), 40 | }); 41 | } 42 | } 43 | Database.GetConnection().Close(); 44 | } 45 | return result; 46 | } 47 | 48 | public static Sale GetSale(DateTime day) 49 | { 50 | Sale result = new Sale() { Value = 0, Date = day, OrderCount = 0, CustomerCount = 0 }; 51 | using (var cmd = Database.CreateCommand("SELECT * FROM `SalesView` WHERE `day` = ?")) 52 | { 53 | Database.BindParameters(cmd, Database.GetProvider().FormatShortDate(day)); 54 | Database.GetConnection().Open(); 55 | using (var reader = cmd.ExecuteReader()) 56 | { 57 | if (reader.Read()) 58 | { 59 | result.Value = reader.GetDecimal(0); 60 | result.OrderCount = reader.GetInt16(2); 61 | result.CustomerCount = reader.GetInt32(3); 62 | } 63 | } 64 | Database.GetConnection().Close(); 65 | } 66 | return result; 67 | } 68 | 69 | public static List GetSalesFromLastWeek() 70 | { 71 | return GetSalesBetween(DateTime.Now.AddDays(-6), DateTime.Now); 72 | } 73 | 74 | public static string[] GetDaysLabelFromLastWeek() 75 | { 76 | return GetDaysLabel(DateTime.Now.AddDays(-6), DateTime.Now); 77 | } 78 | 79 | public static string[] GetDaysLabel(DateTime from, DateTime to) 80 | { 81 | if (from > to) throw new Level1Exception("Start date must not be Greater than end date"); 82 | List result = new List(); 83 | to = to.AddDays(1); 84 | while(!from.ToShortDateString().Equals(to.ToShortDateString())) 85 | { 86 | result.Add(from.ToString("MMM dd")); 87 | from = from.AddDays(1); 88 | } 89 | return result.ToArray(); 90 | } 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /FastFoodPOS/Models/Transaction.cs: -------------------------------------------------------------------------------- 1 | using FastFoodPOS.DatabaseUtil; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Data.Common; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace FastFoodPOS.Models 10 | { 11 | class Transaction 12 | { 13 | public string Id { get; set; } 14 | public DateTime Date { get; set; } 15 | public decimal Cash { get; set; } 16 | public int CashierId { get; set; } 17 | 18 | private decimal _total = -1; 19 | public decimal Total { 20 | get{ 21 | if (Orders == null && _total > -1) 22 | return _total; 23 | return GetOrders().Sum((Order item) => item.Subtotal); 24 | } 25 | } 26 | 27 | public decimal Change 28 | { 29 | get{ 30 | return Cash - Total; 31 | } 32 | } 33 | 34 | List Orders = null; 35 | User Cashier = null; 36 | 37 | public Transaction(List Orders, User Cashier) 38 | { 39 | this.Orders = Orders; 40 | this.Cashier = Cashier; 41 | this.CashierId = Cashier.Id; 42 | } 43 | 44 | public Transaction(decimal total) 45 | { 46 | this._total = total; 47 | } 48 | 49 | public User GetCashier() 50 | { 51 | if (Cashier == null) Cashier = User.Find(CashierId); 52 | return Cashier; 53 | } 54 | 55 | public List GetOrders() 56 | { 57 | if (Orders == null) Orders = Order.GetAll(Id); 58 | return Orders; 59 | } 60 | 61 | public void Save() 62 | { 63 | GenerateId(); 64 | using (var cmd = Database.CreateCommand("INSERT INTO `transactions`(`id`, `user_id`, `cash`) VALUES (@p1, @p2, @p3)")) 65 | { 66 | Database.BindParameters(cmd, Id, Cashier.Id, Cash); 67 | Database.GetConnection().Open(); 68 | cmd.ExecuteNonQuery(); 69 | Database.GetConnection().Close(); 70 | } 71 | Orders.ForEach((Order item) => item.Save(Id)); 72 | } 73 | 74 | public void GenerateId() 75 | { 76 | string result = DateTime.Now.ToString("yyyyMMdd"); 77 | //using (var cmd = Database.CreateCommand("SELECT COUNT(*) FROM `transactions` WHERE FIX(`date_created`)=FIX(NOW())")) 78 | using (var cmd = Database.CreateCommand(Database.GetProvider().QUERY_GENERATE_TRANSACTION_ID)) 79 | { 80 | Database.GetConnection().Open(); 81 | int count = Convert.ToInt32(cmd.ExecuteScalar()) + 1; 82 | Database.GetConnection().Close(); 83 | result += count.ToString("D3"); 84 | } 85 | Id = result; 86 | } 87 | 88 | public static List GetTransactions(DateTime date) 89 | { 90 | var result = new List(); 91 | //using (var cmd = Database.CreateCommand("SELECT * FROM `TransactionsView` WHERE FIX(`date_created`)=@p1")) 92 | using (var cmd = Database.CreateCommand(Database.GetProvider().QUERY_GET_TRANSACTIONS)) 93 | { 94 | Database.BindParameters(cmd, Database.GetProvider().FormatShortDate(date)); 95 | Database.GetConnection().Open(); 96 | using (var reader = cmd.ExecuteReader()) 97 | { 98 | while(reader.Read()) result.Add(ConvertReaderToTransaction(reader)); 99 | } 100 | Database.GetConnection().Close(); 101 | } 102 | return result; 103 | } 104 | 105 | public static List GetAllTransactions() 106 | { 107 | var result = new List(); 108 | using (var cmd = Database.CreateCommand("SELECT * FROM `TransactionsView`")) 109 | { 110 | Database.GetConnection().Open(); 111 | using (var reader = cmd.ExecuteReader()) 112 | { 113 | while (reader.Read()) result.Add(ConvertReaderToTransaction(reader)); 114 | } 115 | Database.GetConnection().Close(); 116 | } 117 | return result; 118 | } 119 | 120 | private static Transaction ConvertReaderToTransaction(DbDataReader reader) 121 | { 122 | return new Transaction(reader.GetDecimal(4)) 123 | { 124 | Id = reader.GetString(0), 125 | CashierId = reader.GetInt16(1), 126 | Date = reader.GetDateTime(2), 127 | Cash = reader.GetDecimal(3) 128 | }; 129 | } 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /FastFoodPOS/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using System.Windows.Forms; 6 | 7 | namespace FastFoodPOS 8 | { 9 | static class Program 10 | { 11 | /// 12 | /// The main entry point for the application. 13 | /// 14 | [STAThread] 15 | static void Main() 16 | { 17 | Application.EnableVisualStyles(); 18 | Application.SetCompatibleTextRenderingDefault(false); 19 | Application.Run(new MainForm()); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /FastFoodPOS/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("FastFoodPOS")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("FastFoodPOS")] 13 | [assembly: AssemblyCopyright("Copyright © 2021")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("8bcd62e3-8eb9-4fed-9258-c4a47ffd0a33")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /FastFoodPOS/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace FastFoodPOS.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | 26 | [global::System.Configuration.ApplicationScopedSettingAttribute()] 27 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 28 | [global::System.Configuration.SpecialSettingAttribute(global::System.Configuration.SpecialSetting.ConnectionString)] 29 | [global::System.Configuration.DefaultSettingValueAttribute("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\\FastFoodDatabase.ac" + 30 | "cdb;Persist Security Info=True")] 31 | public string FastFoodDatabaseConnectionString { 32 | get { 33 | return ((string)(this["FastFoodDatabaseConnectionString"])); 34 | } 35 | } 36 | 37 | [global::System.Configuration.ApplicationScopedSettingAttribute()] 38 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 39 | [global::System.Configuration.DefaultSettingValueAttribute("\r\nCREATE TABLE IF NOT EXISTS `orders` (\r\n `id` int(11) NOT NULL AUTO_INCREMENT,\r" + 40 | "\n `product_id` int(11) NOT NULL,\r\n `transaction_id` varchar(256) NOT NULL,\r\n " + 41 | "`quantity` int(11) NOT NULL,\r\n `price` decimal(10,2) NOT NULL,\r\n PRIMARY KEY(i" + 42 | "d)\r\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;\r\n\r\n\r\nCRE" + 43 | "ATE TABLE IF NOT EXISTS `products` (\r\n `id` int(11) NOT NULL AUTO_INCREMENT,\r\n " + 44 | " `name` varchar(256) NOT NULL,\r\n `category` varchar(256) NOT NULL,\r\n `price` d" + 45 | "ecimal(10,2) NOT NULL,\r\n `is_available` tinyint(1) NOT NULL,\r\n `image` varchar" + 46 | "(256) NOT NULL,\r\n `is_deleted` tinyint(1) NOT NULL DEFAULT \'0\',\r\n PRIMARY KEY(" + 47 | "id)\r\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;\r\n\r\n\r\nCR" + 48 | "EATE TABLE IF NOT EXISTS `transactions` (\r\n `id` varchar(256) NOT NULL,\r\n `use" + 49 | "r_id` int(11) NOT NULL,\r\n `date_created` datetime NOT NULL DEFAULT CURRENT_TIME" + 50 | "STAMP,\r\n `cash` decimal(10,2) NOT NULL,\r\n PRIMARY KEY(id)\r\n) ENGINE=InnoDB DEF" + 51 | "AULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;\r\n\r\n\r\nCREATE TABLE IF NOT EXISTS" + 52 | " `users` (\r\n `id` int(11) NOT NULL AUTO_INCREMENT,\r\n `fullname` varchar(256) N" + 53 | "OT NULL,\r\n `email` varchar(256) NOT NULL,\r\n `role` varchar(256) NOT NULL,\r\n `" + 54 | "password` varchar(256) NOT NULL,\r\n `image` varchar(256) NOT NULL,\r\n `is_delete" + 55 | "d` tinyint(1) NOT NULL DEFAULT \'0\',\r\n PRIMARY KEY(id)\r\n) ENGINE=InnoDB DEFAULT " + 56 | "CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;\r\n\r\n\r\nCREATE OR REPLACE VIEW `OrderTo" + 57 | "tal` AS\r\nSELECT transaction_id, SUM(price*quantity) AS total, Sum(quantity) AS o" + 58 | "rders\r\nFROM orders\r\nGROUP BY transaction_id;\r\n\r\n\r\nCREATE OR REPLACE VIEW `Transa" + 59 | "ctionsView` AS\r\nSELECT transactions.*, OrderTotal.total, OrderTotal.orders\r\nFROM" + 60 | " transactions INNER JOIN OrderTotal ON transactions.id=OrderTotal.transaction_id" + 61 | ";\r\n\r\n\r\nCREATE OR REPLACE VIEW `SalesView` AS\r\nSELECT Sum(TransactionsView.total)" + 62 | " AS Sale, date_created AS day, Sum(TransactionsView.orders) AS total_order, Coun" + 63 | "t(TransactionsView.id) AS total_customer\r\nFROM TransactionsView\r\nGROUP BY day\r\nO" + 64 | "RDER BY day;\r\n\r\n")] 65 | public string MySQLTables { 66 | get { 67 | return ((string)(this["MySQLTables"])); 68 | } 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /FastFoodPOS/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | <?xml version="1.0" encoding="utf-16"?> 7 | <SerializableConnectionString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 8 | <ConnectionString>Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\FastFoodDatabase.accdb;Persist Security Info=True</ConnectionString> 9 | <ProviderName>System.Data.OleDb</ProviderName> 10 | </SerializableConnectionString> 11 | Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\FastFoodDatabase.accdb;Persist Security Info=True 12 | 13 | 14 | 15 | CREATE TABLE IF NOT EXISTS `orders` ( 16 | `id` int(11) NOT NULL AUTO_INCREMENT, 17 | `product_id` int(11) NOT NULL, 18 | `transaction_id` varchar(256) NOT NULL, 19 | `quantity` int(11) NOT NULL, 20 | `price` decimal(10,2) NOT NULL, 21 | PRIMARY KEY(id) 22 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; 23 | 24 | 25 | CREATE TABLE IF NOT EXISTS `products` ( 26 | `id` int(11) NOT NULL AUTO_INCREMENT, 27 | `name` varchar(256) NOT NULL, 28 | `category` varchar(256) NOT NULL, 29 | `price` decimal(10,2) NOT NULL, 30 | `is_available` tinyint(1) NOT NULL, 31 | `image` varchar(256) NOT NULL, 32 | `is_deleted` tinyint(1) NOT NULL DEFAULT '0', 33 | PRIMARY KEY(id) 34 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; 35 | 36 | 37 | CREATE TABLE IF NOT EXISTS `transactions` ( 38 | `id` varchar(256) NOT NULL, 39 | `user_id` int(11) NOT NULL, 40 | `date_created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, 41 | `cash` decimal(10,2) NOT NULL, 42 | PRIMARY KEY(id) 43 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; 44 | 45 | 46 | CREATE TABLE IF NOT EXISTS `users` ( 47 | `id` int(11) NOT NULL AUTO_INCREMENT, 48 | `fullname` varchar(256) NOT NULL, 49 | `email` varchar(256) NOT NULL, 50 | `role` varchar(256) NOT NULL, 51 | `password` varchar(256) NOT NULL, 52 | `image` varchar(256) NOT NULL, 53 | `is_deleted` tinyint(1) NOT NULL DEFAULT '0', 54 | PRIMARY KEY(id) 55 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; 56 | 57 | 58 | CREATE OR REPLACE VIEW `OrderTotal` AS 59 | SELECT transaction_id, SUM(price*quantity) AS total, Sum(quantity) AS orders 60 | FROM orders 61 | GROUP BY transaction_id; 62 | 63 | 64 | CREATE OR REPLACE VIEW `TransactionsView` AS 65 | SELECT transactions.*, OrderTotal.total, OrderTotal.orders 66 | FROM transactions INNER JOIN OrderTotal ON transactions.id=OrderTotal.transaction_id; 67 | 68 | 69 | CREATE OR REPLACE VIEW `SalesView` AS 70 | SELECT Sum(TransactionsView.total) AS Sale, date_created AS day, Sum(TransactionsView.orders) AS total_order, Count(TransactionsView.id) AS total_customer 71 | FROM TransactionsView 72 | GROUP BY day 73 | ORDER BY day; 74 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /FastFoodPOS/Resources/FastFoodDatabase.accdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lenard123/fastfood-pos-csharp/a3d5b89ad377272edc251bf917e7c99113e3a795/FastFoodPOS/Resources/FastFoodDatabase.accdb -------------------------------------------------------------------------------- /FastFoodPOS/Resources/archive_gray.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lenard123/fastfood-pos-csharp/a3d5b89ad377272edc251bf917e7c99113e3a795/FastFoodPOS/Resources/archive_gray.png -------------------------------------------------------------------------------- /FastFoodPOS/Resources/archive_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lenard123/fastfood-pos-csharp/a3d5b89ad377272edc251bf917e7c99113e3a795/FastFoodPOS/Resources/archive_white.png -------------------------------------------------------------------------------- /FastFoodPOS/Resources/burger.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lenard123/fastfood-pos-csharp/a3d5b89ad377272edc251bf917e7c99113e3a795/FastFoodPOS/Resources/burger.png -------------------------------------------------------------------------------- /FastFoodPOS/Resources/burger_soda_black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lenard123/fastfood-pos-csharp/a3d5b89ad377272edc251bf917e7c99113e3a795/FastFoodPOS/Resources/burger_soda_black.png -------------------------------------------------------------------------------- /FastFoodPOS/Resources/burger_soda_gray.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lenard123/fastfood-pos-csharp/a3d5b89ad377272edc251bf917e7c99113e3a795/FastFoodPOS/Resources/burger_soda_gray.png -------------------------------------------------------------------------------- /FastFoodPOS/Resources/burger_soda_plus_gray.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lenard123/fastfood-pos-csharp/a3d5b89ad377272edc251bf917e7c99113e3a795/FastFoodPOS/Resources/burger_soda_plus_gray.png -------------------------------------------------------------------------------- /FastFoodPOS/Resources/burger_soda_plus_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lenard123/fastfood-pos-csharp/a3d5b89ad377272edc251bf917e7c99113e3a795/FastFoodPOS/Resources/burger_soda_plus_white.png -------------------------------------------------------------------------------- /FastFoodPOS/Resources/burger_soda_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lenard123/fastfood-pos-csharp/a3d5b89ad377272edc251bf917e7c99113e3a795/FastFoodPOS/Resources/burger_soda_white.png -------------------------------------------------------------------------------- /FastFoodPOS/Resources/check.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lenard123/fastfood-pos-csharp/a3d5b89ad377272edc251bf917e7c99113e3a795/FastFoodPOS/Resources/check.png -------------------------------------------------------------------------------- /FastFoodPOS/Resources/email.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lenard123/fastfood-pos-csharp/a3d5b89ad377272edc251bf917e7c99113e3a795/FastFoodPOS/Resources/email.png -------------------------------------------------------------------------------- /FastFoodPOS/Resources/error-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lenard123/fastfood-pos-csharp/a3d5b89ad377272edc251bf917e7c99113e3a795/FastFoodPOS/Resources/error-white.png -------------------------------------------------------------------------------- /FastFoodPOS/Resources/glass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lenard123/fastfood-pos-csharp/a3d5b89ad377272edc251bf917e7c99113e3a795/FastFoodPOS/Resources/glass.png -------------------------------------------------------------------------------- /FastFoodPOS/Resources/hide.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lenard123/fastfood-pos-csharp/a3d5b89ad377272edc251bf917e7c99113e3a795/FastFoodPOS/Resources/hide.png -------------------------------------------------------------------------------- /FastFoodPOS/Resources/home_gray.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lenard123/fastfood-pos-csharp/a3d5b89ad377272edc251bf917e7c99113e3a795/FastFoodPOS/Resources/home_gray.png -------------------------------------------------------------------------------- /FastFoodPOS/Resources/home_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lenard123/fastfood-pos-csharp/a3d5b89ad377272edc251bf917e7c99113e3a795/FastFoodPOS/Resources/home_white.png -------------------------------------------------------------------------------- /FastFoodPOS/Resources/icecream.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lenard123/fastfood-pos-csharp/a3d5b89ad377272edc251bf917e7c99113e3a795/FastFoodPOS/Resources/icecream.png -------------------------------------------------------------------------------- /FastFoodPOS/Resources/icon_placeholder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lenard123/fastfood-pos-csharp/a3d5b89ad377272edc251bf917e7c99113e3a795/FastFoodPOS/Resources/icon_placeholder.png -------------------------------------------------------------------------------- /FastFoodPOS/Resources/info.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lenard123/fastfood-pos-csharp/a3d5b89ad377272edc251bf917e7c99113e3a795/FastFoodPOS/Resources/info.png -------------------------------------------------------------------------------- /FastFoodPOS/Resources/key.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lenard123/fastfood-pos-csharp/a3d5b89ad377272edc251bf917e7c99113e3a795/FastFoodPOS/Resources/key.png -------------------------------------------------------------------------------- /FastFoodPOS/Resources/mcdonalds.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lenard123/fastfood-pos-csharp/a3d5b89ad377272edc251bf917e7c99113e3a795/FastFoodPOS/Resources/mcdonalds.png -------------------------------------------------------------------------------- /FastFoodPOS/Resources/product_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lenard123/fastfood-pos-csharp/a3d5b89ad377272edc251bf917e7c99113e3a795/FastFoodPOS/Resources/product_default.png -------------------------------------------------------------------------------- /FastFoodPOS/Resources/question_circle_gray.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lenard123/fastfood-pos-csharp/a3d5b89ad377272edc251bf917e7c99113e3a795/FastFoodPOS/Resources/question_circle_gray.png -------------------------------------------------------------------------------- /FastFoodPOS/Resources/receipt_gray.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lenard123/fastfood-pos-csharp/a3d5b89ad377272edc251bf917e7c99113e3a795/FastFoodPOS/Resources/receipt_gray.png -------------------------------------------------------------------------------- /FastFoodPOS/Resources/receipt_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lenard123/fastfood-pos-csharp/a3d5b89ad377272edc251bf917e7c99113e3a795/FastFoodPOS/Resources/receipt_white.png -------------------------------------------------------------------------------- /FastFoodPOS/Resources/sales_gray.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lenard123/fastfood-pos-csharp/a3d5b89ad377272edc251bf917e7c99113e3a795/FastFoodPOS/Resources/sales_gray.png -------------------------------------------------------------------------------- /FastFoodPOS/Resources/sales_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lenard123/fastfood-pos-csharp/a3d5b89ad377272edc251bf917e7c99113e3a795/FastFoodPOS/Resources/sales_white.png -------------------------------------------------------------------------------- /FastFoodPOS/Resources/search_gray.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lenard123/fastfood-pos-csharp/a3d5b89ad377272edc251bf917e7c99113e3a795/FastFoodPOS/Resources/search_gray.png -------------------------------------------------------------------------------- /FastFoodPOS/Resources/show.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lenard123/fastfood-pos-csharp/a3d5b89ad377272edc251bf917e7c99113e3a795/FastFoodPOS/Resources/show.png -------------------------------------------------------------------------------- /FastFoodPOS/Resources/sign_out_gray.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lenard123/fastfood-pos-csharp/a3d5b89ad377272edc251bf917e7c99113e3a795/FastFoodPOS/Resources/sign_out_gray.png -------------------------------------------------------------------------------- /FastFoodPOS/Resources/sign_out_right_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lenard123/fastfood-pos-csharp/a3d5b89ad377272edc251bf917e7c99113e3a795/FastFoodPOS/Resources/sign_out_right_white.png -------------------------------------------------------------------------------- /FastFoodPOS/Resources/soup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lenard123/fastfood-pos-csharp/a3d5b89ad377272edc251bf917e7c99113e3a795/FastFoodPOS/Resources/soup.png -------------------------------------------------------------------------------- /FastFoodPOS/Resources/unavailable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lenard123/fastfood-pos-csharp/a3d5b89ad377272edc251bf917e7c99113e3a795/FastFoodPOS/Resources/unavailable.png -------------------------------------------------------------------------------- /FastFoodPOS/Resources/user_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lenard123/fastfood-pos-csharp/a3d5b89ad377272edc251bf917e7c99113e3a795/FastFoodPOS/Resources/user_default.png -------------------------------------------------------------------------------- /FastFoodPOS/Resources/users_gray.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lenard123/fastfood-pos-csharp/a3d5b89ad377272edc251bf917e7c99113e3a795/FastFoodPOS/Resources/users_gray.png -------------------------------------------------------------------------------- /FastFoodPOS/Resources/users_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lenard123/fastfood-pos-csharp/a3d5b89ad377272edc251bf917e7c99113e3a795/FastFoodPOS/Resources/users_white.png -------------------------------------------------------------------------------- /FastFoodPOS/Util.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Configuration; 4 | using System.Drawing; 5 | using System.IO; 6 | using System.Linq; 7 | using System.Security.Cryptography; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | using System.Windows.Forms; 11 | 12 | namespace FastFoodPOS 13 | { 14 | class Util 15 | { 16 | public static string GetConfig(string key) 17 | { 18 | return ConfigurationManager.AppSettings[key]; 19 | } 20 | 21 | public static string GetHashSHA256(string text) 22 | { 23 | SHA256Managed hashstring = new SHA256Managed(); 24 | byte[] bytes = Encoding.Unicode.GetBytes(text); 25 | byte[] hash = hashstring.ComputeHash(bytes); 26 | string result = string.Empty; 27 | foreach (byte x in hash) 28 | { 29 | result += String.Format("{0:x2}", x); 30 | } 31 | return result; 32 | } 33 | 34 | public static bool VerifyHash(string text, string hashedtext) 35 | { 36 | return GetHashSHA256(text).Equals(hashedtext); 37 | } 38 | 39 | public static string CopyImage(string source, string filename) 40 | { 41 | CreateImageDirectory(); 42 | filename = Path.GetFileName(filename); 43 | string destination = Path.Combine("images", filename); 44 | if (File.Exists(destination)) 45 | { 46 | FileReplace(source, destination); 47 | } 48 | else 49 | { 50 | File.Copy(source, destination); 51 | } 52 | return destination; 53 | } 54 | 55 | public static void FileReplace(string source, string destination) 56 | { 57 | if (File.Exists(destination + ".bak")) File.Delete(destination + ".bak"); 58 | File.Copy(destination, destination + ".bak"); 59 | File.Delete(destination); 60 | File.Copy(source, destination); 61 | } 62 | 63 | public static string GetFullPath(string path) 64 | { 65 | return Path.Combine(Application.StartupPath, path); 66 | } 67 | 68 | private static void CreateImageDirectory() 69 | { 70 | if(!Directory.Exists("images")){ 71 | Directory.CreateDirectory("images"); 72 | } 73 | } 74 | 75 | public static bool IsEmail(string text) 76 | { 77 | try 78 | { 79 | var addr = new System.Net.Mail.MailAddress(text); 80 | return addr.Address == text; 81 | } 82 | catch (Exception e) 83 | { 84 | Console.WriteLine(e); 85 | return false; 86 | } 87 | } 88 | 89 | public static Image GetImageFromFile(string source) 90 | { 91 | Image result = null; 92 | if (File.Exists(source)) 93 | { 94 | using (var stream = File.OpenRead(source)) 95 | { 96 | result = Image.FromStream(stream); 97 | } 98 | } 99 | return result; 100 | } 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /FastFoodPOS/mcdonalds.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lenard123/fastfood-pos-csharp/a3d5b89ad377272edc251bf917e7c99113e3a795/FastFoodPOS/mcdonalds.ico -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Lenard Mangay-ayam 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Fast Food POS using C#.Net WinForms 2 | 3 | ## Requirements 4 | - Visual Studio 5 | - MS Access or MySQL 6 | 7 | ## How to download? 8 | 1. First Download the source code using git or using this direct [link](https://github.com/lenard123/fastfood-pos-csharp/archive/refs/heads/main.zip) 9 | 2. Open the FastFoodPOS.sln using Visual Studio 10 | 3. On the solution explorer open App.config and enter the password. 11 | 4. Press F5 to compile and run 12 | 13 | ## How to configure the MYSQL 14 | 1. Open the App.config 15 | 2. Change the DbProvider from MSACCESS -> MYSQL 16 | 3. Configure the MySQL database Connection 17 | 4. Fress F5 to compile and run 18 | - This is only tested on MySQL version 8 19 | 20 | ## Issues 21 | 1. If you encounter an error saying "Please try the other variant or install Microsoft Access 2010 redistributable" 22 | - Try to change the build to x86 instead of Any CPU 23 | - If it still don't work, install [Microsoft Access 2010 redistributable](https://www.microsoft.com/en-US/download/details.aspx?id=13255) 24 | 25 | ## Binary 26 | 1. If you don't have Visual Studio and just want to download the system directly. Click [here](https://github.com/lenard123/fastfood-pos-csharp/releases/download/v1.0.0/v1.0.0.rar) 27 | 2. Then Run the FastFoodPOS.exe 28 | 29 | ## License 30 | 31 | See the [LICENSE](LICENSE.md) file for license rights and limitations (MIT). 32 | 33 | Contact me here at my email lenard.mangayayam@gmail.com 34 | to get the password -------------------------------------------------------------------------------- /lib/ClosedXML.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lenard123/fastfood-pos-csharp/a3d5b89ad377272edc251bf917e7c99113e3a795/lib/ClosedXML.dll -------------------------------------------------------------------------------- /lib/DocumentFormat.OpenXml.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lenard123/fastfood-pos-csharp/a3d5b89ad377272edc251bf917e7c99113e3a795/lib/DocumentFormat.OpenXml.dll -------------------------------------------------------------------------------- /lib/ExcelNumberFormat.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lenard123/fastfood-pos-csharp/a3d5b89ad377272edc251bf917e7c99113e3a795/lib/ExcelNumberFormat.dll -------------------------------------------------------------------------------- /lib/Guna.UI2.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lenard123/fastfood-pos-csharp/a3d5b89ad377272edc251bf917e7c99113e3a795/lib/Guna.UI2.dll -------------------------------------------------------------------------------- /lib/LiveCharts.WinForms.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lenard123/fastfood-pos-csharp/a3d5b89ad377272edc251bf917e7c99113e3a795/lib/LiveCharts.WinForms.dll -------------------------------------------------------------------------------- /lib/LiveCharts.Wpf.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lenard123/fastfood-pos-csharp/a3d5b89ad377272edc251bf917e7c99113e3a795/lib/LiveCharts.Wpf.dll -------------------------------------------------------------------------------- /lib/LiveCharts.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lenard123/fastfood-pos-csharp/a3d5b89ad377272edc251bf917e7c99113e3a795/lib/LiveCharts.dll -------------------------------------------------------------------------------- /lib/MySql.Data.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lenard123/fastfood-pos-csharp/a3d5b89ad377272edc251bf917e7c99113e3a795/lib/MySql.Data.dll --------------------------------------------------------------------------------