Beispiel #1
0
        protected void BtnSubmit_Click(object sender, EventArgs e)
        {
            String name = TypeNameTxt.Text;
            String desc = TypeDescriptionTxt.Text;

            clearLabel();
            if (ProductTypeController.PTValidation(name, desc))
            {
                ProductTypeController.addProductType(name, desc);
                Response.Redirect("ProductType.aspx");
            }
            else
            {
                int error = ProductTypeController.NameValidation(name);
                if (error == -1)
                {
                    TypeTxt.Text = "Name must be filled, unique and consists of 5 characters or more";
                }
                else if (error == -2)
                {
                    TypeTxt.Text = "Name must consists of 5 characters or more and unique";
                }
                else if (error == -3)
                {
                    TypeTxt.Text = "Name must be unique";
                }
                if (ProductTypeController.DescValidation(desc) == -1)
                {
                    DescLabel.Text = "Description must be filled";
                }
            }
        }
Beispiel #2
0
        protected void BtnEdit_Click(object sender, EventArgs e)
        {
            PSDAssignment.ProductType productType = ProductTypeController.getProductTypeByID(Convert.ToInt32(Request.QueryString["productTypeID"]));
            int    productTypeID   = productType.Id;
            String productTypeName = TypeNameTxts.Text;
            String productTypeDesc = TypeDescriptionTxts.Text;

            clearLabel();
            if (ProductTypeController.PTUpdateValidation(productTypeName, productTypeDesc, productType))
            {
                ProductTypeController.updateProductType(productTypeID, productTypeName, productTypeDesc);
                Response.Redirect("ProductType.aspx");
            }
            else
            {
                int error = ProductTypeController.NameUpdateValidation(productTypeName, productType.Name);
                if (error == -1)
                {
                    TypeTxt.Text = "Name must be filled, unique and consists of 5 characters or more";
                }
                else if (error == -2)
                {
                    TypeTxt.Text = "Name must consists of 5 characters or more and unique";
                }
                else if (error == -3)
                {
                    TypeTxt.Text = "Name must be unique";
                }
                if (ProductTypeController.DescValidation(productTypeDesc) == -1)
                {
                    DescLabel.Text = "Description must be filled";
                }
            }
        }