private void SaveAdmissionDetails(string strAction)
        {
            try
            {
                EWA_Admission objEWA = new EWA_Admission();
                BL_Admission  objBAL = new BL_Admission();

                // Get College ID And Name From Session

                // Panel 1

                objEWA.TransationAction = strAction.ToString();
                objEWA.AdmissionID      = txtFormNo.Text.ToString();

                objEWA.AdmissionDate = txtAdmissionDate.Text;
                objEWA.OrgID         = Convert.ToInt32(DDL_SelectCollege.SelectedValue);

                objEWA.GRNo    = txtGRNo.Text;
                objEWA.AdharNo = txtAdhar.Text;

                objEWA.FirstName  = txtFirstName.Text.Trim();
                objEWA.MiddleName = txtMiddleName.Text.Trim();
                objEWA.LastName   = txtLastName.Text.Trim();

                objEWA.Course        = ddlCourse.SelectedValue.Trim().Trim();
                objEWA.Branch_ID     = Convert.ToInt32(ddlBranch.SelectedValue);
                objEWA.Class1        = ddlClass.SelectedValue.Trim().Trim();
                objEWA.BirthDate     = txtBirthDate.Text;
                objEWA.BirthPlace    = txtBirthPlace.Text.Trim();
                objEWA.Country1      = ddlCountry.SelectedValue.ToString();
                objEWA.State1        = ddlState.SelectedValue.ToString();
                objEWA.District1     = ddlDistrict.SelectedValue.ToString();
                objEWA.Taluka1       = txtTal.Text.Trim();
                objEWA.City1         = txtCity.Text.Trim();
                objEWA.LastInstitute = txtLastSchool.Text.Trim();
                objEWA.Gender1       = rbtGender.SelectedItem.ToString();
                objEWA.BloodGroup    = ddlBloodGroup.SelectedValue.ToString();
                objEWA.Religion1     = ddlReligion.SelectedValue.ToString();
                objEWA.Subcaste      = txtSubcaste.Text;
                objEWA.MotherTongue  = txtMotherTongue.Text;
                objEWA.Nationality1  = ddlNationality.SelectedValue.ToString();
                objEWA.AddressLine1  = txtAddress1.Text.Trim();
                objEWA.AddressLine2  = txtAddress2.Text.Trim();
                objEWA.FeesCategory  = ddlFeeCategory.SelectedValue.ToString().Trim();
                objEWA.CasteCategory = ddlCaste.SelectedValue.Trim();

                objEWA.ParentName = txtFather.Text.Trim();
                objEWA.MotherName = txtMother.Text.Trim();

                objEWA.ParentMobile = txtFatherMobile.Text.Trim();
                objEWA.ParentEmail  = txtFatherEmail.Text.Trim();

                objEWA.Parent_Education  = txtFatherEdu.Text.Trim();
                objEWA.Parent_Occupation = txtFatherOccu.Text.Trim();

                objEWA.MobileNo      = txtFatherMobile.Text.Trim();
                objEWA.E_Mail        = txtFatherEmail.Text.Trim();
                objEWA.AdmissionYear = System.DateTime.Now.ToString("yyyy");
                objEWA.GuardianName  = txtMother.Text.ToString();
                objEWA.Relation1     = "Mother";

                objEWA.GuardianMobile = txtMotherMobile.Text.Trim();
                objEWA.GuardianEmail  = txtMotherEmail.Text.Trim();

                objEWA.Guardian_Education  = txtMotherEdu.Text.Trim();
                objEWA.Guardian_Occupation = txtMotherOccu.Text.Trim();

                // Panel Parent information

                objEWA.StudentUserName = txtFormNo.Text.Trim();

                objEWA.StudentPassword = txtFormNo.Text.Trim();

                // Iamage Store
                int    length       = 0;
                byte[] imgPhotobyte = null;

                if (fileupload_StudentPhoto.HasFile)
                {
                    length       = fileupload_StudentPhoto.PostedFile.ContentLength;
                    imgPhotobyte = new byte[length];
                    HttpPostedFile img1 = fileupload_StudentPhoto.PostedFile;
                    img1.InputStream.Read(imgPhotobyte, 0, length);
                    ViewState["StudentPhoto"] = imgPhotobyte;
                }
                GridToDatatable();
                objEWA.dtDocuments  = ViewState["tempDocs"] as DataTable;
                objEWA.StudentPhoto = (byte[])ViewState["StudentPhoto"];

                objEWA.Status = "Pending";

                if (Session["GRNO"] != null)
                {
                    if (Session["GRNO"].ToString() == txtGRNo.Text)
                    {
                        //msgBox.ShowMessage("Record already present !!!", "Information", UserControls.MessageBox.MessageStyle.Successfull);
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Information", "alert('Form Submitted Successfully')", true);
                        ClearControls();
                        return;
                    }
                }
                else
                {
                    Session["GRNO"] = txtGRNo.Text;
                }

                int flag = objBAL.InsertInto(objEWA);

                if (flag > 0)
                {
                    if (strAction == "Save")
                    {
                        //string strSMS = null;
                        //string strEmail = null;

                        // strEmail = SendEmails();
                        msgBox.ShowMessage("Form Submitted  Successfully", "Saved", UserControls.MessageBox.MessageStyle.Successfull);
                        print();
                        Button1.Visible = true;
                        btnSave.Visible = false;

                        // msgBox.ShowMessage(strSMS, "Saved", UserControls.MessageBox.MessageStyle.Successfull);

                        // msgBox.ShowMessage(strEmail, "Saved", UserControls.MessageBox.MessageStyle.Successfull);
                        //  ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Form Sumitted  Successfully Check Your Mail  !!!')", true);

                        //  Response.Redirect("~/College_Home.aspx");
                        ClearControls();
                        // Response.Redirect("~/Forms/Admin/College_Home.aspx");
                    }
                    else if (strAction == "Update")
                    {
                        msgBox.ShowMessage("Record Updated Successfully !!!", "Updated", UserControls.MessageBox.MessageStyle.Successfull);
                    }
                    else if (strAction == "Delete")
                    {
                        msgBox.ShowMessage("Record Deleted Successfully !!!", "Deleted", UserControls.MessageBox.MessageStyle.Successfull);
                    }
                }
            }
            catch (Exception)
            {
                // throw;
            }
        }
        private void SaveAdmissionDetails(string strAction)
        {
            try
            {
                EWA_Admission objEWA = new EWA_Admission();
                BL_Admission  objBAL = new BL_Admission();

                // Get College ID And Name From Session

                // Panel 1

                objEWA.TransationAction = strAction.ToString();
                objEWA.AdmissionID      = lbl_ApplicationId.Text.ToString();

                //System.Data.SqlTypes.SqlDateTime AdmissionDate = System.Data.SqlTypes.SqlDateTime.Parse(lblAdmissionDate.Text);
                DateTime datetime1 = Convert.ToDateTime(lblAdmissionDate.Text);

                objEWA.AdmissionDate = datetime1.ToString();
                objEWA.OrgID         = Convert.ToInt32(Session["OrgId"]);

                objEWA.AdmissionType = ddl_AdmissionType.SelectedValue.ToString().Trim();
                objEWA.Course        = ddl_Course.SelectedValue.Trim().Trim();
                objEWA.Branch_ID     = Convert.ToInt32(ddl_Branch.SelectedValue);
                objEWA.Class1        = ddl_Class.SelectedValue.Trim().Trim();

                objEWA.PreviousRollNo = txt_PreviousRollNo.Text.Trim();
                objEWA.FeesCategory   = ddl_FeesCategory.SelectedItem.ToString().Trim();
                objEWA.CasteCategory  = ddl_CasteCategory.SelectedValue.Trim();

                // Panel 2

                objEWA.FirstName  = txt_FirstName.Text.Trim();
                objEWA.MiddleName = txt_MiddleName.Text.Trim();
                objEWA.LastName   = txt_LastName.Text.Trim();
                objEWA.Gender1    = rbt_Gender.SelectedItem.ToString();



                System.Data.SqlTypes.SqlDateTime birthdate = System.Data.SqlTypes.SqlDateTime.Parse(txt_BirthDate.Text);

                // DateTime birthdate = DateTime.ParseExact(txt_BirthDate.Text, "yyyy-MM-dd", CultureInfo.InvariantCulture);


                DateTime datetime = Convert.ToDateTime(txt_BirthDate.Text);
                objEWA.BirthDate = datetime.ToString();



                objEWA.BirthPlace   = txt_BirthPlace.Text.Trim();
                objEWA.AddressLine1 = txt_Address1.Text.Trim();
                objEWA.AddressLine2 = txt_Address2.Text.Trim();
                objEWA.Country1     = ddl_Country.SelectedValue.ToString();
                objEWA.State1       = ddl_State.SelectedValue.ToString();
                objEWA.District1    = ddl_District.SelectedValue.ToString();
                objEWA.Taluka1      = TxtTaluka.Text.Trim();
                objEWA.City1        = TxtCity.Text.Trim();
                if (txt_Pincode.Text != string.Empty)
                {
                    objEWA.PinCode1 = Convert.ToInt32(txt_Pincode.Text);
                }

                objEWA.MarriedStatus = rbt_MarriedStatus.SelectedValue.ToString();
                objEWA.MobileNo      = txt_PersonalMobile.Text.Trim();
                objEWA.E_Mail        = txt_Email.Text.Trim();
                objEWA.Nationality1  = DDL_Nationality.SelectedValue.ToString();

                objEWA.BloodGroup    = ddl_BloodGroup.SelectedValue.ToString();
                objEWA.Handicaped    = ddl_Handicap.SelectedValue.ToString();
                objEWA.Conveyanceuse = ddl_ConveyanceUse.SelectedValue.ToString();
                objEWA.Religion1     = ddl_Religion.SelectedValue.ToString();
                objEWA.Caste1        = ddl_Caste.SelectedItem.ToString();
                objEWA.Subcaste      = txtSubcast.Text.Trim();


                objEWA.SportId = DDL_Sports.SelectedValue.ToString();
                objEWA.AdharNo = DDL_SportLevel.SelectedItem.ToString();

                // Panel 3
                objEWA.GuardianName     = txt_GuardianName.Text.ToString();
                objEWA.Relation1        = ddl_Relation.SelectedItem.ToString();
                objEWA.GuardianAddress1 = txt_GuardianAddress1.Text.ToString().Trim();
                objEWA.GuardianAddress2 = txt_GuardianAddress2.Text.ToString().Trim();
                objEWA.GuardianCountry  = ddl_GuardianCountry.SelectedItem.ToString().Trim();
                objEWA.GuardianState    = ddl_GuardianState.SelectedItem.ToString();
                objEWA.GuardianDistrict = ddl_GuardianDistrict.SelectedItem.ToString();
                objEWA.GuardianTaluka   = txtGuardianTaluka.Text.ToString().Trim();
                objEWA.GuardianCity     = txtGuardianCity.Text;
                if (txt_GuardianPincode.Text != string.Empty)
                {
                    objEWA.GuardianPinCode = Convert.ToInt32(txt_GuardianPincode.Text);
                }

                objEWA.GuardianMobile = txt_GuardianMobile.Text.Trim();
                objEWA.GuardianEmail  = txt_GuardianEmail.Text.Trim();

                // Panel Parent information

                objEWA.ParentName     = txt_ParentName.Text.Trim();
                objEWA.MotherName     = txt_MotherName.Text.Trim();
                objEWA.ParentAddress1 = txt_ParentAddress1.Text.Trim();
                objEWA.ParentAddress2 = txt_ParentAddress2.Text.Trim();
                objEWA.ParentCountry  = ddl_ParentCountry.SelectedItem.ToString();
                objEWA.ParentState    = ddl_ParentState.SelectedItem.ToString();
                objEWA.ParentTaluka   = txt_ParentCity.Text.ToString().Trim();
                if (txt_ParentPincode.Text != string.Empty)
                {
                    objEWA.ParentPinCode = Convert.ToInt32(txt_ParentPincode.Text);
                }

                objEWA.ParentMobile = txt_PersonalMobile.Text.Trim();
                objEWA.ParentEmail  = txt_ParentEmail.Text.Trim();


                // Panel Last Instituter information

                objEWA.LastClass     = txt_LastAttendedClass.Text.Trim();
                objEWA.ResidentType  = ddl_ResidentType.SelectedItem.ToString();
                objEWA.LastInstitute = txt_LastAttendedClass.Text.Trim();

                objEWA.PassingMonth = ddl_LastExamPassingMonth.SelectedValue.ToString();
                objEWA.PassingYear  = ddl_LastExamPassingYear.SelectedItem.ToString();
                objEWA.Result1      = txt_Result.Text.Trim();
                objEWA.Percentage1  = txt_Percentage.Text.Trim();

                objEWA.Gap1 = ddl_Gap.SelectedItem.ToString();
                objEWA.TcNo = txt_TcNo.Text.Trim();

                objEWA.BankName = txtBankName.Text.Trim();
                if (txt_AccountNo.Text != string.Empty)
                {
                    objEWA.AccountNo = txt_AccountNo.Text.ToString().Trim();
                }

                objEWA.Branch1  = txt_BranchName.Text.Trim();
                objEWA.IFSCCode = txt_IFSCCode.Text.Trim();



                objEWA.StudentUserName = txt_UserName.Text.Trim();

                objEWA.StudentPassword = txt_Password.Text.Trim();

                // Iamage Store
                int    length       = 0;
                byte[] imgSignbyte  = null;
                byte[] imgPhotobyte = null;

                if (fileupload_StudentPhoto.HasFile)
                {
                    length       = fileupload_StudentPhoto.PostedFile.ContentLength;
                    imgPhotobyte = new byte[length];
                    HttpPostedFile img1 = fileupload_StudentPhoto.PostedFile;
                    img1.InputStream.Read(imgPhotobyte, 0, length);
                    ViewState["StudentPhoto"] = imgPhotobyte;
                }

                objEWA.StudentPhoto = (byte[])ViewState["StudentPhoto"];;

                if (fileupload_StudentSign.HasFile)
                {
                    length      = fileupload_StudentSign.PostedFile.ContentLength;
                    imgSignbyte = new byte[length];
                    HttpPostedFile img1 = fileupload_StudentSign.PostedFile;
                    img1.InputStream.Read(imgSignbyte, 0, length);
                    ViewState["StudentSign"] = imgSignbyte;
                }
                //objEWA.StudentSign = (byte[])ViewState["StudentSign"];


                objEWA.StudentUserName = txt_UserName.Text;

                objEWA.StudentPassword = txt_Password.Text;

                objEWA.Status = "Pending";

                int flag = objBAL.InsertInto(objEWA);

                if (flag > 0)
                {
                    if (strAction == "Save")
                    {
                        msgBox.ShowMessage("Form Sumitted  Successfully Check Your Mail  !!!", "Saved", UserControls.MessageBox.MessageStyle.Successfull);
                        string strSMS   = null;
                        string strEmail = null;

                        msgBox.ShowMessage(strSMS, "Saved", UserControls.MessageBox.MessageStyle.Successfull);
                        strEmail = SendEmails();
                        msgBox.ShowMessage(strEmail, "Saved", UserControls.MessageBox.MessageStyle.Successfull);

                        Response.Redirect("~/College_Home.aspx");
                    }
                    else if (strAction == "Update")
                    {
                        msgBox.ShowMessage("Record Updated Successfully !!!", "Updated", UserControls.MessageBox.MessageStyle.Successfull);
                    }
                    else if (strAction == "Delete")
                    {
                        msgBox.ShowMessage("Record Deleted Successfully !!!", "Deleted", UserControls.MessageBox.MessageStyle.Successfull);
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }