Exemple #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["registersuccess"] != null)
            {
                Response.Write("<script>alert('register successfull');</script");
            }

            if (Request.QueryString["login"] != null)
            {
                String email       = Request.Form["email"];
                String password    = Request.Form["password"];
                bool   loginResult = new helper().Login(email, password);
                if (loginResult == true)
                {
                    String userRole = Session["UserRole"].ToString();
                    if (userRole.Equals("Customer"))
                    {
                        Response.Redirect("Cust_Home.aspx");
                    }
                    if (userRole.Equals("Staff"))
                    {
                        Response.Redirect("Staff_Home.aspx");
                    }
                }
                else
                {
                    Response.Write("<script>alert('Login failed, incorrect username or password');</script");
                }
            }
        }
Exemple #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["register"] != null)
            {
                String email          = Request.Form["email"];
                String password       = Request.Form["password"];
                String userRole       = "Customer";
                String name           = Request.Form["name"];
                String companyname    = Request.Form["comname"];
                String contact        = Request.Form["contact"];
                String personincharge = Request.Form["pic"];
                bool   isEmailExist   = new helper().isEmailExists(email);

                if (!isEmailExist)
                {
                    String query    = "INSERT INTO Users (Email, Password, UserRole) OUTPUT INSERTED.UID VALUES ('" + email + "','" + password + "','" + userRole + "')";
                    int    custid   = helper.registerQuery(query);
                    String regquery = $"INSERT INTO Customers(CID, Name, Company_Name, Contact, Per_I_C, Email) VALUES ({custid},'{name}','{companyname}','{contact}','{personincharge}','{email}')";
                    helper.executeQuery(regquery);
                    Response.Redirect("Login.aspx?registersuccess=true");
                }
                else
                {
                    Response.Write("<script>alert('Email already exists!');</script");
                }
            }
        }
Exemple #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["forpass"] != null)
            {
                string email = Request.Form["email"];

                bool checkemail = new helper().isEmailExists(email);
                if (checkemail)
                {
                    string      password = helper.getPassword(email);
                    MailMessage mm       = new MailMessage("*****@*****.**", email);
                    mm.Subject    = "Password Recovery";
                    mm.Body       = string.Format("Hi {0},<br /><br />Your password is {1}.<br /><br />Thank You.", email, password);
                    mm.IsBodyHtml = true;
                    SmtpClient smtp = new SmtpClient();
                    smtp.Host      = "smtp.gmail.com";
                    smtp.EnableSsl = true;
                    NetworkCredential NetworkCred = new NetworkCredential();
                    NetworkCred.UserName       = "******";
                    NetworkCred.Password       = "******";
                    smtp.UseDefaultCredentials = true;
                    smtp.Credentials           = NetworkCred;
                    smtp.Port = 587;
                    smtp.Send(mm);
                    Response.Write("<script>alert('email sent')</script>");
                }
                else
                {
                    Response.Write("<script>alert('email not exists in the system')</script>");
                }
            }
        }