Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Microsoft.VisualBasic;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Data;
- using System.Drawing;
- using System.Diagnostics;
- using System.Windows.Forms;
- using System.Linq;
- using System.Xml.Linq;
- using System.Data.SqlClient;
- namespace POSMainForm
- {
- public partial class frmLogin : Form
- {
- public frmLogin()
- {
- InitializeComponent();
- }
- private void frmLogin_Load(object sender, EventArgs e)
- {
- SQLConn.getData();
- }
- private void Login()
- {
- try
- {
- SQLConn.sqL = "SELECT * FROM Staff WHERE Username = '" + txtusername.Text + "' AND UPassword = '" + txtPassword.Text + "'";
- SQLConn.ConnDB();
- SQLConn.cmd = new SqlCommand(SQLConn.sqL, SQLConn.conn);
- SQLConn.dr = SQLConn.cmd.ExecuteReader();
- if (SQLConn.dr.Read() == true)
- {
- if (SQLConn.dr["Role"].ToString().ToUpper() == "Admin")
- {
- frmMain m = new frmMain(SQLConn.dr["Username"].ToString(),Convert.ToInt32(SQLConn.dr["StaffID"]));
- m.Show();
- this.Hide();
- }
- else
- {
- // frmPOS m = new frmPOS(Convert.ToInt32(SQLConn.dr["StaffID"]));
- // m.Show();
- this.Hide();
- }
- }
- else
- {
- Interaction.MsgBox("Invalid Password. Please try again.",MsgBoxStyle.Exclamation, "Login");
- }
- }
- catch (Exception ex)
- {
- Interaction.MsgBox(ex.Message);
- }
- finally
- {
- SQLConn.cmd.Dispose();
- SQLConn.conn.Close();
- }
- }
- private void txtPassword_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- {
- Login();
- }
- }
- private void txtusername_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- {
- Login();
- }
- }
- private void btnCancel_Click(object sender, EventArgs e)
- {
- Application.Exit();
- }
- private void frmLogin_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.F12)
- {
- frmDatabaseConfig dc = new frmDatabaseConfig();
- dc.ShowDialog();
- }
- }
- private void btnOkay_Click_1(object sender, EventArgs e)
- {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement