protected void btnSubmit_Click(object sender, EventArgs e)
    {
        try
        {
            Int64 UserId = Convert.ToInt64(Session["UserId"]);

            //DataTable dtFaculty = TMSFacultyDetails.GetSearch(null, UserId, 1, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, 1).Tables[0];
            DataTable dtFaculty = TMSFacultyDetails.GetStaffFacultyDetails(null, 7, UserId).Tables[0];
            if (dtFaculty.Rows.Count > 0)
            {
                Int64             FacultyId  = Convert.ToInt64(dtFaculty.Rows[0]["FD_FacultyDetailsId"]);
                TMSFacultyDetails objFaculty = TMSFacultyDetails.Get(FacultyId);
                if (objFaculty != null)
                {
                    //objFaculty.FDImage = ImageE;

                    if (FileUpload1.PostedFile.FileName != "")
                    {
                        bool   isExist = false;
                        string strFatherFileNameWithPath = FileUpload1.PostedFile.FileName;
                        string strFatherExtensionName    = System.IO.Path.GetExtension(strFatherFileNameWithPath);
                        string strFatherFileName         = System.IO.Path.GetFileName(strFatherFileNameWithPath).Replace(" ", "_");

                        if (strFatherExtensionName.Equals(".jpg") || strFatherExtensionName.Equals(".gif") || strFatherExtensionName.Equals(".png") || strFatherExtensionName.Equals(".jpeg") || strFatherExtensionName.Equals(".bmp"))
                        {
                            isExist = File.Exists(Server.MapPath(@"~\\UploadImages\\FacultyPhoto\\" + strFatherFileName));

                            string[] Name           = strFatherFileName.Split('.');
                            string   Fname          = Name[0];
                            string   ReplacFileName = Fname + "_" + DateTime.Now.ToString("yyyyMMddhhmmss") + strFatherExtensionName;
                            FileUpload1.PostedFile.SaveAs(Server.MapPath(@"..\\UploadImages\\FacultyPhoto\\" + ReplacFileName));
                            objFaculty.FDImage = "../UploadImages/FacultyPhoto/" + ReplacFileName;
                        }
                        else
                        {
                            dvMsg.Visible   = true;
                            lblMessage.Text = "Please Upload .jpg,.gif,.jpeg,.bmp File Only !";
                            dvMsg.Attributes.Add("class", "error_msg");
                            return;
                        }
                    }

                    objFaculty.Update();
                    Response.Redirect("ChangePhoto.aspx?msg=Photo is updated Successfully");
                }
            }
        }
        catch (Exception ex) { }
    }
    protected void btnEdit_Click(object sender, EventArgs e)
    {
        try
        {
            btnSave.Text = "Update";
            SectionEditProfile.Visible = true;
            SectionViewProfile.Visible = false;
            fillCountry();
            BindState();
            BindCity();
            //fillQualification();
            fillCompletedYear();
            Int64     UserId    = Convert.ToInt64(Session["UserId"]);
            DataTable dtFaculty = TMSFacultyDetails.GetStaffFacultyDetails(null, 7, UserId).Tables[0];
            if (dtFaculty.Rows.Count > 0)
            {
                Int64             FacultyId  = Convert.ToInt64(dtFaculty.Rows[0]["FD_FacultyDetailsId"]);
                TMSFacultyDetails objFaculty = TMSFacultyDetails.Get(FacultyId);
                if (objFaculty != null)
                {
                    txtFullName.Text            = objFaculty.FDFirstName;
                    txtMiddleName.Text          = objFaculty.FDMiddleName;
                    txtLatName.Text             = objFaculty.FDLastName;
                    txtBithPlace.Text           = objFaculty.FDBirthPlace;
                    txtDOB.Text                 = String.Format("{0:MM/dd/yyyy}", objFaculty.FDBirthDate);
                    ddlBloddGroup.SelectedValue = Convert.ToString(objFaculty.FDBloodGroup);
                    txtNationality.Text         = objFaculty.FDNationality;
                    txtCaste.Text               = objFaculty.FDCaste;
                    txtSubcaste.Text            = objFaculty.FDSubCaste;
                    ddlGender.SelectedValue     = objFaculty.FDGender;
                    txtMotherTongue.Text        = objFaculty.FDMotherTongue;
                    txtMedicalproblems.Text     = objFaculty.FDMedicalProblem;
                    if (objFaculty.FDJoiningDate != null)
                    {
                        txtDOJ.Text = String.Format("{0:MM/dd/yyyy}", objFaculty.FDJoiningDate);
                    }
                    if (objFaculty.FDHighestDegreeCompletd != null)
                    {
                        //ddlHighestDegree.SelectedValue = objFaculty.FDHighestDegreeCompletd;
                        txtHeighestDegree.Text = objFaculty.FDHighestDegreeCompletd.ToString();;
                    }
                    if (objFaculty.FDSpecificExpertise != "")
                    {
                        ddlSpeciallization.SelectedItem.Text = objFaculty.FDSpecificExpertise;
                    }
                    if (objFaculty.FDCompletionDate != "")
                    {
                        ddlCompletedYear.SelectedValue = objFaculty.FDCompletionDate;
                    }
                    txtUniversity.Text = objFaculty.FDUniversity;

                    txtLastSchoolWas.Text = objFaculty.FDLastSchoolwas;

                    if (objFaculty.FDLastSchoolFromDate != null)
                    {
                        txtLastSchoolFrom.Text = String.Format("{0:MM/dd/yyyy}", objFaculty.FDLastSchoolFromDate);
                    }
                    if (objFaculty.FDLastSchoolToDate != null)
                    {
                        txtLastSchoolTo.Text = String.Format("{0:MM/dd/yyyy}", objFaculty.FDLastSchoolToDate);
                    }
                    txtTotalExpInYear.Text  = objFaculty.FDExperienceTo;
                    txtTotalExpInMonth.Text = objFaculty.FDExperienceFrom;

                    Int64             AddressId  = Convert.ToInt64(objFaculty.FDAddressId);
                    TMSAddressDetails objAddress = TMSAddressDetails.Get(AddressId);
                    if (objAddress != null)
                    {
                        txtAddress.Text          = objAddress.ADPermanentAddress;
                        txtmobileNo.Text         = objAddress.ADMobileNo;
                        txtResidencePhone.Text   = objAddress.ADLandLineNo;
                        txtPin.Text              = objAddress.ADPinCode;
                        txtEmailID.Text          = objAddress.ADEmailId;
                        ddlCountry.SelectedValue = objAddress.ADCountryId.ToString();
                        BindState();
                        ddlState.SelectedValue = objAddress.ADStateId.ToString();
                        BindCity();
                        ddlCity.SelectedValue = objAddress.ADCityId.ToString();
                    }
                    Image2.Visible   = true;
                    Image2.ImageUrl  = objFaculty.FDImage;
                    Session["Image"] = objFaculty.FDImage;
                }
            }
        }
        catch (Exception ex) { }
    }
 protected void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         string ImageE = EditGetImage();
         if (ImageE == "Ext")
         {
             dvMsg.Visible   = true;
             lblMessage.Text = "InValid File Format";
             dvMsg.Attributes.Add("class", "error_msg");
         }
         else
         {
             Int64     UserId    = Convert.ToInt64(Session["UserId"]);
             DataTable dtFaculty = TMSFacultyDetails.GetStaffFacultyDetails(null, 7, UserId).Tables[0];
             if (dtFaculty.Rows.Count > 0)
             {
                 Int64             FacultyId  = Convert.ToInt64(dtFaculty.Rows[0]["FD_FacultyDetailsId"]);
                 TMSFacultyDetails objFaculty = TMSFacultyDetails.Get(FacultyId);
                 if (objFaculty != null)
                 {
                     objFaculty.FDFirstName      = txtFullName.Text;
                     objFaculty.FDBirthPlace     = txtBithPlace.Text;
                     objFaculty.FDBirthDate      = Convert.ToDateTime(txtDOB.Text);
                     objFaculty.FDBloodGroup     = ddlBloddGroup.SelectedValue;
                     objFaculty.FDNationality    = txtNationality.Text;
                     objFaculty.FDCaste          = txtCaste.Text;
                     objFaculty.FDSubCaste       = txtSubcaste.Text;
                     objFaculty.FDGender         = ddlGender.SelectedValue;
                     objFaculty.FDMotherTongue   = txtMotherTongue.Text;
                     objFaculty.FDMedicalProblem = txtMedicalproblems.Text;
                     if (txtDOJ.Text != "")
                     {
                         objFaculty.FDJoiningDate = Convert.ToDateTime(txtDOJ.Text);
                     }
                     else
                     {
                         objFaculty.FDJoiningDate = null;
                     }
                     //objFaculty.FDHighestDegreeCompletd = ddlHighestDegree.SelectedValue;
                     objFaculty.FDHighestDegreeCompletd = txtHeighestDegree.Text;
                     objFaculty.FDSpecificExpertise     = ddlSpeciallization.SelectedItem.Text;
                     objFaculty.FDCompletionDate        = ddlCompletedYear.SelectedValue;
                     objFaculty.FDUniversity            = txtUniversity.Text;
                     objFaculty.FDLastSchoolwas         = txtLastSchoolWas.Text;
                     if (txtLastSchoolFrom.Text != "")
                     {
                         objFaculty.FDLastSchoolFromDate = Convert.ToDateTime(txtLastSchoolFrom.Text);
                     }
                     if (txtLastSchoolTo.Text != "")
                     {
                         objFaculty.FDLastSchoolToDate = Convert.ToDateTime(txtLastSchoolTo.Text);
                     }
                     objFaculty.FDExperienceTo   = txtTotalExpInYear.Text;
                     objFaculty.FDExperienceFrom = txtTotalExpInMonth.Text;
                     objFaculty.FDImage          = ImageE;
                     objFaculty.Update();
                     Int64             AddressId         = Convert.ToInt64(objFaculty.FDAddressId);
                     TMSAddressDetails objAddressDetails = TMSAddressDetails.Get(AddressId);
                     if (objAddressDetails != null)
                     {
                         objAddressDetails.ADPermanentAddress = txtAddress.Text.Trim();
                         if (!string.IsNullOrEmpty(ddlCity.SelectedValue))
                         {
                             objAddressDetails.ADCityId = Convert.ToInt64(ddlCity.SelectedValue);
                         }
                         if (!string.IsNullOrEmpty(ddlCountry.SelectedValue))
                         {
                             objAddressDetails.ADCountryId = Convert.ToInt64(ddlCountry.SelectedValue);
                         }
                         if (!string.IsNullOrEmpty(ddlState.SelectedValue))
                         {
                             objAddressDetails.ADStateId = Convert.ToInt64(ddlState.SelectedValue);
                         }
                         objAddressDetails.ADEmailId    = txtEmailID.Text.Trim();
                         objAddressDetails.ADMobileNo   = txtmobileNo.Text.Trim();
                         objAddressDetails.ADPinCode    = txtPin.Text.Trim();
                         objAddressDetails.ADLandLineNo = txtResidencePhone.Text;
                         objAddressDetails.Update();
                     }
                     TMSUserLogin objLogin = TMSUserLogin.Get(Convert.ToInt64(Session["UserId"]));
                     if (objLogin != null)
                     {
                         //objLogin.ULUserName = txtEmailID.Text.Trim();
                         objLogin.ULEmailId = txtEmailID.Text.Trim();
                         objLogin.Update();
                     }
                     BindAccountManagerDetails();
                     SectionEditProfile.Visible = false;
                     SectionViewProfile.Visible = true;
                     dvMsg.Visible   = true;
                     lblMessage.Text = "Profile Is Updated Successfully";
                     dvMsg.Attributes.Add("class", "warring_msg");
                 }
             }
         }
     }
     catch (Exception ex) { }
 }