Advertisement
Guest User

form1

a guest
Apr 24th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.72 KB | None | 0 0
  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. using System.Data.OleDb;
  11.  
  12. namespace vjezba_baza
  13. {
  14.     public partial class Form1 : Form
  15.     {
  16.         User odabraniUser;
  17.         public Form1()
  18.         {
  19.             InitializeComponent();
  20.         }
  21.         OleDbConnection con = new OleDbConnection("Provider=OraOLEDB.Oracle; OLEDB.NET=True; DATA SOURCE = veza1; PERSIST SECURITY INFO=True;USER ID = MHRANJ; PASSWORD = DfhI51aB461");
  22.         string userid;
  23.         private void LoginBtn_Click(object sender, EventArgs e)
  24.         {
  25.             con.Open();
  26.             if (UsernameText.Text != "")
  27.             {
  28.                
  29.                 string querry = "select * from SHOP_USER";
  30.                 OleDbDataAdapter adapter = new OleDbDataAdapter(querry, con);
  31.                 DataTable dt = new DataTable();
  32.                 adapter.Fill(dt);
  33.                 bool pristupi = false;
  34.                 foreach (DataRow row in dt.Rows)
  35.                 {
  36.                     if (row[1].ToString() == UsernameText.Text)
  37.                     {
  38.                         userid = row[0].ToString();
  39.                         odabraniUser = new User(userid);
  40.                         pristupi = true;
  41.                     }
  42.                 }
  43.                 if (pristupi)
  44.                 {
  45.                     Form2 f2 = new Form2(odabraniUser);
  46.                     f2.Show();
  47.                 }
  48.                 else MessageBox.Show("Invalid username");
  49.             }
  50.             else MessageBox.Show("Input username");
  51.             con.Close();
  52.         }
  53.     }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement