using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;

namespace car
{
    public partial class log_in : Form
    {
        public log_in()
        {
            InitializeComponent();
        }

        static OleDbConnection con = new OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=cardb.mdb;jet oledb:Database Password=☺☻♥♦♣♠");
        OleDbDataAdapter da = new OleDbDataAdapter("", con);
        DataSet ds = new DataSet();

        private void buttonX1_Click_1(object sender, EventArgs e)
        {
            string type;
            if (comboBoxEx1.SelectedIndex == 0) type = "admin";
            else type = "user";
            string s = "select id from login where type='" + type + "'and users='" + textBoxX1.Text + "' and id='" + textBoxX2.Text + "' ";
            OleDbDataAdapter da = new OleDbDataAdapter(s, con);
            da.Fill(ds, "t1");
            if (ds.Tables["t1"].Rows.Count > 0)
            {
                if (comboBoxEx1.SelectedIndex == 0)
                    variable.i = 1;
                else
                    variable.i = 2;

                this.Hide();
                menu fm = new menu();
                fm.ShowDialog();

            }
            else
            {
                MessageBox.Show("رمز عبور یا نام کاربری اشتباه می باشد", "اخطار");
            }
        }

        private void buttonX2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void textBoxX1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
                buttonX1_Click_1(sender, e);
        }

        private void textBoxX2_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
                buttonX1_Click_1(sender, e);
        }

        private void comboBoxEx1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
                buttonX1_Click_1(sender, e);
        }
    }
}
