protected void btnAccess_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         string opass = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(txtCpass.Text, "SHA1");
         var oldpass = new ServiceReference1.Service1Client().Get_User_By_UserName_v2(Session["username"].ToString()).Password;
         if (opass != oldpass)
         {
             ScriptManager.RegisterStartupScript(this, GetType(), "Thông báo", "alert('Current Password is incorrect !!!');", true);
         }
         else
         {
             ServiceReference1.User user = new ServiceReference1.User();
             user.Username = Session["username"].ToString();
             string pass = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(txtNpass.Text, "SHA1");
             user.Password = pass;
             ServiceReference1.Service1Client sr = new ServiceReference1.Service1Client();
             if (sr.Update_Password(user) == 1)
             {
                 ScriptManager.RegisterStartupScript(this, GetType(), "Thông báo", "alert('Change successed !!!');", true);
                 Binding_data();
             }
             else
             {
                 ScriptManager.RegisterStartupScript(this, GetType(), "Thông báo", "alert('Error: Try again !!!');", true);
             }
         }
     }        
 }
 protected void btnlogin_Click(object sender, EventArgs e)
 {
     var user = new ServiceReference1.Service1Client().Get_User_By_UserName_v2(txtusername.Text);
     if (user != null && txtmail.Text == user.Email)
     {
         try
         {
             new CheckValidate.CheckDataValidate().send_Mail(user.Username, user.Email, "Message from ONLINE RAILWAY RESERVATION SYSTEM", "<h2 style='color:#0091d4; text-align:center'>ONLINE RAILWAY RESERVATION SYSTEM</h2><br/> " + "<h3 style='text-align:center; font-weight:bold'>YOUR NEW PASSWORD</h3><br/><br/>" + "Username: "******"<br/>" + "Password: "******"SHA1"); // encrypt password
             ServiceReference1.User u = new ServiceReference1.User();
             u.Username = user.Username;
             u.Password = pass;
             if(new ServiceReference1.Service1Client().Update_Password(u) == 1){
                 lblkq.Text = "Check mail to receive new password";
             }
         }
         catch (Exception)
         {
             ScriptManager.RegisterStartupScript(this, GetType(), "Thông báo", "alert('Can not send mail !!!');", true);
         }
     }
     else
     {
         lblkq.Text = "Username or email are incorrect";
     }
 }
Exemplo n.º 3
0
        public void AddUser(User user)
        {
            try
            {
                User usr = new User(user.FirstName, user.LastName, user.Email, user.Login, user.Password);
                ServiceReference1.User usr1 = new ServiceReference1.User();

                usr1.Name     = usr.FirstName;
                usr1.Surname  = usr.LastName;
                usr1.Email    = usr.Email;
                usr1.Login    = usr.Login;
                usr1.Password = EncodePasswordToBase64(usr.Password);

                sr.AddUser(usr1);
            }
            catch (Exception ex)
            {
                Console.Write(ex);
            }
        }
Exemplo n.º 4
0
 private void InitLogin()
 {
     ServiceReference1.CoreServiceClient proxy = new ServiceReference1.CoreServiceClient();
     ServiceReference1.User _user = new ServiceReference1.User();
     try
     {
         if (_user.Fullname == "failed")
         {
             MessageBox.Show("Login Failed");
         }
         else
         {
             _user = proxy.VerifyLogin("leon", "passwrd");
             MessageBox.Show("USER="******":"+_user.Fullname);
     }
 }
Exemplo n.º 5
0
 private void InitLogin()
 {
     ServiceReference1.CoreServiceClient proxy = new ServiceReference1.CoreServiceClient();
     ServiceReference1.User _user = new ServiceReference1.User();
     try
     {
         if (_user.Fullname == "failed")
         {
             MessageBox.Show("Login Failed");
         }
         else
         {
             _user = proxy.VerifyLogin("leon", "passwrd");
             MessageBox.Show("USER="******":"+_user.Fullname);
     }
 }
 protected void btnSave_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         ServiceReference1.User user = new ServiceReference1.User();
         user.Username = Session["username"].ToString();
         user.Email = txtEmail.Text;
         user.Phone_Number = txtPhone.Text;
         user.Gender = ddlGender.SelectedItem.Text;
         ServiceReference1.Service1Client sr = new ServiceReference1.Service1Client();
         if (sr.Update_Info(user) == 1)
         {
             ScriptManager.RegisterStartupScript(this, GetType(), "Thông báo", "alert('Successed !!!');", true);
             Binding_data();
         }
         else
         {
             ScriptManager.RegisterStartupScript(this, GetType(), "Thông báo", "alert('Error: Try again !!!');", true);
         }
     }
 }
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            ServiceReference1.User user = new ServiceReference1.User();
            user.Username = username;
            user.Email = txtEmail.Text;
            user.Phone_Number = txtPhone.Text;
            user.Gender = Checking_Gender();
            user.Role_ID = int.Parse(ddlUserType.SelectedValue);
            user.Password = pass;
            user.Security_Code = security_code;

            if (new ServiceReference1.Service1Client().Update_Users(user) == 1)
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "Thông báo", "alert('Update user successed !!!');", true);
                BindingData_Table();
                Reset();
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "Thông báo", "alert('Update coach failed !!!');", true);
            }
        }
    }
 protected void btnAdd_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         ServiceReference1.User user = new ServiceReference1.User();
         user.Username = txtUsername.Text;
         user.Email = txtEmail.Text;
         user.Phone_Number = txtPhone.Text;
         user.Gender = Checking_Gender();
         user.Role_ID = int.Parse(ddlUserType.SelectedValue);
         string pass_tusinh = RandomString();
         string pass = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(pass_tusinh, "SHA1"); // encrypt password
         user.Password = pass;
         user.Security_Code = pass;
         if (Check_username(user.Username) == false)
         {
             ScriptManager.RegisterStartupScript(this, GetType(), "Thông báo", "alert('Username already exist !!!');", true);
         }
         else
         {
             if (new ServiceReference1.Service1Client().Add_Users(user) == 1)
             {
                 ScriptManager.RegisterStartupScript(this, GetType(), "Thông báo", "alert('Add user successed !!!');", true);
                 BindingData_Table();
                 try
                 {
                     //clsEmail _cls = new clsEmail();
                     new CheckValidate.CheckDataValidate().send_Mail(user.Username,txtEmail.Text.Trim(),"Message from ONLINE RAILWAY RESERVATION SYSTEM","<h2 style='color:#0091d4; text-align:center'>ONLINE RAILWAY RESERVATION SYSTEM</h2><br/> " + "<h3 style='text-align:center; font-weight:bold'>YOUR ACCOUNT</h3><br/><br/>" + "Username: "******"<br/>" + "Password: "******"Message from ONLINE RAILWAY RESERVATION SYSTEM", );
                 }
                 catch (Exception)
                 {
                     ScriptManager.RegisterStartupScript(this, GetType(), "Thông báo", "alert('Can not send mail !!!');", true);
                 }
                 Reset();
             }
             else
             {
                 ScriptManager.RegisterStartupScript(this, GetType(), "Thông báo", "alert('Add coach failed !!!');", true);
             }
         }
     }
 }
Exemplo n.º 9
0
 public System.Threading.Tasks.Task <bool> AddUserAsync(ServiceReference1.User user)
 {
     return(base.Channel.AddUserAsync(user));
 }
Exemplo n.º 10
0
 public bool AddUser(ServiceReference1.User user)
 {
     return(base.Channel.AddUser(user));
 }
Exemplo n.º 11
0
 // THIS IS NOT YET DONE FRONT END
 protected void createUserSubmit_Click(object sender, EventArgs e)
 {
     ServiceReference1.User user = new ServiceReference1.User(); // Set this via fields #Crelde
     try
     {
         Controller.CreateUser(user);
     }
     catch (NotLoggedInException)
     {
         // Shouldn't ever happen, but if it does, do a popup and send back to login screen. #Crelde
     }
     catch (InsufficientRightsException)
     {
         // Shouldn't ever happen as the button shouldn't be visible to a user without rights.
     }
     catch (InadequateObjectException)
     {
         // User has not given enough information, explain to the user that both email and password are required. #Crelde
     }
     catch (KeyOccupiedException)
     {
         // The email that was given is already in use on the server, explain this to the user #Crelde
     }
 }
Exemplo n.º 12
0
 private void Button_Click_2(object sender, RoutedEventArgs e)
 {
     int check = 0;
     if (isEmail(registerName.Text) == false)
     {
         MessageBox.Show("Email is not correct!");
     }
     else if (registerPass.Password.Trim().Length == 0)
     {
         MessageBox.Show("Write a password!");
     }
     else
     {
         for (int i = 0; i < userList.Count; i++)
         {
             if (registerName.Text == userList[i].username)
             {
                 MessageBox.Show("Username already taken!");
                 check = 1;
             }
         }
         if (check == 0)
         {
             ServiceReference1.User u = new ServiceReference1.User();
             u.username = registerName.Text;
             u.password = registerPass.Password;
             ServiceReference1.Service1Client client = new ServiceReference1.Service1Client();
             client.addUserAsync(u);
             client.addUserCompleted += client_addUserCompleted;
         }
     }
 }
Exemplo n.º 13
0
        /// <summary>
        /// This method is called and executed when the page is loaded.
        /// A specific user's information is displayed on this page.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if ((int)HttpContext.Current.Session["User_lvl"] > 0 && (int)HttpContext.Current.Session["User_lvl"] < 8)
            {
                btnRemoveOrg.Visible  = false;
                btnRemoveUser.Visible = false;

                try
                {
                    userDiv.Visible            = false;
                    OrgDiv.Visible             = false;
                    VolunteerFrame.Visible     = false;
                    RateReviewNPOFrame.Visible = false;
                    AvgRatingFrame.Visible     = false;

                    if (Request.QueryString["orgId"] != null)
                    {
                        OrgDiv.Visible = true;
                        int tmpID = int.Parse(Request.QueryString["orgId"].ToString());
                        ServiceReference1.Service1Client serv       = new ServiceReference1.Service1Client();
                        ServiceReference1.Organisation   currentOrg = serv.getOrg(tmpID);
                        orgDetailsDiv.InnerHtml = "<table style='width: 100%; border: solid #ddd; border-width: 1px 1px 1px 1px; clear: both; margin: 10px 0 30px; height: 0;'><tr><td><h1>" + currentOrg.OrganisationName + "</h1></td><td></td><td></td><td></td></tr><tr><td><h1>Address:</h1></td><td></td><td></td><td></td></tr><tr><td></td><td>" + currentOrg.Street + "</td><td></td><td></td></tr><tr><td></td><td>" + currentOrg.Suburb + "</td><td></td><td></td></tr><tr><td></td><td>" + currentOrg.Province + "</td><td></td><td></td></tr><tr><td><h1>Contact number:</h1></td><td>" + currentOrg.ContactNumber + "</td><td></td><td></td></tr><tr><td><h1>Industry:</h1></td><td>" + currentOrg.Industry + "</td><td></td><td></td></tr><table>";
                        ServiceReference1.UserDetail u = (ServiceReference1.UserDetail)HttpContext.Current.Session["User"];

                        if ((int)HttpContext.Current.Session["User_lvl"] == 7)
                        {
                            btnRemoveOrg.Visible = true;
                        }

                        if (u.AccessLvl == 5)
                        {
                            VolunteerFrame.Visible = true;
                            VolunteerFrame.Src     = "frames/VolunteerPage.aspx?Org_ID=" + tmpID;
                        }

                        if (u.AccessLvl == 5 || u.AccessLvl == 3)
                        {
                            RateReviewNPOFrame.Visible = true;
                            RateReviewNPOFrame.Src     = "frames/RateReviewNPO.aspx?orgId=" + tmpID;
                        }
                        if (currentOrg.OrganisationType == 1)
                        {
                            if (u.AccessLvl == 1 || u.AccessLvl == 2 || u.AccessLvl == 3 || u.AccessLvl == 4 || u.AccessLvl == 5 || u.AccessLvl == 6 || u.AccessLvl == 7)
                            {
                                AvgRatingFrame.Visible = true;
                                AvgRatingFrame.Src     = "frames/AverageRating.aspx?orgId=" + tmpID;
                            }
                        }

                        try
                        {
                            ServiceReference1.UserDetail user = (ServiceReference1.UserDetail)HttpContext.Current.Session["User"];
                            ServiceReference1.FileClass  file = serv.getFile(tmpID, true);
                            MemoryStream ms = new MemoryStream(file.FileBytes, 0, file.FileBytes.Length);
                            orgPic.ImageUrl = "data:image/jpg;base64," + Convert.ToBase64String(file.FileBytes);
                        }
                        catch (Exception ex)
                        {
                            imgUser.ImageUrl = "~/images/ina.jpg";
                        }
                    }

                    if (Request.QueryString["userId"] != null)
                    {
                        userDiv.Visible = true;
                        int tmpID = int.Parse(Request.QueryString["userId"].ToString());
                        ServiceReference1.Service1Client serv        = new ServiceReference1.Service1Client();
                        ServiceReference1.User           currentUser = serv.getUser(tmpID);
                        IndDetailsDiv.InnerHtml = "<table style='width: 100%; border: solid #ddd; border-width: 1px 1px 1px 1px; clear: both; margin: 10px 0 30px; height: 0;'><tr><td><h1>" + currentUser.FirstNameValue + " " + currentUser.LastNameValue + "</h1></td><td></td><td></td><td></td></tr><tr><td><h2>Email:</h2></td><td>" + currentUser.EmailValue + "</td><td></td><td></td></tr></table>";

                        if ((int)HttpContext.Current.Session["User_lvl"] == 7)
                        {
                            btnRemoveUser.Visible = true;
                        }

                        try
                        {
                            ServiceReference1.UserDetail user = (ServiceReference1.UserDetail)HttpContext.Current.Session["User"];
                            ServiceReference1.FileClass  file = serv.getUserImage(user.userValue.UserID);
                            MemoryStream ms = new MemoryStream(file.FileBytes, 0, file.FileBytes.Length);
                            imgUser.ImageUrl = "data:image/jpg;base64," + Convert.ToBase64String(file.FileBytes);
                        }
                        catch (Exception ex)
                        {
                            imgUser.ImageUrl = "~/images/avatar1.png";
                        }
                    }
                }
                catch (Exception ex)
                {
                }
            }
        }