public void NewImageResource(object sender, EventArgs e) { FileUpload fileUpload = (FileUpload)Page.FindControlRecursive("imageResourceFile"); if (fileUpload.HasFile) { try { string fileName = Path.GetFileName(fileUpload.FileName); string path = "~/Subjects/" + subjectID + "/Images/"; fileUpload.SaveAs(Server.MapPath(path) + fileName); ResourceCRUD resources = new ResourceCRUD(); bool addSuccess = resources.AddResources("img", fileName, int.Parse(ViewState["blockID"].ToString()), "img"); if (addSuccess) { Refresh(); } } catch (Exception ex) { } } }
public void NewDownloadableResource(object sender, EventArgs e) { FileUpload fileUpload = (FileUpload)Page.FindControlRecursive("downloadResourceFile"); TextBox resourceName = (TextBox)Page.FindControlRecursive("downloadResourceName"); if (fileUpload.HasFile) { try { string fileName = Path.GetFileName(fileUpload.FileName); string path = "~/Subjects/" + subjectID + "/Downloadables/"; fileUpload.SaveAs(Server.MapPath(path) + fileName); ResourceCRUD resources = new ResourceCRUD(); bool addSuccess = resources.AddResources(resourceName.Text, fileName, int.Parse(ViewState["blockID"].ToString()), "download"); if (addSuccess) { resourceName.Text = string.Empty; Refresh(); } } catch (Exception ex) { } } return; }
public void DeleteResource(object sender, CommandEventArgs e) { int resID = int.Parse(e.CommandArgument.ToString()); ResourceCRUD resources = new ResourceCRUD(); bool success = resources.DeleteResource(resID); if (success) { Refresh(); } }
public void NewTextResource(object sender, EventArgs e) { TextBox resource = (TextBox)Page.FindControlRecursive("textResource"); string text = resource.Text; ResourceCRUD resources = new ResourceCRUD(); bool addSuccess = resources.AddResources("text", text, int.Parse(ViewState["blockID"].ToString()), "text"); if (addSuccess) { resource.Text = string.Empty; Refresh(); } }
public void NewTaskResource(object sender, EventArgs e) { TextBox taskName = (TextBox)Page.FindControlRecursive("taskName"); TextBox taskText = (TextBox)Page.FindControlRecursive("taskText"); TextBox taskDate = (TextBox)Page.FindControlRecursive("taskDate"); ResourceCRUD resources = new ResourceCRUD(); bool addSuccess = resources.AddTaskResource(int.Parse(ViewState["blockID"].ToString()), taskName.Text, taskText.Text, DateTime.Parse(taskDate.Text)); if (addSuccess) { taskName.Text = string.Empty; taskText.Text = string.Empty; Refresh(); } }
public void NewVideoResource(object sender, EventArgs e) { TextBox resourceName = (TextBox)Page.FindControlRecursive("videoResourceName"); TextBox resourcePath = (TextBox)Page.FindControlRecursive("videoPath"); string link = resourcePath.Text.Replace("watch?v=", "embed/"); ResourceCRUD resources = new ResourceCRUD(); bool addSuccess = resources.AddResources(resourceName.Text, link, int.Parse(ViewState["blockID"].ToString()), "video"); if (addSuccess) { resourceName.Text = string.Empty; resourcePath.Text = string.Empty; Refresh(); } }
public void NewRiddleResource(object sender, EventArgs e) { TextBox riddleName = (TextBox)Page.FindControlRecursive("riddleName"); FileUpload audioFile = (FileUpload)Page.FindControlRecursive("riddleAudioFile"); FileUpload imageFile = (FileUpload)Page.FindControlRecursive("riddleImageFile"); TextBox ogText = (TextBox)Page.FindControlRecursive("OGText"); TextBox transText = (TextBox)Page.FindControlRecursive("TransText"); TextBox answer = (TextBox)Page.FindControlRecursive("riddleAnswer"); if (audioFile.HasFile) { try { string audioFilename = Path.GetFileName(audioFile.FileName); string path = "~/Subjects/" + subjectID + "/Audios/"; audioFile.SaveAs(Server.MapPath(path) + audioFilename); string imageFilename = Path.GetFileName(imageFile.FileName); if (imageFilename != "") { string path2 = "~/Subjects/" + subjectID + "/Images/"; imageFile.SaveAs(Server.MapPath(path2) + imageFilename); } ResourceCRUD resources = new ResourceCRUD(); bool addSuccess = resources.AddRiddleResource(int.Parse(ViewState["blockID"].ToString()), riddleName.Text, audioFilename, imageFilename, ogText.Text, transText.Text, answer.Text); if (addSuccess) { riddleName.Text = string.Empty; ogText.Text = string.Empty; transText.Text = string.Empty; answer.Text = string.Empty; Refresh(); } } catch (Exception ex) { } } }
public void NewTestResource(object sender, EventArgs e) { TextBox testName = (TextBox)Page.FindControlRecursive("testName"); FileUpload fileUpload = (FileUpload)Page.FindControlRecursive("testResourceFile"); if (fileUpload.HasFile) { try { string fileName = Path.GetFileName(fileUpload.FileName); ResourceCRUD resources = new ResourceCRUD(); int resourceID = resources.AddTestResource(int.Parse(ViewState["blockID"].ToString()), testName.Text, fileName); string path = "~/Subjects/" + subjectID + "/Tests/"; path = Server.MapPath(path) + resourceID; Directory.CreateDirectory(path); fileUpload.SaveAs(path + "/" + fileName); bool addSuccess = resources.AddZip(resourceID, (int)subjectID, fileName, path); if (addSuccess) { testName.Text = string.Empty; Refresh(); } } catch (Exception ex) { } } }