public static string updateProductType(ProductType pt, string name, string description)
        {
            if (name.Length < 5)
            {
                return("Name must at least 5 characters!");
            }
            else if (description.Length <= 0)
            {
                return("Description must not be empty!");
            }
            else if (!name.Equals(pt.Name) && !ProductTypeHandler.validateProductTypeName(name))
            {
                return(String.Format("These product type name has already taken! " +
                                     "Use old name: '{0}' or other non-existent product type instead.", pt.Name));
            }

            try
            {
                ProductTypeHandler.updateProductType(pt.ID, name, description);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                return("Database update on server failure, please try again!");
            }
            return("");
        }
Esempio n. 2
0
        public String updateAttempt(String targetId, String productType, String desc)
        {
            String errMsg = validateInput(productType, desc);

            if (errMsg == null)
            {
                List <ProductTypes> listProductTypes = productTypeHdlr.getProductType();
                errMsg = validateProductType(productType, listProductTypes);
                if (errMsg == null)
                {
                    productTypeHdlr.updateProductType(targetId, productType, desc);
                    return(errMsg);
                }
                ;
            }

            return(errMsg);
        }
Esempio n. 3
0
        protected void updateCurrentProductType_Click(object sender, EventArgs e)
        {
            int         id = Int32.Parse(Request.QueryString["id"]);
            ProductType p = ProductTypeHandler.get(id);
            String      Name = tbNameType.Text, Description = tbDescriptionType.Text, messageError = "";
            int         ID = p.ID;

            messageError = ProductTypeController.update(Name, Description);

            if (messageError != "")
            {
                lblErrorUpdateProductType.Text = messageError;
            }
            else
            {
                ProductTypeHandler.updateProductType(ID, Name, Description);
                lblErrorUpdateProductType.Text = "Your product type has been updated";
            }
        }
Esempio n. 4
0
 public static void updateProductType(int id, String name, String desc)
 {
     ProductTypeHandler.updateProductType(id, name, desc);
 }