protected void btn_AddUsers_Click(object sender, EventArgs e)
        {
            var userIdTxt = userid.Text.Trim();

            if (!password.Text.Trim().Equals(string.Empty) && !userIdTxt.Equals(string.Empty))
            {
                if (new TPSDataHandling().IsUserExists(userIdTxt))
                {
                    lblMessage.Text = "UserId(" + userIdTxt + ") already exists.";
                    return;
                }

                bool Done = new TPSDataHandling().addUser(userIdTxt, password.Text, DropDownList_Level.SelectedValue);
                if (Done)
                {
                    if (DropDownList_Level.SelectedValue.Equals("S"))
                    {
                        userDatabase.addStaff(userIdTxt, "", "", "", "", "", "", "", "");
                    }

                    lblMessage.Text = "User(" + userIdTxt + ") was successfully added!";
                    ds = userDatabase.grabDataSet("SELECT * FROM [login]");
                    user_grid.DataSource = ds;
                    user_grid.DataBind();
                }
                else
                {
                    lblMessage.Text = "The user could not be added!";
                }
            }
            else
            {
                lblMessage.Text = "Please enter valid userName and password!";
            }
        }
        protected void btn_Update_Click(object sender, EventArgs e)
        {
            var tps       = new TPSDataHandling();
            var userIdTxt = userid.Text.Trim();

            if (!userIdTxt.Equals(string.Empty))
            {
                if (!new TPSDataHandling().IsUserExists(userIdTxt))
                {
                    lblMessage.Text = "Update :: UserId(" + userIdTxt + ") not found.";
                    return;
                }

                if (tps.updateUser(userIdTxt, password.Text, DropDownList_Level.SelectedValue))
                {
                    lblMessage.Text = "UserId(" + userIdTxt + ") successfully updated.";
                    ds = userDatabase.grabDataSet("SELECT * FROM [login]");
                    user_grid.DataSource = ds;
                    user_grid.DataBind();
                }
                else
                {
                    lblMessage.Text = "Failed to update UserId(" + userIdTxt + ").";
                }
            }
            else
            {
                lblMessage.Text = "Invalid UserId.";
            }
        }
        protected void btnDeleteUser_Click(object sender, EventArgs e)
        {
            var tps = new TPSDataHandling();

            if (!userid.Text.Trim().Equals(string.Empty))
            {
                var userIdTxt = userid.Text.Trim();
                if (tps.deleteUser(userIdTxt))
                {
                    if (DropDownList_Level.SelectedValue.Equals("S"))
                    {
                        tps.deleteStaff(userIdTxt);
                    }

                    lblMessage.Text = "UserId(" + userIdTxt + ") was successfully deleted.";
                    ds = userDatabase.grabDataSet("SELECT * FROM [login]");
                    user_grid.DataSource = ds;
                    user_grid.DataBind();
                }
            }
            else
            {
                lblMessage.Text = "Invalid UserId.";
            }
            userid.Text   = "";
            password.Text = "";
        }
        // Handles when the pages loads
        protected void Page_Load(object sender, EventArgs e)
        {
            // Security Check
            if (Session["SecurityLevel"].ToString() == "S")
            {
                Server.Transfer("index.aspx", true);
            }
            else if (Session["SecurityLevel"].ToString() == "M" || Session["SecurityLevel"].ToString() == "C")
            {
                // Do nothing
            }
            else
            {
                Server.Transfer("login.aspx", true);
            }

            // Grab a dataset
            tpsData = new TPSDataHandling();
            ds      = tpsData.grabDataSet("SELECT staff.[userid] AS [ID], [full_name] AS [Name], [experience] AS [Experience (Years)], [degree] AS [Degree], [salary] AS [Salary], [city] AS [City], [state] AS [State] FROM staff, login WHERE login.[userid] = staff.[userid] AND [security] = 'S'");
            // Check for postback data in case of changes
            if (!Page.IsPostBack)
            {
                Session["DataView"]   = new DataView(ds.Tables[0]);
                staff_grid.DataSource = ds;
                Session["Staff"]      = "";
            }
            else
            {
                selectedStaff         = Session["Staff"].ToString();
                staff_grid.DataSource = (DataView)Session["DataView"];
            }

            // Bind data
            staff_grid.DataBind();
        }
        // Method for when page loads
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["SecurityLevel"].ToString() == "C")
            {
                Server.Transfer("index.aspx", true);
            }
            else if (Session["SecurityLevel"].ToString() == "S" || Session["SecurityLevel"].ToString() == "M")
            {
                // Do nothing
            }
            else
            {
                Server.Transfer("login.aspx", true);
            }

            tpsDataHandling = new TPSDataHandling();

            if (!IsPostBack)
            {
                myDict = tpsDataHandling.getStaff(Session["UserID"].ToString());

                txtName.Text = myDict["full_name"];

                if (ddlDegree.Items.Contains(new ListItem(myDict["degree"])))
                {
                    ddlDegree.SelectedValue = myDict["degree"];
                }


                txtExperience.Text = myDict["experience"];
                txtSalary.Text     = myDict["salary"];
                txtStreet.Text     = myDict["street"];
                txtCity.Text       = myDict["city"];
                txtState.Text      = myDict["state"];
                txtZipcode.Text    = myDict["zipcode"];
            }

            string[] dirs = Directory.GetFiles(Server.MapPath("Pictures") + "\\");
            foreach (string dir in dirs)
            {
                if (dir.Contains(Session["UserID"].ToString()))
                {
                    imgProfile.ImageUrl = "~/Pictures/" + Session["UserID"].ToString() + "." + Path.GetExtension(dir).Substring(1);
                    imgProfile.Visible  = true;
                }
            }

            dirs = Directory.GetFiles(Server.MapPath("Resume") + "\\");
            foreach (string dir in dirs)
            {
                if (dir.Contains(Session["UserID"].ToString()))
                {
                    lbResume.Visible = true;
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["SecurityLevel"].ToString() == "M")
            {
                //Do nothing
            }
            else if (Session["SecurityLevel"].ToString() == "S" || Session["SecurityLevel"].ToString() == "C")
            {
                Server.Transfer("index.aspx", true);
            }
            else
            {
                Server.Transfer("login.aspx", true);
            }

            userDatabase = new TPSDataHandling();

            ds = userDatabase.grabDataSet("SELECT * FROM login");
            user_grid.DataSource = ds;
            user_grid.DataBind();
        }
Beispiel #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["SecurityLevel"].ToString() == "M")
            {
                // Do nothing
            }
            else if (Session["SecurityLevel"].ToString() == "S" || Session["SecurityLevel"].ToString() == "C")
            {
                Server.Transfer("index.aspx", true);
            }
            else
            {
                Server.Transfer("login.aspx", true);
            }

            tpsData = new TPSDataHandling();
            ds      = tpsData.grabDataSet("SELECT * FROM requests");
            if (!IsPostBack)
            {
                staff_grid.DataSource = ds;
                staff_grid.DataBind();
                selectedValue = "";
            }
        }
Beispiel #8
0
 protected void Page_Load(object sender, EventArgs e)
 {
     useDatabase              = new TPSDataHandling();
     Session["UserID"]        = "";
     Session["SecurityLevel"] = "";
 }