コード例 #1
0
ファイル: Login.aspx.cs プロジェクト: ctmartinez1992/Grafo
 protected void Log_Click(object sender, EventArgs e)
 {
     try
     {
         TM_TDG.WithDataSets.BLL.Utilizadores utilizadoresbll = new TM_TDG.WithDataSets.BLL.Utilizadores();
         DataTable dtutilizadores = utilizadoresbll.Autenticar(username.Text, password.Text);
         if (dtutilizadores.Rows.Count != 0)
         {
             foreach (DataRow dbRow in dtutilizadores.Rows)
             {
                 // User info
                 Session["user"]     = dbRow["username"];
                 Session["name"]     = dbRow["name"];
                 Session["id"]       = dbRow["id"];
                 Session["email"]    = dbRow["email"];
                 Session["state"]    = dbRow["state"];
                 Session["dt_birth"] = dbRow["dt_birth"];
                 Session["phone"]    = dbRow["phone"];
                 Response.Redirect("~/Member/Main.aspx");
             }
         }
         else
         {
             Label5.Text = "Login Errado";
         }
     }
     catch (Exception)
     {
         Label5.Text = "Erro ao tentar autenticar";
     }
 }
コード例 #2
0
        protected void Registar_Click(object sender, EventArgs e)
        {
            TM_TDG.WithDataSets.BLL.Utilizadores user = new TM_TDG.WithDataSets.BLL.Utilizadores();
            int      d     = Convert.ToInt32(Birth.Text.Split('-')[0]);
            int      m     = Convert.ToInt32(Birth.Text.Split('-')[1]);
            int      y     = Convert.ToInt32(Birth.Text.Split('-')[2]);
            DateTime birth = new DateTime(y, m, d);

            if (user.INSERT_Utilizador(Nome.Text, Username.Text, Password.Text, birth, Phone.Text, Email.Text) == 0)
            {
                Label5.Text = "Username unavailable";
            }
            else
            {
                Label5.Text = "Registration successful... redirecting...";
                Response.AddHeader("REFRESH", "10;URL=Default.aspx");
            }
        }