コード例 #1
0
        private void button3_Click(object sender, EventArgs e)
        {
            this.Hide();
            employeeLogin employeeLogin = new employeeLogin();

            employeeLogin.Show();
        }
コード例 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                SqlConnection sqlcon = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=" + "C:\\Users\\" + Environment.UserName + "\\Documents\\hoteldatabase.mdf" + ";Integrated Security=True;Connect Timeout=30");

                string query = "Select * from Login where Username = '******' and Password = '******'";



                SqlDataAdapter sda  = new SqlDataAdapter(query, sqlcon);
                DataTable      dtbl = new DataTable();
                sda.Fill(dtbl);



                if (dtbl.Rows.Count == 1)
                {
                    String searchValue = textBox1.Text;
                    int    rowIndex    = -1;
                    foreach (DataGridViewRow row in dataGridView1.Rows)
                    {
                        if (row.Cells[1].Value.ToString().Equals(searchValue))
                        {
                            rowIndex = row.Index;
                            break;
                        }
                    }


                    string output = dataGridView1.Rows[rowIndex].Cells["Type"].Value.ToString();

                    output = Regex.Replace(output, @"\s", "");



                    if (output == "Admin") //o xrisths einai admin
                    {
                        this.Hide();
                        ownerlogin ownerlogin = new ownerlogin();
                        ownerlogin.Show();
                    }

                    else
                    {
                        // o xristis den einai admin
                        this.Hide();
                        employeeLogin employeeLogin = new employeeLogin();
                        employeeLogin.Show();
                    }
                }

                else
                {
                    MessageBox.Show("Invalid Username or password");
                }
            }
            catch
            {
                MessageBox.Show("Something Went Wrong");
            }
        }