protected void btnAdd_Click(object sender, EventArgs e) { string prodID = ""; try { product = new PRODUCT(); service = new SERVICE(); bservice = new BRAID_SERVICE(); string price = String.Format("{0:N2}", txtPrice.Text); product.ProductID = function.GenerateRandomProductID(); product.Name = txtName.Text; product.ProductDescription = txtDescription.Text; product.Price = Convert.ToDecimal(txtPrice.Text); service.NoOfSlots = int.Parse(drpNoOfSlots.SelectedValue); service.Type = drpType.SelectedValue.ToString(); bservice.ProductID = product.ProductID; bservice.StyleID = rblStyle.SelectedValue.ToString(); bservice.LengthID = rblLength.SelectedValue.ToString(); bservice.WidthID = rblWidth.SelectedValue.ToString(); if (drpType.SelectedValue == "B") { handler.BLL_AddBraidService(bservice); handler.BLL_AddService(product, service); } else if (drpType.SelectedValue == "A") { handler.BLL_AddService(product, service); } else if (drpType.SelectedValue == "N") { handler.BLL_AddService(product, service); } Boolean fileOK = false; string path = Server.MapPath("~/Theam/img/"); if (flUploadServiceimg.HasFile) { String fileExtension = System.IO.Path.GetExtension(flUploadServiceimg.FileName).ToLower(); String[] allowedExtensions = { ".gif", ".png", ".jpeg", ".jpg" }; for (int i = 0; i < allowedExtensions.Length; i++) { if (fileExtension == allowedExtensions[i]) { fileOK = true; } } } if (File.Exists(path + product.ProductID + ".jpg")) { File.Delete(path + product.ProductID + ".jpg"); } if (fileOK) { flUploadServiceimg.PostedFile.SaveAs(path + product.ProductID + ".jpg"); } prodID = product.ProductID; } catch (Exception Err) { function.logAnError(Err.ToString()); Response.Redirect("http://sict-iis.nmmu.ac.za/beauxdebut/error.aspx?Error=An Error Occured Communicating With The Data Base, Try Again Later"); } //redirect to previous page Response.Redirect("../Cheveux/Service.aspx?ProductID=" + prodID); }