protected void GetComplaintNumber()
        {
            using (ComplaintsTabLinq.ComplaintsTabDataContext cdc = new ComplaintsTabLinq.ComplaintsTabDataContext())
            {
                string cmpnumber = ""; string respondent = "";
                ComplaintsTabLinq.TbL_Complaint cmp = cdc.TbL_Complaints.OrderByDescending(c => c.Complaint_ID).First();
                cmpnumber = cmp.Complaint_Number;

                using (Person_Details.Person_LicenseDataContext plc = new Person_Details.Person_LicenseDataContext())
                {
                    Person_Details.tbl_PersonDetail obj = new Person_Details.tbl_PersonDetail();
                    obj = plc.tbl_PersonDetails.Where(c => c.Person_ID == cmp.Respondent_ID).SingleOrDefault();
                    if (obj.object_type != 1)
                    {
                        respondent = obj.Business;
                    }
                    else
                    {
                        respondent = obj.First_Name + ' ' + obj.Middle_Name + ' ' + obj.Last_Name;
                    }
                }
                if (ddl_source.SelectedValue == "1257" || ddl_source.SelectedValue == "1038" || ddl_source.SelectedValue == "1039" || ddl_source.SelectedValue == "1040" || ddl_source.SelectedValue == "1041" || ddl_source.SelectedValue == "1259" || ddl_source.SelectedValue == "1417" || ddl_source.SelectedValue == "1419")
                {
                    Mail.SendMail("", System.Configuration.ConfigurationManager.AppSettings["cmpcreated"].ToString(), "", "Case  Created ", "A case has been created with the number  : " + cmpnumber + "<br/><br/>Respondent  : " + respondent);
                }
                else
                {
                    Mail.SendMail("", System.Configuration.ConfigurationManager.AppSettings["cmpcreated1"].ToString(), "", "Case  Created ", "A case has been created with the number  : " + cmpnumber + "<br/><br/>Respondent  : " + respondent);
                }
            }
        }
        protected void btndownloadall_ServerClick(object sender, EventArgs e)
        {
            string ZipfileName = "";

            ComplaintsTabLinq.TbL_Complaint obj = ComplaintsTabLinq.ClsComplaints.Get_ComplaintNumber(Convert.ToInt32(hfdperid.Value));
            if (obj != null)
            {
                ZipfileName = "Case Documents For - " + obj.Complaint_Number + ".Zip";
            }
            else
            {
                ZipfileName = "MyZipFiles.Zip";
            }
            Response.ContentType = "application/zip";
            Response.AddHeader("Content-Disposition", "filename=" + ZipfileName);
            byte[]          buffer       = new byte[4098];
            ZipOutputStream ZipOutStream = new ZipOutputStream(Response.OutputStream);

            ZipOutStream.SetLevel(3);
            try
            {
                List <USP_GetAllDocumentsDownloadResult> Getdocuments = Person_Details.Licensing_Details.GetAlldocumentsDownload(Convert.ToInt32(hfdperid.Value));
                foreach (var i in Getdocuments.ToList())
                {
                    string docmonth = ""; string docpath = "";
                    string docyear = i.docpath.Substring(39, 4);
                    if (Convert.ToDateTime(i.Document_Date).Month < 10)
                    {
                        docmonth = i.docpath.Substring(44, 1);
                        docpath  = i.docpath.Substring(46);
                    }
                    else
                    {
                        docmonth = i.docpath.Substring(44, 2);
                        docpath  = i.docpath.Substring(47);
                    }


                    string   filepath = System.Configuration.ConfigurationManager.AppSettings["docpath"].ToString() + "\\" + docyear + "\\" + docmonth + "\\" + docpath;
                    Stream   fs       = File.OpenRead(filepath);
                    ZipEntry zipentry = new ZipEntry(ZipEntry.CleanName(i.Description));
                    zipentry.Size = fs.Length;
                    ZipOutStream.PutNextEntry(zipentry);
                    int count = fs.Read(buffer, 0, buffer.Length);
                    while (count > 0)
                    {
                        ZipOutStream.Write(buffer, 0, count);
                        count = fs.Read(buffer, 0, buffer.Length);
                        if (!Response.IsClientConnected)
                        {
                            break;
                        }
                        Response.Flush();
                    }
                    fs.Close();
                }
                ZipOutStream.Close();
                Response.Flush();
                Response.End();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }