protected void btnEdit_Click(object sender, EventArgs e) { bool hasError = false; // Verify that stocks are correctly entered try { int stocks = Convert.ToInt32(txtStocks.Text); // Verify that stocks are >= 0 if (stocks < 0) { hasError = true; // Show error message lblEditError = FormatLbl.Error("Ensure that stocks are a positive value."); } else { artpiece.Stocks = stocks; } } catch (Exception ex) { hasError = true; // Show error message lblEditError = FormatLbl.Error("Ensure that stocks are numerical."); } if (!hasError) { //Update artpiece ArtpieceDao dao = new ArtpieceDao(); dao.Update(artpiece); // Show success msg lblEditError = FormatLbl.Success("Stocks successfully updated"); } // Refresh page //Net.RefreshPage(); }
protected void Page_Load(object sender, EventArgs e) { // Initialize FormatLbl = new FormatLabel(lblEditError); if (Session["customer"] == null) { Response.Redirect("~/Pages/LoginRegister.aspx"); } else { // Clear error message lblEditError.Text = ""; if (!IsPostBack) { CustomerDao dao = new CustomerDao(); Customer customer = (Customer)Session["customer"]; // Update the one in the session and page customer = dao.Get("CUSTID", customer.Id); Session["customer"] = customer; //nameLbl.Text = customer.Username + " " + customer.DisplayName; //usernameLbl.Text = customer.Id; lblName.Text = customer.DisplayName; lblUsername.Text = "@" + customer.Username; username.Text = customer.Username; displayName.Text = customer.DisplayName; email.Text = customer.Email; cardNo.Text = customer.CreditCardNo; } } if (Request.QueryString["Edit"] != null) { lblEditError = FormatLbl.Success("Account successfully updated"); } lblEditError.ID = "lblEditError"; }
protected void Page_Load(object sender, EventArgs e) { FormatLbl = new FormatLabel(lblEditError); if (Session["artist"] == null) { Response.Redirect("~/Pages/LoginRegister.aspx"); } else { // Clear error message lblEditError.Text = ""; if (!IsPostBack) { ArtistDao dao = new ArtistDao(); Artist artist = (Artist)Session["artist"]; // Update the one in the session and page artist = dao.Get("ARTISTID", artist.Id); Session["artist"] = artist; //nameLbl.Text = artist.Username + " " + artist.DisplayName; //usernameLbl.Text = artist.Id; lblName.Text = artist.DisplayName; lblUsername.Text = "@" + artist.Username; lblBio.Text = artist.Bio; username.Text = artist.Username; displayName.Text = artist.DisplayName; email.Text = artist.Email; bio.Text = artist.Bio; } } if (Request.QueryString["Edit"] != null) { lblEditError = FormatLbl.Success("Account successfully updated"); } }