12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- 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();
- }
-
- }
- }
- catch(Exception ex)
- {
- MessageBox.Show(ex.Message.ToString(),"", MessageBoxButtons.OK, MessageBoxIcon.Error );
- }
- }
- }
- }
|