Advertisement
Guest User

IWin32Window for displaying a Metro message box in c#

a guest
Nov 25th, 2016
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.57 KB | None | 0 0
  1. using MetroFramework.Forms;
  2. using System;
  3. using MetroFramework;
  4. using System.Data.SQLite;
  5. using System.Windows.Forms;
  6.  
  7. namespace LeaveManagementSystem
  8. {
  9.     public partial class frmLogin : MetroForm
  10.     {
  11.         SQLiteConnection m_dbConnection=null;
  12.         private string useremail = null;
  13.         private string password = null;
  14.         private string username = null;
  15.         private string acountType = null;
  16.         private int userId = -1;
  17.         private int count = 0;
  18.  
  19.         public frmLogin()
  20.         {
  21.             InitializeComponent();
  22.             dbConnector();
  23.            
  24.         }
  25.  
  26.        
  27.  
  28.         public void dbConnector()
  29.         {
  30.  
  31.             string path = AppDomain.CurrentDomain.BaseDirectory;
  32.             m_dbConnection = new SQLiteConnection(@"Data Source=" + path + "\\database\\LeaveDB.sqlite;Version=3;");
  33.             m_dbConnection.Open();
  34.     }
  35.         private void linkLabelCreakeAcc_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
  36.         {
  37.             frmCreateAccount fCreateAccount = new frmCreateAccount();
  38.             fCreateAccount.Show();
  39.             this.Hide();
  40.         }
  41.  
  42.         private void btnLogin_Click(object sender, EventArgs e)
  43.         {
  44.             string sql = "select UserEmail,Password,UserName,UserID,AccountType from tblUser";
  45.             SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection);
  46.             SQLiteDataReader reader = command.ExecuteReader();
  47.             while (reader.Read())
  48.             {
  49.                 //useremail = reader["UserEmail"].ToString();
  50.                 //password = reader["Password"].ToString();
  51.                
  52.                 if (txtemail.Text.ToString() == reader["UserEmail"].ToString() && txtpassword.Text.ToString() == reader["Password"].ToString())
  53.                 {
  54.                     count++;
  55.                     useremail = reader["UserEmail"].ToString();
  56.                     password = reader["Password"].ToString();
  57.                     username = reader["UserName"].ToString();
  58.                     userId = Convert.ToInt32(reader["UserID"].ToString());
  59.                     acountType = reader["AccountType"].ToString();
  60.  
  61.                 }
  62.             }
  63.  
  64.             if (count == 1)
  65.             {
  66.                 MetroMessageBox.Show(this, "Sucessfully Login", "Sucessful", MessageBoxButtons.OK, 250);
  67.                
  68.        
  69.                 frmContainer frmcont = new frmContainer();
  70.                 frmcont.getsetUserEmail=getUserEmail().ToString();
  71.                 frmcont.getsetUserName = getUserName().ToString();
  72.                 frmcont.getsetAcountType = getAcountType().ToString();
  73.                 frmcont.getsetUserId = getUserId();
  74.                 frmcont.Show();
  75.                   m_dbConnection.Close();
  76.                 this.Hide();
  77.             }
  78.             else if (count > 1)
  79.             {
  80.                 MessageBox.Show("Duplicate Account found.\nSorry to Login");
  81.             }
  82.             else
  83.             {
  84.                 MessageBox.Show("UserName or password not correct");
  85.             }
  86.         }////
  87.  
  88.         public string getUserName()
  89.         {
  90.             return this.username;
  91.         }
  92.         public string getUserEmail()
  93.         {
  94.             return this.useremail;
  95.         }
  96.         public string getAcountType()
  97.         {
  98.             return this.acountType;
  99.         }
  100.         public int getUserId()
  101.         {
  102.             return this.userId;
  103.         }
  104.  
  105.         private void frmLogin_FormClosing(object sender, FormClosingEventArgs e)
  106.         {
  107.             Application.Exit();
  108.         }
  109.     }
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement