コード例 #1
0
        //function to handle staff login (Admin and Kitchen) --> Sania Jain
        private void staffLogin_Click(object sender, RoutedEventArgs e)
        {
            ofosDataContext dc = new ofosDataContext();
            ISingleResult <StaffLogin_CheckResult> tab = dc.StaffLogin_Check(UserNameTextBox.Text, passwordTextBox.Text);

            Console.WriteLine(tab);
            foreach (StaffLogin_CheckResult val in tab)
            {
                if (val.Type != null)
                {
                    if (val.Type == "Admin")
                    {
                        //redirect to Admin code flow
                        Admin.FoodItemForm fi = new Admin.FoodItemForm();
                        fi.ShowDialog();
                    }
                    else if (val.Type == "Kitchen")
                    {
                        KitchenStaff.Kitchen ki = new KitchenStaff.Kitchen();
                        ki.ReloadButton.Visibility = Visibility.Hidden;
                        ki.ShowDialog();
                        //redirect to Kitchen code flow
                    }
                }
            }
        }
コード例 #2
0
        //function to handle staff login (Admin and Kitchen) --> Sania Jain
        private void staffLogin_Click(object sender, RoutedEventArgs e)
        {
            ofosDataContext dc = new ofosDataContext();
            //fetching all values from staffLogin table
            ISingleResult <StaffLogin_CheckResult> tab = dc.StaffLogin_Check(UserNameTextBox.Text, passwordTextBox.Password);

            Console.WriteLine(tab);
            var lst = tab.ToList();

            //check if the db has no record of staff show error of incorrect credentials.
            if (lst.Count == 0)
            {
                staffLoginError.Content = "Incorrect Credentials";
            }
            else
            {
                staffLoginError.Content = "";
                foreach (var val in lst)
                {
                    //check the type of staff - Kitchen or Admin
                    if (val.Type != null)
                    {
                        if (val.Type == "Admin")
                        {
                            //redirect to Admin code flow
                            Admin.FoodItemForm fi = new Admin.FoodItemForm();
                            fi.ShowDialog();
                        }
                        else if (val.Type == "Kitchen")
                        {
                            //redirect to Kitchen code flow
                            KitchenStaff.Kitchen ki = new KitchenStaff.Kitchen();
                            ki.ReloadButton.Visibility = Visibility.Hidden;
                            ki.ShowDialog();
                        }
                    }
                }
            }
        }