示例#1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            //kick out if validation failed
            if (!(Page.IsValid))
            {
                //Do over; Reset anything here that needs a reset
                ResetImgMgr();
                return;
            }

            //tally up ShaperCodeValue
            if (hdnIsShaper.Value == "1")
            {
                TallyShaperCode();
            }

            string strSQL = string.Empty;
            string txtPhoneNumber;
            string emailNotify;
            string blogNotify;
            string profPic;
            int    showPhoneNum;
            int    iAcctType;

            IDBManager dbManager = new DBManager(DataProvider.SqlServer);

            dbManager.ConnectionString = ConfigurationManager.ConnectionStrings["myConn"].ConnectionString;;

            //Verify unique e-mail id.
            if (Session["EmailId"].ToString() != txtEmail.Text)
            {
                if (verify_User(dbManager.ConnectionString, txtEmail.Text))
                {
                    lblStatus.ForeColor = System.Drawing.Color.Red;
                    lblStatus.Text      = "That e-mail is already registered.  Please try again.";
                    return;
                }
            }

            //show phone flag
            showPhoneNum = (int)0;

            //Free acct=1; Commercial = 2
            iAcctType   = Convert.ToInt16(radioAcctType.SelectedValue);
            emailNotify = rdoEmailNotify.SelectedValue;
            blogNotify  = rdoBlogNotify.SelectedValue;

            txtPhoneNumber = txtAreaCode.Text + "-" + txtPhoneNum.Text;

            //if no phone num is entered then showPhonenum flag must be set to zero
            if (txtAreaCode.Text != "" && txtPhoneNum.Text != "")
            {
                if (chkShowPhone.Checked == true)
                {
                    showPhoneNum = (int)1;
                }
            }

            //Get user's id
            string uId = Session["userId"].ToString();

            strSQL  = "UPDATE tblUser SET txtFullName = '" + txtFullName.Text;
            strSQL += "' ,txtEmail = '" + txtEmail.Text;
            strSQL += "',txtPhoneNum = '" + txtPhoneNumber;
            strSQL += "',iShowPhoneNum = '" + showPhoneNum;
            strSQL += "',iAcctType = '" + iAcctType;
            strSQL += "',notify_comment_flg = '" + emailNotify;
            strSQL += "',notify_blog_flg = '" + blogNotify;
            strSQL += "',txtUserName = '******',txtHomeTown = '" + Global.CheckString(txtHomeTown.Text);
                strSQL += "',txtWebSite = '" + Global.CheckString(txtWebsite.Text);
                strSQL += "',txtUserDetails = '" + Global.CheckString(txtDetails.Text);
                strSQL += "',iWisdom = '" + Global.CheckString(txtShapingYrs.Text);
                strSQL += "',txtBrandName = '" + Global.CheckString(txtBrandName.Text);
                strSQL += "',iRegion = '" + cboRegion.SelectedValue;

                if (hdnShaperCode.Value.Length > 0)
                {
                    strSQL += "',iShaperCode = '" + Global.CheckString(hdnShaperCode.Value);
                }
            }

            //skip pwd processing if the change pwd panel is not visible
            if (pnlChangePwd.Visible && txtPassword1.Text.Length > 1)
            {
                BoardHunt.classes.hasher pHash = new BoardHunt.classes.hasher();

                //Get SALT and encode to string
                byte[] saltBytes  = pHash.GenerateSALT();
                string saltString = Convert.ToBase64String(saltBytes);

                //get hash and encode to string with SALT
                byte[] hBytes = pHash.getHash(saltString, txtPassword1.Text);
                string hPass  = Convert.ToBase64String(hBytes);  //hashed textual password

                //build SQL
                strSQL += "' ,txtPassword = '******',salt = '" + saltString + "',sashimi = '" + (int)1;
            }

            //get profile pic if loaded and control set
            if (rdoImgMgr1.SelectedValue == "Change" || rdoImgMgr1.SelectedValue == "Add")
            {
                if (!CheckFileType())
                {
                    ResetImgMgr();
                    return;
                }

                //TODO: check for file before attempting to upload
                profPic = UpLoadAllImages();
                strSQL += "' ,profilePic = '" + profPic;
                //delete old profile pic
                if (!(hdnProfilePic.Value.IndexOf("nopic64.jpg") > 0))
                {
                    //ErrorLog.ErrorRoutine(false, "Deleting old pic: " + Server.MapPath(hdnProfilePic.Value));
                    DeleteFile();
                }
            }
            else
            {
                if (rdoImgMgr1.SelectedValue == "Delete")
                {
                    DeleteFile();
                    //set to empty string
                    strSQL += "' ,profilePic = '";
                }
                //else KEEP: do nothing
            }

            strSQL += "' WHERE id = '" + uId + "'";
            ErrorLog.ErrorRoutine(false, "strSQL-> " + strSQL);

            try
            {
                dbManager.Open();
                dbManager.ExecuteNonQuery(CommandType.Text, strSQL);

                //Set new EmailId
                Session["EmailId"] = txtEmail.Text;
                //classes.Email.SendEmail("BH Profile Change", "*****@*****.**", "For User: "******"EmailId"].ToString() + " iD: " + uId);
                Response.Redirect("UserMenu.aspx", false);
            }
            catch (Exception ex)
            {
                ErrorLog.ErrorRoutine(false, "edit_profile:error" + ex.Message);
                lblStatus.Text = "Error: Connection Bad.<br>";
                classes.Email.SendErrorEmail("edit_profile:error" + ex.Message);
            }
            finally
            {
                dbManager.Close();
                dbManager.Dispose();
            }
        }
示例#2
0
        //private void imgAddFav_Click(object sender, System.Web.UI.ImageClickEventArgs e)
        //{
        //    if (Session["LoggedIn"].ToString() == "No")
        //    {
        //        Global.CreateMessageAlert(this.Page, "You must be logged in to do that.", "alertKey");
        //        return;
        //    }

        //    //add this entry into the favorites table
        //    string strSQL;
        //    string myConnectString;

        //    //form connect string
        //    myConnectString = ConfigurationManager.ConnectionStrings["myConn"].ConnectionString;;


        //    //Build SQL
        //    strSQL = "INSERT INTO tblFavs (userId, entryId)";
        //    strSQL += "VALUES ('" + Session["userId"].ToString() + "','" + Request.QueryString["iD"].ToString() + "')";

        //    SqlConnection myConnection = new SqlConnection(myConnectString);

        //    //TODO: need to check for duplicate entries
        //    try
        //    {
        //        myConnection.Open();

        //        SqlCommand objCommand = new SqlCommand(strSQL, myConnection);
        //        objCommand.ExecuteNonQuery();

        //        myConnection.Close();

        //        BindComments();

        //        Global.CreateMessageAlert(this.Page,"Entry has been added to your favorites.", "alertKey");

        //    }

        //    catch
        //    {
        //        lblStatus.Text = "SQL Error: Connection Bad.<br>";
        //        lblStatus.Text = "SQL: " + strSQL;
        //    }


        //}

        protected void btnPostComment_Click(object sender, EventArgs e)
        {
            //add this entry into the favorites table
            string strSQL;
            string myConnectString;

            //check login status
            if (Session["LoggedIn"].ToString() == "No")
            {
                //TODO: display please log in?
                return;
            }

            //check for an empty comment
            if (txtComment.Text.Length <= 0)
            {
                txtComment.BorderColor = Color.Red;
                return;
            }

            //form connect string
            myConnectString = ConfigurationManager.ConnectionStrings["myConn"].ConnectionString;;

            //Build SQL
            strSQL  = "INSERT INTO tblComments (entryId, userId, txtComment, dPosted)";
            strSQL += "VALUES ('" + Convert.ToInt32(hdnEId.Value) + "','" + Convert.ToInt32(Session["userId"].ToString()) + "','" + Global.CheckString(txtComment.Text) + "','" + DateTime.Now + "')";

            SqlConnection myConnection = new SqlConnection(myConnectString);

            //TODO: need to check for duplicate entries - ?
            try
            {
                myConnection.Open();

                SqlCommand objCommand = new SqlCommand(strSQL, myConnection);
                objCommand.ExecuteNonQuery();

                string[] eLinkArr = new string[1];
                eLinkArr[0] = Request.Url.ToString();

                //Send E-mail
                if (hdnNotifyEmail.Value == "Y")
                {
                    classes.Email.SendEmail("A new comment was posted on your board", lnkEmailData.CommandArgument, classes.Email.MSG_POSTED_COMMENT, eLinkArr);
                }

                Response.Redirect(Request.Url.ToString());
            }

            catch (Exception ex)
            {
                ErrorLog.ErrorRoutine(false, "ItemDetails:Error posting comment:" + ex.Message);
                lblStatus.Text = "Error posting comment.<br>";
            }

            finally
            {
                myConnection.Close();
            }
        }
示例#3
0
/*
 */
        private void SubmitItem(bool publishVal)
        {
            classes.BoardItem tmpBoardItem2 = (classes.BoardItem)Session["Item"];

            // - Tasks:
            // - Move pics from temp dir to surf dir then delete *.* temp dir
            // - Write entry to db from object

            if (tmpBoardItem2 == null)
            {
                ErrorLog.ErrorRoutine(false, "Error:Preview_Post:imgContinue_Click: BoardItem obj NULL: Session: " + Session.SessionID);
                //ErrorLog.ErrorRoutine(false, "Error:Preview_Post:imgContinue_Click: SessionID: " + Session.SessionID);

                pnlError.Visible = true;
                return;
            }
            else
            {
                ErrorLog.ErrorRoutine(false, "Preview_Post:imgContinue_Click:ENTRYITEM OK: " + Session.SessionID);
            }

            tmpBoardItem2.Created = DateTime.Now;
            tmpBoardItem2.Details = Global.CheckString(tmpBoardItem2.Details);
            tmpBoardItem2.Brand   = Global.CheckString(tmpBoardItem2.Brand);
            tmpBoardItem2.Shaper  = Global.CheckString(tmpBoardItem2.Shaper);

            //Shaperhouse
            if (tmpBoardItem2.AdType == 4)
            {
                if (publishVal)
                {
                    tmpBoardItem2.Status = 5;
                }
                else
                {
                    tmpBoardItem2.Status = 4;
                }
            }

            //check for pics
            if (hdnProcPics.Value == "True" && tmpBoardItem2.AdType != (int)2)
            {
                if (MoveFiles(tmpBoardItem2.Category, tmpBoardItem2.AdType))
                {
                    DeletePicsInTempDir();
                }
            }

            //Save entry
            try
            {
                //write entry to db
                if (tmpBoardItem2.SaveItem())
                {
                    //update user's entry count
                    if (UpdateEntryCount(tmpBoardItem2.IUser.ToString()))
                    {
                        if (!publishVal)
                        {
                            Response.Redirect("post_manager.aspx?q=4", false);
                        }
                        Response.Redirect("post_finish.aspx", false);
                    }
                }
                else
                {
                    lblStatus.Text = "Error posting";
                }
            }
            catch { lblStatus.Text = "ERROR"; }
            finally { }

            //TODO: Remove.  Do we needed it?
            //Session["Item"] = tmpBoardItem;
        }