public void Delete(int intDelSubPonena)
        {
            bool boolMess = false;
            try
            {
                AccreditationDataContext objDb = new AccreditationDataContext();
                objDb.Connection.ConnectionString = System.Configuration.ConfigurationManager.AppSettings["constr"];

                LINQ.TblSubpoenaFrm gc = objDb.TblSubpoenaFrms.Where(D => D.SubpoenaFrmId == intDelSubPonena).Single();
                gc.Active = false;

                objDb.SubmitChanges();

                boolMess = true;
                // Console.WriteLine("ok");
                // Response.Redirect("GroupList.aspx");
            }
            catch (Exception ex)
            {
                boolMess = false;
            }

            return;
            // return boolMess;
        }
        protected void btn_Submit_Click(object sender, EventArgs e)
        {
            AccreditationDataContext objDb = new AccreditationDataContext();
            objDb.Connection.ConnectionString = System.Configuration.ConfigurationManager.AppSettings["constr"];
            //LINQ.User client = objDb.Users.Where(D => D.UserName == txtUserName.Text).Single();
            var user = objDb.TblUserRegistrations.Where(D => D.UserEmail == Querystring.Trim()).FirstOrDefault();
            if (txtnewPassword.Text == txtconfirmmpass.Text)
            {
                if (user.TempPass == txttempass.Text)
                {
                    user.TempPass = "";
                    user.HashPass = DbConnection.GetHash(txtnewPassword.Text);
                    user.Active = true;
                    objDb.SubmitChanges();
                    Response.Redirect("Login.aspx");
                    return;
                }
                else
                {
                    lbFailureText.Text = "Wrong temporary password";

                }

            }
            else
            {

                lbFailureText.Text = "Please confirm password does not match";
            }
        }
        public static void Update(int GrpId, string GrpName, string Address1, string Address2,
                                    string City, int StateId,/*int Zipcode,*/ int CountryId)
        {
            AccreditationDataContext objDB = new AccreditationDataContext();
            objDB.Connection.ConnectionString = System.Configuration.ConfigurationManager.AppSettings["constr"];
            //string report = null;
            try
            {
                LINQ.TblGroupCreation grp = objDB.TblGroupCreations.First(D => D.GrpId == GrpId);
                grp.GrpName = GrpName;
                grp.Address1 = Address1;
                grp.Address2 = Address2;
                grp.City = City;
                grp.StateId = StateId;
                // grp.Zipcode = Zipcode;
                grp.CountryId = CountryId;

                objDB.SubmitChanges();
                // report = BLL.Constants.Update;
            }
            catch (Exception ex)
            {
                //  report = BLL.Constants.NotUpdated;
            }

            //  return report;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string subpoeanaId = Request.QueryString["subpoeanaId"];
            string status = Request.QueryString["Status"];
            string message = string.Empty;

             AccreditationDataContext db = new AccreditationDataContext();
            db.Connection.ConnectionString = System.Configuration.ConfigurationManager.AppSettings["constr"];
            var stsubpoeanrs =
                (from c in db.TblSubpoenaFrms
                 where c.SubpoenaFrmId == int.Parse(subpoeanaId)
                 select c).FirstOrDefault();
            if (status.ToLower() == "yes")
            {
                stsubpoeanrs.Status = ((int)BLL.Constants.Status.YES).ToString(); //"Close";
                stsubpoeanrs.UpdatedOn = DateTime.Now;
                db.SubmitChanges();
                lblMessage.Text = "Accepted subpoena";
                message = "Subpoena hass been accepted by detective";
            }
            else if (status.ToLower() == "maybe")
            {
                stsubpoeanrs.Status = ((int)BLL.Constants.Status.MAYBE).ToString(); //"Close";
                stsubpoeanrs.UpdatedOn = DateTime.Now;
                db.SubmitChanges();
                lblMessage.Text = "Subpoena accepted";
                message = "Subpoena hass been accepted by detective with may be late comment.";
            }
            else
            {
                stsubpoeanrs.Status = ((int)BLL.Constants.Status.NO).ToString();// "Rejected";
                stsubpoeanrs.SaveType = "Save"; //Rejected subpoena change to save status.
                stsubpoeanrs.UpdatedOn = DateTime.Now;
                db.SubmitChanges();
                lblMessage.Text = "Rejected subpoena";
                message = "Subpoena hass been rejected by detective. <br/>Subpoena changed to Save state";
            }
            //stsubpoeanrs.CreatedBy
            SendMail(stsubpoeanrs.CreatedBy, stsubpoeanrs.SubpoenaName, message);
        }
 public static void AddExternalGroupMap(List<LINQ.ExternalGroupMap> externalGroupMapcollection)
 {
     AccreditationDataContext objdb = new AccreditationDataContext();
     IEnumerable<LINQ.ExternalGroupMap> externalGroups = (from e in objdb.ExternalGroupMaps where e.ExternalGroupName.Equals(externalGroupMapcollection[0].ExternalGroupName) select e);
     bool flag = true;
     if (externalGroups.Any())
     {
         foreach (LINQ.ExternalGroupMap ws in externalGroupMapcollection)
         {
             flag = true;
             foreach (LINQ.ExternalGroupMap g in externalGroups)
             {
                 if (g.AMSGroupName.Equals(ws.AMSGroupName))
                 {
                     flag = false;
                 }
             }
             if (flag)
             {
                 objdb.ExternalGroupMaps.InsertOnSubmit(ws);
             }
         }
         flag = true;
         foreach (LINQ.ExternalGroupMap g in externalGroups)
         {
             flag = true;
             foreach (LINQ.ExternalGroupMap ws in externalGroupMapcollection)
             {
                 if (g.AMSGroupName.Equals(ws.AMSGroupName))
                 {
                     flag = false;
                 }
             }
             if (flag)
             {
                 objdb.ExternalGroupMaps.DeleteOnSubmit(g);
             }
         }
     }
     else
     {
         objdb.ExternalGroupMaps.InsertAllOnSubmit(externalGroupMapcollection);
     }
     objdb.SubmitChanges();
 }
Exemple #6
0
        /// <summary>
        /// Edit the Faculty
        /// </summary>
        /// <param name="FacultyId"></param>
        /// <param name="FacultyName"></param>
        /// <param name="Description"></param>
        /// <param name="Message"></param>
        /// <returns></returns>
        public static bool Update(int FacultyId, string FacultyName, string Description, out string Message)
        {
            AccreditationDataContext objDB = new AccreditationDataContext();
            try
            {
                LINQ.Faculty faculty = objDB.Faculties.First(F => F.FacultyId == FacultyId);

                faculty.FacultyName = FacultyName;
                faculty.Description = Description;

                objDB.SubmitChanges();
                Message = "Updated successfully";
                return true;
            }
            catch (Exception ex)
            {
                Message = "Cannot Update";
                return false;
            }
        }
        public static bool Delete(int intDelGrp)
        {
            bool boolMess = false;
            try
            {
                AccreditationDataContext objDb = new AccreditationDataContext();
                objDb.Connection.ConnectionString = System.Configuration.ConfigurationManager.AppSettings["constr"];

                LINQ.TblGroupCreation gc = objDb.TblGroupCreations.Where(D => D.GrpId == intDelGrp).Single();
                gc.Active = false;

                objDb.SubmitChanges();

                boolMess = true;
            }
            catch (Exception ex)
            {
                boolMess = false;
            }
            return boolMess;
        }
        public static void Update(int UserId, string UserFirstName, string UserLastName, string UserEmail, int Group)
        {
            AccreditationDataContext objDB = new AccreditationDataContext();
            objDB.Connection.ConnectionString = System.Configuration.ConfigurationManager.AppSettings["constr"];
            //string report = null;
            try
            {
                LINQ.TblUserRegistration urr = objDB.TblUserRegistrations.First(D => D.UserId == UserId);
                urr.UserFirstName = UserFirstName;
                urr.UserLastName = UserLastName;
                urr.UserEmail = UserEmail;
                urr.Group = Group;

                objDB.SubmitChanges();
                //  report = BLL.Constants.Update;
            }
            catch (Exception ex)
            {
                //  report = BLL.Constants.NotUpdated;
            }

            //  return report;
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (hdneditId.Value != null && hdneditId.Value != "" && int.Parse(hdneditId.Value.ToString()) > 0)
                {
                    AccreditationDataContext objDB = new AccreditationDataContext();
                    objDB.Connection.ConnectionString = System.Configuration.ConfigurationManager.AppSettings["constr"];
                    using (AccreditationDataContext group = new AccreditationDataContext())
                    {
                        LINQ.TblPasswordChange grp = objDB.TblPasswordChanges.First(D => D.PasswordChangeId == int.Parse(hdneditId.Value.ToString()));

                        grp.EmailAddress = txtEmail.Text.Trim();
                        grp.TempPassword = txtTempPassword.Text.Trim();
                        grp.NewPassword = txtNewPassword.Text.Trim();
                        grp.RetypePassword = txtRetypPassword.Text.Trim();

                        grp.Active = true;
                        objDB.SubmitChanges();

                    }
                }else{

                    if (!IsExistEmail(txtEmail.Text.Trim()))
                    {
                        if (string.Compare(txtNewPassword.Text.Trim(), txtRetypPassword.Text.Trim()).Equals(0))
                        {
                            using (AccreditationDataContext passwordchange = new AccreditationDataContext())
                            {
                                TblPasswordChange passwordchange1 = new TblPasswordChange
                                {
                                    EmailAddress = txtEmail.Text.Trim(),
                                    TempPassword = txtTempPassword.Text.Trim(),
                                    NewPassword = txtNewPassword.Text.Trim(),
                                    RetypePassword = txtRetypPassword.Text.Trim(),
                                };
                                passwordchange.Connection.ConnectionString = System.Configuration.ConfigurationManager.AppSettings["constr"];
                                passwordchange.TblPasswordChanges.InsertOnSubmit(passwordchange1);
                                passwordchange.SubmitChanges();

                                // Utilities.CreateMessageLabel(this, BLL.Constants.Insert, true);
                            }
                        }

                    }
                }

                Response.Redirect("PasswordList.aspx");
                return;
        }
        protected void btnSubmit1_Click(object sender, EventArgs e)
        {
            //if (DropDownCountry.SelectedIndex > 0 && DropDownState.SelectedIndex > 0 && txtGroupName.Text.Trim() != string.Empty && txtAddress1.Text.Trim() != string.Empty && txtCity.Text.Trim() != string.Empty)
            ////if (txtGroupName.Text.Trim().Length > 0 && txtLastName.Text.Trim().Length > 0 && txtEmail.Text.Trim().Length > 0 && Convert.ToInt16(DropDownGroup.SelectedItem.Value)>0)
            //{
            if (btnSubmit1.Text.Equals("Submit"))
            {

                if (hdneditId.Value != null && hdneditId.Value != "" && int.Parse(hdneditId.Value.ToString()) > 0)
                {

                    AccreditationDataContext objDB = new AccreditationDataContext();
                    objDB.Connection.ConnectionString = System.Configuration.ConfigurationManager.AppSettings["constr"];
                    using (AccreditationDataContext group = new AccreditationDataContext())
                    {
                        LINQ.TblGroupCreation grp = objDB.TblGroupCreations.First(D => D.GrpId == int.Parse(hdneditId.Value.ToString()));
                        if (grp.GrpName.Trim() == txtGroupName.Text.Trim())
                        {
                            grp.GrpName = txtGroupName.Text.Trim();
                            grp.Address1 = txtAddress1.Text.Trim();
                            grp.Address2 = txtAddress2.Text.Trim();
                            grp.City = txtCity.Text.Trim();
                            grp.StateId = Convert.ToInt16(DropDownState.SelectedItem.Value);
                            grp.Zipcode = txtZipcode.Text;
                            grp.CountryId = Convert.ToInt16(DropDownCountry.SelectedItem.Value);
                            grp.Active = true;
                            objDB.SubmitChanges();
                            showOutputMessage((int)BLL.Constants.MessageType.Success, "Group updated successfully.");
                        }
                        else
                        {
                            if (!IsExistGroup(txtGroupName.Text.Trim(), int.Parse(hdneditId.Value.ToString())))
                            {
                                grp.GrpName = txtGroupName.Text.Trim();
                                grp.Address1 = txtAddress1.Text.Trim();
                                grp.Address2 = txtAddress2.Text.Trim();
                                grp.City = txtCity.Text.Trim();
                                grp.StateId = Convert.ToInt16(DropDownState.SelectedItem.Value);
                                grp.Zipcode = txtZipcode.Text;
                                grp.CountryId = Convert.ToInt16(DropDownCountry.SelectedItem.Value);
                                grp.Active = true;
                                objDB.SubmitChanges();
                                showOutputMessage((int)BLL.Constants.MessageType.Success, "Group updated successfully.");
                            }
                            else
                            {
                               // Response.Write("<script>alert('This Group Name Already exist.')</script>");
                                showOutputMessage((int)BLL.Constants.MessageType.Fail, "This Group Name Already exist.");
                                return;
                                //Utilities.CreateMessageLabel(this, BLL.Constants.UnableToCreateGroup, false);
                            }
                        }

                    }

                }
                else
                {
                    if (!IsExistGroup(txtGroupName.Text.Trim(), 0))
                    {
                        using (AccreditationDataContext group = new AccreditationDataContext())
                        {
                            TblGroupCreation group1 = new TblGroupCreation
                            {
                                GrpName = txtGroupName.Text.Trim(),
                                Address1 = txtAddress1.Text.Trim(),
                                Address2 = txtAddress2.Text.Trim(),
                                City = txtCity.Text.Trim(),
                                StateId = Convert.ToInt16(DropDownState.SelectedItem.Value),
                                Zipcode = txtZipcode.Text,
                                CountryId = Convert.ToInt16(DropDownCountry.SelectedItem.Value),
                                Active = true,
                            };
                            group.Connection.ConnectionString = System.Configuration.ConfigurationManager.AppSettings["constr"];
                            group.TblGroupCreations.InsertOnSubmit(group1);
                            group.SubmitChanges();
                            showOutputMessage((int)BLL.Constants.MessageType.Success, "Group created successfully.");

                        }
                    }
                    else
                    {
                       // Response.Write("<script>alert('This Group Name Already exist.')</script>");
                        showOutputMessage((int)BLL.Constants.MessageType.Fail, "This Group Name Already exist.");
                        return;
                        //Utilities.CreateMessageLabel(this, BLL.Constants.UnableToCreateGroup, false);
                    }

                }

            }

            Response.AddHeader("REFRESH", "5;URL=GroupList.aspx");
            //Response.Redirect("GroupList.aspx");
            return;
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            //if (txtFirstName.Text.Trim().Length > 0 && txtLastName.Text.Trim().Length > 0 && txtEmail.Text.Trim().Length > 0 && DropDownGroup.SelectedIndex > 0)
            //{
            if (btnSubmit.Text.Equals("Submit"))
            {

                if (hdneditId.Value != null && hdneditId.Value != "" && int.Parse(hdneditId.Value.ToString()) > 0)
                {
                    AccreditationDataContext objDB = new AccreditationDataContext();
                    objDB.Connection.ConnectionString = System.Configuration.ConfigurationManager.AppSettings["constr"];
                    using (AccreditationDataContext group = new AccreditationDataContext())
                    {
                        LINQ.TblUserRegistration grp = objDB.TblUserRegistrations.First(D => D.UserId == int.Parse(hdneditId.Value.ToString()));
                        if (grp.UserEmail.Trim() == txtEmail.Text.Trim())
                        {
                            grp.UserFirstName = txtFirstName.Text.Trim();
                            grp.UserLastName = txtLastName.Text.Trim();
                            grp.UserEmail = txtEmail.Text.Trim();
                            grp.Group = Convert.ToInt16(DropDownGroup.SelectedItem.Value);
                            grp.UpdatedOn = DateTime.Now;
                            grp.UpdatedBy = Session["UserEmail"].ToString();
                            grp.userRole = DropdownUserrole.SelectedItem.Value;
                            //grp.Active = true;

                            objDB.SubmitChanges();
                            showOutputMessage((int)BLL.Constants.MessageType.Success, "User Updated Successully.");

                        }
                        else
                        {
                            if (!IsExistEmail(txtEmail.Text.Trim(), int.Parse(hdneditId.Value.ToString())))
                            {
                                grp.UserFirstName = txtFirstName.Text.Trim();
                                grp.UserLastName = txtLastName.Text.Trim();
                                grp.UserEmail = txtEmail.Text.Trim();
                                grp.Group = Convert.ToInt16(DropDownGroup.SelectedItem.Value);
                                grp.UpdatedOn = DateTime.Now;
                                grp.UpdatedBy = Session["UserEmail"].ToString();
                                grp.userRole = DropdownUserrole.SelectedItem.Text;
                                // grp.Active = true;
                                objDB.SubmitChanges();
                                showOutputMessage((int)BLL.Constants.MessageType.Success, "User Updated Successully.");
                                System.Threading.Thread.Sleep(3000);
                            }
                            else
                            {
                                //Response.Write("<script>alert('This Email Already exist.')</script>");
                                showOutputMessage((int)BLL.Constants.MessageType.Fail, "This Email Already exist.");
                                return;
                                //Utilities.CreateMessageLabel(this, BLL.Constants.UnableToCreateGroup, false);
                            }

                        }
                    }
                }
                else
                {
                    if (!IsExistEmail(txtEmail.Text.Trim(), 0))
                    {
                        string temppass = CreateRandomPassword(6);
                        using (AccreditationDataContext registration = new AccreditationDataContext())
                        {
                            TblUserRegistration registration1 = new TblUserRegistration
                            {
                                UserFirstName = txtFirstName.Text.Trim(),
                                UserLastName = txtLastName.Text.Trim(),
                                UserEmail = txtEmail.Text.Trim(),
                                Group = Convert.ToInt16(DropDownGroup.SelectedItem.Value),
                                CreatedBy = Session["UserEmail"].ToString(),
                                CreatedOn = DateTime.Now,
                                Active = false,
                                userRole = DropdownUserrole.SelectedItem.Text,
                                TempPass = temppass,
                                HashPass = ""
                            };
                            registration.Connection.ConnectionString = System.Configuration.ConfigurationManager.AppSettings["constr"];
                            registration.TblUserRegistrations.InsertOnSubmit(registration1);
                            registration.SubmitChanges();
                            SendMail(txtEmail.Text.Trim(), txtFirstName.Text, temppass);
                            showOutputMessage((int)BLL.Constants.MessageType.Success, "User created Successully.");
                            System.Threading.Thread.Sleep(3000);
                        }
                    }
                    else
                    {
                        //Response.Write("<script>alert('This Email Already exist.')</script>");
                        showOutputMessage((int)BLL.Constants.MessageType.Fail, "This Email Already exist.");
                        return;
                        //Utilities.CreateMessageLabel(this, BLL.Constants.UnableToCreateGroup, false);
                    }
                } //--

            }

            Response.AddHeader("REFRESH", "5;URL=UserRegList.aspx");
               // Response.Redirect("UserRegList.aspx");
            return;
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            String NewCaseId="";
            //if (DrpDwnCity.SelectedIndex > 0 && txtGrpName.Text.Trim() != string.Empty
            //    && txtNatureofBsns1.Text.Trim() != string.Empty && txtAddr1.Text.Trim() != string.Empty)
            //string queryautonum = " select isnull(MAX(CaseId),0)+1 from TblSubpoenaFrm where  ISNUMERIC(CaseId)=1";
            string queryautonum = "select isnull(MAX(SUBSTRING(CaseId,6,6)),0)+1 from TblSubpoenaFrm";
            DataSet Result = DbConnection.GetMultitableTableData(queryautonum);
            String CaseIdUpld="";
            //try
            //{
            if (btnSave.Text.Equals("Save"))
            {
             //   Constants cons = new Constants();

                if (txtEditSubpoeanaId.Value != null && txtEditSubpoeanaId.Value != "" && int.Parse(txtEditSubpoeanaId.Value.ToString()) > 0)
                {
                    AccreditationDataContext objDB = new AccreditationDataContext();
                    objDB.Connection.ConnectionString = System.Configuration.ConfigurationManager.AppSettings["constr"];
                    using (AccreditationDataContext group = new AccreditationDataContext())
                    {
                        LINQ.TblSubpoenaFrm Sbf = objDB.TblSubpoenaFrms.First(D => D.SubpoenaFrmId == int.Parse(txtEditSubpoeanaId.Value.ToString()));
                        CaseIdUpld=Sbf.CaseId;
                        Sbf.SubpoenaName = txtSubpoenaName.Text.Trim();
                        Sbf.StateId = Convert.ToInt16(DrpDwnState.SelectedItem.Value);
                        Sbf.CountyId = Convert.ToInt16(DrpDwnCounty.SelectedItem.Value);
                        Sbf.GroupId = Convert.ToInt16(DropDownGroup.SelectedItem.Value);
                        Sbf.Supervisor = txtSupervisor.Text.Trim();
                        Sbf.Representative = txtRepresentative.Text.Trim();
                        // Sbf.PDFPath = pdfFileName;
                        Sbf.DetectiveId = Convert.ToInt16(DropDownDetective.SelectedItem.Value);
                        // Sbf.CaseId = "CASE-" + Result.Tables[0].Rows[0][0].ToString().PadLeft(6, Convert.ToChar("0"));
                        // OfficialName =
                        // DetativeName = txtAddr1.Text.Trim(),
                        Sbf.OfficialName = string.Empty;// "Test name";
                        Sbf.DetativeName = DropDownDetective.SelectedItem.Text;// "Test";

                        //   Sbf.Status = Constants.Status.NEW.ToString();
                        Sbf.SaveType = "Save";
                        Sbf.Date = (txtDate.Text.Trim().ToString().Length > 0) ? Convert.ToDateTime(txtDate.Text.Trim()) : System.DateTime.Now;
                        Sbf.Custodian = txtCustodian.Text.Trim();
                        Sbf.RecordsPertainTo = txtRecordsPertainTo.Text.Trim();
                        Sbf.AddressIndividualBusiness = txtAddressIndividualBusiness.Text.Trim();
                        Sbf.CrimeUnderInvestigation = txtCrimeUnderInvestigation.Text.Trim();
                        Sbf.FSS = txtFSS.Text.Trim();
                        Sbf.Suspect = txtSuspect.Text.Trim();
                        Sbf.Offense = txtOffense.Text.Trim();
                        Sbf.InformationRequested = txtInformationRequested.Text.Trim();
                        // Disclaimer =
                        Sbf.ProbableCause = txtProbableCause.Text.Trim();
                        //Status =
                        Sbf.Disclaimer = chkboxYes.Checked == true ? true : false;
                        Sbf.SignatureRequired = txtRepresentative.Text.Trim();
                        Sbf.DisclaimerYes = chkboxNo.Checked == true ? true : false;

                        Sbf.IsDigitalSupervisor = RdoSupDigSig.Checked == true ? true : false;
                        Sbf.IsDigitalRepresentative = RdoDigSig.Checked == true ? true : false;
                        Sbf.SupervisorSignatureRequired = txtSupervisorSig.Text.Trim();
                        Sbf.RepresentativeSig = txtRepresentativeSig.Text.Trim();
                        Sbf.Active = true;
                        if (UploadRepFile.HasFile)
                            Sbf.RepresentiveSignatureFile = getUploadFileName(CaseIdUpld, UploadRepFile.FileName, REPRESENTATIVE_SIGNATURE);
                        if (UploadSupFile.HasFile)
                            Sbf.SupervisorSignatureFile = getUploadFileName(CaseIdUpld, UploadSupFile.FileName, SUPERVISOR_SIGNATURE);
                        // CreatedOn = System.DateTime.Now,
                        Sbf.UpdatedBy = Session["UserEmail"].ToString();
                        Sbf.UpdatedOn = System.DateTime.Now;
                        objDB.SubmitChanges();
                    }

                }
                else
                {

                    using (AccreditationDataContext subpoena = new AccreditationDataContext())
                    {

                        CaseIdUpld="CASE-" + Result.Tables[0].Rows[0][0].ToString().PadLeft(6, Convert.ToChar("0"));
                        TblSubpoenaFrm subpoena1 = new TblSubpoenaFrm

                        {
                            SubpoenaName = txtSubpoenaName.Text.Trim(),
                            StateId = Convert.ToInt16(DrpDwnState.SelectedItem.Value),
                            CountyId = Convert.ToInt16(DrpDwnCounty.SelectedItem.Value),
                            GroupId = Convert.ToInt16(DropDownGroup.SelectedItem.Value),
                            Supervisor = txtSupervisor.Text.Trim(),
                            Representative = txtRepresentative.Text.Trim(),
                            DetectiveId = Convert.ToInt16(DropDownDetective.SelectedItem.Value),
                            CaseId = "CASE-" + Result.Tables[0].Rows[0][0].ToString().PadLeft(6, Convert.ToChar("0")),
                            // OfficialName =
                            // DetativeName = txtAddr1.Text.Trim(),
                            OfficialName =string.Empty,// "Test name",
                            DetativeName = DropDownDetective.SelectedItem.Text,//string.Empty,//"Test",
                            Status =((int)BLL.Constants.Status.NEW).ToString(),// Constants.Status.NEW.ToString(),
                            SaveType = "Save",
                            Date = (txtDate.Text.Trim().ToString().Length > 0) ? Convert.ToDateTime(txtDate.Text.Trim()) : System.DateTime.Now,
                            Custodian = txtCustodian.Text.Trim(),
                            RecordsPertainTo = txtRecordsPertainTo.Text.Trim(),
                            AddressIndividualBusiness = txtAddressIndividualBusiness.Text.Trim(),
                            CrimeUnderInvestigation = txtCrimeUnderInvestigation.Text.Trim(),

                            FSS = txtFSS.Text.Trim(),
                            Suspect = txtSuspect.Text.Trim(),
                            Offense = txtOffense.Text.Trim(),
                            InformationRequested = txtInformationRequested.Text.Trim(),
                            // Disclaimer =
                            ProbableCause = txtProbableCause.Text.Trim(),
                            //Status =
                            Disclaimer = chkboxYes.Checked == true ? true : false,
                            DisclaimerYes = chkboxNo.Checked == true ? true : false,
                            IsDigitalSupervisor = RdoSupDigSig.Checked == true ? true : false,
                            IsDigitalRepresentative = RdoDigSig.Checked == true ? true : false,
                            SupervisorSignatureRequired = txtSupervisorSig.Text.Trim(),
                            SignatureRequired = txtRepresentative.Text.Trim(),
                            RepresentativeSig = txtRepresentativeSig.Text.Trim(),
                            Active = true,
                            CreatedBy = Session["UserEmail"].ToString(),
                            CreatedOn = System.DateTime.Now,
                            RepresentiveSignatureFile=UploadRepFile.HasFile==true?getUploadFileName(CaseIdUpld,UploadRepFile.FileName,REPRESENTATIVE_SIGNATURE):string.Empty,
                            SupervisorSignatureFile = UploadSupFile.HasFile == true ? getUploadFileName(CaseIdUpld, UploadSupFile.FileName, SUPERVISOR_SIGNATURE) : string.Empty,
                            //UpdatedOn = System.DateTime.Now
                        };

                        NewCaseId = subpoena1.CaseId;
                        subpoena.Connection.ConnectionString = System.Configuration.ConfigurationManager.AppSettings["constr"];
                        subpoena.TblSubpoenaFrms.InsertOnSubmit(subpoena1);
                        subpoena.SubmitChanges();

                    }
                }
                if (UploadRepFile.HasFile)
                {
                    UploadFile(getUploadFileName(CaseIdUpld, UploadRepFile.FileName, REPRESENTATIVE_SIGNATURE), REPRESENTATIVE_SIGNATURE);
                    HypRepSig.Text = getUploadFileName(CaseIdUpld, UploadRepFile.FileName, REPRESENTATIVE_SIGNATURE);
                    HypRepSig.NavigateUrl = "Uploads/Signature/" + getUploadFileName(CaseIdUpld, UploadRepFile.FileName, REPRESENTATIVE_SIGNATURE);
                }

                if (UploadSupFile.FileName != "")
                {
                    UploadFile(getUploadFileName(CaseIdUpld, UploadSupFile.FileName, SUPERVISOR_SIGNATURE), SUPERVISOR_SIGNATURE);
                    HypSupSig.Text = getUploadFileName(CaseIdUpld, UploadSupFile.FileName, SUPERVISOR_SIGNATURE);
                    HypSupSig.NavigateUrl = getUploadFileName(CaseIdUpld, UploadSupFile.FileName, SUPERVISOR_SIGNATURE);
                }

            }
            if(NewCaseId !="")
                showOutputMessage((int)BLL.Constants.MessageType.Success, "Subpoena Saved Successfully..Case ID is " + NewCaseId);
                //Page.ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('Subpoena Saved Successfully..Case ID is " + NewCaseId + "');window.location.href='SubpoenaProducers.aspx';", true);
            else
                showOutputMessage((int)BLL.Constants.MessageType.Success, "Subpoena Updated Successfully");
                //Page.ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('Subpoena Updated Successfully');window.location.href='SubpoenaProducers.aspx';", true);
            Response.AddHeader("REFRESH", "5;URL=SubpoenaProducers.aspx");
            return;
            //  }
            //catch(Exception Ex)
            //{
            //}
        }
        protected void bntSubmit_Click(object sender, EventArgs e)
        {
            //string pdfFileName = DateTime.Now.ToString("yyyyMMddHHmmssfff") + "_Subpoeana.pdf";
            string pdfFileName = DateTime.Now.ToString("yyyyMMddHHmmssfff") + "_Subpoeana.pdf";
            AccreditationDataContext objDB = new AccreditationDataContext();
            objDB.Connection.ConnectionString = System.Configuration.ConfigurationManager.AppSettings["constr"];
            String CaseIdUpld = "";
            int subpoeanaCuurId = 0;

            if (txtEditSubpoeanaId.Value != null && txtEditSubpoeanaId.Value != "" && int.Parse(txtEditSubpoeanaId.Value.ToString()) > 0)
            {
                subpoeanaCuurId = int.Parse(txtEditSubpoeanaId.Value.ToString());
                using (AccreditationDataContext group = new AccreditationDataContext())
                {
                    LINQ.TblSubpoenaFrm Sbf = objDB.TblSubpoenaFrms.First(D => D.SubpoenaFrmId == int.Parse(txtEditSubpoeanaId.Value.ToString()));
                    CaseIdUpld = Sbf.CaseId;
                    Sbf.SubpoenaName = txtSubpoenaName.Text.Trim();
                    Sbf.StateId = Convert.ToInt16(DrpDwnState.SelectedItem.Value);
                    Sbf.CountyId = Convert.ToInt16(DrpDwnCounty.SelectedItem.Value);
                    Sbf.GroupId = Convert.ToInt16(DropDownGroup.SelectedItem.Value);
                    Sbf.Supervisor = txtSupervisor.Text.Trim();
                    Sbf.Representative = txtRepresentative.Text.Trim();
                    Sbf.PDFPath = pdfFileName;
                    Sbf.DetectiveId = Convert.ToInt16(DropDownDetective.SelectedItem.Value);
                    // Sbf.CaseId = "CASE-" + Result.Tables[0].Rows[0][0].ToString().PadLeft(6, Convert.ToChar("0"));
                    // OfficialName =
                    // DetativeName = txtAddr1.Text.Trim(),
                    Sbf.OfficialName = string.Empty;// "Test name";
                    Sbf.DetativeName = DropDownDetective.SelectedItem.Text;// string.Empty;// "Test";
                    Sbf.Status = ((int)BLL.Constants.Status.NEW).ToString();// "New";
                    Sbf.SaveType = "Submit";
                    Sbf.Date = (txtDate.Text.Trim().ToString().Length > 0) ? Convert.ToDateTime(txtDate.Text.Trim()) : System.DateTime.Now;
                    Sbf.Custodian = txtCustodian.Text.Trim();
                    Sbf.RecordsPertainTo = txtRecordsPertainTo.Text.Trim();
                    Sbf.AddressIndividualBusiness = txtAddressIndividualBusiness.Text.Trim();
                    Sbf.CrimeUnderInvestigation = txtCrimeUnderInvestigation.Text.Trim();
                    if (UploadRepFile.HasFile)
                        Sbf.RepresentiveSignatureFile = getUploadFileName(CaseIdUpld, UploadRepFile.FileName, REPRESENTATIVE_SIGNATURE);
                    if (UploadSupFile.HasFile)
                        Sbf.SupervisorSignatureFile = getUploadFileName(CaseIdUpld, UploadSupFile.FileName, SUPERVISOR_SIGNATURE);
                    Sbf.FSS = txtFSS.Text.Trim();
                    Sbf.Suspect = txtSuspect.Text.Trim();
                    Sbf.Offense = txtOffense.Text.Trim();
                    Sbf.InformationRequested = txtInformationRequested.Text.Trim();
                    Sbf.IsDigitalSupervisor = RdoSupDigSig.Checked == true ? true : false;
                    Sbf.IsDigitalRepresentative = RdoDigSig.Checked == true ? true : false;
                    // Disclaimer =
                    Sbf.ProbableCause = txtProbableCause.Text.Trim();
                    //   Sbf.SignatureRequired=txt

                    Sbf.Active = true;
                    Sbf.UpdatedBy = Session["UserEmail"].ToString();
                    // Sbf.CreatedOn = System.DateTime.Now;
                    Sbf.UpdatedOn = System.DateTime.Now;
                    objDB.SubmitChanges();
                    showOutputMessage((int)BLL.Constants.MessageType.Success, "Subpoena submitted Successfully");
                }

            }
            else
            {

              //  string queryautonum = "select isnull(MAX(CaseId),0)+1 from TblSubpoenaFrm where  ISNUMERIC(CaseId)=1";
                string queryautonum = "select isnull(MAX(SUBSTRING(CaseId,6,6)),0)+1 from TblSubpoenaFrm";
                DataSet Result = DbConnection.GetMultitableTableData(queryautonum);
                using (AccreditationDataContext subpoena = new AccreditationDataContext())
                {
                    CaseIdUpld = "CASE-" + Result.Tables[0].Rows[0][0].ToString().PadLeft(6, Convert.ToChar("0"));
                    TblSubpoenaFrm subpoena1 = new TblSubpoenaFrm

                    {
                        SubpoenaName = txtSubpoenaName.Text.Trim(),
                        StateId = Convert.ToInt16(DrpDwnState.SelectedItem.Value),
                        CountyId = Convert.ToInt16(DrpDwnCounty.SelectedItem.Value),
                        GroupId = Convert.ToInt16(DropDownGroup.SelectedItem.Value),
                        Supervisor = txtSupervisor.Text.Trim(),
                        Representative = txtRepresentative.Text.Trim(),
                        PDFPath = pdfFileName,
                        DetectiveId = Convert.ToInt16(DropDownDetective.SelectedItem.Value),
                        CaseId = "CASE-" + Result.Tables[0].Rows[0][0].ToString().PadLeft(6, Convert.ToChar("0")),
                        // OfficialName =
                        // DetativeName = txtAddr1.Text.Trim(),
                        OfficialName =string.Empty,// "Test name",
                        DetativeName =DropDownDetective.SelectedItem.Text,// "Test",
                        Status = ((int)BLL.Constants.Status.NEW).ToString(),//"New",
                        SaveType = "Submit",
                        Date = (txtDate.Text.Trim().ToString().Length > 0) ? Convert.ToDateTime(txtDate.Text.Trim()) : System.DateTime.Now,
                        Custodian = txtCustodian.Text.Trim(),
                        RecordsPertainTo = txtRecordsPertainTo.Text.Trim(),
                        AddressIndividualBusiness = txtAddressIndividualBusiness.Text.Trim(),
                        CrimeUnderInvestigation = txtCrimeUnderInvestigation.Text.Trim(),

                        IsDigitalSupervisor = RdoSupDigSig.Checked == true ? true : false,
                        IsDigitalRepresentative = RdoDigSig.Checked == true ? true : false,
                        RepresentiveSignatureFile = UploadRepFile.HasFile == true ? getUploadFileName(CaseIdUpld, UploadRepFile.FileName, REPRESENTATIVE_SIGNATURE) : string.Empty,
                        SupervisorSignatureFile = UploadSupFile.HasFile == true ? getUploadFileName(CaseIdUpld, UploadSupFile.FileName, SUPERVISOR_SIGNATURE) : string.Empty,

                        FSS = txtFSS.Text.Trim(),
                        Suspect = txtSuspect.Text.Trim(),
                        Offense = txtOffense.Text.Trim(),
                        InformationRequested = txtInformationRequested.Text.Trim(),
                        SignatureRequired = txtRepresentative.Text.Trim(),
                        RepresentativeSig = txtRepresentativeSig.Text.Trim(),
                        // Disclaimer =
                        ProbableCause = txtProbableCause.Text.Trim(),
                        //Status =

                        Active = true,
                        CreatedOn = System.DateTime.Now,
                        CreatedBy = Session["UserEmail"].ToString(),
                        //UpdatedOn = System.DateTime.Now
                    };

                    if (UploadRepFile.HasFile)
                    {
                        UploadFile(getUploadFileName(CaseIdUpld, UploadRepFile.FileName, REPRESENTATIVE_SIGNATURE), REPRESENTATIVE_SIGNATURE);
                        HypRepSig.Text = getUploadFileName(CaseIdUpld, UploadRepFile.FileName, REPRESENTATIVE_SIGNATURE);
                        HypRepSig.NavigateUrl = "Uploads/Signature/" + getUploadFileName(CaseIdUpld, UploadRepFile.FileName, REPRESENTATIVE_SIGNATURE);
                    }

                    if (UploadSupFile.FileName != "")
                    {
                        UploadFile(getUploadFileName(CaseIdUpld, UploadSupFile.FileName, SUPERVISOR_SIGNATURE), SUPERVISOR_SIGNATURE);
                        HypSupSig.Text = getUploadFileName(CaseIdUpld, UploadSupFile.FileName, SUPERVISOR_SIGNATURE);
                        HypSupSig.NavigateUrl = getUploadFileName(CaseIdUpld, UploadSupFile.FileName, SUPERVISOR_SIGNATURE);
                    }

                    //UploadSupFile.SaveAs(Server.MapPath("Uploads/Signature\\" + UploadSupFile.FileName));
                    subpoena.Connection.ConnectionString = System.Configuration.ConfigurationManager.AppSettings["constr"];
                    subpoena.TblSubpoenaFrms.InsertOnSubmit(subpoena1);
                    subpoena.SubmitChanges();
                    subpoeanaCuurId = subpoena1.SubpoenaFrmId;
                    showOutputMessage((int)BLL.Constants.MessageType.Success, "Subpoena submitted Successfully");
                }

            }

            CreatePdfFile(pdfFileName);

            var userRegDetect = objDB.TblUserRegistrations.Where(x => x.UserId == Convert.ToInt16(DropDownDetective.SelectedItem.Value)).FirstOrDefault();
            SendMail(userRegDetect.UserEmail, userRegDetect.UserFirstName, subpoeanaCuurId, userRegDetect.Group);
            Response.AddHeader("REFRESH", "5;URL=SubpoenaProducers.aspx");
            //Response.Redirect("SubpoenaProducers.aspx");
            return;
        }