예제 #1
0
        private void LoadMenu()
        {
            // player.Play();//music

            switch (Utility.User.Permission)
            {
            case "Student":
                Student.Menu Student_Connect = new Student.Menu();
                Student_Connect.Student_Name.Text = "      " + Utility.User.F_name + " " + Utility.User.L_name;
                Student_Connect.ShowDialog();
                break;

            case "Exam_Section":
                Exams_Section.Menu Exam_Connect = new Exams_Section.Menu();
                Exam_Connect.Student_Name.Text = "      " + Utility.User.F_name + " " + Utility.User.L_name;
                Exam_Connect.ShowDialog();
                break;

            case "Tech_Team":
                Tech_Team.Menu Tech_Connect = new Tech_Team.Menu();
                Tech_Connect.Student_Name.Text = "      " + Utility.User.F_name + " " + Utility.User.L_name;
                Tech_Connect.ShowDialog();
                break;

            case "Dean_of_Faculty":
                Dean_of_Faculty.Menu Dean_Connect = new Dean_of_Faculty.Menu();
                Dean_Connect.Student_Name.Text = "      " + Utility.User.F_name + " " + Utility.User.L_name;
                Dean_Connect.ShowDialog();
                break;

            case "Admin":
                Admin.Menu Connect = new Admin.Menu();
                Connect.Admin_name.Text = "      " + Utility.User.F_name + " " + Utility.User.L_name;
                Connect.ShowDialog();
                break;

            case "Lecturer":
                Lecturer.Menu Connect1 = new Lecturer.Menu();
                Connect1.Lecturer_Name.Text = "      " + Utility.User.F_name + " " + Utility.User.L_name;
                Connect1.ShowDialog();
                break;

            case "Teaching_Assistant":
                Teaching_Assistant.Menu Connect2 = new Teaching_Assistant.Menu();
                Connect2.Teaching_Assistant_Name.Text = "      " + Utility.User.F_name + " " + Utility.User.L_name;
                Connect2.ShowDialog();
                break;

            case "Secretary":
                Secretary.Menu Connect3 = new Secretary.Menu();
                Connect3.Secretary_Name.Text = "      " + Utility.User.F_name + " " + Utility.User.L_name;
                Connect3.ShowDialog();
                break;

            default:
                Console.WriteLine("Wrong User Permission - Check your Database");
                break;
            }
        }
예제 #2
0
        private void DisplayAppropriateMessage(FacebookOAuthResult facebookOAuthResult)
        {
            if (facebookOAuthResult != null)
            {
                if (facebookOAuthResult.IsSuccess)
                {
                    _accessToken = facebookOAuthResult.AccessToken;
                    var fb = new FacebookClient(facebookOAuthResult.AccessToken);

                    var     result        = fb.Get("me", new { fields = new[] { "first_name", "last_name", "name", "gender", "id", "age_range" } });
                    var     cl            = fb;
                    dynamic result1       = fb.Get("me?fields=id,name,email");
                    string  _currentEmail = result1.email;
                    //NewUser.EmaillF=_currentEmail;
                    // MessageBox.Show(_currentEmail);
                    // MessageBox.Show(result1.name);
                    // MessageBox.Show(result1.id);
                    // SqlConnection sqlcon=null;
                    // General.ConnectToSql(sqlcon);
                    string        connetionString = "Data Source = whitesnow.database.windows.net; Initial Catalog = Mazal; Integrated Security = False; User ID = Grimm; Password = #!7Dwarfs; Connect Timeout = 15; Encrypt = False; TrustServerCertificate = True; ApplicationIntent = ReadWrite; MultiSubnetFailover = False";
                    SqlConnection sqlcon          = new SqlConnection(connetionString);
                    sqlcon.Open();
                    SqlCommand    cmd = new SqlCommand("select * from person where Email='" + _currentEmail + "'", sqlcon);
                    SqlDataReader dr  = cmd.ExecuteReader();
                    if (dr.Read() == true)
                    {
                        string ID = string.Copy(dr[0].ToString());
                        using (Entities context = new Entities())
                        {
                            if (context.Person.Any(p => p.ID == ID))
                            {
                                Utility.User = context.Person.SingleOrDefault(p => p.ID == ID);
                            }

                            switch (Utility.User.Permission)
                            {
                            case "Student":
                                PRPJECT4NEW.Student.Menu Student_Connect = new PRPJECT4NEW.Student.Menu();
                                Student_Connect.Student_Name.Text = "      " + Utility.User.F_name + " " + Utility.User.L_name;
                                Student_Connect.ShowDialog();
                                break;

                            case "Exam_Section":
                                PRPJECT4NEW.Exams_Section.Menu Exam_Connect = new PRPJECT4NEW.Exams_Section.Menu();
                                Exam_Connect.Student_Name.Text = "      " + Utility.User.F_name + " " + Utility.User.L_name;
                                Exam_Connect.ShowDialog();
                                break;

                            case "Tech_Team":
                                PRPJECT4NEW.Tech_Team.Menu Tech_Connect = new PRPJECT4NEW.Tech_Team.Menu();
                                Tech_Connect.Student_Name.Text = "      " + Utility.User.F_name + " " + Utility.User.L_name;
                                Tech_Connect.ShowDialog();
                                break;

                            case "Dean_of_Faculty":
                                PRPJECT4NEW.Dean_of_Faculty.Menu Dean_Connect = new PRPJECT4NEW.Dean_of_Faculty.Menu();
                                Dean_Connect.Student_Name.Text = "      " + Utility.User.F_name + " " + Utility.User.L_name;
                                Dean_Connect.ShowDialog();
                                break;

                            case "Admin":
                                PRPJECT4NEW.Admin.Menu Connect = new PRPJECT4NEW.Admin.Menu();
                                Connect.Admin_name.Text = "      " + Utility.User.F_name + " " + Utility.User.L_name;
                                Connect.ShowDialog();
                                break;

                            case "Lecturer":
                                PRPJECT4NEW.Lecturer.Menu Connect1 = new PRPJECT4NEW.Lecturer.Menu();
                                Connect1.Lecturer_Name.Text = "      " + Utility.User.F_name + " " + Utility.User.L_name;
                                Connect1.ShowDialog();
                                break;

                            case "Teaching_Assistant":
                                PRPJECT4NEW.Teaching_Assistant.Menu Connect2 = new PRPJECT4NEW.Teaching_Assistant.Menu();
                                Connect2.Teaching_Assistant_Name.Text = "      " + Utility.User.F_name + " " + Utility.User.L_name;
                                Connect2.ShowDialog();
                                break;

                            case "Secretary":
                                PRPJECT4NEW.Secretary.Menu Connect3 = new PRPJECT4NEW.Secretary.Menu();
                                Connect3.Secretary_Name.Text = "      " + Utility.User.F_name + " " + Utility.User.L_name;
                                Connect3.ShowDialog();
                                break;

                            default:
                                Console.WriteLine("Wrong User Permission - Check your Database");
                                break;
                            }
                        }

                        var    dict   = Json.Deserialize(result.ToString()) as Dictionary <string, object>;
                        string id     = dict["id"].ToString();
                        string name   = dict["name"].ToString();
                        string Lname  = dict["first_name"].ToString();
                        string Fname  = dict["last_name"].ToString();
                        string gender = dict["gender"].ToString();


                        btnLogout.Visible = true;
                    }
                    else
                    {
                        MessageBox.Show("You are not in the system!");

                        // MessageBox.Show(facebookOAuthResult.ErrorDescription);
                    }
                    this.btnLogoutClick();
                }
            }
        }