コード例 #1
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            System.Web.UI.HtmlControls.HtmlTextArea textArea = (System.Web.UI.HtmlControls.HtmlTextArea)(form1.FindControl("description"));
            String textarea = textArea.Value;
            int    user     = Convert.ToInt32(Session["id"]);
            String opfield  = operationField.Items[operationField.SelectedIndex].Value;

            if (name.Text.Equals("") || contactnumber.Text.Equals("") || contactemail.Text.Equals("") || textarea.Equals("") || state.Text.Equals("") || city.Text.Equals("") || street.Text.Equals(""))
            {
                Label8.Text = "Ju lutem plotesoni te gjitha fushat!";
            }
            else
            {
                CompanyDB.addCompanyInfo(opfield, contactnumber.Text, contactemail.Text, textarea, user, name.Text);
                UsersDB.addAddress(state.Text, city.Text, street.Text, user);
                //UsersDB.addSocialMedia(company.Text, facebook.Text, twitter.Text, linkedin.Text, instagram.Text,user);
                Response.Redirect("companyProfile.aspx");
            }
        }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Convert.ToString(Session["sessionValue"]) == "set")
            {
                if (Convert.ToInt32(UsersDB.userType(Convert.ToString(Session["email"]))) == 1)
                {
                    if (UsersDB.profileFilled(Convert.ToInt32(Session["id"]), "company"))
                    {
                        profile.NavigateUrl      = "~/companyProfile.aspx";
                        notification.NavigateUrl = "~/UserNotifications.aspx";
                    }
                    else
                    {
                        profile.NavigateUrl      = "~/companyProfileToFill.aspx";
                        notification.NavigateUrl = "~/UserNotifications.aspx";
                    }
                    home.NavigateUrl = "~/mainPageCompany.aspx";
                }
                else
                if (Convert.ToInt32(UsersDB.userType(Convert.ToString(Session["email"]))) != 1)
                {
                    if (UsersDB.profileFilled(Convert.ToInt32(Session["id"]), "user"))
                    {
                        profile.NavigateUrl      = "~/profile.aspx";
                        notification.NavigateUrl = "~/CompanyNotifications.aspx";
                    }
                    else
                    {
                        profile.NavigateUrl      = "~/profileToFill.aspx";
                        notification.NavigateUrl = "~/CompanyNotifications.aspx";
                    }

                    home.NavigateUrl = "~/mainPageUser.aspx";
                }
            }
            else
            {
                System.Windows.Forms.MessageBox.Show("Kjo faqe nuk mund te aksesohet sepse ju nuk jeni te loguar!");
                Response.Redirect("Login.aspx");
            }
        }
コード例 #3
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            int user = Convert.ToInt32(Session["id"]);

            foreach (ListItem i in CheckBoxList1.Items)
            {
                if (i.Selected == true)
                {
                    UsersDB.addPreference(user, i.Text);
                }
            }

            if (Convert.ToInt32(Session["company"]) == 1)
            {
                Response.Redirect("mainPageCompany.aspx");
            }
            else
            {
                Response.Redirect("mainPageUser.aspx");
            }
        }
コード例 #4
0
        protected void Button1_Click2(object sender, EventArgs e)
        {
            String opField   = operationField.Items[operationField.SelectedIndex].Value;
            String contactNr = contactNumber.Text;
            String contactEm = contactEmail.Text;

            System.Web.UI.HtmlControls.HtmlTextArea textArea = (System.Web.UI.HtmlControls.HtmlTextArea)(form1.FindControl("description"));
            String description = textArea.Value;
            int    user        = Convert.ToInt32(Session["id"]);

            if (contactEm.Equals("") || contactNr.Equals("") || description.Equals("") || state.Text.Equals("") || city.Text.Equals("") || street.Text.Equals(""))
            {
                infoError.Text = "Ju lutem plotesoni te gjitha fushat!";
            }
            else
            {
                NormalUserDB.normalUserInfo(opField, contactNr, contactEm, description, user);
                UsersDB.addAddress(state.Text, city.Text, street.Text, user);
                //UsersDB.addSocialMedia("", facebook.Text, twitter.Text, linkedin.Text, instagram.Text, user);
                Response.Redirect("profile.aspx");
            }
        }
コード例 #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Convert.ToString(Session["sessionValue"]) == "set")
            {
                if (Convert.ToInt32(UsersDB.userType(Convert.ToString(Session["email"]))) == 1)
                {
                    if (UsersDB.profileFilled(Convert.ToInt32(Session["id"]), "company"))
                    {
                        profile.NavigateUrl = "~/companyProfile.aspx";
                    }
                    else
                    {
                        profile.NavigateUrl = "~/companyProfileToFill.aspx";
                    }
                    home.NavigateUrl         = "~/mainPageCompany.aspx";
                    notification.NavigateUrl = "~/UserNotifications.aspx";
                }
                else
                if (Convert.ToInt32(UsersDB.userType(Convert.ToString(Session["email"]))) != 1)
                {
                    if (UsersDB.profileFilled(Convert.ToInt32(Session["id"]), "user"))
                    {
                        profile.NavigateUrl = "~/profile.aspx";
                    }
                    else
                    {
                        profile.NavigateUrl = "~/profileToFill.aspx";
                    }

                    home.NavigateUrl         = "~/mainPageUser.aspx";
                    notification.NavigateUrl = "~/CompanyNotifications.aspx";
                }
            }
            else
            {
                System.Windows.Forms.MessageBox.Show("Kjo faqe nuk mund te aksesohet sepse ju nuk jeni te loguar!");
                Response.Redirect("Login.aspx");
            }

            int           idcomp  = Convert.ToInt32(Session["id"]);
            String        query   = "SELECT * FROM Users WHERE id = @id";
            SqlConnection connect = UsersDB.GetConnection();
            SqlCommand    command = new SqlCommand(query, connect);

            command.Parameters.AddWithValue("@id", idcomp);
            connect.Open();
            SqlDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                ouremail.Text = Convert.ToString(reader["email"]);
            }

            int id = Convert.ToInt32(Request.QueryString["id"]);

            query   = "SELECT * FROM Users WHERE id = @id";
            connect = UsersDB.GetConnection();
            command = new SqlCommand(query, connect);
            command.Parameters.AddWithValue("@id", id);
            connect.Open();
            reader = command.ExecuteReader();
            while (reader.Read())
            {
                useremail.Text = Convert.ToString(reader["email"]);

                subject.Text = "Pergjigje per lajmerimin";
            }
        }
コード例 #6
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            emailError.Text    = "";
            passwordError.Text = "";

            //check if all the fields are not empty
            if (name.Text != "" && email.Text != "" && password.Text != "")
            {
                //checks if email is valid
                string pattern = @"^[a-z][a-z|0-9|]*([_][a-z|0-9]+)*([.][a-z|0-9]+([_][a-z|0-9]+)*)?@[a-z][a-z|0-9|]*\.([a-z][a-z|0-9]*(\.[a-z][a-z|0-9]*)?)$";
                Match  match   = Regex.Match(email.Text.Trim(), pattern, RegexOptions.IgnoreCase);

                if (!match.Success)
                {
                    emailError.Text = "*Email-i duhet te jete ne formatin [email protected]";
                }
                else
                {
                    //check if this email is already registerd in our database
                    bool checkEmail = UsersDB.getUser(email.Text);
                    if (checkEmail == true)
                    {
                        emailError.Text = "*Ky email eshte i regjistruar!";
                    }
                    else
                    {
                        //check if password is valid
                        pattern = @"^.*(?=.{8,})(?=.*[\d])(?=.*[\W]).*$";
                        match   = Regex.Match(password.Text.Trim(), pattern, RegexOptions.IgnoreCase);
                        if (!match.Success)
                        {
                            passwordError.Text = "*Fjalekalimi duhet te kete te pakten 8 karaktere,nje numer dhe nje karakter special!";
                        }
                        else
                        {
                            //create salt to use it for password hash
                            byte[] salt;
                            new RNGCryptoServiceProvider().GetBytes(salt = new byte[16]);
                            var    pbkdf2    = new Rfc2898DeriveBytes(password.Text, salt, 10000);
                            byte[] hash      = pbkdf2.GetBytes(20);
                            byte[] hashBytes = new byte[36];
                            Array.Copy(salt, 0, hashBytes, 0, 16);
                            Array.Copy(hash, 0, hashBytes, 16, 20);
                            string savedPasswordHash = Convert.ToBase64String(hashBytes);

                            //check if the user is registering as a normal user or a company
                            if (CheckBox1.Checked)
                            {
                                UsersDB.addUser(name.Text, email.Text, savedPasswordHash, "1", "0");
                            }
                            else
                            {
                                UsersDB.addUser(name.Text, email.Text, savedPasswordHash, "0", "1");
                            }

                            String confirm_code = UsersDB.retrieveConfirmCode(email.Text);

                            //send confirmation email
                            MailMessage m  = new MailMessage();
                            SmtpClient  sc = new SmtpClient();
                            try
                            {
                                m.From = new MailAddress("*****@*****.**", "*****@*****.**");
                                m.To.Add(new MailAddress(email.Text, email.Text));

                                m.Subject    = "Email konfirmimi";
                                m.IsBodyHtml = true;
                                String body = "Ju lutem konfirmoni llogarine tuaj duke klikuar <html><body><a href='http://*****:*****@gmail.com", "Serena123!");
                                sc.EnableSsl = true;
                                sc.Send(m);
                            }
                            catch (Exception ex)
                            {
                            }

                            //empty the fields again
                            name.Text     = "";
                            email.Text    = "";
                            password.Text = "";
                            //redirect to another page
                            Server.Transfer("Login.aspx", true);
                        }
                    }
                }
            }
            else
            {
                error.Text = "*Duhet ti plotesoni te gjitha fushat!";
            }
        }