protected void btnInsert_Click(object sender, EventArgs e) { int prodID = 1; int PTID = int.Parse(txtPTID.Text); string prodName = txtName.Text; int prodPrice = int.Parse(txtPrice.Text); int prodStock = int.Parse(txtStock.Text); if (PTRepository.getID(int.Parse(txtPTID.Text)) != null) { if (int.Parse(txtPrice.Text) < 1000) { price.Visible = true; } else if (int.Parse(txtStock.Text) < 1) { stock.Visible = true; } else { productRepository.updateProduct(prodID, PTID, prodName, prodPrice, prodStock); } } else { notFound.Visible = true; } }
protected void btnUpdatePT_Click(object sender, EventArgs e) { int PTID = 1; string PTName = txtName.Text; string PTDesc = txtDesc.Text; if (PTName != null && PTDesc != null) { if (PTName.Length > 5) { if (PTRepository.getName(PTName) != null) { alrExists.Visible = true; } else { PTRepository.updateProductType(PTID, PTName, PTDesc); txtName.Text = txtDesc.Text = ""; Response.Redirect("Update PT.aspx"); } } else { txtNameLen.Visible = true; } } }
protected void btnDeletePT_Click1(object sender, EventArgs e) { if (PTRepository.getID(int.Parse(txtID.Text)) != null) { PTRepository.deleteProductType(int.Parse(txtID.Text)); Response.Redirect("View PT.aspx"); } else { notFound.Visible = true; } }
protected void btnInsertPT_Click(object sender, EventArgs e) { int PTID = 1; string PTName = txtName.Text; string PTDesc = txtDesc.Text; if (PTName.Length > 5 && PTRepository.getName(PTName) == null) { PTRepository.createProductType(PTID, PTName, PTDesc); success.Visible = true; txtName.Text = txtDesc.Text = ""; } else { txtNameLen.Visible = true; } }
protected void Page_Load(object sender, EventArgs e) { if (Session["UserEmail"] == null) { btnHome.Visible = true; // btnInsertPT.Visible = false; // btnUpdatePT.Visible = false; //btnDeletePT.Visible = false; btnInsertPT.Visible = true; btnUpdatePT.Visible = true; btnDeletePT.Visible = true; labelID.Visible = true; txtID.Visible = true; } if (Session["UserEmail"] != null) { btnInsertPT.Visible = false; btnUpdatePT.Visible = false; btnDeletePT.Visible = false; labelID.Visible = false; txtID.Visible = false; string email = Session["UserEmail"].ToString(); User user = userRepository.getEmail(email); if (user.RoleID == 1) { btnInsertPT.Visible = true; btnUpdatePT.Visible = true; btnDeletePT.Visible = true; labelID.Visible = true; txtID.Visible = true; } } GridView.DataSource = PTRepository.getViewPT(); GridView.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { GridView.DataSource = PTRepository.getViewPT(); GridView.DataBind(); }