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!";
            }
        }
        // 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();
        }
        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();
        }
예제 #4
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 = "";
            }
        }