Example #1
0
        private void btLogin_Click(object sender, EventArgs e)
        {
            string email = txtEmail.Text;
            string pass  = txtPassword.Text;

            if (string.IsNullOrEmpty(email))
            {
                MessageBox.Show("Please enter your email !", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtEmail.Focus();
                return;
            }
            try
            {
                using (GarageManagementEntities db = new GarageManagementEntities())
                {
                    var query = from n in db.Admins where n.emailAdmin == email && n.password == pass select n;
                    if (query.SingleOrDefault() != null)
                    {
                        MessageBox.Show("Login successfull !!!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        Form2 a = new Form2();
                        a.Show();
                    }
                    else
                    {
                        MessageBox.Show("Your email or password is incorrect.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #2
0
        private void Form2_Load(object sender, EventArgs e)
        {
            GarageManagementEntities db = new GarageManagementEntities();

            dataGridView1.DataSource = db.Admins.ToList();
            for (int i = 0; i <= dataGridView1.Columns.Count - 1; i++)
            {
                //store autosized widths
                int colw = dataGridView1.Columns[i].Width;
                //remove autosizing
                dataGridView1.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
                //set width to calculated by autosize
                dataGridView1.Columns[i].Width = colw;
            }
        }