Exemplo n.º 1
0
        public static FacultyUser facultyLogin(string facultyName, string facultyPwd)
        {
            FacultyUser   f            = new FacultyUser();
            SqlConnection myConnection = new SqlConnection(Properties.Settings.Default.PeachTreeConnectionString);
            SqlDataReader myReader     = null;
            string        queryStr     = "SELECT * FROM PTA_Faculty WHERE FacultyName = @paramFName AND FacultyPword = @paramFPwd";
            SqlCommand    cmd          = new SqlCommand(queryStr, myConnection);

            cmd.Parameters.AddWithValue("@paramFName", facultyName);
            cmd.Parameters.AddWithValue("@paramFPwd", facultyPwd);
            try
            {
                myConnection.Open();
                myReader = cmd.ExecuteReader();
                while (myReader.Read())
                {
                    int facultyID = int.Parse(myReader["PTA_ID_Faculty"].ToString());
                    f = new FacultyUser(facultyID, facultyName);
                    return(f);
                }
                return(null);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                return(null);
            }
            finally
            {
                myConnection.Close();
            }
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["UserSession"] != null)
            {
                s = (SiteUser)Session["UserSession"];
                if (s.UserType1 == "Marketing Manager")
                {
                    lblMarketingManager.Visible       = true;
                    lblNoComment.Visible              = true;
                    lblNoComment14Days.Visible        = true;
                    lblNoCommentsResult.Visible       = true;
                    lblNoComments14DaysResult.Visible = true;
                    lblNoCommentsResult.Text          = DBConnection.report_getContributionsNoResponse();
                    lblNoComments14DaysResult.Text    = DBConnection.report_getContributionsNoResponse14Days();
                }
                facultyID = s.FacultyID;
            }
            else if (Session["FacultySession"] != null)
            {
                f         = (FacultyUser)Session["FacultySession"];
                facultyID = f.FacultyID1;
            }
            else
            {
                Session.Clear();
                Response.Redirect("~/UI/Default.aspx");
            }
            competitions = DBConnection.getCompetitons();

            if (!IsPostBack)
            {
                ddlComps.Items.Clear();
                foreach (Competition c in competitions)
                {
                    ddlComps.Items.Add(c.Name);
                }
                ddlComps.SelectedIndex = 0;
            }
        }
Exemplo n.º 3
0
 protected void btnFacultySignIn_Click(object sender, EventArgs e)
 {
     try
     {
         string      facultyName = ddlFaculty.SelectedItem.ToString();
         string      facultyPwd  = txtFacultyPwd.Text;
         FacultyUser f           = DBConnection.facultyLogin(facultyName, facultyPwd);
         if (f != null)
         {
             Session["FacultySession"] = f;
             Response.Redirect("~/UI/Home.aspx");
         }
         else
         {
             lblFacultyLoginErr.Text = "Error logging in.";
         }
     }
     catch (Exception)
     {
         lblFacultyLoginErr.Text = "Error logging in.";
     }
 }
Exemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["UserSession"] != null)
            {
                s = (SiteUser)Session["UserSession"];
                switch (s.UserType1)
                {
                // Student
                case "Student":
                    s = new Student(s.UserID1, s.GivenName1, s.Surname1, s.UserType1, s.Email1, s.Password1, s.MobileNumber1, s.GenderID, s.FacultyID, s.LastLogin);
                    break;

                // Marketing Coordinator
                case "Marketing Coordinator":
                    s = new MarketingCoordinator(s.UserID1, s.GivenName1, s.Surname1, s.UserType1, s.Email1, s.Password1, s.MobileNumber1, s.GenderID, s.FacultyID, s.LastLogin);
                    break;

                // Marketing Manager
                case "Marketing Manager":
                    s = new MarketingManager(s.UserID1, s.GivenName1, s.Surname1, s.UserType1, s.Email1, s.Password1, s.MobileNumber1, s.GenderID, s.FacultyID, s.LastLogin);
                    break;

                // Administrator
                case "Administrator":
                    s = new Administrator(s.UserID1, s.GivenName1, s.Surname1, s.UserType1, s.Email1, s.Password1, s.MobileNumber1, s.GenderID, s.FacultyID, s.LastLogin);
                    break;

                default:
                    Session.Clear();
                    Response.Redirect("~/UI/Default.aspx");
                    break;
                }
                setupPageForUser(s);
                lblWelcome.Text = "Welcome, " + s.GivenName1 + "!";
                if (vowels.Contains(s.UserType1[0].ToString()))
                {
                    lblUserType.Text = "You are logged in as an " + s.UserType1;
                }
                else
                {
                    lblUserType.Text = "You are logged in as a " + s.UserType1;
                }
                if (s.LastLogin != DateTime.MinValue)
                {
                    lblLastLogin.Text = "Last logged in: " + s.LastLogin;
                }
            }
            else if (Session["FacultySession"] != null)
            {
                f = (FacultyUser)Session["FacultySession"];
                lblWelcome.Text = "Welcome, " + f.FacultyName1 + " guest!";
                setupPageForFacultyGuest();
            }
            else if (Session["GuestSession"] != null)
            {
                lblWelcome.Text = "Welcome, Guest!";
                setupPageForGuest();
            }
            else
            {
                Session.Clear();
                Response.Redirect("~/UI/Default.aspx");
            }
        }