protected void GetDataForm() { if (ddlCategory.SelectedValue == "1") { txtCategory.Visible = true; Category category = new Category(); if (string.IsNullOrEmpty(txtCategory.Text)) { pnlRed.Visible = true; lblError.Text = "Category is null."; return; } category.Category_Id = Guid.NewGuid(); category.Category_Name = txtCategory.Text; if (categoryBll.Category_CheckName(category.Category_Name)) { pnlRed.Visible = false; pnlRed.Visible = true; lblError.Text = "This category name have already used.."; return; } if (!categoryBll.Category_Insert(category)) { pnlRed.Visible = false; pnlRed.Visible = true; lblError.Text = "Do not success category."; return; } Product product = CreateProduct(); if (product == null) { pnlRed.Visible = true; lblError.Text = "Company name is null."; return; } product.Category_Id = category.Category_Id; if (!productBll.Product_Insert(product)) { pnlGreen.Visible = false; pnlRed.Visible = true; lblError.Text = "Do not success."; return; } pnlRed.Visible = false; pnlGreen.Visible = true; lblSuccess.Text = "Have a Success"; return; } else { if (ddlCategory.SelectedValue == "0") { pnlRed.Visible = true; lblError.Text = "category name is null."; return; } Product product = CreateProduct(); if (product == null) { pnlRed.Visible = true; lblError.Text = "Company name is null."; return; } product.Category_Id = new Guid(ddlCategory.SelectedValue); if (!productBll.Product_Insert(product)) { pnlGreen.Visible = false; pnlRed.Visible = true; lblError.Text = "Do not success."; return; } pnlGreen.Visible = true; pnlRed.Visible = false; lblSuccess.Text = "Have a Success"; return; } }