protected void submitBtn_Click(object sender, EventArgs e) { bool stat = true; String name = typeNameBox.Text; String desc = descBox.Text; if (!InsertProductTypeController.isBoxFilled(name)) { stat = false; nameValidate.Text = "Name must be filled!"; } if (!InsertProductTypeController.isBoxFilled(desc)) { stat = false; descValidate.Text = "Description must be filled!"; } if (!InsertProductTypeController.checkLenght(name)) { warningLbl.Text = "Name must be 5 chars or more"; } else { if (InsertProductTypeController.isTypeAlreadyExist(name)) { warningLbl.Text = "Type already exist!"; } else if (stat) { InsertProductTypeController.createType(name, desc); Response.Redirect("../VProductType/ViewProductType.aspx"); } } }
private Boolean DataValidation(string name, string desc) { string errorMessage = ""; if (InsertProductTypeController.ProductTypeValidation(name, desc, out errorMessage) == false) { return(HandleWrongFormat(errorMessage)); } return(true); }
protected void DoInsertNewType(object sender, EventArgs e) { string typeName = TxtTypeName.Text.ToString(); string desc = TxtDescription.Text.ToString(); if (DataValidation(typeName, desc) == true) { InsertProductTypeController.InsertNewProductTypeController(typeName, desc); Response.Redirect("ViewProductType.aspx"); } }
protected void BtnUpdateProductType_Click(object sender, EventArgs e) { String Name = BoxTypeName.Text.ToString(); String Description = BoxDescription.Text.ToString(); int ID = InsertProductTypeController.CountData() + 1; Response response = InsertProductTypeController.DoInsertProductType(ID, Name, Description); if (response.successStatus == false) { LabelInsertProduct.Text = response.message; } else { Response.Redirect("ViewProductType.aspx"); } }
protected void btnInsertPT_Click(object sender, EventArgs e) { string name = typeName.Text.ToString(); string desc = typeDesc.Text.ToString(); string errorMsg = ""; lblInfo.Visible = true; bool success = InsertProductTypeController.validateInsert(name, desc, out errorMsg); if (success) { lblInfo.Text = errorMsg; Response.Redirect("ViewProductType.aspx"); } else { lblInfo.Text = errorMsg; } }
protected void Page_Load(object sender, EventArgs e) { if (InsertProductTypeController.isUserLoggedIn()) { if (!InsertProductTypeController.isUserAnAdmin(Request.Cookies["user_email"].Value)) { userWarnLbl.Text = "403 Forbidden! Reason: You're not an admin!"; typeNameBox.Enabled = false; descBox.Enabled = false; submitBtn.Visible = false; } } else { userWarnLbl.Text = "403 Forbidden! Reason: You're not logged in as admin!"; typeNameBox.Enabled = false; descBox.Enabled = false; submitBtn.Visible = false; logoutBtn.Visible = false; } }