Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                try
                {
                    string reg = Request.QueryString["pg"].ToString();
                    switch (reg)
                    {
                    case "login":
                        MultiView1.ActiveViewIndex = 0;
                        break;

                    case "errorlog":
                        string error = Request.QueryString["error"].ToString();
                        MultiView1.ActiveViewIndex = 0;
                        promt.Text = "<div class='error'>" + encryptype.psDescrypt(error) + "</div><br/>";
                        break;

                    case "reguser":
                        MultiView1.ActiveViewIndex = 1;
                        break;

                    case "K/nGKCEBhtE=":
                        MultiView1.ActiveViewIndex = 0;
                        string nwuser = Request.QueryString["usersave"].ToString();
                        user   Usr    = db.users.First(u => u.username == nwuser);
                        txtuser.Text = Usr.username;
                        break;
                    }
                    sitename Sitnme = db.sitenames.First();
                    Page.Title = string.Format(Sitnme.title.ToString());
                    menu Mne = db.menus.First(use => use.menu_name == "home");
                    lbl_sitename.Text = "<a  style='font-size:20px;' class='TextLightI WatermarkedInputContainer' href='" + Mne.alias + "'>" + Sitnme.title.ToString() + "</a>"; //call sitename
                    lbltitle2.Text    = "<a  style='font-size:20px;' class='TextLightI WatermarkedInputContainer' href='" + Mne.alias + "'>" + Sitnme.title.ToString() + "</a>"; //call sitename


                    //var sption = from s in db.soptions
                    //             where s.disc == "gender"
                    //             select s.name;

                    //if (sption != null)
                    //{
                    //    drpgender.DataSource = sption.Distinct().ToList();
                    //    drpgender.DataBind();
                    //}
                }
                catch (Exception ex)
                {
                }
            }
        }
Example #2
0
 protected void Button3_Click(object sender, EventArgs e)
 {
     Label2.Text = classsecuryty.psDescrypt(TextBox3.Text);
 }
Example #3
0
        protected void btnsubmit_Click(object sender, EventArgs e)
        {
            HttpCookie cookie   = Request.Cookies["rowenref"];                           //declaration of cookie
            user       Usrs     = db.users.First(u => u.username == cookie["username"]); //retrieve uer id
            string     password = clssEncryptsecurity.psDescrypt(Usrs.password);         //show password


            string Id         = Request.QueryString["id"];
            string Profilepic = Usrs.Image.ToString();

            if (fileuserimage.PostedFile == null)
            {
                if (Profilepic == null)
                {
                    db.sp_UPDATE_tbl_userInfo(Convert.ToInt16(Usrs.id), cookie["username"], clssEncryptsecurity.psEncrypt(password), txtfname.Text, txtlname.Text, txtemail.Text, dropgender.Text, txtmname.Text, txtaddress.Text, null);
                    Label1.Text = "<div class='ok'>Update user info Successful</div>";
                    MultiView2.ActiveViewIndex = 0;
                }
                else
                {
                    db.sp_UPDATE_tbl_userInfo(Convert.ToInt16(Usrs.id), cookie["username"], clssEncryptsecurity.psEncrypt(password), txtfname.Text, txtlname.Text, txtemail.Text, dropgender.Text, txtmname.Text, txtaddress.Text, Usrs.Image);
                    Label1.Text = "<div class='ok'>Update user info Successful</div>";
                    MultiView2.ActiveViewIndex = 0;
                }
            }
            else
            {
                if (fileuserimage.PostedFile != null)
                {
                    string sub = string.Empty, imagePath = string.Empty, imgFilename = string.Empty;
                    // Check that there is a file
                    if (fileuserimage.PostedFile != null)
                    {
                        //Path to store uploaded files on server - make sure your paths are unique


                        string filePath  = "../profilepic/oreginal/" + txtusername.Text + ".jpg";
                        string thumbPath = "../profilepic/thumb/" + txtusername.Text + ".jpg";

                        // Check file size (mustn’t be 0)
                        HttpPostedFile myFile   = fileuserimage.PostedFile;
                        int            nFileLen = myFile.ContentLength;
                        if ((nFileLen > 0) && (System.IO.Path.GetExtension(myFile.FileName).ToLower() == ".jpg"))
                        {
                            // Read file into a data stream
                            byte[] myData = new Byte[nFileLen];
                            myFile.InputStream.Read(myData, 0, nFileLen);
                            myFile.InputStream.Dispose();

                            // Save the stream to disk as temporary file. make sure the path is unique!
                            System.IO.FileStream newFile = new System.IO.FileStream(Server.MapPath(filePath + "_temp.jpg"),
                                                                                    System.IO.FileMode.Create);

                            newFile.Write(myData, 0, myData.Length);

                            // run ALL the image optimisations you want here..... make sure your paths are unique
                            // you can use these booleans later if you need the results for your own labels or so.
                            // dont call the function after the file has been closed.
                            bool success = ResizeImageAndUpload(newFile, thumbPath, 300, 300);
                            success = ResizeImageAndUpload(newFile, filePath, 1200, 900);

                            // tidy up and delete the temp file.
                            newFile.Close();
                            System.IO.File.Delete(Server.MapPath(filePath + "_temp.jpg"));
                        }
                        imgFilename = Path.GetFileName(thumbPath);

                        Stream imgdatastream = fileuserimage.PostedFile.InputStream;
                        int    imgdatalen    = fileuserimage.PostedFile.ContentLength;
                        byte[] imgdata       = new byte[imgdatalen];
                        int    n             = imgdatastream.Read(imgdata, 0, imgdatalen);

                        db.sp_UPDATE_tbl_userInfo(Convert.ToInt16(Usrs.id), cookie["username"], clssEncryptsecurity.psEncrypt(password), txtfname.Text, txtlname.Text, txtemail.Text, dropgender.Text, txtmname.Text, txtaddress.Text, imgFilename);
                        Label1.Text = "<div class='ok'>Update user info Successful</div>";
                        MultiView2.ActiveViewIndex = 0;
                        Response.Redirect("account.aspx");
                    }
                }
            }
        }