private void buttonLogin_Click(object sender, EventArgs e)
 {
     if (!textBoxLogin.Text.Equals("") || !textBoxPass.Text.Equals(""))
     {
         try
         {
             var result = (from user in data.Users
                           where user.login == textBoxLogin.Text
                           select new { user }).FirstOrDefault();
             if (result == null)
             {
                 labelMsg.Text    = "User not found";
                 labelMsg.Visible = true;
             }
             else if (PasswordHash.checkPassword(textBoxPass.Text, result.user.password))
             {
                 labelMsg.Text    = "Zalogowano !!!";
                 labelMsg.Visible = true;
                 FormMenu formMain = new FormMenu(result.user);
                 formMain.Show();
                 this.Hide();
             }
             else
             {
                 labelMsg.Text    = "Zly login lub haslo !!!";
                 labelMsg.Visible = true;
             }
         }
         catch (System.Data.SqlClient.SqlException ex)
         {
             MessageBox.Show("Connection lost");
             this.Close();
         }
         catch (Exception ex)
         {
             labelMsg.Text    = "Zly login lub haslo !!!";
             labelMsg.Visible = true;
         }
     }
     else
     {
         MessageBox.Show("Enter login and password");
     }
 }
Esempio n. 2
0
        public FormLawReq(FormMenu form)
        {
            InitializeComponent();
            this.formHandler = form;
            data             = new DataClasses1DataContext();

            //ADDING VALUES TO COMBOBOXES
            //JOB CONTRACTS
            Dictionary <string, string> jobContracts = new Dictionary <string, string>();

            jobContracts.Add("11 godzin", "11 godzin dziennego odpoczynku");
            jobContracts.Add("35 godzin", "35 godzin tygodniowego odpoczynku");
            jobContracts.Add("niedziele", "Co czwarta niedziela wolna");
            comboBoxLaws.DataSource    = new BindingSource(jobContracts, null);
            comboBoxLaws.DisplayMember = "Value";
            comboBoxLaws.ValueMember   = "Key";

            lawRequirement = data.LawRequirements.SingleOrDefault(x => x.idRequirements == 1);
            labelLaw.Text  = lawRequirement.reqDesc;
        }