protected void btnAdd_Click(object sender, EventArgs e) { string filename, filepath, extension; if (!fileUpload.HasFile) { msgbox("select photo to upload"); return; } else { /*Upload Files to folder*/ filename = Path.GetFileNameWithoutExtension(fileUpload.PostedFile.FileName); extension = Path.GetExtension(fileUpload.PostedFile.FileName); filepath = Server.MapPath("~/Upload/Testimonial") + "\\" + filename + DateTime.Now.ToString("_ddMMyyyyhhmmss") + extension; if (File.Exists(filepath)) { File.Delete(filepath); } else { fileUpload.PostedFile.SaveAs(filepath); } lblUrl.Text = filepath.Substring(filepath.LastIndexOf("\\") + 1); } obj = new TestimonialMaster(); obj.AuthorName = txtAuthor.Text; obj.Contents = txtContents.Text; obj.Photo = lblUrl.Text; //obj.IsVisible = chkVisible.Checked; obj.CreatedBy = 1; obj.UpdatedBy = 1; obj.TestimonialID = Convert.ToInt16(lblTestimonialID.Text); if (lblTestimonialID.Text.Equals("-1")) { obj1 = new TestimonialMasterDataManager(); obj1.AddTestimonialDetail(obj); msgbox("Testimonial Added successfully!!!"); } else { obj1 = new TestimonialMasterDataManager(); obj1.UpdateTestimonialDetail(obj); msgbox("Testimonial updated successfully!!!"); } Clear(); bind(); }
public void AddTestimonialDetail(TestimonialMaster obj) { try { SqlParameter[] parameter = new SqlParameter[] { new SqlParameter("@AuthorName", obj.AuthorName), new SqlParameter("@Photo", obj.Photo), // new SqlParameter("@IsVisible",obj.IsVisible.Equals(true)?1:0), new SqlParameter("@Contents", obj.Contents), new SqlParameter("@CreatedBy", obj.CreatedBy), new SqlParameter("@UpdatedBy", obj.UpdatedBy) }; DBOperate.ExecuteProcedureWithOutReturn("usp_AddTestimonial", parameter); } catch { throw; } }