コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                using (MSIPortalContext ctx = new MSIPortalContext())
                {
                    string   id            = Request.QueryString["ID"];
                    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>();

                    lblTitle.Text       = postingDetail.PostTitle.Trim();
                    lblName.Text        = postingDetail.ProviderFirstName + " " + postingDetail.ProviderLastName;
                    lblAddress.Text     = postingDetail.ProviderAddress;
                    lblDescription.Text = postingDetail.PostDescription;
                    lblEmail.Text       = postingDetail.ProviderEmail;
                    lblPhone.Text       = postingDetail.ProviderPhoneNo;
                    if (File.Exists(Server.MapPath(postingDetail.ImageUrl)))
                    {
                        itemImage.ImageUrl = postingDetail.ImageUrl;
                    }
                    else
                    {
                        itemImage.ImageUrl = "/Styles/images/image_not_found.jpg";
                    }
                }
            }
        }
コード例 #2
0
        private void SetFieldsForUpdate(string id)
        {
            using (MSIPortalContext ctx = new MSIPortalContext())
            {
                Guid     postId  = new Guid(id);
                var      post    = from p in ctx.tbl_Post where p.PostID == postId select p;
                tbl_Post objPost = post.ToList <tbl_Post>().FirstOrDefault <tbl_Post>();


                this.ddlCommonCountry.SelectedValue   = objPost.LU_tbl_City.LU_tbl_Country.CountryID;
                this.ddlCommonCity.SelectedValue      = objPost.CityID;
                this.ddlCommonCategory.SelectedValue  = objPost.CategoryID;
                this.txtCommonProviderFirstName.Text  = objPost.ProviderFirstName;
                this.txtCommonProviderLastName.Text   = objPost.ProviderLastName;
                this.txtCommonProviderAddress.Text    = objPost.ProviderAddress;
                this.txtCommonProviderEmil.Text       = objPost.ProviderEmail;
                this.txtCommonProviderPhone.Text      = objPost.ProviderPhoneNo;
                this.txtCommonPostingTitle.Text       = objPost.PostTitle;
                this.txtCommonPostingDescription.Text = objPost.PostDescription;
                PSImage.ImageUrl = objPost.ImageUrl + "?id=" + Guid.NewGuid();

                if (objPost.PSTID == "001")
                {
                    rdoCommonSales.Checked = true;
                }
                else
                {
                    rdoCommonService.Checked = true;
                }
                ddlRank.SelectedValue = Convert.ToString(objPost.Rank);
            }
        }
コード例 #3
0
        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
            }
        }
コード例 #4
0
 private tbl_Post GetPost()
 {
     using (MSIPortalContext ctx = new MSIPortalContext())
     {
         string   id            = Request.QueryString["ID"];
         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>();
         return(postingDetail);
     }
 }
コード例 #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();
        }
コード例 #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                tbl_Post post = GetPost();
                FillDetails();
                this.FillCommonCountry();       // Value Set
                this.FillAllCity();
                this.FillCategoryDropDownBox(); // Value Set.

                this.SetFieldsForUpdate();
                TabContainer1.ActiveTabIndex = 0;
            }
        }
コード例 #7
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");
                }
            }
        }
コード例 #8
0
        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();
        }
コード例 #9
0
        //protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        //{
        //    TabPanelEditPost.Visible = true;
        //    TabPanelEditPost.Focus();
        //}



        #region TabYourPost
        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            TabPanelEditPost.Visible     = true;
            TabContainer1.ActiveTabIndex = 3;
            if (e.CommandName == "Modify")
            {
                string argument = e.CommandArgument.ToString();
                using (MSIPortalContext ctx = new MSIPortalContext())
                {
                    Guid     postId  = new Guid(e.CommandArgument.ToString());
                    var      post    = from p in ctx.tbl_Post where p.PostID == postId select p;
                    tbl_Post objPost = post.ToList <tbl_Post>().FirstOrDefault <tbl_Post>();
                    Session["PostTobeModify"] = objPost;


                    this.ddlCommonCountry.SelectedValue   = objPost.LU_tbl_City.LU_tbl_Country.CountryID;
                    this.ddlCommonCity.SelectedValue      = objPost.CityID;
                    this.ddlCategory.SelectedValue        = objPost.CategoryID;
                    this.txtCommonProviderFirstName.Text  = objPost.ProviderFirstName;
                    this.txtCommonProviderLastName.Text   = objPost.ProviderLastName;
                    this.txtCommonProviderAddress.Text    = objPost.ProviderAddress;
                    this.txtCommonProviderEmil.Text       = objPost.ProviderEmail;
                    this.txtCommonProviderPhone.Text      = objPost.ProviderPhoneNo;
                    this.txtCommonPostingTitle.Text       = objPost.PostTitle;
                    this.txtCommonPostingDescription.Text = objPost.PostDescription;
                    PSImage.ImageUrl = objPost.ImageUrl;

                    if (objPost.PSTID == "001")
                    {
                        rdoCommonSales.Checked = true;
                    }
                    else
                    {
                        rdoCommonService.Checked = true;
                    }
                }
            }
        }
コード例 #10
0
        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
        }
コード例 #11
0
        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
            }
        }
コード例 #12
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
            }
        }