Ejemplo n.º 1
0
        private void BindData()
        {
            try
            {
                DataTable dt = new DataTable();
                if (Request.QueryString["RefHandle"] != null && Request.QueryString["RefIndex"] != null)
                {
                    objAttachmentcls = new AttachmentCls();
                    objAttachmentcls.AttachmentHandle = Request.QueryString["AthHandle"];
                    objAttachmentcls.IndexValue       = Request.QueryString["Index"];
                    dt = objAttachmentcls.GetAllExistingAttachments();
                    // HttpContext.Current.Cache.Insert("ATHData", dt, null, DateTime.Now.AddMinutes(20), TimeSpan.Zero);
                    if (dt.Rows.Count > 0)
                    {
                        gvAttachment.DataSource = dt;
                        gvAttachment.DataBind();
                        divNoRecord.Visible = false;
                        //  gvExistingAttachments.Visible = true;
                        divViewAttachment.Visible = true;
                        //  divExistingAttachNotExists.Visible = false;
                    }
                    else
                    {
                        divNoRecord.Visible = true;
                        // divExistingAttachNotExists.Visible = true;
                        divViewAttachment.Visible = false;
                    }
                }

                else if (Request.QueryString["AthHandle"] != null && Request.QueryString["Index"] != null && Request.QueryString["AttachedBy"] != null)
                {
                    if (HttpContext.Current.Cache["ATHData"] == null)
                    {
                        objAttachmentcls = new AttachmentCls();
                        objAttachmentcls.AttachmentHandle = Request.QueryString["AthHandle"];
                        objAttachmentcls.IndexValue       = Request.QueryString["Index"];
                        dt = objAttachmentcls.GetAttachments();
                        HttpContext.Current.Cache.Insert("ATHData", dt, null, DateTime.Now.AddMinutes(20), TimeSpan.Zero);
                    }
                    else
                    {
                        dt = (DataTable)HttpContext.Current.Cache["ATHData"];
                    }
                    if (dt.Rows.Count > 0)
                    {
                        gvAttachment.DataSource = dt;
                        gvAttachment.DataBind();
                        divNoRecord.Visible       = false;
                        divViewAttachment.Visible = true;
                    }
                    else
                    {
                        divNoRecord.Visible       = true;
                        divViewAttachment.Visible = false;
                    }
                }
                // else
                // {

                else
                {
                    ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('No Data found');", true);
                }

                // }
            }
            catch (System.Exception ex)
            {
                ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Due to some technical issue record not found');", true);
            }
        }