protected void submitBtn_Click(object sender, EventArgs e) { bool stat = true; int id = Convert.ToInt32(typeIdBox.Text); string name = typeNameBox.Text; string desc = typeDescBox.Text; if (!UpdateProductTypeController.isBoxFilled(name)) { nameValidate.Text = "Name must be filled!"; } if (!UpdateProductTypeController.isBoxFilled(desc)) { descValidate.Text = "Description must be filled!"; } if (!UpdateProductTypeController.checkLengthRequirement(name)) { warningLbl.Text = "Name must be 5 chars or more!"; } else if (UpdateProductTypeController.findMatches(name)) { warningLbl.Text = "Name cannot be same with any data in database!"; } else if (stat) { UpdateProductTypeController.update(id, name, desc); Response.Redirect("./ViewProductType.aspx"); } }
protected void Page_Load(object sender, EventArgs e) { if (Session["LoginSession"] == null) { Response.Redirect("../HomeView/Home.aspx"); } else { String ID = Session["LoginSession"].ToString(); MsUser user = HomeController.FetchDataForHome(ID); if (user.RoleID != "RL1") { Response.Redirect("../HomeView/Home.aspx"); } else { if (Request.QueryString["id"] == null) { Response.Redirect("../HomeView/Home.aspx"); } else { if (!IsPostBack) { String ProductTypeID = Request.QueryString["id"]; MsProductType type = UpdateProductTypeController.SearchProductType(ProductTypeID); BoxTypeName.Text = type.ProductTypeName.ToString(); BoxDescription.Text = type.ProductTypeDescription.ToString(); } } } } }
protected void Page_Load(object sender, EventArgs e) { if (UpdateProductTypeController.isUserLoggedIn()) { if (UpdateProductTypeController.isUserAnAdmin(Request.Cookies["user_email"].Value)) { if (!IsPostBack) { int id = Convert.ToInt32(Request.QueryString["id"]); ProductType thisPT = UpdateProductTypeController.requestDetail(id); typeIdBox.Text = id.ToString(); typeNameBox.Text = thisPT.ProductTypeName; typeDescBox.Text = thisPT.ProductTypeDesc; } } else { userWarnLbl.Text = "403. You are not an admin!"; typeNameBox.Enabled = false; typeDescBox.Enabled = false; submitBtn.Visible = false; } } else { userWarnLbl.Text = "403. You are not logged in as admin!"; typeNameBox.Enabled = false; typeDescBox.Enabled = false; submitBtn.Visible = false; logoutBtn.Visible = false; } }
private Boolean DataValidation(string name, string desc) { string errorMessage = ""; if (UpdateProductTypeController.ProductTypeValidation(name, desc, oldTypeName, out errorMessage) == false) { return(HandleWrongFormat(errorMessage)); } return(true); }
protected void DoUpdateType(object sender, EventArgs e) { string typeName = TxtTypeName.Text.ToString(); string desc = TxtDescription.Text.ToString(); if (DataValidation(typeName, desc) == true) { UpdateProductTypeController.GetUpdateProductTypeController(typeId, typeName, desc); Response.Redirect("ViewProductType.aspx"); } }
private void SetTypeData() { typeId = Int32.Parse(Request.QueryString["productTypeId"]); ProductType currData = UpdateProductTypeController.GetProductTypeController(typeId); oldTypeName = currData.Name.ToString(); if (!Page.IsPostBack) { TxtTypeName.Text = currData.Name.ToString(); TxtDescription.Text = currData.Description.ToString(); } }
protected void BtnUpdateProductType_Click(object sender, EventArgs e) { String ProductTypeID = Request.QueryString["id"]; String ProductTypeName = BoxTypeName.Text.ToString(); String ProductTypeDesc = BoxDescription.Text.ToString(); Response response = UpdateProductTypeController.UpdateProductType(ProductTypeID, ProductTypeName, ProductTypeDesc); if (response.successStatus == false) { LabelUpdateProduct.Text = response.message; } else { Response.Redirect("ViewProductType.aspx"); } }
protected void btnUpdatefix_Click(object sender, EventArgs e) { string name = UpdateTypeName.Text.ToString(); string desc = UpdateDesc.Text.ToString(); string updID = Request.QueryString["id"]; newID = int.Parse(updID); string errorMsg = ""; labelError.Visible = true; bool success = UpdateProductTypeController.validateUpdate(newID, name, desc, out errorMsg); if (!success) { labelError.Text = errorMsg; } else { Response.Redirect("ViewProductType.aspx"); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Session["user"] != null) { User us = (User)Session["user"]; if (us.RoleID == 1) { GridViewUpdate.DataSource = UpdateProductTypeController.getAllProductType(); GridViewUpdate.DataBind(); } else { Response.Redirect("Home.aspx"); } } else { Response.Redirect("Home.aspx"); } } }