Exemplo n.º 1
0
        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();
        }
Exemplo n.º 2
0
        protected void grdTestimonial_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Delete_Testimonial")
            {
                int         rowIndex = ((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex;
                GridViewRow grid     = grdTestimonial.Rows[rowIndex];
                int         id       = Convert.ToInt32(((Label)grid.FindControl("lblID")).Text);

                obj1 = new TestimonialMasterDataManager();
                obj1.DeleteTestimonialDetail(id);
                Clear();
                bind();
                msgbox("Testimonial Deleted successfully!!!");
            }
        }
Exemplo n.º 3
0
 private void bind()
 {
     obj1 = new TestimonialMasterDataManager();
     grdTestimonial.DataSource = obj1.GetTestimonialList();
     grdTestimonial.DataBind();
 }