protected void btnNotify_Investigators_Click(object sender, EventArgs e)
        {
            string secondinvestigator = "", emails = "";

            // investigator = AdminLinq.Admin.Getemail(ddlcompinvestigate.SelectedValue);
            secondinvestigator = AdminLinq.Admin.Getemail(ddlcompinvestigate2.SelectedValue);
            string firstinv = "";

            firstinv = AdminLinq.Admin.Getemail(ddlcompinvestigate.SelectedValue);
            emails   = secondinvestigator;

            DataTable dt = new DataTable();

            dt = Utilities_Licensing.GetNameandLicno(Convert.ToInt32(hfdautoid.Value));
            int i = Mail.SendMail1("", emails, "[email protected];[email protected];[email protected];[email protected]", "Investigation assigned", "You have been assigned to assist " + firstinv + " with this investigation.<br/><br/>Case # : " + Request.QueryString[1].ToString() + "<br/><br/>Respondent Name : " + dt.Rows[0]["Name"].ToString());

            if (i == 1)
            {
                string js = " altbox('Mail sent successfully.');";
                ScriptManager.RegisterStartupScript(Page, GetType(), "scr", js, true);
            }
            else
            {
                string js = " altbox('Mail not sent.');";
                ScriptManager.RegisterStartupScript(Page, GetType(), "scr", js, true);
            }
        }
        protected void btnupdateComplaint_Click(object sender, EventArgs e)
        {
            string person  = "";
            string caseno  = "";
            string prvres  = "";
            string curres  = "";
            string pstatus = "";
            string cstatus = "";

            using (ComplaintsTabLinq.ComplaintsTabDataContext cdb = new ComplaintsTabDataContext())
            {
                ComplaintsTabLinq.TbL_Complaint objcom = cdb.TbL_Complaints.Where(c => c.Complaint_ID == Convert.ToInt32(hfdautoid.Value)).SingleOrDefault();
                pstatus = objcom.Complaint_Status;
                cstatus = ddlcompstatus.SelectedValue;
                prvres  = objcom.PersonResponcible_ID;
                curres  = ddlcompresposible.SelectedValue;
                objcom.Respondent_type = hfdRespondentType.Value.ToString() == "1" ? "1" : "2";
                objcom.Respondent_ID   = Convert.ToInt32(hfdRespondentId.Value);
                objcom.Source_Id       = ddlcompsource.SelectedValue.ToString();
                objcom.Category_Id     = ddlcompcategory.SelectedValue.ToString();
                if (txtcompdaterecive.Text != "")
                {
                    objcom.DateReceived = Convert.ToDateTime(txtcompdaterecive.Text);
                }
                else
                {
                    objcom.DateReceived = Convert.ToDateTime("01/01/1900");
                }
                //if (txtcomodocketed.Text != "")
                //    objcom.DateDocketed = Convert.ToDateTime(txtcomodocketed.Text);
                //else
                //    objcom.DateDocketed = Convert.ToDateTime("01/01/1900");

                objcom.Address1 = txtcompadd1.Text;
                objcom.Address2 = txtcompadd2.Text;
                objcom.City     = txtcompcity.Text;
                //objcom.State = ddlcompstate.SelectedValue.ToString();
                objcom.Zip = txtcompzip.Text;
                objcom.PersonResponcible_ID = ddlcompresposible.SelectedValue.ToString();
                caseno       = objcom.Complaint_Number;
                objcom.State = ddlcompstate.SelectedValue;
                if (txtdateinvgcomplete.Text != "")
                {
                    objcom.DateInvestigationComplete = Convert.ToDateTime(txtdateinvgcomplete.Text);
                }
                else
                {
                    objcom.DateInvestigationComplete = Convert.ToDateTime("01/01/1900");
                }

                objcom.ComplaintType = "1";

                objcom.InvestiGator_ID       = ddlcompinvestigate.SelectedValue.ToString();
                objcom.SecondInvestigatiorID = ddlcompinvestigate2.SelectedValue.ToString();
                objcom.Compainant            = txtcomplainant.Text;
                if (txtInvestigateAssigned.Text != "")
                {
                    objcom.DateInvestigatorAssigned = Convert.ToDateTime(txtInvestigateAssigned.Text);
                }
                else
                {
                    objcom.DateInvestigatorAssigned = Convert.ToDateTime("01/01/1900");
                }
                if (txtInvestigatorReceived.Text != "")
                {
                    objcom.DateInvestigatorReceived = Convert.ToDateTime(txtInvestigatorReceived.Text);
                }
                else
                {
                    objcom.DateInvestigatorReceived = Convert.ToDateTime("01/01/1900");
                }
                //  objcom.Consultant = ddlNurseConsultant.SelectedValue.ToString();
                objcom.Complaint_Status = ddlcompstatus.SelectedValue.ToString();
                objcom.modifiedby       = Convert.ToInt32(Session["UID"].ToString());
                objcom.modifieddate     = Convert.ToDateTime(System.DateTime.Now.ToString("MM/dd/yyyy"));
                if (prvres != curres)
                {
                    ComplaintsTabLinq.tbl_Personresponsible_History his = new tbl_Personresponsible_History();
                    his.Complaint_id = objcom.Complaint_ID;
                    his.Old_person   = Convert.ToInt32(prvres);
                    his.New_Person   = Convert.ToInt32(curres);
                    his.Changedby    = Convert.ToInt32(Session["UID"].ToString());
                    his.Changeddt    = DateTime.Now;
                    cdb.tbl_Personresponsible_Histories.InsertOnSubmit(his);
                }
                if (pstatus != cstatus)
                {
                    ComplaintsTabLinq.tbl_ComplaintStatusChanged_History cmpstatushis = new tbl_ComplaintStatusChanged_History();
                    cmpstatushis.Complaint_ID        = objcom.Complaint_ID;
                    cmpstatushis.Complaint_Number    = objcom.Complaint_Number;
                    cmpstatushis.Person_ID           = objcom.Respondent_ID;
                    cmpstatushis.Old_Status          = pstatus;
                    cmpstatushis.New_Status          = cstatus;
                    cmpstatushis.Date_Status_Changed = Convert.ToDateTime(DateTime.Now.ToShortDateString());
                    cmpstatushis.Modify_By           = Session["UID"].ToString();
                    cmpstatushis.Modify_Date         = Convert.ToDateTime(DateTime.Now.ToShortDateString());
                    cdb.tbl_ComplaintStatusChanged_Histories.InsertOnSubmit(cmpstatushis);
                }
                cdb.SubmitChanges();
            }
            if (prvres != curres && ddlcompstatus.SelectedValue != "1049")
            {
                prvres = AdminLinq.Admin.Getemail(prvres);
                //prvres = prvres + ";" + "*****@*****.**";
                curres = AdminLinq.Admin.Getemail(curres);
                DataTable dt = new DataTable();
                dt = Utilities_Licensing.GetNameandLicno(Convert.ToInt32(hfdautoid.Value));
                string st = @"<table cellspacing='0' width='100%' >
                              <tr>
                              <td style='text-align:left;' colspan='3'><b>This Email is to notify you that a case has been assigned to you.</b><br/><br/></td>
                              </tr>";
                foreach (DataRow dr in dt.Rows)
                {
                    st = st + @"<tr>
                                <td style='text-align: left;'><b>Respondent :</b></td>  
                                <td style='text-align:left;'>" + dr["Name"].ToString() + "</td></tr>";
                    st = st + @"<tr>
                                <td style='text-align: left;'><b>License Type :</b></td>  
                                <td style='text-align:left;'>" + dr["License_Type"].ToString() + "</td></tr>";
                    st = st + @"<tr>
                                <td style='text-align: left;'><b>License # :</b></td>  
                                <td style='text-align:left;'>" + dr["Lic_no"].ToString() + "</td></tr>";
                    st = st + @"<tr>
                            <td style='text-align:left;'><b>License Status :</b></td>
                            <td style='text-align:left;'>" + dr["LicenseStatus"].ToString() + "</td></tr>";
                }
                if (chkattachdoc.Checked == true)
                {
                    DataSet ds       = Utilities_Licensing.GetDocumentPath(hfdautoid.Value);
                    string  docpath  = ds.Tables[0].Rows[0]["docpath"].ToString();
                    string  comments = ds.Tables[0].Rows[0]["Comments"].ToString();
                    if (docpath.ToString() != "")
                    {
                        st = st + @"<tr><td colspan='2'>&nbsp;</td></tr><tr>
                                <td colspan='2' style='text-align:left;'><a href=" + docpath + " style='text-decoration:none;' target='blank'>Download Initial Complaint Document</a></td></tr>";
                    }
                    if (comments != "" && comments != null)
                    {
                        st = st + @"<tr><td colspan='2'>&nbsp;</td></tr><tr>
<td style='text-align:left;'>Comments :</td><td style='text-align:left'>" + comments + "</td></tr>";
                    }
                }
                st = st + "</table>";

                if (ddlcompsource.SelectedValue == "1257" || ddlcompsource.SelectedValue == "1038" || ddlcompsource.SelectedValue == "1039" || ddlcompsource.SelectedValue == "1040" || ddlcompsource.SelectedValue == "1041" || ddlcompsource.SelectedValue == "1259")
                {
                    Mail.SendMail(ddlcompresposible.SelectedItem.Text, curres, prvres, "Case Assigned : " + caseno, st);
                }
                else
                {
                    prvres = prvres + ";" + "*****@*****.**" + ";" + "*****@*****.**" + ";" + "*****@*****.**";
                    Mail.SendMail(ddlcompresposible.SelectedItem.Text, curres, prvres, "Case Assigned : " + caseno, st);
                }
            }
            if (pstatus != "1049" && cstatus == "1049")
            {
                if (ddlcompsource.SelectedValue == "1257" || ddlcompsource.SelectedValue == "1038" || ddlcompsource.SelectedValue == "1039" || ddlcompsource.SelectedValue == "1040" || ddlcompsource.SelectedValue == "1041" || ddlcompsource.SelectedValue == "1259")
                {
                    DataTable dt = new DataTable();
                    dt = Utilities_Licensing.GetNameandLicno(Convert.ToInt32(hfdautoid.Value));
                    string st = @"<table cellspacing='0' width='100%' >
                              <tr>
                              <td style='text-align:left;' colspan='3'><b>This Email is to notify you that a case :" + caseno + "  Has Been Closed. </b><br/><br/></td></tr>";
                    foreach (DataRow dr in dt.Rows)
                    {
                        st = st + @"<tr>
                                <td style='text-align: left;'><b>Respondent :</b></td>  
                                <td style='text-align:left;'>" + dr["Name"].ToString() + "</td></tr>";
                        st = st + @"<tr>
                                <td style='text-align: left;'><b>License Type :</b></td>  
                                <td style='text-align:left;'>" + dr["License_Type"].ToString() + "</td></tr>";
                        st = st + @"<tr>
                                <td style='text-align: left;'><b>License # :</b></td>  
                                <td style='text-align:left;'>" + dr["Lic_no"].ToString() + "</td></tr>";
                    }
                    st = st + "</table>";

                    Mail.SendMail("", System.Configuration.ConfigurationManager.AppSettings["cmpclose"].ToString(), "", "Case  Closed ", st);
                }
                else
                {
                    DataTable dt = new DataTable();
                    dt = Utilities_Licensing.GetNameandLicno(Convert.ToInt32(hfdautoid.Value));
                    string st = @"<table cellspacing='0' width='100%' >
                              <tr>
                              <td style='text-align:left;' colspan='3'><b>This Email is to notify you that a case :" + caseno + "  Has Been Closed. </b><br/><br/></td></tr>";
                    foreach (DataRow dr in dt.Rows)
                    {
                        st = st + @"<tr>
                                <td style='text-align: left;'><b>Respondent :</b></td>  
                                <td style='text-align:left;'>" + dr["Name"].ToString() + "</td></tr>";
                        st = st + @"<tr>
                                <td style='text-align: left;'><b>License Type :</b></td>  
                                <td style='text-align:left;'>" + dr["License_Type"].ToString() + "</td></tr>";
                        st = st + @"<tr>
                                <td style='text-align: left;'><b>License # :</b></td>  
                                <td style='text-align:left;'>" + dr["Lic_no"].ToString() + "</td></tr>";
                    }
                    st = st + "</table>";

                    Mail.SendMail("", System.Configuration.ConfigurationManager.AppSettings["cmpclose1"].ToString(), "", "Case  Closed ", st);
                }
            }
            string js = " altbox('Complaints updated successfully.');";

            ScriptManager.RegisterStartupScript(Page, GetType(), "scr", js, true);
        }