Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using System.Data.SqlClient;
- namespace Retail_POS.Forms
- {
- public partial class frmLogin : Form
- {
- // declaration
- int Attempts = 0;
- public static bool _Logged = false;
- public static string _USERID = "";
- public static string _PASSWORD = "";
- public static string _USERNAME = "";
- public static bool _FILE = false ;
- public static bool _MANAGE = false ;
- public static bool _REPORTS = false ;
- public static bool _SALES = false ;
- public static bool _STOCK = false ;
- public static bool _ADMINISTRATOR = false ;
- public static bool _UNDO_SALE = false ;
- public frmLogin()
- {
- InitializeComponent();
- }
- private void frmLogin_Load(object sender, EventArgs e)
- {
- SqlConnection sqlConnection = new SqlConnection(
- "Server=AUTUMN-PC\\SQLEXPRESS;" +
- "Integrated Security=True");
- // Create command
- //SqlCommand cmdLogin = new SqlCommand(
- // "SELECT userid, password FROM userprofile", sqlConnection);
- //open connection
- sqlConnection.Open();
- // // Execute the command
- // SqlDataReader reader = comm.ExecuteReader();
- // while (reader.Read())
- // {
- // txtUserName += reader[""];
- // txtPassword += reader["PASSWORD"];
- // }
- //close
- //reader.Close();
- //conn.Close();
- }
- //Functions and procedure
- private bool fnLogin(string prmUSER_NAME, string prmPASSWORD)
- {
- // Initialize connection
- // Define database connection
- //SqlConnection conn = new SqlConnection(
- // "Server=AUTUMN-PC\\SQLEXPRESS;" +
- // "Database=RetailPOS;User ID=sa;" +
- // "Password=m1nwoo");
- bool Return = false;
- try
- {
- string varSQL = "SELECT USERPROFILE.USERID " +
- " FROM USERPROFILE " +
- " WHERE USERPROFILE.USERID='" + prmUSER_NAME + "' " +
- " AND USERPROFILE.PASSWORD ='" + prmPASSWORD + "'";
- SqlConnection sqlConnection = new SqlConnection(Class.clsMain.CnnStr);
- //sqlConnection.Open();
- SqlCommand cmdLogin = new SqlCommand(varSQL,sqlConnection);
- SqlDataReader drLogin = cmdLogin.ExecuteReader();
- while (drLogin.Read())
- {
- Return=true;
- _USERID =drLogin["USERID"].ToString();
- _PASSWORD = drLogin["PASSWORD"].ToString();
- _USERNAME = drLogin["USERNAME"].ToString();
- }
- drLogin.Close();
- sqlConnection.Close();
- cmdLogin.Dispose();
- return (Return);
- }
- catch (Exception ex) {
- MessageBox.Show("fnLogin\n" + ex.Message,
- "System Information");
- return (Return);
- }
- }
- private void ButtonLogin_Click(object sender, EventArgs e)
- {
- _Logged = fnLogin(txtUserName.Text,txtPassword.Text);
- if (Attempts >= 3)
- {
- _Logged = false;
- MessageBox.Show("Sorry,Too many attempts. Please Contact Admin",
- "System Information");
- this.Close();
- }
- if (_Logged)
- this.Close();
- }
- private void buttonCancel_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement