Example #1
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            using (MSIPortalContext ctx = new MSIPortalContext())
            {
                var user = from u in ctx.tbl_User
                           join p in ctx.tbl_UserPassword on u.UserID equals p.UserID
                           where u.LoginName == txtUserName.Text.Trim() && p.Password == txtPassword.Text.Trim()
                           select u;

                List <tbl_User> userList = user.ToList <tbl_User>();

                if (userList.Count > 0)
                {
                    tbl_User singleUser = userList.FirstOrDefault <tbl_User>();
                    if (singleUser.RoleID.Trim() == "001") // Admin User
                    {
                        Session.Add("User", singleUser);
                        Response.Redirect("AdminPanel.aspx");
                    }
                    else
                    {
                        Session.Add("User", singleUser);
                        Response.Redirect("UserLoggedinHome.aspx");
                    }
                }
                else
                {
                    lblMessage.Text      = "Incorrect UserName/Password.";
                    MessagePanel.Visible = true;
                }
            }
        }
        protected void txtPassword_TextChanged(object sender, EventArgs e)
        {
            if (this.FindUserByEmailAndPassword() != null && this.FindUserByEmailAndPassword().Count > 0)
            {
                tbl_User user = FindUserByEmailAndPassword().FirstOrDefault <tbl_User>();
                FillAboutYouSecttion(user);
                commonImageUpload.Focus();
            }
            else
            {
                //Enabled The controls
                txtConfirmPassword.Enabled = true;
                txtUserFirstlName.Enabled  = true;
                txtUserLastName.Enabled    = true;

                ddlUserLocation.Enabled = true;


                //Set Empty Value
                txtConfirmPassword.Text       = string.Empty;
                txtUserFirstlName.Text        = string.Empty;
                txtUserLastName.Text          = string.Empty;
                ddlUserLocation.SelectedValue = "0";

                txtConfirmPassword.Focus();
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                BindGrid();


                TabContainer1.ActiveTabIndex = 0;
                TabPanelEditPost.Visible     = false;

                if (Session["User"] != null)
                {
                    tbl_User user = (tbl_User)Session["User"];
                    lblFirstName.Text = user.FirstName.Trim();
                    lblLastName.Text  = user.LastName.Trim();
                    lblLoginName.Text = user.LoginName.Trim();
                    lblUserRole.Text  = "Ordinary User";
                }

                //=============On EditPost is activated

                this.FillCommonCountry();
                this.FillCategoryDropDownBox();
                this.FillAllCity();
            }
        }
Example #4
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            this.ClearMessagePanel();

            if (IsValid())
            {
                using (MSIPortalContext ctx = new MSIPortalContext())
                {
                    try
                    {
                        // Setup User
                        tbl_User user = new tbl_User();
                        user.UserID    = Guid.NewGuid();
                        user.LoginName = txtEmail.Text.Trim();
                        user.FirstName = txtFirstName.Text.Trim();
                        user.LastName  = txtLastName.Text.Trim();
                        user.RoleID    = ddlUserType.SelectedValue;
                        user.CityID    = ddlCity.SelectedValue;
                        user.IsActive  = true;
                        user.EditUser  = ((tbl_User)Session["User"]).UserID;
                        user.EditDate  = DateTime.Now;

                        //Setup Password
                        tbl_UserPassword pass = new tbl_UserPassword();
                        pass.UserID   = user.UserID;
                        pass.Password = txtPassword.Text.Trim();
                        pass.EditUser = ((tbl_User)Session["User"]).UserID;
                        pass.EditDate = DateTime.Now;

                        ctx.tbl_User.Add(user);
                        ctx.tbl_UserPassword.Add(pass);
                        ctx.SaveChanges();
                        this.ClearForm();
                        lblSuccessMessage.Text = "User created successfully.";
                        lblErrorMessage.Text   = string.Empty;
                        MessagePanel.Visible   = true;
                        txtEmail.Focus();
                        this.BindGrid();
                    }
                    catch (DbEntityValidationException dbEx)
                    {
                        foreach (var validationErrors in dbEx.EntityValidationErrors)
                        {
                            foreach (var validationError in validationErrors.ValidationErrors)
                            {
                                Trace.Write("Property: {0} Error: {1}" + validationError.PropertyName, validationError.ErrorMessage);
                            }
                        }
                    }
                    catch (Exception Ex)
                    {
                    }// End of Catch
                }
            }
        }
        private void BindGrid()
        {
            using (MSIPortalContext ctx = new MSIPortalContext())
            {
                tbl_User user = (tbl_User)Session["User"];

                var list = from p in ctx.tbl_Post where p.PostingUserID == user.UserID orderby p.EditDate descending select p;

                if (list != null)
                {
                    GridView1.DataSource = list.ToList <tbl_Post>();
                    GridView1.DataBind();
                }
            }
        }
Example #6
0
        protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            GridView1.EditIndex = -1;
            GridViewRow row       = GridView1.Rows[e.RowIndex];
            string      loginName = row.Cells[0].Text;
            string      roleId    = ((DropDownList)(row.Cells[5].Controls[1])).SelectedValue;

            using (MSIPortalContext ctx = new MSIPortalContext()) {
                var      varUser = from u in ctx.tbl_User where u.LoginName == loginName select u;
                tbl_User user    = varUser.FirstOrDefault <tbl_User>();
                user.RoleID           = roleId;
                user.EditUser         = ((tbl_User)Session["User"]).UserID;
                ctx.Entry(user).State = EntityState.Modified;
                ctx.SaveChanges();
            }


            this.BindGrid();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            tbl_User user = (tbl_User)Session["User"];

            if (user != null)
            {
                if (user.RoleID == "001")
                {
                    Server.Transfer("AdminPanel.aspx");
                }
                else
                {
                    Server.Transfer("UserLoggedinHome.aspx");
                }
            }
            else
            {
                Response.Redirect("Home.aspx");
            }
        }
Example #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            tbl_User user = (tbl_User)Session["User"];

            if (user == null)
            {
                Response.Redirect("AccessDenied.aspx");
            }
            else
            {
                if (user.RoleID.Trim() != "001")
                {
                    Response.Redirect("AccessDenied.aspx");
                }
            }

            ImageButtonUser.Attributes.Add("onmouseover", "src='Styles/Images/userMO.png'");
            ImageButtonUser.Attributes.Add("onmouseout", "src='Styles/Images/user.png'");


            ImageButtonCountry.Attributes.Add("onmouseover", "src='Styles/Images/countryMO.png'");
            ImageButtonCountry.Attributes.Add("onmouseout", "src='Styles/Images/country.png'");

            ImageButtonCity.Attributes.Add("onmouseover", "src='Styles/Images/cityMO.png'");
            ImageButtonCity.Attributes.Add("onmouseout", "src='Styles/Images/city.png'");

            ImageButtonCategory.Attributes.Add("onmouseover", "src='Styles/Images/categoryMO.png'");
            ImageButtonCategory.Attributes.Add("onmouseout", "src='Styles/Images/category.png'");

            ImageButtonApprove.Attributes.Add("onmouseover", "src='Styles/Images/approveMO.png'");
            ImageButtonApprove.Attributes.Add("onmouseout", "src='Styles/Images/approve.png'");

            ImageButtonSearch.Attributes.Add("onmouseover", "src='Styles/Images/searchMO.png'");
            ImageButtonSearch.Attributes.Add("onmouseout", "src='Styles/Images/search.png'");

            ImageButtonRank.Attributes.Add("onmouseover", "src='Styles/Images/rankMO.png'");
            ImageButtonRank.Attributes.Add("onmouseout", "src='Styles/Images/rank.png'");

            ImageButtonAdvertisement.Attributes.Add("onmouseover", "src='Styles/Images/AdvertisementsMO.png'");
            ImageButtonAdvertisement.Attributes.Add("onmouseout", "src='Styles/Images/Advertisements.png'");
        }
        private void FillAboutYouSecttion(tbl_User user)
        {
            tbl_UserPassword pass = FindPasswordByUserId(user.UserID).FirstOrDefault <tbl_UserPassword>();

            txtUserEmail.Text             = user.LoginName.Trim();
            txtPassword.Text              = pass.Password.Trim();
            txtConfirmPassword.Text       = pass.Password.Trim();
            txtUserFirstlName.Text        = user.FirstName.Trim();
            txtUserLastName.Text          = user.LastName.Trim();
            ddlUserLocation.SelectedValue = user.CityID.Trim();


            //Disable Controls
            txtUserEmail.Enabled        = false;
            txtPassword.Enabled         = false;
            txtConfirmPassword.Enabled  = false;
            txtUserFirstlName.Enabled   = false;
            txtUserLastName.Enabled     = false;
            ddlUserLocation.Enabled     = false;
            lblUserEmailValidation.Text = string.Empty;
        }
 public static string[] ReturnUserData(string email, string password)
 {
     using (MSIPortalContext ctx = new MSIPortalContext())
     {
         var user = from u in ctx.tbl_User
                    join p in ctx.tbl_UserPassword on u.UserID equals p.UserID
                    where u.LoginName == email && p.Password == password
                    select u;
         tbl_User objUser = user.FirstOrDefault <tbl_User>();
         if (objUser != null)
         {
             string[] names = new string[4] {
                 password, objUser.FirstName, objUser.LastName, objUser.CityID
             };
             return(names);
         }
         else
         {
             return(null);
         }
     }
 }
Example #11
0
        protected void btnUpdatePassword_Click(object sender, EventArgs e)
        {
            tbl_User user = (tbl_User)Session["User"];

            using (MSIPortalContext ctx = new MSIPortalContext())
            {
                var pass = from p in ctx.tbl_UserPassword
                           where p.Password == txtExistingPassword.Text.Trim() && p.tbl_User.LoginName == user.LoginName
                           select p;
                tbl_UserPassword password = pass.FirstOrDefault <tbl_UserPassword>();

                if (password != null)
                {
                    if (txtNewPassword.Text.Trim() == txtConfirmNewPassword.Text.Trim())
                    {
                        password.Password         = txtNewPassword.Text.Trim();
                        ctx.Entry(password).State = EntityState.Modified;
                        ctx.SaveChanges();
                        txtExistingPassword.Text   = string.Empty;
                        txtNewPassword.Text        = string.Empty;
                        txtConfirmNewPassword.Text = string.Empty;

                        cpSuccessMessage.Text = "Password changed successfully";
                        cpErrorMessage.Text   = string.Empty;
                        txtExistingPassword.Focus();
                    }
                    else
                    {
                        cpSuccessMessage.Text = string.Empty;
                        cpErrorMessage.Text   = "New password and confirm new password miss match.";
                    }
                }
                else
                {
                    cpSuccessMessage.Text = string.Empty;
                    cpErrorMessage.Text   = "Provided password does not exist.";
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            //============Access Control================
            tbl_User user = (tbl_User)Session["User"];

            if (user == null)
            {
                Response.Redirect("AccessDenied.aspx");
            }
            else
            {
                if (user.RoleID.Trim() != "001")
                {
                    Response.Redirect("AccessDenied.aspx");
                }
            }
            //======================Access Control=============


            if (!Page.IsPostBack)
            {
                Session.Add("ListId", ListId);
                // Fill Search Section
                this.FillSearchCountry();
                this.FillSearchCategory();


                // Fill Edit Rank Section

                this.FillCommonCountry();       // Value Set
                this.FillAllCity();
                this.FillCategoryDropDownBox(); // Value Set.

                //this.SetFieldsForUpdate();
                TabContainer1.ActiveTabIndex = 0;
                TabPanelEditRank.Visible     = false;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                tbl_User user            = (tbl_User)Session["User"];
                int      fileLeftSlider  = Directory.GetFiles(Server.MapPath("~/ads_left/"), "*.*", SearchOption.TopDirectoryOnly).Length;
                int      fileRightSlider = Directory.GetFiles(Server.MapPath("~/ads_right/"), "*.*", SearchOption.TopDirectoryOnly).Length;

                Session["FileCountLeft"]  = fileLeftSlider;
                Session["FileCountRight"] = fileRightSlider;
                if (user != null)
                {
                    WelcomeUserName     = user.FirstName + " " + user.LastName;
                    btnLoginLogout.Text = "Logout";
                }
                else
                {
                    WelcomeUserName     = "******";
                    btnLoginLogout.Text = "Login";
                }
                //
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                this.FillCategoryDropDownBox();
                rdoCommonService.Checked = true;

                this.FillUserLocation();
                this.ClearMessagePanel();
                this.FillCommonCountry();
                // this.FillCommonCity();

                //if User Is Logged in Fill the About U section
                tbl_User user = (tbl_User)Session["User"];
                if (user == null)
                {
                    //FillAboutYouSecttion(user);
                    PanelAboutYou.Visible = true;
                }
                ddlCommonCountry.Focus();
                txtPassword.Attributes["type"]        = "password";
                txtConfirmPassword.Attributes["type"] = "password";
            }
        }
        private void SavePost()
        {
            ClearMessagePanel();
            using (MSIPortalContext ctx = new MSIPortalContext())
            {
                try
                {
                    tbl_Post         post     = new tbl_Post();
                    tbl_User         user     = new tbl_User();
                    tbl_UserPassword password = new tbl_UserPassword();

                    //===========Initialize the User Table
                    if (Session["User"] != null)
                    {
                        user = (tbl_User)Session["User"];
                    }
                    else if (FindUserByEmailAndPassword().Count > 0)
                    {
                        user = FindUserByEmailAndPassword().FirstOrDefault <tbl_User>();
                    }
                    else if (FindUserByEmailAndPassword().Count == 0) // If Existing User but not Logged In  [Eaml&Password Count May be 0]
                    {
                        if (FindUserByEmailOnly().Count == 0)         // Insert only if this email is completely new [Email count may be greater than 0]
                        {
                            //Set User
                            user           = new tbl_User();
                            user.UserID    = Guid.NewGuid();
                            user.LoginName = this.txtUserEmail.Text.Trim();
                            user.FirstName = this.txtUserFirstlName.Text.Trim();
                            user.LastName  = this.txtUserLastName.Text.Trim();
                            user.RoleID    = "02"; // Ordinary User
                            user.CityID    = ddlUserLocation.SelectedValue;
                            user.IsActive  = true;
                            user.EditUser  = user.UserID;
                            user.EditDate  = DateTime.Now;

                            //Set Password
                            password.UserID   = user.UserID;
                            password.Password = txtPassword.Text.Trim();
                            password.EditUser = user.UserID;
                            password.EditDate = DateTime.Now;

                            //Add to Context
                            ctx.tbl_User.Add(user);
                            ctx.tbl_UserPassword.Add(password);
                        }
                        else
                        {
                            MessagePanel.Visible = true;
                            txtUserEmail.Focus();
                            lblUserEmailValidation.Text = "*";
                            lblErrorMessage.Text        = "Already registered email";
                            lblSuccessMessage.Visible   = false;
                            return; // Stop Inserting any Single Record
                        }
                    }

                    //============Initialize Post Table
                    post.PostID     = Guid.NewGuid();
                    post.CategoryID = ddlCategory.SelectedValue;
                    post.CityID     = ddlCommonCity.SelectedValue;


                    if (rdoCommonSales.Checked)
                    {
                        post.PSTID = "001";
                    }
                    else
                    {
                        post.PSTID = "002";
                    }

                    post.PostTitle       = this.txtCommonPostingTitle.Text.Trim();
                    post.PostDescription = this.txtCommonPostingDescription.Text.Trim();



                    if (commonImageUpload.PostedFile.FileName != string.Empty)
                    {
                        commonImageUpload.SaveAs(Server.MapPath("~/imageupload/" + post.PostID + ".jpg"));
                        post.ImageUrl = "/imageupload/" + post.PostID + ".jpg";
                    }
                    else
                    {
                        post.ImageUrl = "/Styles/images/" + "no_image.jpg";
                    }



                    post.PostingUserID     = user.UserID;
                    post.ProviderFirstName = txtCommonProviderFirstName.Text.Trim();
                    post.ProviderLastName  = txtCommonProviderLastName.Text.Trim();
                    post.ProviderAddress   = txtCommonProviderAddress.Text.Trim();
                    post.ProviderEmail     = txtCommonProviderEmil.Text.Trim();
                    post.ProviderPhoneNo   = txtCommonProviderPhone.Text.Trim();
                    post.Approved          = false;
                    post.Rank     = 999; // Default value to make sure out of rank
                    post.EditUser = user.UserID;
                    post.EditDate = DateTime.Now;

                    ctx.tbl_Post.Add(post);
                    ctx.SaveChanges();
                    //---------------After Successful Save Do the following operation
                    MessagePanel.Visible      = true;
                    lblSuccessMessage.Visible = true;
                    lblSuccessMessage.Text    = "Your posting is successful!";
                    //this.SendConfirmationEmail();
                    lblUserEmailValidation.Text = string.Empty;
                    this.ClearForm();
                    ddlCommonCountry.Focus();
                }
                catch (DbEntityValidationException dbEx)
                {
                    foreach (var validationErrors in dbEx.EntityValidationErrors)
                    {
                        foreach (var validationError in validationErrors.ValidationErrors)
                        {
                            Trace.Write("Property: {0} Error: {1}" + validationError.PropertyName, validationError.ErrorMessage);
                        }
                    }
                }
                catch (Exception Ex)
                {
                    Response.Write(Ex.ToString());
                } // End of Catch
            }     // End of Using
        }