123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Data.SqlClient;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace ad
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- SqlConnection connection = new SqlConnection("Data Source=CLASS3108;Initial Catalog=konkurstest;Integrated Security=True");
- SqlCommand command = new SqlCommand("SELECT * FROM users WHERE password=@password AND login =@login ", connection);
- command.Parameters.Add("@password", textBox1.Text);
- command.Parameters.Add("@login", textBox2.Text);
- SqlDataReader read = null;
- connection.Open();
- try
- {
- read = command.ExecuteReader();
- read.Read();
-
- if (read["admin"].ToString() == "1")
- {
- Form2 f2 = new Form2();
- f2.Show();
- this.Hide();
- }
- if (read["manager"].ToString() == "1")
- {
- Form3 f3 = new Form3();
- f3.Show();
- this.Hide();
- }
- }
- catch(Exception ex)
- {
- MessageBox.Show(ex.Message.ToString(), "",MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- }
- }
|