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.SqlClient;

namespace check
{
    public partial class login : Form
    {
        static SqlConnection con = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\check.mdf;Integrated Security=True");
        SqlDataAdapter da = new SqlDataAdapter();
        DataSet ds = new DataSet();

        public Boolean Result = false;
        public Boolean ch_account;
        public Boolean ch_bank;
        public Boolean ch_ckeck;
        public Boolean ch_ckecklist;
        public Boolean ch_remider;
        public Boolean ch_users;

        public login()
        {
            InitializeComponent();
        }

        private void btn_login_Click(object sender, EventArgs e)
        {
            if (txt_password.Text == cmb_username.SelectedItem.ToString())
            {
                Result = true;
                ch_account = Convert.ToBoolean((cmb_username.SelectedItem)["account"].ToString());
                ch_bank = Convert.ToBoolean((cmb_username.SelectedItem)["bank"].ToString());
                ch_ckeck = Convert.ToBoolean((cmb_username.SelectedItem)["ckeck"].ToString());
                ch_ckecklist = Convert.ToBoolean((cmb_username.SelectedItem)["ckecklist"].ToString());
                ch_remider = Convert.ToBoolean((cmb_username.SelectedItem)["remider"].ToString());
                ch_users = Convert.ToBoolean((cmb_username.SelectedItem)["users"].ToString());
                this.Close();
            }

            else
            {
                MessageBox.Show("رمز عبور وارد شده صحیح نیست");
            }
        }

        private void login_Load(object sender, EventArgs e)
        {
            DataTable dt1 = new DataTable();
            DataBase db1 = new DataBase();
            dt1 = db1.MySelect("select * from users");
            cmb_username.DataSource = dt1;
            cmb_username.DisplayMember = "username";
            cmb_username.ValueMember = "password";
            Font f = new System.Drawing.Font("tahoma",8);
            cmb_username.ListElement.Font = f;

        }

        private void btn_cancel_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }
    }
}
