private void btnLogin_Click(object sender, EventArgs e) { db = new DBPOS(); users = db.GetUserAccounts(); current = 0; if (String.IsNullOrEmpty(txtBxUserName.Text) && String.IsNullOrEmpty(txtBxPassword.Text)) { lblLoginErrorMsg.Text = "Please ensure all fields are entered"; txtBxUserName.ResetText(); txtBxPassword.ResetText(); } else if (users.Exists(u => u.Username.Equals(txtBxUserName.Text))) { current = users.FindIndex(u => u.Username.Equals(txtBxUserName.Text)); if (users[current].Username.Equals(txtBxUserName.Text) && users[current].Password.Equals(txtBxPassword.Text)) { lblLoginErrorMsg.Text = ""; txtBxUserName.ResetText(); txtBxPassword.ResetText(); MessageBox.Show(string.Format("Welcome {0}! Your AccountType is {1}.", users[current].Username, users[current].AccountType)); UserControlPanel cp = new UserControlPanel(); cp.CurrentUser = users[current]; cp.ShowDialog(); } } else { txtBxUserName.ResetText(); txtBxPassword.ResetText(); lblLoginErrorMsg.Text = "Either the username or password was incorrect."; } }
public void ChangeAccountSettings_Load(object sender, EventArgs e) { txtBxPasswordNew.PasswordChar = '\u2022'; txtBxCVC.MaxLength = 3; txtBxCreditCardNo.MaxLength = 16; txtBxMobileNoNew.MaxLength = 8; txtBxSixDigitPIN.MaxLength = 6; txtBxCreditCardNo.MaxLength = 16; if (user.AccountType == "Administrator" || user.AccountType == "Vendor") { dbp = new DBPOS(); users = dbp.GetUserAccounts(); panelPg2.Visible = true; CustPanel.Visible = false; PassEmailPanel.Visible = true; panelPg3.Visible = false; PassEmailPanel.Location = new Point(37, 31); txtBxPasswordNew.Text = users[0].Password; txtBxEmailNew.Text = users[0].Email; } else { dbp = new DBPOS(); users = dbp.GetUserInfo(user.AccountID); txtBxFirstNameNew.Text = users[0].FirstName; txtBxLastNameNew.Text = users[0].LastName; txtBxMobileNoNew.Text = users[0].MobileNo.ToString(); txtBxPasswordNew.Text = users[0].Password; txtBxEmailNew.Text = users[0].Email; panelPg2.Visible = true; panelPg3.Visible = false; } }
private void LoadVendors(object sender, EventArgs e) { DBPOS dbp = new DBPOS(); vendors = dbp.LoadVendorAccounts(); DataTable vendor = new DataTable(); vendor.Columns.Add("VendorID"); vendor.Columns.Add("AccountID"); vendor.Columns.Add("Name"); vendor.Columns.Add("ContactPerson"); vendor.Columns.Add("ContactNo"); lvLoadVendor.View = View.Details; foreach (Vendor v in vendors) { vendor.Rows.Add(v.VendorID,v.AccountID,v.Name,v.ContactPerson,v.ContactNo); } lvLoadVendor.Items.Clear();//Clear the ListView control first before adding ListViewItems foreach (DataRow dr in vendor.Rows) { ListViewItem item = new ListViewItem(); item.Text = dr["VendorID"].ToString(); item.SubItems.Add(dr["AccountID"].ToString()); item.SubItems.Add(dr["Name"].ToString()); item.SubItems.Add(dr["ContactPerson"].ToString()); item.SubItems.Add(dr["ContactNo"].ToString()); lvLoadVendor.Items.Add(item); } }
private void btnSubmit_Click(object sender, EventArgs e) { dbp = new DBPOS(); dbp.UpdateAccount(txtBxPasswordNew.Text,txtBxEmailNew.Text,user.Username); dbp.UpdateCustomer(txtBxFirstNameNew.Text, txtBxLastNameNew.Text, txtBxMobileNoNew.Text,user.Username); MessageBox.Show("Your account has been updated, without payment changes"); this.Close(); }
private void btnSubmit_Click(object sender, EventArgs e) { string genderType = ""; if (radioMale.Checked) { genderType = "M"; } else if (radioFemale.Checked) { genderType = "F"; } DBPOS dbp = new DBPOS(); dbp.InsertCategory(txtBxDescription.Text, genderType); MessageBox.Show("The category has been added"); this.Close(); }
private void btnNext_Click(object sender, EventArgs e) { DBPOS dbp = new DBPOS(); //start of validation if (String.IsNullOrEmpty(txtBxUsername.Text) || String.IsNullOrEmpty(txtBxPassword.Text) || String.IsNullOrEmpty(txtBxFirstName.Text) || String.IsNullOrEmpty(txtBxLastName.Text) || String.IsNullOrEmpty(txtBxEmail.Text) || String.IsNullOrEmpty(txtBxAddress.Text) || String.IsNullOrEmpty(txtBxMobileNo.Text)) { lblErrorRegistration.Text = "Please ensure all fields are entered"; lblErrorRegistration.Visible = true; } else if (dbp.ValidateUsername(txtBxUsername.Text) == false) { lblErrorRegistration.Text = string.Format("Username \'{0}\' already exists!",txtBxUsername.Text); lblErrorRegistration.Visible = true; } else if (!Regex.Match(txtBxMobileNo.Text, @"^+\d{0,9}$").Success) { lblErrorRegistration.Text = "Please enter a valid Mobile Number"; lblErrorRegistration.Visible = true; } else if (!Regex.Match(txtBxEmail.Text, @"(@)(.+)$").Success) { lblErrorRegistration.Text = "Please enter a valid Email"; lblErrorRegistration.Visible = true; } else { lblErrorRegistration.Text = ""; panelPg1.Visible = false; panelPg2.Visible = true; } //end of validation }
private void btnCreateVendor_Click(object sender, EventArgs e) { if (String.IsNullOrEmpty(txtBxUsername.Text) || String.IsNullOrEmpty(txtBxPassword.Text) || String.IsNullOrEmpty(txtBxEmail.Text)) { lblAddVendorError.Text = "Please ensure all fields are entered"; lblAddVendorError.Visible = true; } else { DBPOS dbp = new DBPOS(); dbp.InsertAccount(txtBxEmail.Text, txtBxUsername.Text, txtBxPassword.Text, "GETDATE()",2); dbp.InsertVendor(dbp.GetAccountID(txtBxUsername.Text),txtBxUsername.Text, txtBxContactPerson.Text, txtBxContactNo.Text); MessageBox.Show("Vendor account has been created."); txtBxEmail.Text = ""; txtBxUsername.Text = ""; txtBxPassword.Text = ""; txtBxEmail.Text = ""; txtBxContactPerson.Text = ""; txtBxContactNo.Text = ""; } }
public void CreateControls() { db = new DBPOS(); switch(user.AccountType) { case "Administrator": case "Owner": /*Administrator/Owner Control Panel*/ FlowLayoutPanel AdminPanel = new FlowLayoutPanel(); AdminPanel.AutoScroll = true; AdminPanel.Size = new Size(581, 308); AdminPanel.Location = new Point(10, 51); AdminPanel.Padding = new Padding(5, 0, 5, 5); Button viewPOSBtn = new Button(); viewPOSBtn.Size = new Size(124, 52); viewPOSBtn.Text = "View Shop"; viewPOSBtn.Click += OpenPOS; Button addVendorBtn = new Button(); addVendorBtn.Size = new Size(124, 52); addVendorBtn.Text = "Add Vendor"; addVendorBtn.Click += OpenAddVendor; Button addCategoryBtn = new Button(); addCategoryBtn.Size = new Size(124, 52); addCategoryBtn.Text = "Add Category"; addCategoryBtn.Click += AddCategory; Button addProductBtn = new Button(); addProductBtn.Size = new Size(124, 52); addProductBtn.Text = "Add Product"; Button viewVendorsBtn = new Button(); viewVendorsBtn.Size = new Size(124, 52); viewVendorsBtn.Text = "View Vendors"; viewVendorsBtn.Click += OpenViewVendor; Button viewProductsBtn = new Button(); viewProductsBtn.Size = new Size(124, 52); viewProductsBtn.Text = "View Products"; Button salesReportBtn = new Button(); salesReportBtn.Size = new Size(124, 52); salesReportBtn.Text = "Sales Report"; Button changeAccountDetailsBtn = new Button(); changeAccountDetailsBtn.Size = new Size(124, 52); changeAccountDetailsBtn.Text = "Change Account Details"; changeAccountDetailsBtn.Click += ChangeAccountSettings; this.Controls.Add(AdminPanel); AdminPanel.Controls.Add(viewPOSBtn); AdminPanel.Controls.Add(addVendorBtn); AdminPanel.Controls.Add(addCategoryBtn); AdminPanel.Controls.Add(addProductBtn); AdminPanel.Controls.Add(viewVendorsBtn); AdminPanel.Controls.Add(viewProductsBtn); AdminPanel.Controls.Add(salesReportBtn); AdminPanel.Controls.Add(changeAccountDetailsBtn); break; case "Vendor": /*Vendor Controls*/ FlowLayoutPanel VendorPanel = new FlowLayoutPanel(); VendorPanel.AutoScroll = true; VendorPanel.Size = new Size(581, 308); VendorPanel.Location = new Point(10, 71); VendorPanel.Padding = new Padding(5, 5, 5, 5); this.Controls.Add(VendorPanel); break; case "Customer": /*Customer Controls*/ FlowLayoutPanel CustomerPanel = new FlowLayoutPanel(); CustomerPanel.AutoScroll = true; CustomerPanel.Size = new Size(581, 308); CustomerPanel.Location = new Point(10, 71); CustomerPanel.Padding = new Padding(5, 5, 5, 5); viewPOSBtn = new Button(); viewPOSBtn.Size = new Size(124, 52); viewPOSBtn.Text = "&Shop"; viewPOSBtn.Click += OpenPOS; changeAccountDetailsBtn = new Button(); changeAccountDetailsBtn.Size = new Size(124, 52); changeAccountDetailsBtn.Text = "Change Account Details"; changeAccountDetailsBtn.Click += ChangeAccountSettings; this.Controls.Add(CustomerPanel); CustomerPanel.Controls.Add(viewPOSBtn); CustomerPanel.Controls.Add(changeAccountDetailsBtn); break; default: FlowLayoutPanel DefaultPanel = new FlowLayoutPanel(); DefaultPanel.AutoScroll = true; DefaultPanel.Size = new Size(581, 308); DefaultPanel.Location = new Point(10, 71); DefaultPanel.Padding = new Padding(5, 5, 5, 5); Label l = new Label(); l.Text = "Default Panel"; this.Controls.Add(DefaultPanel); DefaultPanel.Controls.Add(l); break; } }
private void btnSubmit_Click(object sender, EventArgs e) { panelPg1.Visible = false; panelPg2.Visible = true; DialogResult dr; DBPOS dbp = new DBPOS(); string cardType = ""; if (radioMasterVisa.Checked) { cardType = radioMasterVisa.Text; } else if (radioAmericanExp.Checked) { cardType = radioAmericanExp.Text; } if (String.IsNullOrEmpty(txtBxCreditCardName.Text) || String.IsNullOrEmpty(txtBxCreditCardNo.Text) || String.IsNullOrEmpty(txtBxCVC.Text) || String.IsNullOrEmpty(txtBxSixDigitPIN.Text) || !radioAmericanExp.Checked && !radioMasterVisa.Checked) { dr = MessageBox.Show("Are you sure you want to skip Entering Credit Card Details? (Can be entered later)", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.No) { MessageBox.Show( "Please ensure that you have fill in all your credit card credentials to complete your payment.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { dbp.InsertAccount(txtBxEmail.Text, txtBxUsername.Text, txtBxPassword.Text, "GETDATE()", 1); dbp.InsertCustomer(dbp.GetAccountID(txtBxUsername.Text), txtBxFirstName.Text, txtBxLastName.Text, txtBxMobileNo.Text, dtpDOB.Value.Date); MessageBox.Show("Your account has been created, without payment"); this.Close(); } } else { dbp.InsertAccount(txtBxEmail.Text, txtBxUsername.Text, txtBxPassword.Text, "GETDATE()", 1); dbp.InsertCustomer(dbp.GetAccountID(txtBxUsername.Text), txtBxFirstName.Text, txtBxLastName.Text, txtBxMobileNo.Text, dtpDOB.Value.Date); dbp.InsertCreditCard(dbp.GetAccountID(txtBxUsername.Text), txtBxCreditCardName.Text, long.Parse(txtBxCreditCardNo.Text), dtpExpiryDate.Value,int.Parse(txtBxCVC.Text), int.Parse(txtBxSixDigitPIN.Text), cardType); MessageBox.Show("Your account has been created, with payment"); this.Close(); } }
private void btnUpdateCreditCard_Click(object sender, EventArgs e) { string cardType = ""; if (radioMasterVisa.Checked) { cardType = radioMasterVisa.Text; } else if (radioAmericanExp.Checked) { cardType = radioAmericanExp.Text; } dbp = new DBPOS(); dbp.UpdateAccount(txtBxEmailNew.Text, txtBxPasswordNew.Text, user.Username); dbp.UpdateCustomer(txtBxFirstNameNew.Text, txtBxLastNameNew.Text, txtBxMobileNoNew.Text, user.Username); dbp.InsertCreditCard(dbp.GetAccountID(user.Username), txtBxCreditCardName.Text, long.Parse(txtBxCreditCardNo.Text), dtpExpiryDate.Value, int.Parse(txtBxCVC.Text), int.Parse(txtBxSixDigitPIN.Text), cardType); MessageBox.Show("Your account has been updated, with payment changes"); this.Close(); }
//When confirm button is pressed (Print receipt upon successful payment input) private void MakePayment(object sender, EventArgs e) { if (!cashPaymentRadio.Checked || !creditCardRadio.Checked) //First conditon checking if a mode of payment was selected { //Payment mode: Credit Card if (creditCardRadio.Checked) { //All credentials not filled in if (String.IsNullOrEmpty(txtBxSixDigitPIN.Text)) { MessageBox.Show( "Please ensure that you have fill in all your credit card credentials to complete your payment.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } //All credentials were filled in with valid input else { DBPOS dbp = new DBPOS(); /*When a successful payment is made, the PaymentMadeEvent will be invoked and send a boolean value of true to the POS*/ PaymentMade( this, new PaymentMadeEventArgs() { SuccessfulPayment = true, IsCreditCardPayment = true, IsCashPayment = false, HasDiscount = hasDiscount, BeforeDiscountTotalAmount = beforeDiscount, DiscountedValue = discountedAmount, Total = total, TransactionItems = transactionItems }); this.Close(); } } //Payment mode: CASH else if (cashPaymentRadio.Checked) { //Checks for valid & correct payment amount if (String.IsNullOrEmpty(txtbxCashPayment.Text) || decimal.TryParse(txtbxCashPayment.Text, out cashPaymentInput) == false || cashPaymentInput <= 0) { MessageBox.Show( "Please ensure you have entered a valid & correct payment value for your purchase.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } //Checks for input amount > total amount user suppose to pay else if (cashPaymentInput < total) { MessageBox.Show( "Please ensure you have entered at least " + total.ToString("C", CultureInfo.CreateSpecificCulture("en-US")), "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } //If valid and correct payment amount was input, shows receipt else { cashPaymentInput = decimal.Parse(txtbxCashPayment.Text); changeDue = cashPaymentInput - total; //Display Change if the change amount is > 0 if (changeDue > 0) { MessageBox.Show("Your change is " + changeDue.ToString("C", CultureInfo.CreateSpecificCulture("en-US")), "Change Due", MessageBoxButtons.OK, MessageBoxIcon.None); } PaymentMade( this, new PaymentMadeEventArgs() { SuccessfulPayment = true, IsCashPayment = true, HasDiscount = hasDiscount, BeforeDiscountTotalAmount = beforeDiscount, DiscountedValue = discountedAmount, Total = total, CashPaymentInput = cashPaymentInput, ChangeDue = changeDue, TransactionItems = transactionItems }); this.Close(); } } //Checks if no payment mode was selected else { MessageBox.Show( "Please ensure that you have chose your preferred mode of payment.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } //PaymentMade(this, new PaymentMadeEventArgs() { PaymentSuccess = true }); } //Ends of no payment mode selected if conditional check }