public void bindMaterial() { clsStudyMaterial m = new clsStudyMaterial(); DataSet ds = m.ListMaterial(Convert.ToInt32(hfFacultyID.Value)); rpMaterial.DataSource = ds; rpMaterial.DataBind(); }
protected void btnSubmitStudyMaterial_Click(object sender, EventArgs e) { clsStudyMaterial sm = new clsStudyMaterial(); sm.Course_ID = Convert.ToInt32(ddCourse.SelectedValue); sm.Faculty_ID = Convert.ToInt32(hfFacultyID.Value); sm.Subject_ID = Convert.ToInt32(ddSubject.SelectedValue); sm.Title = txtTitle.Text; sm.Description = txtMaterialDescription.Text; sm.Upload_Date = DateTime.Now; if (FileUpload.HasFile) { string filename = Path.GetFileName(FileUpload.PostedFile.FileName); string path = "../StudyMaterial/" + filename; FileUpload.SaveAs(Server.MapPath("~/StudyMaterial/") + filename); sm.File_Path = path; // Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "Alert", "alert('Image saved!')", true); if (!string.IsNullOrEmpty(hfFacultyID.Value) && !string.IsNullOrEmpty(ddSubject.SelectedValue) && !string.IsNullOrEmpty(ddCourse.SelectedValue)) { sm.AddStudyMaterial(sm); bindMaterial(); pnlform.Visible = false; pnldata.Visible = true; ddCourse.SelectedValue = ""; ddSubject.SelectedValue = ""; txtTitle.Text = ""; txtMaterialDescription.Text = ""; } } }
public bool AddStudyMaterial(clsStudyMaterial sm) { SqlParameter[] sp = new SqlParameter[7]; sp[0] = new SqlParameter("@Course_ID",sm.Course_ID); sp[1] = new SqlParameter("@Faculty_ID",sm.Faculty_ID); sp[2] = new SqlParameter("@Subject_ID",sm.Subject_ID); sp[3] = new SqlParameter("@Title", sm.Title); sp[4] = new SqlParameter("@Description",sm.Description); sp[5] = new SqlParameter("@File_Path",sm.File_Path); sp[6] = new SqlParameter("@Upload_Date",sm.Upload_Date); return datalayer.Execute_NonQuery("sp_AddStudyMaterial", CommandType.StoredProcedure, sp); }