1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Data.SqlClient;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace WindowsFormsApp1
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- SqlConnection connection = new SqlConnection("Data Source=CLASS3109;Initial Catalog=hotel;Integrated Security=True");
- connection.Open();
-
- SqlCommand Command = new SqlCommand("select * from users where login=@login AND password=@password", connection);
- Command.Parameters.Add("@login" ,textBox1.Text);
- Command.Parameters.Add("@password", textBox2.Text);
- SqlDataReader read = null;
-
- try
- {
-
- read = Command.ExecuteReader();
- if(read.HasRows){
- 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 );
- }
- }
- }
- }
|