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; } } }
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 } }
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(); }
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 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 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 } }
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 } }