protected void btnUpdate_Click(object sender, EventArgs e)
        {
            if (IsValidUpdate())
            {
                using (MSIPortalContext ctx = new MSIPortalContext())
                {
                    LU_tbl_City cityToBeUpdate = (LU_tbl_City)Session["LU_tbl_City_ToEdit"];

                    cityToBeUpdate.CityName = txtCityForEdit.Text;
                    if (((tbl_User)Session["User"]) != null)
                    {
                        cityToBeUpdate.EditUser = ((tbl_User)Session["User"]).UserID;  // User
                    }
                    cityToBeUpdate.EditDate = DateTime.Now;


                    ctx.LU_tbl_City.Attach(cityToBeUpdate);
                    ctx.Entry(cityToBeUpdate).State = System.Data.Entity.EntityState.Modified;
                    ctx.SaveChanges();

                    this.BindGrid();
                    TabContainer1.ActiveTabIndex = 1;
                    TabPanelEditCity.Visible     = false;
                }
            }
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (IsValid())
            {
                using (MSIPortalContext ctx = new MSIPortalContext())
                {
                    try
                    {
                        LU_tbl_City city        = new LU_tbl_City();
                        var         maxId       = ctx.LU_tbl_City.Select(c => c.CityID).Max(); // Select Max Id
                        int         newId       = Convert.ToInt32(maxId) + 1;
                        string      newStringId = newId.ToString("D3");

                        city.CityID   = newStringId;
                        city.CityName = txtCity.Text.Trim();
                        city.EditUser = ((tbl_User)Session["User"]).UserID;
                        city.EditDate = DateTime.Now;

                        ctx.LU_tbl_City.Add(city);
                        ctx.SaveChanges();
                        cpSuccessMessage.Text = "City added successfully";
                        this.BindGrid();
                        cpErrorMessage.Text = string.Empty;
                        txtCity.Text        = string.Empty;
                        txtCity.Focus();
                        MessagePanel.Visible = true;
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }
        }
        private void UpdateRank()
        {
            //============Initialize Post Table
            using (MSIPortalContext ctx = new MSIPortalContext())
            {
                //try
                //{
                string   id      = hiddenPostId.Value;
                var      posting = from post in ctx.tbl_Post where post.PostID == new Guid(id) select post;
                tbl_Post objPost = posting.ToList <tbl_Post>().FirstOrDefault <tbl_Post>();

                objPost.Rank = Convert.ToInt32(ddlRank.SelectedValue); // Only Rank WIll Update
                ctx.tbl_Post.Attach(objPost);
                ctx.Entry(objPost).State = System.Data.Entity.EntityState.Modified;
                ctx.SaveChanges();
                ////---------------After Successful Update Do the following operation
                MessagePanel.Visible = true;
                //lblSuccessMessage.Visible = true;
                //lblSuccessMessage.Text = "Rank updated suffessfully.";
                TabContainer1.ActiveTabIndex = 1;
                TabPanelEditRank.Visible     = false;


                // GEt Parameter for Bind DataGrid
                string cat  = ddlSearchCategory.SelectedValue;
                string city = ddlCity.SelectedValue;
                string type = string.Empty;

                if (rdoProduct.Checked)
                {
                    type = "001";
                }
                else
                {
                    type = "002";
                }

                BinGridData(cat, city, type);
                TabContainer1.ActiveTabIndex = 0;

                //}
                //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
            }
        }
Exemple #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
                }
            }
        }
Exemple #5
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            MSIPortalContext ctx = new MSIPortalContext();
            tbl_Post         ads = new tbl_Post();

            ads.PostTitle       = this.txtTitle.Text;
            ads.PostDescription = this.txtDescription.Text;
            //ads.AdImage = FileUpload1.FileBytes;
            ads.CategoryID = "1";
            ctx.tbl_Post.Add(ads);
            ctx.SaveChanges();
        }
Exemple #6
0
        protected void btnApprove_Click(object sender, EventArgs e)
        {
            using (MSIPortalContext ctx = new MSIPortalContext())
            {
                string id = Request.QueryString["ID"];
                if (id != string.Empty)
                {
                    var      posting       = from post in ctx.tbl_Post where post.PostID == new Guid(id) select post;
                    tbl_Post postingDetail = posting.ToList <tbl_Post>().FirstOrDefault <tbl_Post>();

                    postingDetail.Approved         = true;
                    ctx.Entry(postingDetail).State = EntityState.Modified;
                    ctx.SaveChanges();
                    Response.Redirect("ApprovePost.aspx");
                }
            }
        }
        protected void btnApprove_Click(object sender, EventArgs e)
        {
            MaintainCheckedId();// Put Checked Id to Session
            List <string> approvalList = (List <string>)Session["ListId"];

            using (MSIPortalContext ctx = new MSIPortalContext())
            {
                foreach (string id in approvalList)
                {
                    tbl_Post post = ctx.tbl_Post.Where(p => p.PostID == new Guid(id)).FirstOrDefault <tbl_Post>();
                    post.Approved         = true;
                    ctx.Entry(post).State = EntityState.Modified;
                    ctx.SaveChanges();
                }
            }
            BinGridData();
        }
Exemple #8
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            using (MSIPortalContext ctx = new MSIPortalContext())
            {
                var    maxId       = ctx.LU_tbl_Category.Select(c => c.CategoryID).Max(); // Select Max Id
                int    newId       = Convert.ToInt32(maxId) + 1;
                string newStringId = newId.ToString("D4");

                var count = ctx.LU_tbl_Category.Where(c => c.CategoryName.Trim() == txtCategiryName.Text.Trim()).Count(); // Count Based on given Category Name

                if (Convert.ToInt32(count) > 0)                                                                           // Duplicacy Check
                {
                    lblError.Text        = "Duplicate entry not allowed.";
                    lblSuccess.Text      = string.Empty;
                    MessagePanel.Visible = true;
                }
                else
                {
                    if (TreeView1.SelectedNode == null)   // Validate if parent node is not selected
                    {
                        lblError.Text        = "Parent node must be selected.";
                        lblSuccess.Text      = string.Empty;
                        MessagePanel.Visible = true;
                        return;
                    }

                    LU_tbl_Category category = new LU_tbl_Category();
                    category.CategoryID   = newStringId;
                    category.ParentCatID  = TreeView1.SelectedNode.Value.ToString();
                    category.CategoryName = txtCategiryName.Text.Trim();
                    category.PSTID        = ddlSalesService.SelectedValue;
                    category.EditUser     = Guid.NewGuid(); // Needs Modification Will Come from Login Session
                    category.EditDate     = DateTime.Now;
                    ctx.LU_tbl_Category.Add(category);
                    ctx.SaveChanges();
                    lblSuccess.Text               = "Record saved successfully";
                    txtCategiryName.Text          = string.Empty;
                    ddlSalesService.SelectedValue = "000";
                    lblError.Text        = string.Empty;
                    MessagePanel.Visible = true;
                    txtCategiryName.Focus();
                }
            }
            this.PopulateTree();
        }// End of Method Populate Tree
Exemple #9
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (IsValid())
            {
                using (MSIPortalContext ctx = new MSIPortalContext())
                {
                    try
                    {
                        LU_tbl_City city        = new LU_tbl_City();
                        var         maxId       = ctx.LU_tbl_City.Select(c => c.CityID).Max(); // Select Max Id
                        int         newId       = Convert.ToInt32(maxId) + 1;
                        string      newStringId = newId.ToString("D3");

                        city.CityID    = newStringId;
                        city.CityName  = txtCity.Text.Trim();
                        city.CountryID = ddlCountry.SelectedValue;
                        city.EditUser  = ((tbl_User)Session["User"]).UserID;
                        city.EditDate  = DateTime.Now;

                        ctx.LU_tbl_City.Add(city);
                        ctx.SaveChanges();
                        lblSuccessMessage.Text   = "City added successfully";
                        lblErrorMessage.Text     = string.Empty;
                        txtCity.Text             = string.Empty;
                        ddlCountry.SelectedValue = "0";
                        ddlCountry.Focus();
                        MessagePanel.Visible = true;
                    }
                    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
                }
            }
        }
Exemple #10
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();
        }
Exemple #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.";
                }
            }
        }
        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
        }
        protected void btnPost_Click(object sender, EventArgs e)
        {
            //============Initialize Post Table
            using (MSIPortalContext ctx = new MSIPortalContext())
            {
                //try
                //{
                tbl_Post objPost = (tbl_Post)Session["PostTobeModify"];
                objPost.CategoryID = ddlCategory.SelectedValue;
                objPost.CityID     = ddlCommonCity.SelectedValue;
                LU_tbl_City city = ctx.LU_tbl_City.Where(c => c.CityID == ddlCommonCity.SelectedValue).FirstOrDefault <LU_tbl_City>();
                objPost.LU_tbl_City = city;

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

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


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

                //}



                //objPost.PostingUserID = ((tbl_User)Session["User"]).UserID;  // As it has benn already posted so no need to modify
                objPost.ProviderFirstName = txtCommonProviderFirstName.Text.Trim();
                objPost.ProviderLastName  = txtCommonProviderLastName.Text.Trim();
                objPost.ProviderAddress   = txtCommonProviderAddress.Text.Trim();
                objPost.ProviderEmail     = txtCommonProviderEmil.Text.Trim();
                objPost.ProviderPhoneNo   = txtCommonProviderPhone.Text.Trim();
                //objPost.Approved = false;
                if (((tbl_User)Session["User"]) != null)
                {
                    objPost.EditUser = ((tbl_User)Session["User"]).UserID;      // User
                }
                objPost.EditDate = DateTime.Now;

                ctx.tbl_Post.Attach(objPost);
                ctx.Entry(objPost).State = System.Data.Entity.EntityState.Modified;

                ctx.SaveChanges();
                ////---------------After Successful Save Do the following operation
                //MessagePanel.Visible = true;
                //lblSuccessMessage.Visible = true;
                this.BindGrid();
                TabContainer1.ActiveTabIndex = 2;
                TabPanelEditPost.Visible     = false;
                //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)
                //{


                //}// End of Catch
            }
        }
Exemple #14
0
        private void UpdatePost()
        {
            //============Initialize Post Table
            using (MSIPortalContext ctx = new MSIPortalContext())
            {
                //try
                //{
                string   id      = Request.QueryString["ID"];
                var      posting = from post in ctx.tbl_Post where post.PostID == new Guid(id) select post;
                tbl_Post objPost = posting.ToList <tbl_Post>().FirstOrDefault <tbl_Post>();


                objPost.CategoryID = ddlCategory.SelectedValue;
                objPost.CityID     = ddlCommonCity.SelectedValue;
                // LU_tbl_City city = ctx.LU_tbl_City.Where(c => c.CityID == ddlCommonCity.SelectedValue).FirstOrDefault<LU_tbl_City>();
                //objPost.LU_tbl_City = city;

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

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


                if (commonImageUpload.PostedFile != null && commonImageUpload.PostedFile.FileName != string.Empty)
                {
                    commonImageUpload.SaveAs(Server.MapPath("~/imageupload/" + objPost.PostID + ".jpg"));
                    objPost.ImageUrl = "/imageupload/" + objPost.PostID + ".jpg";
                }



                //objPost.PostingUserID = ((tbl_User)Session["User"]).UserID;  // As it has benn already posted so no need to modify
                objPost.ProviderFirstName = txtCommonProviderFirstName.Text.Trim();
                objPost.ProviderLastName  = txtCommonProviderLastName.Text.Trim();
                objPost.ProviderAddress   = txtCommonProviderAddress.Text.Trim();
                objPost.ProviderEmail     = txtCommonProviderEmil.Text.Trim();
                objPost.ProviderPhoneNo   = txtCommonProviderPhone.Text.Trim();
                //objPost.Approved = false;
                if (((tbl_User)Session["User"]) != null)
                {
                    objPost.EditUser = ((tbl_User)Session["User"]).UserID;  // User
                }
                objPost.EditDate = DateTime.Now;

                ctx.tbl_Post.Attach(objPost);
                ctx.Entry(objPost).State = System.Data.Entity.EntityState.Modified;

                ctx.SaveChanges();
                ////---------------After Successful Update Do the following operation
                MessagePanel.Visible      = true;
                lblSuccessMessage.Visible = true;
                lblSuccessMessage.Text    = "Record updated suffessfully.";
                this.FillDetails(); // Update Display View of Details As well
                TabContainer1.ActiveTabIndex = 0;

                //}
                //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
            }
        }