Ejemplo n.º 1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     string sUid = Request.QueryString["uid"].ToString();
     sUid = sUid.Replace(" ", "+");
     UserInfoBll usrBll = new UserInfoBll();
     usrBll.UpdateActivation(Convert.ToInt32(UtilityClass.Decrypt(sUid)));
 }
Ejemplo n.º 2
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            UserInfoBll userInfoBll = new UserInfoBll(); ;
            int intErr = 0;

            try
            {
                int adminId = userInfoBll.ValidateAdmin(UserName.Text.Trim(), Password.Text.Trim());
                if (string.IsNullOrEmpty(adminId.ToString().Trim()))
                {
                    intErr = 1;
                    lblError.Text = "Invalid Adminname and Password! Please try again.";
                    lblError.Visible = false;
                }
                else
                {
                    Session.Abandon();
                    Session.RemoveAll();

                    if (Session["UserId"] == null)
                        Session.Add("UserId", adminId.ToString());
                    if (Session["UserType"] == null)
                        Session.Add("UserType", "2");
                        Response.Cookies.Clear();
                    HttpCookie cadminId = new HttpCookie("UserId", adminId.ToString().Trim());
                    HttpCookie cadmintype = new HttpCookie("UserType", "2");
                        cadminId.Expires = DateTime.Now.AddDays(5);
                    cadmintype.Expires = DateTime.Now.AddDays(5);

                        Response.Cookies.Add(cadminId);
                    Response.Cookies.Add(cadmintype);
                    if (RememberMe.Checked == true)
                    {
                        HttpCookie cadminname = new HttpCookie("AdminName", UserName.ToString().Trim());
                        HttpCookie cadminpwd = new HttpCookie("AdminPassword", Password.ToString().Trim());
                        cadminname.Expires = DateTime.Now.AddDays(5);
                        cadminpwd.Expires = DateTime.Now.AddDays(5);

                        Response.Cookies.Add(cadminname);
                        Response.Cookies.Add(cadminpwd);
                    }
                }
            }
            catch (System.Threading.ThreadAbortException)
            {
            }
            catch (Exception ex)
            {
                FailureText.Text = ex.Message.ToString();

                intErr = 1;
                lblError.Text = ex.Message.ToString();
                lblError.Visible = false;
            }

            if (intErr == 0)
                Response.Redirect("Default.aspx");
        }
Ejemplo n.º 3
0
 protected void btnSend_Click(object sender, EventArgs e)
 {
     if (txtNewPwd.Text.Trim() != "" && txtNewPwd.Text.Trim() == txtConPwd.Text.Trim())
     {
         UserInfoBll usrBll = new UserInfoBll();
         usrBll.UpdateUserPassword(Convert.ToInt32(strUserId), txtNewPwd.Text.Trim());
         tblMessage.InnerText = "Your Password has changed. Check your login..";
         lblError.Visible = false;
         txtConPwd.Text = "";
         txtNewPwd.Text = "";
     }
     else
     {
         lblError.Visible = true;
         lblError.Text = "Please enter confirm password as above";
     }
 }
Ejemplo n.º 4
0
        protected void btnBlock_Click(object sender, EventArgs e)
        {
            foreach (GridViewRow r in GridView1.Rows)
            {
                int intBlockVal = 0;
                CheckBox chk = (CheckBox)r.Cells[0].FindControl("chkDelStatus");
                if (chk.Checked)
                {
                    intBlockVal = 1;
                }

                string sUserId = GridView1.DataKeys[r.RowIndex].Value.ToString();

                objUser = new UserInfoBll();
                objUser.UpdateUserDeleteStatus(Convert.ToInt32(sUserId), intBlockVal);
            }

            //lblMessage.Visible = true;
            //lblMessage.Text = "Selected users are deleted";
        }
Ejemplo n.º 5
0
 void LoadUserInfo()
 {
     UserInfoBll userBll = new UserInfoBll();
     DataTable dt = userBll.SelectProfile(Convert.ToInt32(Session["UserId"].ToString()));
     if (dt.Rows.Count > 0)
     {
         lblName.Text = dt.Rows[0]["FirstName"].ToString() + " "+dt.Rows[0]["LastName"].ToString();
         if (dt.Rows[0]["Gender"].ToString() == "1")
             lblGender.Text = "Male";
         else if (dt.Rows[0]["Gender"].ToString() == "2")
             lblGender.Text = "Female";
         else if (dt.Rows[0]["Gender"].ToString() == "0")
             lblGender.Text = "Rather not say";
         lblEmail.Text = dt.Rows[0]["Email"].ToString();
         lblMobile.Text = dt.Rows[0]["Mobile"].ToString();
         lblAddress.Text = dt.Rows[0]["Address"].ToString();
         lblStreetname.Text = dt.Rows[0]["StreetName"].ToString();
         lblCountry.Text = dt.Rows[0]["CountryName"].ToString();
         lblCity.Text = dt.Rows[0]["CityName"].ToString();
         lblState.Text = dt.Rows[0]["StateName"].ToString();
         lblZipcode.Text = dt.Rows[0]["ZipCode"].ToString();
     }
 }
Ejemplo n.º 6
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            int intErrorCount = 0;

            if (strEmail != txtEmail.Text.Trim())
            {
                MailCheck(txtEmail.Text.Trim());

                if (intMailAvail == 1)
                {
                    intErrorCount++;
                    lblErrorEmail.Visible = true;
                }
                else
                    lblErrorEmail.Visible = false;
            }
            if (intErrorCount == 0)
            {
                UserInfoBll userBll = new UserInfoBll();
                UserProfile userProfile = new UserProfile();

                try
                {

                    userProfile.UserId = Convert.ToInt32(Session["UserId"].ToString());
                    userProfile.UserName = strUsername;
                    if (txtNewpwd.Text.Trim() != "")
                        userProfile.UserPassword = txtNewpwd.Text;
                    else
                        userProfile.UserPassword = strPassword;

                    userProfile.FirstName = txtFirstName.Text.ToString().Trim();
                    userProfile.LastName = txtLastName.Text.ToString().Trim();
                    userProfile.Email = txtEmail.Text.ToString().Trim();
                    userProfile.Address = txtAddress.Text.ToString().Trim();
                    userProfile.Mobile = txtMobile.Text.ToString().Trim();
                    userProfile.StreetName = txtStreetname.Text.ToString().Trim();
                    userProfile.CityId = Convert.ToInt32(ddlCity.SelectedItem.Value.ToString().Trim());
                    userProfile.StateId = Convert.ToInt32(ddlState.SelectedItem.Value.ToString().Trim());
                    userProfile.ZipCode = txtZipcode.Text.ToString().Trim();
                    userProfile.CountryId = Convert.ToInt32(ddlCountry.SelectedItem.Value.ToString().Trim());
                    userProfile.Gender = int.Parse(RadioButtonList1.SelectedItem.Value.ToString().Trim());

                    if (intErrorCount == 0)
                    {
                        int x = userBll.CreateUserInfo(userProfile);
                        //HttpContext.Current.Session.Add("UserId", x);

                        //SendMailtoUser(x);
                        Response.Redirect("MyProfile.aspx");
                    }

                }
                catch (System.Threading.ThreadAbortException th)
                {

                }
                catch (Exception ex)
                {
                }
            }
        }
Ejemplo n.º 7
0
        void MailCheck(string strEmailAddr)
        {
            UserInfoBll userBll = new UserInfoBll();
            DataTable dt = userBll.AvailableMail(strEmailAddr.Trim());

            if (dt.Rows.Count == 0)
            {
                intMailAvail = 0;
            }
            else
            {
                intMailAvail = 1;
            }
        }
Ejemplo n.º 8
0
 void LoadUserInfo()
 {
     UserInfoBll userBll = new UserInfoBll();
     DataTable dt = userBll.SelectProfile(Convert.ToInt32(Session["UserId"].ToString()));
     if (dt.Rows.Count > 0)
     {
         strUsername = dt.Rows[0]["UserName"].ToString();
         strPassword = dt.Rows[0]["UserPassword"].ToString();
         hdnPassword.Value = strPassword;
         txtFirstName.Text = dt.Rows[0]["FirstName"].ToString();
         txtLastName.Text=dt.Rows[0]["LastName"].ToString();
         RadioButtonList1.SelectedValue = dt.Rows[0]["Gender"].ToString();
         txtEmail.Text = dt.Rows[0]["Email"].ToString();
         strEmail = dt.Rows[0]["Email"].ToString();
         txtMobile.Text = dt.Rows[0]["Mobile"].ToString();
         txtAddress.Text = dt.Rows[0]["Address"].ToString();
         txtStreetname.Text = dt.Rows[0]["StreetName"].ToString();
         ddlCountry.Text = dt.Rows[0]["CountryName"].ToString();
         for (int i = 0; i < ddlCountry.Items.Count; i++)
         {
             if (ddlCountry.Items[i].Text == dt.Rows[0]["CountryName"].ToString())
                 ddlCountry.SelectedIndex = i;
         }
         for (int i = 0; i < ddlCity.Items.Count; i++)
         {
             if (ddlCity.Items[i].Text == dt.Rows[0]["CityName"].ToString())
                 ddlCity.SelectedIndex = i;
         }
         for (int i = 0; i < ddlState.Items.Count; i++)
         {
             if (ddlState.Items[i].Text == dt.Rows[0]["StateName"].ToString())
                 ddlState.SelectedIndex = i;
         }
         txtZipcode.Text = dt.Rows[0]["ZipCode"].ToString();
     }
 }
Ejemplo n.º 9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.Cookies["UserType"] != null)
            {
                Session.Add("UserType", Request.Cookies["UserType"].Value.ToString());
            }
            if (Request.QueryString.Count == 1)
                {
                    if (this.Page.Title.Contains("Activa") == false)
                {
                        if (Session["UserId"] == null)
                    Session.Add("UserId", Request.QueryString["uid"].ToString());
                }
            }
            else if (Request.Cookies["UserId"] != null)
            {
                Session.Add("UserId", Request.Cookies["UserId"].Value.ToString());
            }

            if (this.Page.Title.Contains("Admin") || (Session["UserId"] != null && Session["UserType"] != null && Session["UserType"].ToString() == "2"))
            {
                welcomeMessage.InnerText = "Welcome Admin";
                isShowHideControl = "2";
            }
            else if (Session["UserId"] == null)
            {
                    welcomeMessage.InnerText = "Welcome Guest";
                isShowHideControl = "0";
                }
                else
                {
                    UserInfoBll usr = new UserInfoBll();
                    DataTable dt = usr.SelectProfile(Convert.ToInt32(Session["UserId"].ToString()));
                    if (dt.Rows.Count > 0)
                    {
                        welcomeMessage.InnerText = "Welcome " + dt.Rows[0]["UserName"].ToString();
                    }
                isShowHideControl = "1";
                }

            //if (welcomeMessage.InnerText.Contains("Guest") || string.IsNullOrWhiteSpace(welcomeMessage.InnerText))
            //{
            //    isShowHideControl = "0";
            //}
            //else if (welcomeMessage.InnerText.Contains("Admin"))
            //{
            //    isShowHideControl = "2";
            //}
            //else
            //{
            //    isShowHideControl = "1";
            //}

            //// To find IP address of a machine behind LAN you can use this code
            //string strHostName = Dns.GetHostName();
            //IPHostEntry ipEntry = Dns.GetHostEntry(strHostName);

            ////lblIPAddress.Text = Convert.ToString(ipEntry.AddressList[1]);
            ////lblHostName.Text = Convert.ToString(ipEntry.HostName);

            ////string clientIPLocation = string.Empty;

            //Find IP Address Behind Proxy Or Client Machine In ASP.NET
            string IPAdd = string.Empty;
            IPAdd = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];

            if (string.IsNullOrEmpty(IPAdd))
            {
                IPAdd = Request.ServerVariables["REMOTE_ADDR"];
                //lblIPBehindProxy.Text = IPAdd;
            }

            string JSON = GetLocation(IPAdd);
            if (!string.IsNullOrWhiteSpace(JSON))
            {
                JavaScriptSerializer Serializer = new JavaScriptSerializer();
                dynamic dynamicResult = Serializer.Deserialize<dynamic>(JSON);

                //Response.Write(dynamicResult["countryName"].ToString());
                //Response.Write(dynamicResult["countryCode"].ToString());
                //Response.Write(dynamicResult["city"].ToString());
                //Response.Write(dynamicResult["region"].ToString());
                //Response.Write(dynamicResult["latitude"].ToString());
                //Response.Write(dynamicResult["longitude"].ToString());

                currentLocation.InnerText = string.Format(" / Country: {0}/{1}, City: {2}/{3} ",
                    dynamicResult["countryName"].ToString(), dynamicResult["countryCode"].ToString(),dynamicResult["city"].ToString(),
                    dynamicResult["region"].ToString());
                if (Session["Location"] == null)
                    Session.Add("Location", dynamicResult["city"].ToString());

                //Session.Add("Location", "wyoming");
            }
            else
            {
            string userHostIpAddress = IPAdd; // "117.197.193.243";
            IPAddress ipAddress;
            //Response.Write("<script>alert('"+userHostIpAddress+"')</Script>");
            if (userHostIpAddress == "::1")
            {
                userHostIpAddress = "117.197.193.243";
            }
            if (IPAddress.TryParse(userHostIpAddress, out ipAddress))
            {

                string country = ipAddress.Country(); // return value: UNITED STATES
                string iso3166TwoLetterCode = ipAddress.Iso3166TwoLetterCode(); // return value: US
                currentLocation.InnerText = string.Format("Country: {0} / Location: {1} ", country, iso3166TwoLetterCode);

                    if (Session["Location"] == null)
                        Session.Add("Location", iso3166TwoLetterCode);
                    //Session.Add("Location", "wyoming");

                //Label1.Text = country;
            }
            }
        }
Ejemplo n.º 10
0
        protected void btnSend_Click(object sender, EventArgs e)
        {
            UserInfoBll userBll = new UserInfoBll();
            DataTable dt = userBll.SelectUserByEmail(txtEmail.Text.Trim());

            if (dt.Rows.Count > 0)
            {
                string strUserId = dt.Rows[0]["UserID"].ToString();
                string strUsername = dt.Rows[0]["UserName"].ToString();
                string strPassword = dt.Rows[0]["UserPassword"].ToString();

                string mUname = ConfigurationManager.AppSettings["mailUsername"].ToString();
                string mPwd = ConfigurationManager.AppSettings["mailPassword"].ToString();
                string mFrom = "";
                string mTo = txtEmail.Text.Trim();
                string mCC = "";
                string mSubject = "Yard E-Cart Password request";
                string serverPath = ConfigurationManager.AppSettings["ApplicationPath"].ToString() + "/Login.aspx";
                string activatePath = ConfigurationManager.AppSettings["ApplicationPath"].ToString() + "/ActivateUser.aspx?uid=" + UtilityClass.Encrypt(strUserId.ToString()).ToString();
                string resetPath = ConfigurationManager.AppSettings["ApplicationPath"].ToString() + "/ResetPassword.aspx?uid=" + UtilityClass.Encrypt(strUserId.ToString()).ToString();

                string mMsg = "";

                if (dt.Rows[0]["UserStatus"].ToString() == "0")
                {
                    mMsg = "<html><body><form id='form1' runat='server'><div>" +
                    "Dear " + strUsername + ",<br /><br />As you request, your username and password is given below:<br><br>" +
                    "<b>UserName : "******"<br>Password : "******"</b>" +
                    "<br /><br />Before we can activate your account one last step must be taken to complete your registration." +
                    "<br /><br />Please note - you must complete this last step to become a registered member. You will only need to visit this URL once to activate your account." +
                    "<br /><br />To complete your registration, please visit this URL:<br />" +
                    "<a href='" + activatePath + "' runat='server' >" + activatePath + "</a>" +
                    "<br /><br />Now you can login with Yard E-Cart<br />" +
                    "<a href='" + serverPath + "' runat='server' >" + serverPath + "</a>" +
                    "<br /><br />Or you can reset password with below link<br />" +
                    "<a href='" + resetPath + "' runat='server' >" + resetPath + "</a>" +
                    "<br /><br /><br /><br />All the best,<br />Yard E-Cart.</div></form></body></html>";
                }
                else
                {
                    mMsg = "<html><body><form id='form1' runat='server'><div>" +
                    "Dear " + strUsername + ",<br /><br />As you request, your username and password is given below:<br><br>" +
                    "<b>UserName : "******"<br>Password : "******"</b>" +
                    "<br /><br />Now you can login with Yard E-Cart<br />" +
                    "<a href='" + serverPath + "' runat='server' >" + serverPath + "</a>" +
                    "<br /><br />Or you can reset password with below link<br />" +
                    "<a href='" + resetPath + "' runat='server' >" + resetPath + "</a>" +
                    "<br /><br /><br /><br />All the best,<br />Yard E-Cart.</div></form></body></html>";

                }
                UtilityClass.SendMail(mUname, mPwd, mFrom, mTo, mCC, mSubject, mMsg, true);

                tblMessage.InnerText = "User Name and Password are sending to " + txtEmail.Text.Trim() + ". Check your mail..";
                txtEmail.Text = "";
            }
            else
            {
                lblError.Visible = true;
                lblError.Text = "Please enter your correct E-mail address.";
            }
        }
Ejemplo n.º 11
0
        void BindAlbumGrid()
        {
            int k = GridView1.PageCount;
            GridView1.Controls.Clear();

            //gridpageIndex = 0;
            UserInfoBll objUser = new UserInfoBll();
            dt = objUser.SelectUserPurchases(Convert.ToInt32(Session["UserId"].ToString()));
            lblCart.Text = dt.Rows.Count.ToString() + " Items in Your Purchase";

            if (dt.Rows.Count > 4)
            {
                decimal dPageSize = (dt.Rows.Count / 4M);
                //GridView1.PagerSettings.PageButtonCount = Convert.ToInt32(Math.Floor(dPageSize));
                //GridView1.PageSize = Convert.ToInt32(Math.Ceiling(dPageSize));
            }
            GridView1.DataSource = dt.DefaultView;
            GridView1.DataBind();
        }
Ejemplo n.º 12
0
        void LoadUsers()
        {
            objUser = new UserInfoBll();
            if (txtSearch.Text.ToString().Trim() == "")
            dt = objUser.SelectAllProfile();
            else
                dt = objUser.SearchUsers(txtSearch.Text.ToString().Trim());
            GridView1.DataSource = dt;
            GridView1.DataBind();

            if (dt.Rows.Count > 0)
            {
                tblUser.Visible = true;
                lblError.Visible = false;
            }
            else
            {
                tblUser.Visible = false;
                lblError.Visible = true;
                lblError.Text = "No Users";
            }
        }
Ejemplo n.º 13
0
        protected void btnSaveAd_Click(object sender, EventArgs e)
        {
            //string str = fileuploadImg.PostedFile.FileName;
            HttpFileCollection fileCollection = Request.Files;
            for (int i = 0; i < fileCollection.Count; i++)
            {
                HttpPostedFile uploadfile = fileCollection[i];
                string fileName = Path.GetFileName(uploadfile.FileName);
            }
                AdDetailsBll adbll = new AdDetailsBll();

            UserInfoBll usrinfo = new UserInfoBll();
            dt = usrinfo.SelectProfile(Convert.ToInt32(strUserId)); // userid
            try
            {

                #region .. CREATE AD POST ..

                int intAdpostId = adbll.CreateAdPost(
                    Convert.ToInt32(strAdpostId),
                    txtTitle.Text.ToString(),
                    txtDesc.Text.ToString(),
                    txtKeywords.Text.ToString(),
                    Convert.ToInt32(strUserId),
                    Convert.ToInt32(ddlCategory.SelectedItem.Value.ToString()),
                    Convert.ToDecimal(txtPrice.Text.ToString()),
                    Convert.ToInt32(dt.Rows[0]["StateId"].ToString()),
                    Convert.ToInt32(dt.Rows[0]["CityId"].ToString()),
                    Convert.ToInt32(dt.Rows[0]["CountryId"].ToString()),
                    dt.Rows[0]["ZipCode"].ToString(),
                    Convert.ToDateTime(DatePicker1.SelectedDate.ToString()),
                    "NEW",
                    0
                    );

                #endregion

                adbll.CreateAdImageDetails(Convert.ToInt32(strImageId), Convert.ToInt32(strAdpostId), strAllImgPath, txtVidolink.Text.ToString());

                Response.Redirect("MyAdposts.aspx");

            }
            catch (System.Threading.ThreadAbortException th)
            {
            }
            catch (Exception ex)
            {
            }
        }
Ejemplo n.º 14
0
        protected void btnRegister_Click(object sender, EventArgs e)
        {
            UserInfoBll userBll = new UserInfoBll();
            UserProfile userProfile = new UserProfile();

            try
            {
                string ErrorMsg = "";
                userProfile.UserId = 0;
                userProfile.FirstName = txtFirstname.Text.ToString().Trim();
                userProfile.LastName = txtLastname.Text.ToString().Trim();
                userProfile.Email = txtEmail.Text.ToString().Trim();
                userProfile.UserName = txtUsername.Text.ToString().Trim();
                userProfile.UserPassword = txtPassword.Text.ToString().Trim();
                userProfile.Address = txtAddress.Text.ToString().Trim();
                userProfile.Mobile = txtMobile.Text.ToString().Trim();
                userProfile.StreetName = txtStreetname.Text.ToString().Trim();
                userProfile.CityId = Convert.ToInt32(ddlCity.SelectedItem.Value.ToString().Trim());
                userProfile.StateId = Convert.ToInt32(ddlState.SelectedItem.Value.ToString().Trim());
                userProfile.ZipCode = txtZipcode.Text.ToString().Trim();
                userProfile.CountryId = Convert.ToInt32(ddlCountry.SelectedItem.Value.ToString().Trim());
                userProfile.Gender = int.Parse(RadioButtonList1.SelectedItem.Value.ToString().Trim());
                ErrorMsg = "Error:";
                int intErrorCount = 0;

                UserCheck();

                if (this.intUserAvail == 1)
                    intErrorCount++;

                if (txtPassword.Text != txtRePassword.Text)
                {
                    //errPwd.Text = "Password mismatch";
                    //errPwd.Visible = true;
                    intErrorCount++;
                }
                //else
                    //errPwd.Visible = false;

                if (chkYardecart.Checked==false)
                {
                    ErrCheck.Text = "Please check signup";
                    ErrCheck.Visible = true;
                    intErrorCount++;
                }
                else
                    ErrCheck.Visible = false;

                MailCheck();
                if (intMailAvail == 1)
                {
                    intErrorCount++;
                    lblErrorEmail.Visible = true;
                }
                else
                    lblErrorEmail.Visible = false;

                if (chkYardecart.Checked == true && intErrorCount == 0)
                {
                    int x = userBll.CreateUserInfo(userProfile);
                    //HttpContext.Current.Session.Add("UserId", x);

                    SendMailtoUser(x);
                    Response.Redirect("Success.aspx");
                }

            }
            catch (System.Threading.ThreadAbortException th)
            {

            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message;
                lblError.Visible = true;
            }
        }
Ejemplo n.º 15
0
 void UserCheck()
 {
     //string sourcepath = "";
     UserInfoBll userBll = new UserInfoBll();
     DataTable dt = userBll.AvailableUser(txtUsername.Text.ToString().Trim());
     if (dt.Rows.Count == 0 && txtUsername.Text.ToString().Trim() !=  "")
     {
         intUserAvail = 0;
         //checkUser.Visible = true;
         imgAvailable.Visible = true;
         imgNotAvailable.Visible = false;
     }
     else
     {
         intUserAvail = 1;
         imgAvailable.Visible = false;
         imgNotAvailable.Visible = true;
     }
 }
Ejemplo n.º 16
0
 void MailCheck()
 {
     UserInfoBll userBll = new UserInfoBll();
     DataTable dt = userBll.AvailableMail(txtEmail.Text.ToString().Trim());
     if (dt.Rows.Count == 0)
     {
         intMailAvail = 0;
     }
     else
     {
         intMailAvail = 1;
     }
 }
Ejemplo n.º 17
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            UserInfoBll userInfoBll = new UserInfoBll();;
            int intErr = 0;

            try
            {
                int userId = userInfoBll.ValidateUser(UserName.Text.Trim(), Password.Text.Trim());
                if (string.IsNullOrEmpty(userId.ToString().Trim()))
                {
                    intErr = 1;
                    lblError.Text = "Invalid Username and Password! Please try again.";
                    lblError.Visible = false;
                }
                else
                {
                    Session.Abandon();
                    Session.RemoveAll();

                    if (Session["UserId"] == null)
                        Session.Add("UserId", userId.ToString());
                    else
                        Session.Add("UserId", userId.ToString());

                    if (Session["UserType"] == null)
                        Session.Add("UserType", "1");
                    Session.Add("IsLoginUser", "true");

                    // Use this line when you want to save a cookie
                    Response.Cookies["TIS"].Value = userId.ToString() + ";" + "true";

                    // How long will cookie exist on client hard disk
                    Response.Cookies["TIS"].Expires = DateTime.Now.AddDays(10);

                    HttpCookie cUserId = new HttpCookie("UserId", userId.ToString().Trim());
                    HttpCookie cUsertype = new HttpCookie("UserType", "1");
                    cUserId.Expires = DateTime.Now.AddDays(5);
                    cUsertype.Expires = DateTime.Now.AddDays(5);
                    Response.Cookies.Add(cUserId);
                    Response.Cookies.Add(cUsertype);

                    if (RememberMe.Checked == true)
                    {
                        //Response.Cookies.Clear();
                        HttpCookie cUsername = new HttpCookie("UserName", UserName.Text.ToString().Trim());
                        HttpCookie cPassword = new HttpCookie("Password", Password.Text.ToString().Trim());
                        cUsername.Expires = DateTime.Now.AddDays(5);
                        cPassword.Expires = DateTime.Now.AddDays(5);

                        Response.Cookies.Add(cUsername);
                        Response.Cookies.Add(cPassword);
                    }
                }
            }
            catch (System.Threading.ThreadAbortException)
            {
            }
            catch (Exception ex)
            {
                FailureText.Text = ex.Message.ToString();

                intErr = 1;
                lblError.Text = ex.Message.ToString();
                lblError.Visible = false;
            }

            if(intErr==0)
            Response.Redirect("Default.aspx?uid="+Session["UserId"].ToString());
        }
Ejemplo n.º 18
0
        protected void btnAddPost_Click(object sender, EventArgs e)
        {
            if (Session["UserId"] == null)
            {
                Response.Redirect("Login.aspx");
            }
            else
            {
                #region .. VALIDATION ..

                int intError = 0;
                if (DatePicker1.SelectedDate.ToString() == "1/1/0001 12:00:00 AM")
                {
                    intError++;
                    ErrDate.Visible = true;
                    ErrDate.Text = "Select Date";
                }
                if (ddlCategory.SelectedIndex == 0)
                {
                    intError++;
                    ErrCategory.Text = "Select Category";
                    ErrCategory.Visible = true;
                }

                if (FileUpload1.HasFile)
                {
                    if (FileUpload1.PostedFile.ContentLength > 1048576)
                    {
                        errFile1.Visible = true;
                        errFile1.Text = "Exceeds maximum limit 1 MB";
                        intError++;
                    }
                    else
                        errFile1.Visible = false;
                }
                if (FileUpload2.HasFile)
                {
                    if (FileUpload2.PostedFile.ContentLength > 1048576)
                    {
                        errFile2.Visible = true;
                        errFile2.Text = "Exceeds maximum limit 1 MB";
                        intError++;
                    }
                    else
                        errFile2.Visible = false;
                }
                if (FileUpload3.HasFile)
                {
                    if (FileUpload3.PostedFile.ContentLength > 1048576)
                    {
                        errFile3.Visible = true;
                        errFile3.Text = "Exceeds maximum limit 1 MB";
                        intError++;
                    }
                    else
                        errFile3.Visible = false;
                }
                if (FileUpload4.HasFile)
                {
                    if (FileUpload4.PostedFile.ContentLength > 1048576)
                    {
                        errFile4.Visible = true;
                        errFile4.Text = "Exceeds maximum limit 1 MB";
                        intError++;
                    }
                    else
                        errFile4.Visible = false;
                }
                if (FileUpload5.HasFile)
                {
                    if (FileUpload5.PostedFile.ContentLength > 1048576)
                    {
                        errFile5.Visible = true;
                        errFile5.Text = "Exceeds maximum limit 1 MB";
                        intError++;
                    }
                    else
                        errFile5.Visible = false;
                }

                #endregion

                if (intError == 0)
                {
                AdDetailsBll adbll = new AdDetailsBll();

                UserInfoBll usrinfo = new UserInfoBll();
                DataTable dt = usrinfo.SelectProfile(Convert.ToInt32(Session["UserId"].ToString())); // userid
                try
                {

                    #region .. CREATE AD POST ..

                    int intAdpostId = adbll.CreateAdPost(
                        0,
                        txtTitle.Text.ToString(),
                        txtDesc.Text.ToString(),
                        txtKeywords.Text.ToString(),
                        Convert.ToInt32(Session["UserId"].ToString()),
                        Convert.ToInt32(ddlCategory.SelectedItem.Value.ToString()),
                        Convert.ToDecimal(txtPrice.Text.ToString()),
                        Convert.ToInt32(dt.Rows[0]["StateId"].ToString()),
                        Convert.ToInt32(dt.Rows[0]["CityId"].ToString()),
                        Convert.ToInt32(dt.Rows[0]["CountryId"].ToString()),
                        dt.Rows[0]["ZipCode"].ToString(),
                            Convert.ToDateTime(DatePicker1.SelectedDate.ToString()),
                        "NEW",
                        0
                        );

                    #endregion

                    #region .. CREATE AD POST IMAGE ..

                    string path = string.Empty;
                    string strImgFinalPath = "";
                    string finalPath = string.Empty;
                    string filePath = string.Empty;
                    int userId = Convert.ToInt32(Session["UserId"].ToString());
                    string sFilename = "";
                    if (FileUpload1.PostedFile != null)
                    {
                        HttpPostedFile myFile = FileUpload1.PostedFile;
                        int nFileLen = myFile.ContentLength;
                        if (nFileLen != 0)
                        {
                            DirectoryInfo dirInfo = null;
                            fileSavePath = "/Data/TS_" + userId + "/Images/";
                            path = Server.MapPath("~" + fileSavePath);
                            if (!Directory.Exists(path))
                            {
                                dirInfo = Directory.CreateDirectory(path);
                            }
                            sFilename = System.IO.Path.GetFileName(myFile.FileName);
                            path = path + "/" + sFilename;
                            FileUpload1.PostedFile.SaveAs(path);

                            finalPath = Path.Combine(fileSavePath, sFilename);
                        }
                    }
                    strImgFinalPath = finalPath;

                    if (FileUpload2.PostedFile != null)
                    {
                        HttpPostedFile myFile = FileUpload2.PostedFile;
                        int nFileLen = myFile.ContentLength;
                        if (nFileLen != 0)
                        {
                            path = Server.MapPath("~" + fileSavePath);
                            sFilename = System.IO.Path.GetFileName(myFile.FileName);
                            path = path + "/" + sFilename;
                            FileUpload2.PostedFile.SaveAs(path);

                            finalPath = Path.Combine(fileSavePath, sFilename);

                            strImgFinalPath = strImgFinalPath + ":" + finalPath;
                        }
                    }

                    if (FileUpload3.PostedFile != null)
                    {
                        HttpPostedFile myFile = FileUpload3.PostedFile;
                        int nFileLen = myFile.ContentLength;
                        if (nFileLen != 0)
                        {
                            path = Server.MapPath("~" + fileSavePath);
                            sFilename = System.IO.Path.GetFileName(myFile.FileName);
                            path = path + "/" + sFilename;
                            FileUpload3.PostedFile.SaveAs(path);

                            finalPath = Path.Combine(fileSavePath, sFilename);
                            strImgFinalPath = strImgFinalPath + ":" + finalPath;
                        }
                    }

                    if (FileUpload4.PostedFile != null)
                    {
                        HttpPostedFile myFile = FileUpload4.PostedFile;
                        int nFileLen = myFile.ContentLength;
                        if (nFileLen != 0)
                        {
                            path = Server.MapPath("~" + fileSavePath);
                            sFilename = System.IO.Path.GetFileName(myFile.FileName);
                            path = path + "/" + sFilename;
                            FileUpload4.PostedFile.SaveAs(path);

                            finalPath = Path.Combine(fileSavePath, sFilename);
                            strImgFinalPath = strImgFinalPath + ":" + finalPath;
                        }
                    }

                    if (FileUpload5.PostedFile != null)
                    {
                        HttpPostedFile myFile = FileUpload5.PostedFile;
                        int nFileLen = myFile.ContentLength;
                        if (nFileLen != 0)
                        {
                            path = Server.MapPath("~" + fileSavePath);
                            sFilename = System.IO.Path.GetFileName(myFile.FileName);
                            path = path + "/" + sFilename;
                            FileUpload5.PostedFile.SaveAs(path);

                            finalPath = Path.Combine(fileSavePath, sFilename);
                            strImgFinalPath = strImgFinalPath + ":" + finalPath;
                        }
                    }

                    adbll.CreateAdImageDetails(0, intAdpostId, strImgFinalPath, txtVidolink.Text.ToString());

                    #endregion

                    Response.Redirect("ViewAds.aspx?aid=" + intAdpostId.ToString() + "&uid=" + Session["UserId"].ToString());

                }
                catch (System.Threading.ThreadAbortException th)
                {
                }
                catch (Exception ex)
                {
                }
            }
            }
        }