Пример #1
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";
                }
            }
        }
Пример #2
0
 public static void deleteProductType(int productTypeID)
 {
     PSDAssignment.ProductType type = getProductTypeByID(productTypeID);
     System.Diagnostics.Debug.WriteLine(type.Name);
     DB.ProductTypes.Remove(type);
     DB.SaveChanges();
 }
Пример #3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Request.QueryString["productTypeID"] == null)
     {
         Response.Redirect("ProductType.aspx");
     }
     PSDAssignment.ProductType productType = ProductTypeController.getProductTypeByID(Convert.ToInt32(Request.QueryString["productTypeID"]));
     if (productType == null)
     {
         Response.Redirect("ProductType.aspx");
     }
     if (!IsPostBack)
     {
         TypeNameTxts.Text        = productType.Name;
         TypeDescriptionTxts.Text = productType.Description;
     }
 }