protected void btn_upload_FILE_Click1(object sender, EventArgs e) { ViewState["url"] = FilePhoto.FileBytes; string fpath = Server.MapPath("~\\SchoolAdmin\\EmployeePhoto\\"); if (!Directory.Exists(fpath)) { var dir = new DirectoryInfo("~\\SchoolAdmin\\"); dir.CreateSubdirectory("EmployeePhoto"); } else { string schoolName = AppSessions.SchoolName; string UserName = txtAddFirstName.Text + "_" + txtAddLastName.Text; string FileName = schoolName + "_" + UserName; string FilePathName = FilePhoto.FileName; string Extension = Path.GetExtension(FilePathName); string FileNewName = FileName + Extension; string FileLocation; FileLocation = fpath + FilePathName; if (File.Exists(FileLocation)) { string UserName1 = txtAddFirstName.Text + "_" + txtAddMiddleName.Text + "_" + txtAddLastName.Text; string FileName1 = schoolName + "_" + UserName1; string FilePathName1 = FilePhoto.FileName; string Extension1 = Path.GetExtension(FilePathName1); string FileNewName1 = FileName1 + Extension1; string FileLocation1 = fpath + FilePathName1; FilePhoto.SaveAs(FileLocation1); imgPhoto.ImageUrl = "~\\SchoolAdmin\\EmployeePhoto\\" + FilePathName; } else { FilePhoto.SaveAs(FileLocation); imgPhoto.ImageUrl = "~\\SchoolAdmin\\EmployeePhoto\\" + FilePathName; } pnlEdit.CssClass = "InVisible"; pnlSearch.CssClass = "InVisible"; pnlAdd.CssClass = "Visible"; } }
protected void btn_Insert_Click(object sender, EventArgs e) { string prodID = Session["foo"].ToString(); int result = 0; string image = ""; string category = ""; decimal budget = decimal.Parse(budgetID.Text); if (FilePhoto.HasFile == true) { image = "Images\\" + FilePhoto.FileName; } Listings prod = new Listings(); //tb_ProductCat can change to ddl_ProdCat result = updateListing(prodID, listingTitleID.Text, descID.Text, (FilePhoto.FileName).ToString(), budget); if (result > 0) { string saveimg = Server.MapPath("") + "\\" + image; FilePhoto.SaveAs(saveimg); //loadProductInfo(); //loadProduct(); //clear1(); Response.Write("<script> alert('Update successful');</script>"); Session.Remove("foo"); Response.Redirect("listing.aspx?listID=" + prodID); } else { Response.Write("<script> alert('Update NOT succesful');</script>"); } }
protected void btn_Insert_Click(object sender, EventArgs e) { int result = 0; string image = ""; string category = ""; decimal budget = decimal.Parse(budgetID.Text); if (FilePhoto.HasFile == true) { image = "Images\\" + FilePhoto.FileName; } string custEmail = Session["user"].ToString(); Listings prod = new Listings(); //tb_ProductCat can change to ddl_ProdCat result = prod.ListingInsert(listingTitleID.Text, descID.Text, (FilePhoto.FileName).ToString(), budget, custEmail); if (result > 0) { string saveimg = Server.MapPath("") + "\\" + image; FilePhoto.SaveAs(saveimg); //loadProductInfo(); //loadProduct(); //clear1(); Response.Write("<script> alert('Insert successful');</script>"); } else { Response.Write("<script> alert('Insert NOT succesful');</script>"); } }