Exemple #1
0
    protected void btnLog_Click(object sender, EventArgs e)
    {
        Users  u         = new Users();
        string user_name = this.txtEmail.Text;

        // sending username and passwrod to verify user
        if (u.userVerification(txtEmail.Text.Trim(), txtPassword.Text.Trim()))
        {
            // get and set user's position to current session
            positionEnum userPosition = u.getUserPosition(txtEmail.Text.Trim());
            if (userPosition == positionEnum.admin)
            {
                this.Session["userid"] = user_name;
                //this.Session["Position"] = "Admin";
                Response.Redirect("Admin_Home.aspx", false);
            }
            else if (userPosition == positionEnum.customer)
            {
                this.Session["userid"] = user_name;
                //this.Session["Position"] = "User";
                Response.Redirect("Home.aspx", false);
            }
            else if (userPosition == positionEnum.manager)
            {
                this.Session["userid"] = user_name;
                //this.Session["Position"] = "User";
                Response.Redirect("Manager_Home.aspx", false);
            }
        }
        else
        {
            lbl1.Text = "Wrong email or password.";
        }
    }
 public ScaleBar()
 {
     this.sizeField = new sizeType();
     this.outlineColorField = new rgbColorType();
     this.labelField = new Label();
     this.imageColorField = new rgbColorType();
     this.colorField = new rgbColorType();
     this.backgroundColorField = new rgbColorType();
     this.intervalsField = "4";
     this.positionField = positionEnum.LR;
     this.postLabelCacheField = booleanEnum.FALSE;
     this.unitsField = unitType.MILES;
     this.statusField = "OFF";
 }
Exemple #3
0
    // Register new user
    public bool registerUser(string email, string fullName, string companyName,
                             string role, string country, string password, positionEnum position)
    {
        try
        {
            // determine wheter the user id has been register by other
            XmlNodeList xNodes = xDoc.SelectNodes("Users/User");
            for (int count = 0; count < xNodes.Count; count++)
            {
                if (email == xNodes.Item(count).Attributes.GetNamedItem("email").Value)
                {
                    return(false); // user id not available.
                }
            }
            XmlNode      rootNode       = xDoc.CreateElement("User");
            XmlAttribute emailAttribute = xDoc.CreateAttribute("email");
            emailAttribute.Value = email;
            rootNode.Attributes.Append(emailAttribute);

            XmlNode fullNameNode = xDoc.CreateElement("fullName");
            fullNameNode.InnerText = fullName;

            XmlNode companyNameNode = xDoc.CreateElement("companyName");
            companyNameNode.InnerText = companyName;

            XmlNode roleNode = xDoc.CreateElement("role");
            roleNode.InnerText = role;

            XmlNode countryNode = xDoc.CreateElement("country");
            countryNode.InnerText = role;

            XmlNode passNode = xDoc.CreateElement("password");
            passNode.InnerText = password;

            XmlNode positionNode = xDoc.CreateElement("position");

            if (position == positionEnum.admin)
            {
                positionNode.InnerText = "admin";
            }
            else if (position == positionEnum.customer)
            {
                positionNode.InnerText = "customer";
            }
            else if (position == positionEnum.manager)
            {
                positionNode.InnerText = "manager";
            }
            else
            {
                positionNode.InnerText = "none";
            }
            rootNode.AppendChild(fullNameNode);
            rootNode.AppendChild(companyNameNode);
            rootNode.AppendChild(roleNode);
            rootNode.AppendChild(countryNode);
            rootNode.AppendChild(passNode);
            rootNode.AppendChild(positionNode);
            xDoc.SelectSingleNode("Users").AppendChild(rootNode);
            return(true);
        }
        catch (Exception)
        {
            return(false);
        }
    }