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

using System.Text.RegularExpressions;
using System.IO;
using System.Globalization;


using System.Runtime.Serialization.Formatters.Binary;
using System.Collections;

using System.Data.SqlClient;
namespace amlakyar
{
    public partial class Login : Form
    {

        static SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\amlak.mdf;integrated security=true;User Instance=True");
        SqlDataAdapter da = new SqlDataAdapter("", con);
        DataSet ds = new DataSet();
        string stru;
        //*************************************************CLASS VARIABLES        
        
       
        //*************************************************CLASS VARIABLES

        public Login()
        {
            InitializeComponent();
        }

        

        private void Form1_Load(object sender, EventArgs e)
        {
            
                timer1.Enabled = true;
                System.Globalization.PersianCalendar pc = new System.Globalization.PersianCalendar();
                DateTime dt = new DateTime();
                dt = DateTime.Now;
                Class_date cdate = new Class_date();
                string date = dt.Year.ToString() + "/" + dt.Month.ToString() + "/" + dt.Day.ToString();

                lb_date.Text = cdate.Shamsi(date);
        }

        private void ChangeLanguageToFarsi()
        {
            try
            {
                CultureInfo farsi = new CultureInfo("fa-IR");
                InputLanguage.CurrentInputLanguage = InputLanguage.FromCulture(farsi);
            }
            catch
            {
            }
        }
    

        private void timer1_Tick(object sender, EventArgs e)
        {
            timer1.Enabled = true;
            System.Globalization.PersianCalendar pcc = new System.Globalization.PersianCalendar();
            DateTime tm = new DateTime();
            tm = DateTime.Now;
           lb_time.Text = pcc.GetHour(tm).ToString() + ":" + pcc.GetMinute(tm).ToString() + ":" + pcc.GetSecond(tm).ToString();


        }

        private void glassButton1_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void glassButton2_Click(object sender, EventArgs e)
        {
            string struser, s;
            if (cmbtype.SelectedItem == "مدیر")
                
            {
                struser = "admin";
                cls_variable.stru = "مدیر املاک";
            }
            else
            {
                cls_variable.stru = "کاربر عادی";
                struser = "user";
            }
            s = "select id from login where type='" + struser + "'and users='" + txtuser.Text + "' and id='" + txtid.Text + "' ";
            SqlDataAdapter da = new SqlDataAdapter(s, con);
            da.Fill(ds, "t1");
            if (ds.Tables["t1"].Rows.Count > 0)
            {
                this.Hide();
                main fm = new main();
                fm.ShowDialog();

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