neeraj kumar

neeraj kumar

  • 1.5k
  • 143
  • 3k

html se pdf generate header issue

May 31 2024 7:46 AM

mujhe esme ye problem aa rhi h ki pdf to generate ho rha h lekin jo second page me header aa rha h content us pr overlap ho ja rha h esi ko fix krna h , plz help 

mai es controller method  se html se pdf generate kr rha hu -: 

MemoryStream stream = GenerateLetter(empId, NewLegalLetter.letterTypeID, AssociateLegalLetterID);
                        stream.Position = 0;
                        FileStream file = new FileStream(pathDownload, FileMode.Create, System.IO.FileAccess.Write);
                        byte[] bytes = new byte[stream.Length];
                        stream.Read(bytes, 0, (int)stream.Length);
                        file.Write(bytes, 0, bytes.Length);
                        file.Close();
                        stream.Close();
                        return Json(new { data = empId }, JsonRequestBehavior.AllowGet);

 

private MemoryStream GenerateLetter(Int64 empId, int letterTypeID, int AssociateLegalLetterID)
        {
            try
            {
                NewHtmlToPDF converter = new NewHtmlToPDF(empId, letterTypeID, AssociateLegalLetterID);
                MemoryStream stream = new MemoryStream();
                converter.SavePDF(stream);
                stream.Position = 0;
                return stream;
            }
            catch (Exception ex)
            {
                throw ex;
            }

        }

 

ye NewHtmlToPDF.cs file h 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Data.SqlClient;
using HtmlAgilityPack;
using System.IO;
using System.Configuration;
using Dapper;
using InnovOne.Core.Settings;
using InnovOne.EntityRepository;
using System.Data;
using MigraDoc.DocumentObjectModel;
using MigraDoc.DocumentObjectModel.Tables;
using MigraDoc.DocumentObjectModel.Shapes;
using MigraDoc.Rendering;
using PdfSharp.Drawing;
using PdfSharp.Pdf;
using InnovOne.Services;

namespace InnovOne.WebUI.Code
{
    public delegate string NewTokenEvaluatorCallback(NewHtmlToPDF theObject, string str);
    public class NewComponentSubDetails
    {
        public int SalaryId { get; set; }
        public string SalaryCode { get; set; }
        public string SalaryComponentType { get; set; }
        public string SalaryComponentName { get; set; }
        public double SalaryAmount { get; set; }
        public double SalaryPercentage { get; set; }
        public int SalaryComponentSeq { get; set; }
    }
    // Added by Shadan
    public class LegelLetterDynamicFields
    {
        public string WayOfWorking { get; set; }
        public string Warnings { get; set; }
        public int LegalLetterTypeId { get; set; }
        public string ShowCauseContent { get; set; }
    }

    // Ended by Shadan

    public class NewSalaryComponents
    {
        public int SalaryId { get; set; }
        public string SalaryCode { get; set; }
        public string EmpCode { get; set; }
        public string salutation { get; set; }
        public string EmployeeName { get; set; }
        public string Reference { get; set; }
        public DateTime LetterDate { get; set; }
        public string Designation { get; set; }
        public string NewDesignation { get; set; }
        public string ClientName { get; set; }
        public string Division { get; set; }
        public string Location { get; set; }
        public string ContractStartDate { get; set; }
        public string ContractEndDate { get; set; }
        public DateTime EngagementLetterDate { get; set; }
        public double TotalCostAmount { get; set; }
        public double GrossSalary { get; set; }
        public string V5DateofJoining { get; set; }
        public string V5CTC { get; set; }
        public string V5InHandSalary { get; set; }
        public double NetSalary { get; set; }
        public double StatutoryTotal { get; set; }
        public string SalaryType { get; set; }
        public string GlobalBranch { get; set; }
        public string EmpMob { get; set; }
        public string EmpEmail { get; set; }
        public string ProjectName { get; set; }
        public string NewProjectName { get; set; }
        public string CurrentProjectName { get; set; }
        public string Reportingperson { get; set; }
        public string CostCode { get; set; }
        public string CTCApplicableFrom { get; set; }
        public string BreCode { get; set; }
        public virtual List<ComponentSubDetails> CompDetails { get; set; }
        public string RoleForGtl { get; set; }
        public string NameInInvoice { get; set; }
        public string ClientRefNo { get; set; }
        public string FatherName { get; set; }
        public string EmpAddress { get; set; }
        public string ReqAddress { get; set; }
        public string NewWorkLocation { get; set; }
        public string PromotionEffectDate { get; set; }

        public string SubsidiaryCompanyNameAlias { get; set; }
        public string NoticePeriodClause { get; set; }
        public string StoreName { set; get; }
        public string StateName { set; get; }

        public string EffectiveDate { get; set; }
        public string PreviousWorkLocation { set; get; }
        public string PreviousDesignation { set; get; }
        public string PreviousClientName { set; get; }
        public long ClientId { set; get; }
        public bool IsClientSpecific { set; get; }
        public string LOIContractualContractStartDate { get; set; }
        public string LOIContractualContractEndDate { get; set; }
        public string RecoveryAmount { get; set; }
        public string CompanyNameOfOtherOrg { get; set; }
        public string DesignationofOtherOrg { get; set; }
        public DateTime StartDate { get; set; }
        public DateTime EndDate { get; set; }
        public string PIPStartDate { get; set; }
        public string PIPEndDate { get; set; }
        public DateTime LegalLeterEffectiveDate { get; set; }
        public string AcctNumber { get; set; }
        public DateTime PIPGeneratedOn { get; set; }
        public DateTime ShowCauseGeneratedOn { get; set; }
        public string PermanentAddress { get; set; }
        public string Target { get; set; }
        public bool ShowInLetters { set; get; }
        public string LastWorkingDate { set; get; }
        public string ActualAmount { get; set; }
        public string AmountCredited { get; set; }
        public string V5RegistrationID { set; get; }
        public string CandidateName { set; get; }
        public string MobileNumber { set; get; }
        public string IsWorkWithAirtel { set; get; }
        public string WorkAirtel_EmpName { set; get; }
        public string WorkAirtel_EmpCode { set; get; }
        public string WorkAirtel_MobileNo { set; get; }
        public string IsVendorWithAirtel { set; get; }
        public string VendorAirtel_EmpName { set; get; }
        public string VendorAirtel_VendorCode { set; get; }
        public string VendorAirtel_MobileNo { set; get; }
        public string SubmittedDate { set; get; }
        public string CandidateSignPath { set; get; }
        public int AssociateId { get; set; }
        public string AcknowledgedOn { get; set; }
        public int InnovID { set; get; }
        public string IsDrawingSalaryWithAirtel { set; get; }
        public string ResponsibleFor { set; get; }
        public string DayDiff { set; get; }
        public string Achievement { get; set; }
        public string Achievement1 { get; set; }
        public string Achievement2 { get; set; }
        public string Achievement3 { get; set; }
        public string AchievementPercentage1 { get; set; }
        public string AchievementPercentage2 { get; set; }
        public string AchievementPercentage3 { get; set; }
        public string Deliverables { get; set; }
        public string RMComments { get; set; }
        public string RMCommentsFinal { get; set; }
        public string BusinessUnitName { get; set; }
        public string ReportingManagerName { get; set; }
        public string Target1 { get; set; }
        public string Target2 { get; set; }
        public string Target3 { get; set; }
        public string FirstMonth { get; set; }
        public string SecondMonth { get; set; }
        public string ThirdMonth { get; set; }
        public string PerfomanceImprovementDate { get; set; }
        public string AbsentFrom { get; set; }
        public string ShowCauseContent { get; set; }
        public string WOWParameterDate { get; set; }
        public string LastWorkingDateDiscontinuation { set; get; }
        public string WorkingDays { set; get; }
        public int AssociateLegalLetterId { set; get; }   // Added by Shadan
        public string Amount { get; set; }
        public string AdvanceNoticeDay { get; set; }
        public string MatterContentDE { get; set; }
        public NewSalaryComponents(Int64 EmpId, int LetterId, Int64 CandidateInterviewId, int AssociateLegalLetterID)
        {
            using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["InnovOneEntities1"].ConnectionString))
            {
                try
                {
                    con.Open();
                    using (SqlCommand cmd = con.CreateCommand())
                    {
                        string Sql = "";

                        if (LetterId == 36 || LetterId == 35 || LetterId == 37 || LetterId == 38 || LetterId == 39 || LetterId == 40
                            || LetterId == 41 || LetterId == 42 || LetterId == 43 || LetterId == 44 || LetterId == 45)
                        {
                            Sql = @"select * from [ufn_GetDetailsForLegalLetterByEmpId](@intEmpId,@intAssociateLegalLetterID);";
                            cmd.CommandText = Sql;
                            cmd.Parameters.AddWithValue("@intEmpId", EmpId);
                            cmd.Parameters.AddWithValue("@intAssociateLegalLetterID", AssociateLegalLetterID);
                            using (SqlDataReader reader = cmd.ExecuteReader())
                            {
                                while (reader.Read())
                                {
                                    LastWorkingDate = (reader["LastWorkingDate"].ToString());
                                    EmpCode = reader["EmployeeCode"].ToString();
                                    Division = reader["ClientID"].ToString();
                                    EmployeeName = reader["CandidateFullName"].ToString();
                                    ClientName = reader["ClientName"].ToString();
                                    SalaryId = reader["SalaryId"].ToInt();
                                    ContractEndDate = reader["ContractStartDate"].ToString();
                                    ContractEndDate = reader["ContractEndDate"].ToString();
                                    V5DateofJoining = reader["DateofJoining"].ToString();
                                    V5CTC = reader["CTC"].ToString(); ;
                                    V5InHandSalary = reader["InHandSalary"].ToString(); ;
                                    Location = (reader["LocationName"].ToString());
                                    Designation = (reader["Designation"].ToString());
                                    CurrentProjectName = (reader["CurrentProjectName"].ToString());
                                    StoreName = (reader["StoreName"].ToString());
                                    StateName = (reader["StateName"].ToString());
                                    LetterDate = (Convert.ToDateTime(reader["LetterDate"]));
                                    EffectiveDate = (reader["EffectiveDate"].ToString());
                                    PreviousWorkLocation = (reader["PreviousWorkLocation"].ToString());
                                    PreviousDesignation = (reader["PreviousDesignation"].ToString());
                                    PreviousClientName = (reader["PreviousClientName"].ToString());
                                    ClientId = (reader["ClientID"].ToInt());
                                    IsClientSpecific = (Convert.ToBoolean(reader["IsClientSpecific"]));
                                    LOIContractualContractStartDate = (reader["LOIContractualStartDate"].ToString());
                                    LOIContractualContractEndDate = (reader["LOIContractualEndDate"].ToString());
                                    RecoveryAmount = (reader["RecoveryAmount"].ToString());
                                    CompanyNameOfOtherOrg = (reader["CompanyNameOfOtherOrg"].ToString());
                                    DesignationofOtherOrg = (reader["DesignationofOtherOrg"].ToString());
                                    PIPStartDate = (reader["PIPStartDate"].ToString());
                                    PIPEndDate = (reader["PIPEndDate"].ToString());
                                    LegalLeterEffectiveDate = (reader["LegalLeterEffectiveDate"].ToDate());
                                    AcctNumber = (reader["AcctNumber"].ToString());
                                    PIPGeneratedOn = (reader["PIPGeneratedOn"].ToDate());
                                    ShowCauseGeneratedOn = (reader["ShowCauseGeneratedOn"].ToDate());
                                    PermanentAddress = (reader["PermanentAddress"].ToString());
                                    Target = (reader["TargetDescription"].ToString());
                                    Target1 = (reader["Target1"].ToString());
                                    Target2 = (reader["Target2"].ToString());
                                    Target3 = (reader["Target3"].ToString());
                                    ActualAmount = (reader["ActualAmount"].ToString());
                                    AmountCredited = (reader["AmountCredited"].ToString());
                                    ResponsibleFor = (reader["ResponsibleFor"].ToString());
                                    Achievement = (reader["Achievement"].ToString());
                                    Achievement1 = (reader["Achievement1"].ToString());
                                    Achievement2 = (reader["Achievement2"].ToString());
                                    Achievement3 = (reader["Achievement3"].ToString());
                                    AchievementPercentage1 = (reader["AchievementPercentage1"].ToString());
                                    AchievementPercentage2 = (reader["AchievementPercentage2"].ToString());
                                    AchievementPercentage3 = (reader["AchievementPercentage3"].ToString());
                                    FirstMonth = (reader["FirstMonth"].ToString());
                                    SecondMonth = (reader["SecondMonth"].ToString());
                                    ThirdMonth = (reader["ThirdMonth"].ToString());
                                    Deliverables = (reader["Deliverables"].ToString());
                                    RMComments = (reader["RMComments"].ToString());
                                    RMCommentsFinal = (reader["RMCommentsFinal"].ToString());
                                    BusinessUnitName = (reader["BusinessUnitName"].ToString());
                                    ReportingManagerName = (reader["ReportingManagerName"].ToString());
                                    PerfomanceImprovementDate = (reader["PerfomanceImprovementDate"].ToString());
                                    AbsentFrom = (reader["AbsentFrom"].ToString());
                                    ShowCauseContent = (reader["ShowCauseContent"].ToString());
                                    WOWParameterDate = (reader["WOWParameterDate"].ToString());
                                    LastWorkingDateDiscontinuation = (reader["LastWorkingDateDiscontinuation"].ToString());
                                    WorkingDays = (reader["WorkingDays"].ToString());
                                    AssociateLegalLetterId = (Convert.ToInt32(reader["AssociateLegalLetterId"])); ///Added by Shadan
                                    Amount = (reader["Amount"].ToString());
                                    AdvanceNoticeDay = (reader["AdvanceNoticeDay"].ToString());
                                    MatterContentDE = (reader["ContentDE"].ToString());
                                    CompDetails = new List<ComponentSubDetails>();
                                    CompDetails.Add(new ComponentSubDetails());
                                }
                                cmd.Dispose();
                            }
                            con.Close();
                        }
                    }
                }
                catch (Exception ex) { }
                con.Close();
            }
        }
    }

    public class NewHtmlToPDF
    {
        SqlConnection DigiCon = new SqlConnection(setting.DigiOneConnection());
        SqlConnection GnetConnection = new SqlConnection(setting.DigiOneConnection());
        System.Data.SqlClient.SqlConnection Gnetconn = new System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings["GNET"].ConnectionString);
        System.Data.SqlClient.SqlConnection con = new System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings["InnovOneEntities1"].ConnectionString); //Added By Priya On 28 Dec 2016
        public Document Doc { get; set; }
        public NewSalaryComponents SalaryComps { get; set; }
        private string _Title;
        public string Title
        {
            get
            {
                return _Title;
            }
            set
            {
                _Title = value;
                Doc.Info.Title = _Title;
            }
        }
        private int ItemSeqNo = 0;
        private int CurColNo = 0;
        private bool ToAddNewPara = true;
        private bool ColumnsAdded = false;

        //Added by neerajk on 23-04-2024

        private string CompanyNameNew = "For FirstMeridian Global Services Private Limited";
        private string CompanyNameV5New = "(Formerly known as V5 Global Services Private Limited)";

        //Added by neerajk on 23-04-2024

        private string SubsidiaryCompanyName = "For FirstMeridian Global Services Private Limited (Formerly known as V5 Global Services Private Limited)",    //Modified by neerajk on 23-04-2024
            LogoImageName = "V5Global-Logo.png",
            SignatureImageName1 = "AuthorizedSignV5.png",
            SignatureImageName2 = "authService2.JPG",
            FooterAddress1 = "Regd.Off.: A 3, Kailas Industrial Complex, Park Site, Vikhroli (W), Mumbai 400 079. India",
            FooterAddress2 = "Tel: +91 22 4218 0000 | www.innov.in | [email protected] | PAN NO : AAECI0979D | CIN: U74900MH2016PTC273940",
            SubsidiaryQuery = "SELECT SubsidiaryCompanyName, LogoImageName, SignatureImageName1, SignatureImageName2, FooterAddress1, FooterAddress2, EmployeeAssignment.MandateId FROM EmployeeAssignment INNER JOIN Mandates ON EmployeeAssignment.MandateId=Mandates.MandateId INNER JOIN SubsidiaryCompany ON Mandates.SubsidiaryCompanyID=SubsidiaryCompany.SubsidiaryCompanyID ";
        private int MandateID = 0;
        public NewTokenEvaluatorCallback CallBack { get; set; }
        public Section CurrentSection { get; set; }
        public Table CurrentTable { get; set; }
        public Row CurrentRow { get; set; }
        public Column CurrentColumn { get; set; }
        public Cell CurrentCell { get; set; }
        public Paragraph CurrentParagraph { get; set; }
        public FormattedText CurrentFormattedText { get; set; }
        private Regex TokenMatchRx;

        private void DefinePageSetup(Document Doc)
        {
            Doc.DefaultPageSetup.LeftMargin = "0.25in";
            Doc.DefaultPageSetup.RightMargin = "0.25in";
            Doc.DefaultPageSetup.TopMargin = ".8in";
            Doc.DefaultPageSetup.BottomMargin = ".8in";
        }
        private void DefineStyles(Document Doc)
        {
            DefinePageSetup(Doc);

            Style style, style2, style3;
            XPdfFontOptions options = new XPdfFontOptions(PdfFontEncoding.Unicode, PdfFontEmbedding.Default);

            style = Doc.Styles["Normal"];
            style.Font.Size = 9;
            style.Font.Bold = false;
            style.Font.Name = "Tahoma";
            style.ParagraphFormat.SpaceBefore = 6;
            style.ParagraphFormat.SpaceAfter = 3;
            style.ParagraphFormat.Alignment = ParagraphAlignment.Justify;

            style2 = Doc.Styles["Heading2"];
            style2.Font.Size = 12;
            style2.Font.Bold = true;
            style2.Font.Name = "Tahoma";
            style2.ParagraphFormat.SpaceBefore = 6;
            style2.ParagraphFormat.SpaceAfter = 3;
            style2.Font.Underline = Underline.None;//Added by neerajk on 24-04-2024
            style2.ParagraphFormat.Alignment = ParagraphAlignment.Center;

            style3 = Doc.Styles["Heading3"];
            style3.Font.Size = 11;
            style3.Font.Bold = true;
            style3.Font.Name = "Tahoma";
            style3.ParagraphFormat.SpaceBefore = 6;
            style3.ParagraphFormat.SpaceAfter = 3;
            style3.Font.Underline = Underline.None;
            style3.ParagraphFormat.Alignment = ParagraphAlignment.Center;

            style3 = Doc.Styles["Heading4"];
            style3.Font.Size = 10;
            style3.Font.Bold = true;
            style3.Font.Name = "Tahoma";
            style3.ParagraphFormat.SpaceBefore = 6;
            style3.ParagraphFormat.SpaceAfter = 3;
            style3.Font.Underline = Underline.None;

            style3 = Doc.Styles["Heading5"];
            style3.Font.Size = 9;
            style3.Font.Bold = true;
            style3.Font.Name = "Tahoma";
            style3.ParagraphFormat.SpaceBefore = 6;
            style3.ParagraphFormat.SpaceAfter = 3;
            style3.Font.Underline = Underline.None;

            style3 = Doc.Styles["Heading6"];
            style3.Font.Size = 15;
            style3.Font.Bold = true;
            style3.Font.Name = "Shivaji01";
            style3.ParagraphFormat.SpaceBefore = 6;
            style3.ParagraphFormat.Alignment = ParagraphAlignment.Justify;
            style3.ParagraphFormat.SpaceAfter = 3;
            style3.Font.Underline = Underline.None;

            Style S = new Style("Small", StyleNames.Normal);
            S.Font.Size = 8;
            S.Font.Name = "Tahoma";
            S.ParagraphFormat.SpaceBefore = 6;
            S.ParagraphFormat.SpaceAfter = 3;
            S.Font.Underline = Underline.None;
            Doc.Styles.Add(S);

            S = new Style("SmallBold", "Small");
            S.Font.Bold = true;
            Doc.Styles.Add(S);
        }
        public void SetDocFont(string fontName)
        {
            foreach (Style style in Doc.Styles)
            {
                style.Font.Name = fontName;
            }
        }

        public bool IsHeaderAndFooterRequired { get; set; }
        public object DataHandle { get; private set; }

        public int LetterId { set; get; }
        public bool IsTypeSalaryRevision { set; get; }
        public NewHtmlToPDF(Int64 Empid, int LetterTypeId, int AssociateLegalLetterID, Int64 CandidateInterviewId = 0)
        {
            LetterId = LetterTypeId;
            Doc = new Document();

            SalaryComps = new NewSalaryComponents(Empid, LetterTypeId, CandidateInterviewId, AssociateLegalLetterID);
            string TokenRegexStr = "{#(.*?)#}";
            TokenMatchRx = new Regex(TokenRegexStr, RegexOptions.Compiled | RegexOptions.IgnoreCase);
            CallBack = new NewTokenEvaluatorCallback(ValueEvaluatorCallback);
            DefineStyles(Doc);
            Title = "Letter";
            object retVal = null;
            this.IsHeaderAndFooterRequired = true;
            try
            {
                AddSection();
                ProcessLetters(LetterTypeId);
            }
            catch (Exception ex)
            {
                throw ex;
            }

        }
        public NewHtmlToPDF(Int64 Empid, int LetterTypeId, bool IsSalaryRevision)
        {
            LetterId = LetterTypeId;
            IsTypeSalaryRevision = IsSalaryRevision;
            Doc = new Document();

            SalaryComps = new NewSalaryComponents(Empid, LetterTypeId, 0, 0);
            string TokenRegexStr = "{#(.*?)#}";
            TokenMatchRx = new Regex(TokenRegexStr, RegexOptions.Compiled | RegexOptions.IgnoreCase);
            CallBack = new NewTokenEvaluatorCallback(ValueEvaluatorCallback);
            DefineStyles(Doc);
            Title = "Letter";
            object retVal = null;
            this.IsHeaderAndFooterRequired = true;
            try
            {
                AddSection();
                ProcessLetters(LetterTypeId);
            }
            catch (Exception ex)
            {
                throw ex;
            }

        }
        private void AddHeader()
        {
            string filename = System.Web.HttpContext.Current.Server.MapPath("~/Content/images/" + LogoImageName);
            Image image = CurrentSection.Headers.Primary.AddImage(filename);
            image.Height = ".65in";
            image.Width = "1.85in";
            image.LockAspectRatio = true;
            image.RelativeVertical = RelativeVertical.Line;
            image.RelativeHorizontal = RelativeHorizontal.Margin;
            image.Top = ShapePosition.Top;
            image.Left = ShapePosition.Left;
            image.WrapFormat.Style = WrapStyle.Through;
            Paragraph paragraph = CurrentSection.Headers.Primary.AddParagraph();
            paragraph.Format.SpaceAfter = "1.02cm";

            Paragraph paragraphimg = CurrentSection.Headers.Primary.AddParagraph();
            paragraphimg.Format.Font.Name = "Tahoma";
            paragraphimg.Format.Font.Size = 7.5;
            paragraphimg.Format.Font.Bold = true;
            paragraphimg.AddText("FirstMeridian Global Services Private Limited (Formerly known as V5 Global Services Private Limited)");
            paragraphimg.Format.Alignment = ParagraphAlignment.Right;
            paragraphimg.Format.LineSpacing = "1cm";
            paragraphimg.Format.LineSpacingRule = LineSpacingRule.OnePtFive;
            paragraphimg.Format.Borders.Bottom = new Border() { Width = "1pt", Color = Colors.Black };

            Paragraph paragraph1 = CurrentSection.Headers.Primary.AddParagraph();
            paragraph1.Format.Font.Name = "Tahoma";
            paragraph1.Format.Font.Size = 8;
            paragraph1.Format.Font.Color = Colors.Black;

            paragraph1.AddText("Corporate Office :- B-1/H-5, Second floor, NH-19, Mohan Cooperative Industrial Estate, New Delhi, Delhi 110044");

            Paragraph paragraph3 = CurrentSection.Headers.Primary.AddParagraph();
            paragraph3.Format.Font.Name = "Tahoma";
            paragraph3.Format.Font.Size = 8;
            paragraph3.Format.Font.Color = Colors.Black;

            paragraph3.AddText("Registered Office :- 501, Jollyboard Tower 1, I Think Techno Campus, Kanjurmarg(East), Mumbai-400042, Maharashtra, India");
            Paragraph paragraph2 = CurrentSection.Headers.Primary.AddParagraph();
            paragraph2.Format.Font.Name = "Tahoma";
            paragraph2.Format.Font.Size = 8;
            paragraph2.Format.Font.Color = Colors.Gray;
            paragraph2.AddText("Contact:- [email protected], www.v5global.com, 1800-833-0905, CIN: U72300MH2005PTC417429");
            paragraph2.Format.Alignment = ParagraphAlignment.Left;
            paragraph2.Format.Borders.Bottom = new Border() { Width = "1pt", Color = Colors.Black };

            if (MandateID == 1835)
            {
                filename = System.Web.HttpContext.Current.Server.MapPath("~/Content/images/" + MandateID + ".png");
                image = CurrentSection.Headers.Primary.AddImage(filename);
                image.LockAspectRatio = true;
                image.RelativeVertical = RelativeVertical.Line;
                image.RelativeHorizontal = RelativeHorizontal.Margin;
                image.Top = ShapePosition.Top;
                image.Left = ShapePosition.Left;
                image.WrapFormat.Style = WrapStyle.Through;
            }

        }
        private void AddFooter()
        {
            Paragraph paragraph = CurrentSection.Footers.Primary.AddParagraph();
            paragraph.Format.Font.Name = "Tahoma";
            paragraph.Format.Font.Size = 9;

            paragraph.AddText(SubsidiaryCompanyName);
            paragraph.AddLineBreak();
            paragraph.AddText(FooterAddress1);
            paragraph.AddLineBreak();
            paragraph.AddText(FooterAddress2);

            paragraph.Format.Font.Size = 9;
            paragraph.Format.Alignment = ParagraphAlignment.Left;
        }
        private void AddImage(string filename1 = "", string filename2 = "", string AssociateName = "")
        {
            // Add the image aligned to the left
            Paragraph imgPara = CurrentSection.AddParagraph();
            imgPara.Format.Alignment = ParagraphAlignment.Left; // Align image to the left
            Image img1 = imgPara.AddImage(filename1);
            img1.LockAspectRatio = true;
            img1.Height = "1.3in";
            imgPara.Format.SpaceAfter = 0; // Disable new line after the paragraph

            //// Add the Associate's name aligned to the right
            //Paragraph associatePara = CurrentSection.AddParagraph();
            //associatePara.Format.Alignment = ParagraphAlignment.Right;
            //associatePara.AddText(AssociateName);
            //associatePara.Format.SpaceAfter = 0; // Disable new line after the paragraph

            // Add 'Authorised Signatory' aligned to the left
            Paragraph authPara = CurrentSection.AddParagraph();
            authPara.Format.Alignment = ParagraphAlignment.Left;
            authPara.AddFormattedText("Authorised Signatory", TextFormat.Bold);
            authPara.AddSpace(90);
            authPara.AddFormattedText("Associate Signature", TextFormat.Bold);
            authPara.Format.SpaceAfter = 0; // Disable new line after the paragraph

            // Add 'Associate Signature' aligned to the right
            //Paragraph signPara = CurrentSection.AddParagraph();
            //signPara.Format.Alignment = ParagraphAlignment.Right;
            //signPara.AddFormattedText("Associate Signature", TextFormat.Bold);
            //signPara.Format.SpaceAfter = 0; // Disable new line after the paragraph
        }
        private void AddImageOFCandidate(string filename1 = "", string filename2 = "")
        {
            Paragraph AuthPara = CurrentSection.AddParagraph();
            Image img1 = AuthPara.AddImage(filename1);
            img1.LockAspectRatio = true;
            img1.Height = "0.85in";

            AuthPara.AddLineBreak();
            AuthPara.AddText("Employee Signature");
        }
        private void AddImageOFCheckBox(string filename1 = "", string filename2 = "")
        {
            Paragraph AuthPara = CurrentSection.AddParagraph();
            Image img1 = AuthPara.AddImage(filename1);
            img1.LockAspectRatio = true;
            img1.Height = "0.20in";
            img1.Width = "0.20in";
            AuthPara.AddText("I Accept.");
            AuthPara.AddLineBreak();
        }
        private void AddImageForContractExtension(string filename1 = "", string filename2 = "")
        {
            Paragraph AuthPara = CurrentSection.AddParagraph();
            Image img1 = AuthPara.AddImage(filename1);
            img1.LockAspectRatio = true;
            //_img.Width = "1.15in";
            img1.Height = "0.65in";
            //Image img2 = AuthPara.AddImage(filename2);
            //img2.LockAspectRatio = true;
            ////_img2.Width = "1.15in";
            //img2.Height = "0.85in";
            //img2.WrapFormat.DistanceLeft = 3;
            AuthPara.AddLineBreak();
            AuthPara.AddText("(Signature & Date)");
            //AuthPara.AddSpace(3);
            //AuthPara.AddText("Authorised Signatory");
            AuthPara.AddSpace(75);
            AuthPara.AddText("(Employee Signature)");
        }
        //End Added By Rahul

        private void AddImageWithoutSignatureAndDate(string filename1 = "", string filename2 = "")
        {
            Paragraph AuthPara = CurrentSection.AddParagraph();
            Image img1 = AuthPara.AddImage(filename1);
            img1.LockAspectRatio = true;
            //_img.Width = "1.15in";
            img1.Height = "0.85in";
            Image img2 = AuthPara.AddImage(filename2);
            img2.LockAspectRatio = true;
            //_img2.Width = "1.15in";
            img2.Height = "0.85in";
            img2.WrapFormat.DistanceLeft = 3;
            AuthPara.AddLineBreak();
            AuthPara.AddText("Authorised Signatory");
            AuthPara.AddSpace(3);
            AuthPara.AddText("Authorised Signatory");
        }
        private void AddImage2(string filename = "")
        {
            Paragraph _p = CurrentSection.AddParagraph();
            _p.Format.LeftIndent = 160;
            Image _img = _p.AddImage(filename);
            _p.AddText("some text here");
        }
        private Section AddSection(/*bool isHeaderAndFooterRequired,*/string className = ""  /*= false*/)
        {
            CurrentSection = Doc.AddSection();
            if (this.IsHeaderAndFooterRequired)
            {
                AddHeader();
                //  AddFooter();
            }
            return CurrentSection;
        }
        private Paragraph AddPara(string className = "", Section section = null)
        {
            if (section == null)
                section = CurrentSection;
            if (section == null)
                return null;
            CurrentParagraph = section.AddParagraph();
            ApplyClassStyle(className);
            return CurrentParagraph;
        }
        private Paragraph AddParaToCell(string className = "", Cell cell = null)
        {
            if (cell == null)
                cell = CurrentCell;
            if (cell == null)
                return null;
            CurrentParagraph = cell.AddParagraph();
            ApplyClassStyle(className);
            return CurrentParagraph;
        }
        private FormattedText AddParaText(String text, string className = "", Paragraph para = null)
        {
            if (para == null)
                para = CurrentParagraph;
            if (para == null)
                return null;
            CurrentFormattedText = para.AddFormattedText(text);
            return CurrentFormattedText;
        }
        private Table AddTable(string className = "", Section section = null)
        {
            if (section == null)
                section = CurrentSection;
            if (section == null)
                return null;
            CurrentTable = section.AddTable();
            return CurrentTable;
        }

        //Added by Vikash K on 09-10-2023
        private Table AddTableWithBorder(int BorederSize, string className = "", Section section = null)
        {
            if (section == null)
                section = CurrentSection;
            if (section == null)
                return null;
            CurrentTable = section.AddTable();

            CurrentTable.Borders.Width = BorederSize;
            return CurrentTable;
        }
        private Column AddColumn(Table table = null, string className = "")
        {
            if (table == null)
                table = CurrentTable;
            if (table == null)
                return null;
            CurrentColumn = table.AddColumn();
            return CurrentColumn;
        }

        private Row AddRow(Table table = null, string className = "")
        {
            if (table == null)
                table = CurrentTable;
            if (table == null)
                return null;
            CurrentRow = table.AddRow();
            return CurrentRow;
        }
        private Cell GetCell(int cellno, Row row = null, string className = "")
        {
            if (row == null)
                row = CurrentRow;
            if (row == null)
                return null;
            CurrentCell = row.Cells[cellno];
            return CurrentCell;
        }
        private Cell GetCell_span(int rowspan, int colspan, int cellno, Row row = null, string className = "")
        {
            if (row == null)
                row = CurrentRow;
            if (row == null)
                return null;
            CurrentCell = row.Cells[cellno];
            CurrentCell.MergeDown = rowspan;
            CurrentCell.MergeRight = colspan;
            return CurrentCell;
        }
        private Hyperlink AddHyperLink(String text, string className = "", Paragraph para = null)
        {
            if (para == null)
                return null;
            return para.AddHyperlink(text);
        }
        public void SavePDF(String FileName)
        {
            PdfDocumentRenderer renderer = new PdfDocumentRenderer(true, PdfSharp.Pdf.PdfFontEmbedding.Always);
            renderer.Document = Doc;
            renderer.RenderDocument();
            renderer.PdfDocument.Save(FileName);
        }
        public void SavePDF(MemoryStream stream)
        {
            PdfDocumentRenderer renderer = new PdfDocumentRenderer(true, PdfSharp.Pdf.PdfFontEmbedding.Always);
            renderer.Document = Doc;
            renderer.RenderDocument();
            renderer.PdfDocument.Save(stream, false);
        }
        public void ProcessLetters(int LetterId)
        {
            try
            {
                string path = "";
                Dictionary<string, object> paramVals = new Dictionary<string, object>();
                paramVals.Add("LetterId", LetterId);
                string fileName = DBUtils.GetScalarResult("select LetterFormat from LetterType where LetterTypeId =  @LetterId", paramVals).ToStr();
                HtmlDocument doc = new HtmlDocument();
                if (fileName != "")
                {
                    path = "~/App_Data/LetterFormat/" + fileName;
                }
                string htmlpath = System.Web.HttpContext.Current.Server.MapPath(path);
                System.IO.StreamReader myFile = new System.IO.StreamReader(htmlpath);
                string myString = myFile.ReadToEnd();
                myFile.Close();

                doc.LoadHtml(myString);

                StringWriter sw = new StringWriter();
                //ConvertTo(doc.DocumentNode.SelectSingleNode("//body"));
                //sw.Flush();
                sw.Flush();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public void ProcessContractRenContents()
        {

            HtmlDocument doc = new HtmlDocument();
            string path = "~/App_Data/PDFLetters/ContractRenewal.html";

            string htmlpath = System.Web.HttpContext.Current.Server.MapPath(path);
            System.IO.StreamReader myFile = new System.IO.StreamReader(htmlpath);
            string myString = myFile.ReadToEnd();
            myFile.Close();

            doc.LoadHtml(myString);

            StringWriter sw = new StringWriter();
            ConvertTo(doc.DocumentNode.SelectSingleNode("//body"));
            sw.Flush();
            //sw.ToString();
        }
        private void ApplyClassStyle(string className)
        {
            if (CurrentParagraph == null)
                return;
            String styleNameToApply = "Normal";

            List<String> classes = new List<string>(className.Split(' '));
            classes.RemoveAll(s => String.IsNullOrEmpty(s.Trim()));
            className = (classes.Count > 0) ? classes[0] : "";
            switch (className)
            {
                case "title":
                case "heading2":
                    styleNameToApply = "Heading2";
                    break;
                case "heading3":
                    styleNameToApply = "Heading3";
                    break;
                case "heading4":
                    styleNameToApply = "Heading4";
                    break;
                case "heading5":
                    styleNameToApply = "Heading5";
                    break;
                case "heading6":
                    styleNameToApply = "Heading6";
                    break;
            }
            CurrentParagraph.Style = styleNameToApply;

            for (int x = 1; x < classes.Count; x++)
            {
                switch (classes[x])
                {
                    case "left":
                        CurrentParagraph.Format.Alignment = ParagraphAlignment.Left;
                        break;
                    case "right":
                        CurrentParagraph.Format.Alignment = ParagraphAlignment.Right;
                        break;
                    case "center":
                    case "centre":
                    case "middle":
                        CurrentParagraph.Format.Alignment = ParagraphAlignment.Center;
                        break;
                    case "justify":
                        CurrentParagraph.Format.Alignment = ParagraphAlignment.Justify;
                        break;
                    case "bold":
                        CurrentParagraph.Format.Font.Bold = true;
                        break;
                    case "italic":
                        CurrentParagraph.Format.Font.Italic = true;
                        break;

                }
            }

        }
        private void ConvertTo(HtmlNode node)
        {
            string html;
            switch (node.NodeType)
            {

                case HtmlNodeType.Text:
                    // script and style must not be output
                    string parentName = node.ParentNode.Name;
                    if ((parentName == "script") || (parentName == "style"))
                        break;

                    // get text
                    html = ((HtmlTextNode)node).Text;
                    html = html.Replace(System.Environment.NewLine, " ");
                    html = FindTokens(html);
                    // is it in fact a special closing node output as text?
                    if (HtmlNode.IsOverlappedClosingElement(html))
                        break;

                    // check the text is meaningful and not a bunch of whitespaces
                    AddParaText(HtmlEntity.DeEntitize(html));
                    if (parentName == "b")
                    {
                        CurrentFormattedText.Font.Bold = true;
                    }
                    if (parentName == "i")
                    {
                        CurrentFormattedText.Font.Italic = true;
                    }
                    //currentCssClass = "";
                    //break;
                    if (parentName == "span")
                    {
                        CurrentFormattedText.Style = "display:block; float:left;color:#000";
                        CurrentFormattedText.Underline = Underline.None;
                        CurrentFormattedText.Color = Colors.Black;
                        CurrentFormattedText.Font.Size = 10;
                    }
                    break;

                case HtmlNodeType.Element:
                    {
                        string currentCssClass = "";
                        HtmlAttribute attrib = node.Attributes["class"];
                        if (!((attrib == null) || attrib.Value == null))
                        {
                            currentCssClass = attrib.Value.ToLower();
                        }
                        switch (node.Name.ToLower())
                        {
                            case "img":
                                {
                                    HtmlAttribute attrib1 = node.Attributes["src"];
                                    string src = attrib1.Value.ToLower();
                                    string src1, src2;
                                    //    MemoryStream srcStream = new MemoryStream();
                                    switch (src)
                                    {
                                        case "auth1.png":
                                            src1 = System.Web.HttpContext.Current.Server.MapPath("~/Content/images/" + SignatureImageName1);
                                            AddImage(src1, "", SalaryComps.EmployeeName);
                                            //src2 = System.Web.HttpContext.Current.Server.MapPath("~/Content/images/" + SignatureImageName2);
                                            // AddImage(src1, src2);
                                            break;

                                        //Added by vikas 29-06-2022
                                        case "empsign.png":
                                            src2 = SalaryComps.CandidateSignPath;
                                            AddImageOFCandidate(src2);
                                            break;
                                        case "iaccept.png":
                                            src1 = System.Web.HttpContext.Current.Server.MapPath("~/Content/images/tick_checkbox.jpeg");
                                            AddImageOFCheckBox(src1);
                                            break;
                                        //End by vikas 

                                        //case "auth2.png":
                                        //    src = System.Web.HttpContext.Current.Server.MapPath("~/Content/images/auth2.png");
                                        //    AddImage2(src);
                                        //    break;
                                        /*
                                    case "giheaderndfooter.png":
                                        src = System.Web.HttpContext.Current.Server.MapPath("~/Content/images/giHeader.png");
                                        AddHeader(src);
                                         src = System.Web.HttpContext.Current.Server.MapPath("~/Content/images/giFooter.png");
                                         AddFooter(src);
                                        break;
                                        */
                                        case "authwithoutsignatureanddate.png":
                                            src1 = System.Web.HttpContext.Current.Server.MapPath("~/Content/images/" + SignatureImageName1);
                                            AddImageWithoutSignatureAndDate(src1);
                                            break;

                                        //Added By Rahul on 03-Jun-2022
                                        case "authcontractextension.png":
                                            src1 = System.Web.HttpContext.Current.Server.MapPath("~/Content/images/" + SignatureImageName1);
                                            AddImageForContractExtension(src1);
                                            break;
                                            //End Added By Rahul
                                    }
                                    //   src = System.Web.HttpContext.Current.Server.MapPath("~/Content/images/auth2.png");
                                    //     AddImage(src);
                                    //      AddImage(srcStream);
                                }
                                break;
                            case "div":
                            case "p":
                                {

                                    if (currentCssClass == "newpage")
                                    {
                                        //  AddFooter();
                                        AddSection();
                                        //    AddHeader();

                                    }
                                    else
                                    {
                                        ///*node.ParentNode.Name.ToLower() != "li"*/
                                        if (ToAddNewPara)
                                            AddPara(currentCssClass);
                                        else
                                            ApplyClassStyle(currentCssClass); //because para is already added but style of this para needsto be applied
                                        ToAddNewPara = true;
                                    }

                                }
                                break;
                            case "ol":
                                ItemSeqNo = 1;
                                break;
                            case "li":
                                {
                                    AddPara();
                                    AddParaText(ItemSeqNo.ToString() + ". ");
                                    ItemSeqNo++;
                                    ToAddNewPara = false;
                                }
                                break;
                            case "table":
                                {
                                    if (node.Attributes.Count > 1 && node.Attributes["border"] != null)
                                    {
                                        HtmlAttribute attrib1 = node.Attributes["border"];
                                        int borderSize = Convert.ToInt32(attrib1.Value.ToLower() == "" ? "0" : attrib1.Value.ToLower());
                                        if (borderSize > 0)
                                        {
                                            AddTableWithBorder(borderSize);
                                        }
                                        else
                                        {
                                            AddTable();
                                        }
                                    }
                                    else
                                    {
                                        AddTable();
                                    }
                                    CurColNo = 0;
                                    ColumnsAdded = false;
                                }
                                break;
                            case "tr":
                                {
                                    if (!ColumnsAdded)
                                    {

                                        HtmlNodeCollection tdNodes = node.SelectNodes("td");
                                        int numcols = tdNodes.Count;
                                        foreach (HtmlNode subnode in tdNodes)
                                        {
                                            string widthAttr = "";
                                            HtmlAttribute atr = subnode.Attributes["width"];
                                            if (!((atr == null) || atr.Value == null))
                                            {
                                                widthAttr = atr.Value.ToLower();
                                            }

                                            Column col = AddColumn();
                                            if (widthAttr != "")
                                            {
                                                try
                                                {
                                                    col.Width = Unit.Parse(widthAttr);
                                                }
                                                catch { }
                                            }
                                        }
                                        ColumnsAdded = true;
                                    }
                                    AddRow();
                                    CurColNo = 0;
                                }
                                break;
                            case "td":
                                {
                                    int rowspan = 0;
                                    int colspan = 0;
                                    if (node.Attributes["rowspan"] != null)
                                    {
                                        HtmlAttribute attrib1 = node.Attributes["rowspan"];
                                        rowspan = Convert.ToInt32(attrib1.Value.ToLower() == "" ? "0" : attrib1.Value.ToLower());

                                    }
                                    if (node.Attributes["colspan"] != null)
                                    {
                                        HtmlAttribute attrib1 = node.Attributes["colspan"];
                                        colspan = Convert.ToInt32(attrib1.Value.ToLower() == "" ? "0" : attrib1.Value.ToLower());

                                    }

                                    if (rowspan > 0 || colspan > 0)
                                    {
                                        Cell cell = GetCell_span(rowspan, colspan, CurColNo);
                                        AddParaToCell(currentCssClass);
                                    }
                                    else
                                    {
                                        Cell cell = GetCell(CurColNo);
                                        AddParaToCell(currentCssClass);
                                    }
                                    CurColNo++;
                                    ToAddNewPara = false;
                                }
                                break;
                            default:
                                break;

                        }
                        if (node.HasChildNodes)
                        {
                            ConvertContentTo(node);
                        }
                    }


                    break;
            }
        }
        private void ConvertContentTo(HtmlNode node)
        {
            foreach (HtmlNode subnode in node.ChildNodes)
            {
                ConvertTo(subnode);
            }
        }
        private string ReplaceTokenValue(string token)
        {
            string retVal = "";
            if (CallBack != null)
            {
                retVal = CallBack(this, token);
                if (token == "salarytable")
                {
                    //TODO: Implement this method
                    //BuildSalaryTale();
                }
            }
            return retVal;
        }
        private string ValueEvaluatorCallback(NewHtmlToPDF theObject, string token)
        {
            switch (token)
            {
                case "candidate":
                    return SalaryComps.salutation + " " + SalaryComps.EmployeeName;
                case "ClientNameWithCondition":
                    if (SalaryComps.ClientId == 1232 || SalaryComps.Division == "1232")
                    {
                        return "Client";
                    }
                    else
                    {
                        return SalaryComps.ClientName;
                    }

                case "date":
                    return SalaryComps.LetterDate.ToString("dd-MMM-yyyy");
                case "client":
                    if (LetterId == 16 || LetterId == 10 || LetterId == 18 || LetterId == 19 || LetterId == 20 || LetterId == 21 || LetterId == 22 || LetterId == 23)
                    {
                        if (SalaryComps.ShowInLetters)
                        {
                            return SalaryComps.ClientName;
                        }
                        else
                        {
                            return "Client";
                        }
                    }
                    else
                    {
                        return SalaryComps.ClientName;
                    }
                case "division":
                    return SalaryComps.Division;
                case "letterId":
                    return SalaryComps.EmpCode;
                case "position":
                    return SalaryComps.Designation;
                case "location":
                    return SalaryComps.Location;
                case "worklocation":
                    return SalaryComps.Location;
                case "V5DateofJoining":
                    return SalaryComps.V5DateofJoining;
                case "V5CTC":
                    return SalaryComps.V5CTC;
                case "V5InHandSalary":
                    return SalaryComps.V5InHandSalary;
                case "brecode":
                    return SalaryComps.BreCode;
                case "contractdatefrom":
                    return SalaryComps.ContractStartDate;
                case "contractdateto":
                    return SalaryComps.ContractEndDate;
                case "empmob":
                    return SalaryComps.EmpMob;
                case "EffectiveDate":
                    return SalaryComps.CTCApplicableFrom;
                case "empemail":
                    return SalaryComps.EmpEmail;
                case "reportingperson":
                    return SalaryComps.Reportingperson;
                case "costcode":
                    return SalaryComps.CostCode;
                case "NewWorkLocation":
                    return SalaryComps.NewWorkLocation;
                //case "project":
                case "project":
                    if (LetterId == 16 || LetterId == 10 || LetterId == 18 || LetterId == 19 || LetterId == 20 || LetterId == 21 || LetterId == 22 || LetterId == 23)
                    {
                        if (SalaryComps.ShowInLetters)
                        {
                            return SalaryComps.ClientName;
                        }
                        else
                        {
                            return "Client";
                        }
                    }
                    else
                    {
                        return SalaryComps.ClientName;
                    }
                case "Newproject":
                    return SalaryComps.NewProjectName;
                case "salarytype":
                    if (SalaryComps.SalaryType == "N")
                    {
                        SalaryComps.SalaryType = "Net";
                    }
                    else if (SalaryComps.SalaryType == "G")
                    {
                        SalaryComps.SalaryType = "Gross";
                    }
                    else if (SalaryComps.SalaryType == "C")
                    {
                        SalaryComps.SalaryType = "CTC";
                    }
                    return SalaryComps.SalaryType;
                case "salaryamount":
                    //FillinSalaryDetails(theObject.SalaryComps);
                    return SalaryComps.TotalCostAmount.ToString();
                case "salarytable":
                    {
                        SalaryRevisionService Services = new SalaryRevisionService();
                        var isNewSalaryStructure = Services.isNewSalaryToShow(SalaryComps.InnovID);
                        if (isNewSalaryStructure)
                        {
                            return SalaryIncrementTable(theObject.SalaryComps);
                        }
                        else
                        {
                            return FillinSalaryDetails(theObject.SalaryComps);
                        }
                    }
                case "ProjectDetailstable":
                    {
                        return FillinProjectDetails(theObject.SalaryComps);
                    }
                case "LocationDetailstable":
                    {
                        return FillinLocationDetails(theObject.SalaryComps);
                    }
                case "PromotionEffectDate":
                    {
                        return SalaryComps.PromotionEffectDate;
                    }
                case "V5SalaryDetails":
                    {
                        if (SalaryComps.IsClientSpecific)
                        {
                            return FillinV5NapsSalaryDetails(theObject.SalaryComps);
                        }
                        else
                        {
                            return FillInV5SalaryDetailsDynamic(theObject.SalaryComps);
                        }
                    }
                case "V5SalaryDetailsPromotion":
                    {
                        return FillinV5SalaryDetailsPromotion(theObject.SalaryComps);
                    }


                case "subsidiarycompanynamealias":
                    return "V5 Global Services Pvt. Ltd.";

                case "storename":
                    return SalaryComps.StoreName;

                case "statename":
                    return SalaryComps.StateName;
                case "Effectivedate":
                    if (LetterId == 10)
                    {
                        return SalaryComps.LastWorkingDate;
                    }
                    else
                    {
                        return SalaryComps.EffectiveDate;
                    }
                case "PreviousWorkLocation":
                    return SalaryComps.PreviousWorkLocation;

                case "PreviousDesignation":
                    return SalaryComps.PreviousDesignation;

                case "PreviousClientName":
                    return SalaryComps.PreviousClientName;
                case "V5SalaryDetailsNote":
                    if (SalaryComps.ClientId == 1406)        //Tata Solar Client
                    {
                        return "You are entitled for a monthly incentive of Rs 9000/- which will be based on your performance";
                    }
                    else if (SalaryComps.ClientId == 1114 || SalaryComps.ClientId == 1115 || SalaryComps.ClientId == 1116 || SalaryComps.ClientId == 1126)   //For Airtel Client
                    {
                        Paragraph newParagraph = CurrentSection.AddParagraph();
                        newParagraph.Format.Alignment = ParagraphAlignment.Left;
                        newParagraph.AddText("Post joining you will have to attend a mandatory Newly Hired Induction Program (NHIP) of 18 " +
                            "working days and depending on the venue of training you may have to travel to an outstation location as well.");
                        newParagraph.AddLineBreak();
                        newParagraph.AddText("The performance of your daily job activities require you to keep an android phone, which should be arranged by you post joining.");
                        newParagraph.AddLineBreak();
                        newParagraph.AddText("Please Note - Incentives are payable subject to NHIP Certification");
                        return "";
                    }
                    else
                    {
                        return "";
                    }

                case "IsV5Dummy":
                    if (SalaryComps.ClientId == 1549)        //V5 Dummy 
                    {
                        Paragraph newParagraph = CurrentSection.AddParagraph();
                        newParagraph.Format.Alignment = ParagraphAlignment.Left;
                        newParagraph.AddText("30 days notice");
                        newParagraph.AddLineBreak();

                        Paragraph newParagraph1 = CurrentSection.AddParagraph();
                        newParagraph1.Format.Alignment = ParagraphAlignment.Left;
                        newParagraph1.AddText("1. Notice period: Employer may terminate, employee services with given 15 days prior notice or equivalent wages to employee. Employee may also terminate his/her employment with the company at any time by giving requisite notice of 1 month e. I. 30 days as per the terms of his/her employment agreement in writing, or equivalent wages in lieu thereof Employee fails to deposit required notice pay in lieu of requisite notice to the company before settling employee’s full and final payment, the same shall be adjusted by the management from employee’s full and final dues payable to employee, and the balance amount will be paid to employee.");

                        Paragraph newParagraph2 = CurrentSection.AddParagraph();
                        newParagraph2.Format.Alignment = ParagraphAlignment.Left;
                        newParagraph2.AddText("60 days notice");
                        newParagraph2.AddLineBreak();

                        Paragraph newParagraph3 = CurrentSection.AddParagraph();
                        newParagraph3.Format.Alignment = ParagraphAlignment.Left;
                        newParagraph3.AddText("2. Notice period: Employer may terminate, employee services with given 15 days prior notice or equivalent wages to employee. Employee may also terminate his/her employment with the company at any time by giving requisite notice of 2 month e. I. 60 days as per the terms of his/her employment agreement in writing, or equivalent wages in lieu thereof Employee fails to deposit required notice pay in lieu of requisite notice to the company before settling employee’s full and final payment, the same shall be adjusted by the management from employee’s full and final dues payable to employee, and the balance amount will be paid to employee.");
                        newParagraph3.AddLineBreak();

                        return "";
                    }
                    else
                    {
                        return "";
                    }


                case "IsElectroluxIndiaPvtLtd":
                    if (SalaryComps.ClientId == 1660)
                    {
                        Paragraph newParagraph1 = CurrentSection.AddParagraph();
                        newParagraph1.Format.Alignment = ParagraphAlignment.Left;
                        newParagraph1.AddText("In case of BGV report is not clear, this Offer will be terminated with immediate effect.");
                        newParagraph1.AddLineBreak();
                        return "";
                    }
                    else
                    {
                        return "";
                    }


                case "IsInfinitiRetailLimited":
                    if (SalaryComps.ClientId == 1664)
                    {
                        Paragraph newParagraph1 = CurrentSection.AddParagraph();
                        newParagraph1.Format.Alignment = ParagraphAlignment.Left;
                        newParagraph1.AddText("In order to ensure uniformity while attending the Customers of the Client Company, the Client may as an option provide you with a standard dress code. The cost of which will be recovered from your salary after completion of 2 months from your date of joining.");
                        newParagraph1.AddLineBreak();
                        return "";
                    }
                    else
                    {
                        return "";
                    }

                case "LineBrekForAccentureSign":
                    if (SalaryComps.ClientId == 1549)
                    {
                        return "\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
                    }
                    else
                    {
                        return "";
                    }
                case "LineBrek":
                    if (SalaryComps.ClientId == 1549)
                    {
                        return "\n\n\n\n\n\n\n";
                    }
                    else
                    {
                        return "";
                    }
                case "EmptyParaghrapsForNormalClient":
                    if (SalaryComps.ClientId != 1549)
                    {
                        return "\n\n\n\n\n\n\n\n\n\n\n";
                    }
                    else
                    {
                        return "";
                    }
                case "LOIContractStartDate":
                    return SalaryComps.LOIContractualContractStartDate;

                case "LOIContractEndDate":
                    return SalaryComps.LOIContractualContractEndDate;
                case "V5DemotionSalaryDetails":
                    return FillinV5SalaryDetailsDemotion(theObject.SalaryComps);
                case "RecoveryAmount":
                    return SalaryComps.RecoveryAmount;

                case "CompanyNameOfOtherOrg":
                    return SalaryComps.CompanyNameOfOtherOrg;

                case "DesignationofOtherOrg":
                    return SalaryComps.DesignationofOtherOrg;

                case "StartDate":
                    return SalaryComps.StartDate.ToString("dd-MMM-yyyy");

                case "LegalLeterEffectiveDate":
                    return SalaryComps.LegalLeterEffectiveDate.ToString("dd-MMM-yyyy"); ;

                case "AccountNumber":
                    return SalaryComps.AcctNumber;

                case "BankDetail":
                    return BankDetail(SalaryComps);

                case "PIPLetter":
                    return PIPLertter();

                case "PIPGeneratedOn":
                    return SalaryComps.PIPGeneratedOn.ToString("dd-MMM-yyyy");
                case "ShowCauseGeneratedOn":
                    return SalaryComps.ShowCauseGeneratedOn.ToString("dd-MMM-yyyy");
                case "PermanentAddress":
                    return SalaryComps.PermanentAddress;
                case "Target":
                    return SalaryComps.Target;
                case "PIPEndDate":
                    //var date = SalaryComps.EndDate;
                    var date = Convert.ToDateTime(SalaryComps.PIPEndDate);
                    var addedday = date.AddDays(1);
                    return addedday.ToString("dd-MMM-yyyy");
                case "LetterHeaderName":
                    if ((LetterId == 1 && IsTypeSalaryRevision == false) || LetterId == 2 || LetterId == 4)
                    {
                        return "Increment Letter";
                    }
                    else
                    {
                        return "Salary Re-structure Letter";
                    }
                case "ActualAmount":
                    return SalaryComps.ActualAmount;

                case "AmountCredited":
                    return SalaryComps.AmountCredited;

                case "ResponsibleFor":
                    return SalaryComps.ResponsibleFor;

                case "ExtraAmount":
                    var ActualAmount = SalaryComps.ActualAmount.ToInt();
                    var AmountCredited = SalaryComps.AmountCredited.ToInt();
                    return (AmountCredited - ActualAmount).ToString();
                case "V5RegistrationID":
                    return SalaryComps.V5RegistrationID;

                case "CandidateName":
                    return SalaryComps.CandidateName;

                case "MobileNumber":
                    return SalaryComps.MobileNumber;
                case "IsWorkWithAirtel":
                    return SalaryComps.IsWorkWithAirtel;

                case "WorkAirtel_EmpName":
                    if (SalaryComps.WorkAirtel_EmpName == "")
                    {
                        SalaryComps.WorkAirtel_EmpName = "--";
                    }
                    return SalaryComps.WorkAirtel_EmpName;
                case "WorkAirtel_EmpCode":
                    if (SalaryComps.WorkAirtel_EmpCode == "")
                    {
                        SalaryComps.WorkAirtel_EmpCode = "--";
                    }
                    return SalaryComps.WorkAirtel_EmpCode;
                case "WorkAirtel_MobileNo":
                    if (SalaryComps.WorkAirtel_MobileNo == "")
                    {
                        SalaryComps.WorkAirtel_MobileNo = "--";
                    }
                    return SalaryComps.WorkAirtel_MobileNo;
                case "IsVendorWithAirtel":
                    return SalaryComps.IsVendorWithAirtel;
                case "VendorAirtel_EmpName":
                    if (SalaryComps.VendorAirtel_EmpName == "")
                    {
                        SalaryComps.VendorAirtel_EmpName = "--";
                    }
                    return SalaryComps.VendorAirtel_EmpName;
                case "VendorAirtel_VendorCode":
                    if (SalaryComps.VendorAirtel_VendorCode == "")
                    {
                        SalaryComps.VendorAirtel_VendorCode = "--";
                    }
                    return SalaryComps.VendorAirtel_VendorCode;
                case "VendorAirtel_MobileNo":
                    if (SalaryComps.VendorAirtel_MobileNo == "")
                    {
                        SalaryComps.VendorAirtel_MobileNo = "--";
                    }
                    return SalaryComps.VendorAirtel_MobileNo;
                case "SubmittedDate":
                    return SalaryComps.SubmittedDate;
                case "NoteforZomato":
                    var text = " ";
                    if (SalaryComps.ClientId == 1673) //Please add  here zomato client id of prod
                    {
                        text = "Associate will be entitled to have a performance-based incentive of 1000 Rs. per month on the basis of achieving set KPIs";

                    }
                    return text;
                case "NoteforCoCODTH":
                    var text2 = " ";
                    if (SalaryComps.ClientName == "Airtel – COCO" || SalaryComps.ClientName == "Airtel DTH - DOST")
                    {
                        text2 = "Note: This is to inform you that wef. July-23 your new CTC structure will be in place. Earlier, your CAPA bonus was paid annually, now this will be considered as a part of your monthly gross salary and will be paid on monthly basis as a fixed salary.";

                    }
                    else
                    {
                        text2 = " ";
                    }
                    return text2;
                case "NoteforHPSellOut":
                    var text3 = " ";
                    if (SalaryComps.ClientName == "HP Sell Out Program")
                    {
                        text3 = "In case you have any clarification in this regard, kindly contact undersigned within 2 days, else this letter shall be considered as deem accepted.";

                    }
                    else
                    {
                        text3 = " ";
                    }
                    return text3;
                case "AcknowledgedOn":
                    return SalaryComps.AcknowledgedOn.ToString();
                case "LastWorkingDate":
                    return SalaryComps.LastWorkingDate;
                case "IsDrawingSalaryWithAirtel":
                    return SalaryComps.IsDrawingSalaryWithAirtel;
                default:
                    return "";

                case "DayDiff":
                    var D1 = Convert.ToDateTime(SalaryComps.PIPEndDate);
                    var D2 = Convert.ToDateTime(SalaryComps.PIPStartDate).AddDays(-1);
                    int d3 = (int)(D1 - D2).TotalDays;
                    return Convert.ToString(d3);

                case "pipStartDate":
                    return Convert.ToDateTime(SalaryComps.PIPStartDate).ToString("dd-MMM-yyyy");
                case "pipEndDate":
                    return Convert.ToDateTime(SalaryComps.PIPEndDate).ToString("dd-MMM-yyyy");

                case "PIPWarningLetter":
                    return PIPWarningLetter1(SalaryComps.AssociateLegalLetterId);   // Added by Shadan
                case "PIPWarningLetter1":
                    return PIPWarningLetterTbl();
                case "Achievement":
                    return SalaryComps.Achievement;
                case "Achievement1":
                    return SalaryComps.Achievement1;
                case "Achievement2":
                    return SalaryComps.Achievement2;
                case "Achievement3":
                    return SalaryComps.Achievement3;
                case "AchievementPercentage1":
                    return SalaryComps.AchievementPercentage1;
                case "AchievementPercentage2":
                    return SalaryComps.AchievementPercentage2;
                case "AchievementPercentage3":
                    return SalaryComps.AchievementPercentage3;
                case "Deliverables":
                    return SalaryComps.Deliverables;
                case "RMComments":
                    return SalaryComps.RMComments;
                case "RMCommentsFinal":
                    return SalaryComps.RMCommentsFinal;
                case "PerfomanceImprovementDate":
                    return SalaryComps.PerfomanceImprovementDate;
                case "AbsentFrom":
                    return SalaryComps.AbsentFrom;
                case "ShowCauseContent":
                    return WayOfWorkingDetails(SalaryComps.AssociateLegalLetterId);
                case "BusinessUnitName":
                    return SalaryComps.BusinessUnitName;
                case "ReportingManagerName":
                    return SalaryComps.ReportingManagerName;
                case "Target1":
                    return SalaryComps.Target1;
                case "Target2":
                    return SalaryComps.Target2;
                case "Target3":
                    return SalaryComps.Target3;
                case "FirstMonth":
                    return SalaryComps.FirstMonth;
                case "SecondMonth":
                    return SalaryComps.SecondMonth;
                case "ThirdMonth":
                    return SalaryComps.ThirdMonth;
                case "WOWParameterDate":
                    return SalaryComps.WOWParameterDate;
                case "LastWorkingDateDiscontinuation":
                    return SalaryComps.LastWorkingDateDiscontinuation;
                case "WorkingDays":
                    return SalaryComps.WorkingDays;
                case "WayOfWorkingDetails":
                    return WayOfWorkingDetails(SalaryComps.AssociateLegalLetterId);
                case "Amount":
                    return SalaryComps.Amount;
                case "SubsidiaryCompanyName":
                    return SubsidiaryCompanyName;
                case "CompanyNameNew":
                    return CompanyNameNew;
                case "CompanyNameV5New":
                    return CompanyNameV5New;
                case "AssociateNameNew":
                    return SalaryComps.EmployeeName;
                case "AdvanceNoticeDay":
                    return SalaryComps.AdvanceNoticeDay;
                case "MatterContentDE":
                    return SalaryComps.MatterContentDE;
            }
        }
        private string FillinSalaryDetails(NewSalaryComponents salComps)
        {
            DriveRepository obj = new DriveRepository();
            OffereLetter Oflet = new OffereLetter();
            string SalaryCode = obj.GetSalaryCode(salComps.SalaryId);
            Oflet.LoadSalDeta(SalaryCode);
            double StatutoryAmount = /*Oflet.ResForOfferLet.AllStatutoryAllowances + */Oflet.ResForOfferLet.StatutorySub;
            double OtherStatutoryAmount = Oflet.MedicalInsuranceV5 + Oflet.LWFCompany;    //+ Oflet.MediclaimV5

            Table Salary = CurrentSection.AddTable();
            Salary.Borders.Color = Colors.Black;
            Salary.Borders.Width = 0.25;
            Salary.Borders.Left.Width = 0.5;
            Salary.Borders.Right.Width = 0.5;
            Salary.Rows.LeftIndent = 0;

            Column column1 = Salary.AddColumn("5cm");
            Column column2 = Salary.AddColumn("1cm");
            column2.Borders.Right.Clear();
            Column column3 = Salary.AddColumn("2cm");
            Column column4 = Salary.AddColumn("5cm");
            Column column5 = Salary.AddColumn("1cm");
            Column column6 = Salary.AddColumn("2cm");


            Row row = Salary.AddRow();
            row.HeadingFormat = true;
            row.Format.Alignment = ParagraphAlignment.Center;
            row.Format.Font.Bold = true;

            row.Cells[0].AddParagraph("GROSS SALARY");
            row.Cells[0].MergeRight = 2;

            if (MandateID == 1858)
                row.Cells[3].AddParagraph("STATUTORY");
            else
                row.Cells[3].AddParagraph("STATUTORY BENEFITS");
            row.Cells[3].MergeRight = 2;

            int grossCount = Oflet.GrossList.Count();
            int statutoryCount = Oflet.StatutoryList.Count();
            int rowcount = 0;


            if (grossCount > statutoryCount)
                rowcount = grossCount;
            else
                rowcount = statutoryCount;

            Row row1;
            for (int i = 0; i < rowcount; i++)
            {
                if (i < rowcount - 1)
                {
                    row1 = Salary.AddRow();
                    row1.Format.Alignment = ParagraphAlignment.Left;

                }
                else
                {
                    row1 = Salary.AddRow();
                }

                if (i < grossCount)
                {
                    row1.Cells[0].AddParagraph(Oflet.GrossList[i].CompCode);
                    row1.Cells[1].AddParagraph("Rs.");
                    row1.Cells[1].Borders.Right.Color = Colors.White;
                    row1.Cells[4].Borders.Right.Color = Colors.White;
                    row1.Cells[2].AddParagraph(Oflet.GrossList[i].Amount.ToString() + "/-");
                    row1.Cells[2].Format.Alignment = ParagraphAlignment.Right;

                }
                if (i < statutoryCount)
                {
                    row1.Cells[3].AddParagraph(Oflet.StatutoryList[i].CompCode);
                    row1.Cells[4].AddParagraph("Rs.");
                    row1.Cells[5].AddParagraph(Oflet.StatutoryList[i].Amount.ToString() + "/-");
                    row1.Cells[5].Format.Alignment = ParagraphAlignment.Right;
                    row1.Cells[4].Borders.Right.Color = Colors.White;
                    row1.Cells[1].Borders.Right.Color = Colors.White;

                }
            }

            row = Salary.AddRow();
            row.HeadingFormat = true;
            row.Format.Alignment = ParagraphAlignment.Center;
            row.Format.Font.Bold = true;


            row.Cells[0].AddParagraph("GROSS SALARY TOTAL");
            row.Cells[1].AddParagraph("Rs.");
            Char BonusType = Oflet.BonusType;
            if (BonusType == 'G')
            {
                row.Cells[2].AddParagraph(Oflet.ResForOfferLet.Gross + "/-");

            }
            else
            {
                // row.Cells[2].AddParagraph(Oflet.ResForOfferLet.Gross + Oflet.BonusValue + "/-");
                row.Cells[2].AddParagraph(Oflet.ResForOfferLet.Gross + "/-");
            }

            row.Cells[2].Format.Alignment = ParagraphAlignment.Right;
            row.Cells[1].Borders.Right.Color = Colors.White;

            row.Cells[3].AddParagraph("STATUTORY TOTAL");
            row.Cells[4].AddParagraph("Rs.");
            //row.Cells[5].AddParagraph(StatutoryAmount + "/-");
            row.Cells[5].AddParagraph(StatutoryAmount + OtherStatutoryAmount + "/-");
            row.Cells[5].Format.Alignment = ParagraphAlignment.Right;
            row.Cells[4].Borders.Right.Color = Colors.White;

            for (int i = 0; i < Oflet.DeductionsList.Count(); i++)
            {
                row1 = Salary.AddRow();
                if (i != (Oflet.DeductionsList.Count()) - 1)
                {
                    row1.Format.Alignment = ParagraphAlignment.Left;
                    row1.Borders.Bottom.Color = Colors.White;
                    row1.Borders.Top.Color = Colors.White;
                }

                row1.Cells[0].AddParagraph(Oflet.DeductionsList[i].CompCode);
                row1.Cells[1].AddParagraph("Rs.");
                row1.Cells[2].AddParagraph(Oflet.DeductionsList[i].Amount + "/-");
                row1.Cells[2].Format.Alignment = ParagraphAlignment.Right;
                row1.Cells[3].MergeRight = 2;
                row1.Cells[1].Borders.Right.Color = Colors.White;
                row1.Cells[4].Borders.Right.Color = Colors.White;
            }

            row = Salary.AddRow();
            row.HeadingFormat = true;
            row.Format.Alignment = ParagraphAlignment.Center;
            row.Format.Font.Bold = true;

            row.Cells[0].AddParagraph("");
            row.Cells[0].AddParagraph().AddFormattedText("", "Normal");
            row.Cells[1].AddParagraph("");
            row.Cells[2].AddParagraph("");
            row.Cells[2].Format.Alignment = ParagraphAlignment.Right;
            row.Cells[1].Borders.Right.Color = Colors.White;

            row.Cells[3].AddParagraph("Monthly Variable (CTC)");
            row.Cells[3].AddParagraph().AddFormattedText("", "Normal");
            row.Cells[4].AddParagraph("Rs.");
            row.Cells[5].AddParagraph((Oflet.MonthlyVariableNoESIC) + "/-");
            row.Cells[5].Format.Alignment = ParagraphAlignment.Right;
            row.Cells[4].Borders.Right.Color = Colors.White;

            row = Salary.AddRow();
            row.HeadingFormat = true;
            row.Format.Alignment = ParagraphAlignment.Center;
            row.Format.Font.Bold = true;

            salComps.NetSalary = Oflet.ResForOfferLet.Net;
            salComps.TotalCostAmount = (Oflet.ResForOfferLet.Gross + StatutoryAmount);

            row.Cells[0].AddParagraph("");
            row.Cells[0].AddParagraph().AddFormattedText("", "Normal");
            row.Cells[1].AddParagraph("");
            row.Cells[2].AddParagraph("");
            row.Cells[2].Format.Alignment = ParagraphAlignment.Right;
            row.Cells[1].Borders.Right.Color = Colors.White;

            row.Cells[3].AddParagraph("Fixed-COST TO COMPANY");
            row.Cells[3].AddParagraph().AddFormattedText("(Gross + Statutory Benefits)", "Normal");
            row.Cells[4].AddParagraph("Rs.");
            //row.Cells[5].AddParagraph((Oflet.ResForOfferLet.Gross + StatutoryAmount) + "/-");

            // Char BonusType = Oflet.BonusType;
            if (BonusType == 'G')
            {
                row.Cells[5].AddParagraph((Oflet.ResForOfferLet.Gross + StatutoryAmount + OtherStatutoryAmount) + "/-");

            }
            else
            {
                //row.Cells[5].AddParagraph((Oflet.ResForOfferLet.Gross + StatutoryAmount + OtherStatutoryAmount + Oflet.BonusValue) + "/-");
                row.Cells[5].AddParagraph((Oflet.ResForOfferLet.Gross + StatutoryAmount + OtherStatutoryAmount) + "/-");
            }

            row.Cells[5].Format.Alignment = ParagraphAlignment.Right;
            row.Cells[4].Borders.Right.Color = Colors.White;

            row = Salary.AddRow();
            row.HeadingFormat = true;
            row.Format.Alignment = ParagraphAlignment.Center;
            row.Format.Font.Bold = true;
            salComps.NetSalary = Oflet.ResForOfferLet.Net;
            salComps.TotalCostAmount = (Oflet.ResForOfferLet.Gross + StatutoryAmount);// Oflet.ResForOfferLet.CTC;
            row.Cells[0].AddParagraph("");
            row.Cells[0].AddParagraph().AddFormattedText("", "Normal");
            row.Cells[1].AddParagraph("");
            row.Cells[2].AddParagraph("");
            row.Cells[2].Format.Alignment = ParagraphAlignment.Right;
            row.Cells[1].Borders.Right.Color = Colors.White;
            row.Cells[3].AddParagraph("Monthly Variable");
            row.Cells[3].AddParagraph().AddFormattedText("", "Normal");
            row.Cells[4].AddParagraph("Rs.");
            row.Cells[5].AddParagraph((Oflet.MonthlyVariable) + "/-");
            row.Cells[5].Format.Alignment = ParagraphAlignment.Right;
            row.Cells[4].Borders.Right.Color = Colors.White;
            row = Salary.AddRow();
            row.HeadingFormat = true;
            row.Format.Alignment = ParagraphAlignment.Center;
            row.Format.Font.Bold = true;

            row.Cells[0].AddParagraph("");
            row.Cells[0].AddParagraph().AddFormattedText("", "Normal");
            row.Cells[1].AddParagraph("");
            row.Cells[2].AddParagraph("");
            row.Cells[2].Format.Alignment = ParagraphAlignment.Right;
            row.Cells[1].Borders.Right.Color = Colors.White;

            row.Cells[3].AddParagraph("Term Insurance");
            row.Cells[3].AddParagraph().AddFormattedText("", "Normal");
            row.Cells[4].AddParagraph("Rs.");
            row.Cells[5].AddParagraph((Oflet.TermIns) + "/-");
            row.Cells[5].Format.Alignment = ParagraphAlignment.Right;
            row.Cells[4].Borders.Right.Color = Colors.White;
            row = Salary.AddRow();
            row.HeadingFormat = true;
            row.Format.Alignment = ParagraphAlignment.Center;
            row.Format.Font.Bold = true;

            salComps.NetSalary = Oflet.ResForOfferLet.Net;
            salComps.TotalCostAmount = (Oflet.ResForOfferLet.Gross + StatutoryAmount);// Oflet.ResForOfferLet.CTC;

            row.Cells[0].AddParagraph("NET SALARY");
            row.Cells[0].AddParagraph().AddFormattedText("", "Normal");
            row.Cells[1].AddParagraph("Rs.");
            row.Cells[2].AddParagraph(salComps.NetSalary + "/-");
            row.Cells[2].Format.Alignment = ParagraphAlignment.Right;
            row.Cells[1].Borders.Right.Color = Colors.White;


            row.Cells[3].AddParagraph("COST TO COMPANY");
            row.Cells[3].AddParagraph().AddFormattedText("(Monthly Variable + Fixed CTC)", "Normal");
            row.Cells[4].AddParagraph("Rs.");
            row.Cells[5].AddParagraph((Oflet.MonthlyVariable + Oflet.ResForOfferLet.Gross + StatutoryAmount + OtherStatutoryAmount) + "/-");
            row.Cells[5].Format.Alignment = ParagraphAlignment.Right;
            row.Cells[4].Borders.Right.Color = Colors.White;

            return "";
        }

        private string FillinV5SalaryDetails(NewSalaryComponents salComps)
        {
            DriveRepository obj = new DriveRepository();
            OffereLetter Oflet = new OffereLetter();
            string SalaryCode = obj.GetSalaryCode(salComps.SalaryId);
            Oflet.LoadSalDeta(SalaryCode);
            double StatutoryAmount = /*Oflet.ResForOfferLet.AllStatutoryAllowances + */Oflet.ResForOfferLet.StatutorySub;

            Table Project = CurrentSection.AddTable();
            Project.Borders.Color = Colors.Gray;
            Project.Borders.Width = 0.25;
            Project.Borders.Left.Width = 0.5;
            Project.Borders.Right.Width = 0.5;
            Project.Rows.LeftIndent = 0;

            Column column1 = Project.AddColumn("10cm");
            Column column2 = Project.AddColumn("5cm");

            Row row = Project.AddRow();
            row.HeadingFormat = true;
            row.Format.Alignment = ParagraphAlignment.Center;
            row.Format.Font.Bold = true;

            row.Cells[0].AddParagraph("Particulars");
            row.Cells[1].AddParagraph("Salary Package(P.M.)");

            Row row1 = Project.AddRow();
            row1.HeadingFormat = true;
            row1.Format.Alignment = ParagraphAlignment.Left;

            row1.Cells[0].AddParagraph("Basic");
            row1.Cells[1].AddParagraph(Oflet.ResForOfferLet.Basic + "/-");


            Row row2 = Project.AddRow();
            row2.HeadingFormat = true;
            row2.Format.Alignment = ParagraphAlignment.Left;

            row2.Cells[0].AddParagraph("HRA");
            row2.Cells[1].AddParagraph(Oflet.ResForOfferLet.HRA + "/-");


            Row row3 = Project.AddRow();
            row3.HeadingFormat = true;
            row3.Format.Alignment = ParagraphAlignment.Left;

            row3.Cells[0].AddParagraph("Bonus");
            row3.Cells[1].AddParagraph(Oflet.ResForOfferLet.Bonus + "/-");

            Row row4 = Project.AddRow();
            row4.HeadingFormat = true;
            row4.Format.Alignment = ParagraphAlignment.Left;

            row4.Cells[0].AddParagraph("SpclPF");
            row4.Cells[1].AddParagraph(Oflet.SpecialAllowanceMH + "/-");

            ///
            Row row5 = Project.AddRow();
            row5.HeadingFormat = true;
            row5.Format.Alignment = ParagraphAlignment.Left;

            row5.Cells[0].AddParagraph("OtherAllowance");
            row5.Cells[1].AddParagraph(Oflet.ResForOfferLet.OtherAllowance + "/-");
            ///
            ///
            Row row6 = Project.AddRow();
            row6.HeadingFormat = true;
            row6.Format.Alignment = ParagraphAlignment.Left;

            row6.Cells[0].AddParagraph("MobileAllowance");
            row6.Cells[1].AddParagraph(Oflet.MobileAllowance + "/-");
            ///

            Row row7 = Project.AddRow();
            row7.HeadingFormat = true;
            row7.Format.Alignment = ParagraphAlignment.Left;
            row7.Format.Font.Bold = true;


            row7.Cells[0].AddParagraph("Total salary");

            //if (BonusType = "G" )
            //{
            row7.Cells[1].AddParagraph(Oflet.ResForOfferLet.Gross + "/-");
            //}


            Row row8 = Project.AddRow();
            row8.HeadingFormat = true;
            row8.Format.Alignment = ParagraphAlignment.Left;
            row8.Format.Font.Bold = true;

            row8.Cells[0].AddParagraph("Gross");
            row8.Cells[1].AddParagraph(Oflet.ResForOfferLet.Gross + "/-");

            Row row9 = Project.AddRow();
            row9.HeadingFormat = true;
            row9.Format.Alignment = ParagraphAlignment.Left;

            row9.Cells[0].AddParagraph("Employer ESIC");
            row9.Cells[1].AddParagraph(Oflet.ResForOfferLet.ESICEmployer + "/-");


            Row row10 = Project.AddRow();
            row10.HeadingFormat = true;
            row10.Format.Alignment = ParagraphAlignment.Left;

            row10.Cells[0].AddParagraph("Employer PF");
            row10.Cells[1].AddParagraph(Oflet.ResForOfferLet.PFEmployer + "/-");

            Row row11 = Project.AddRow();
            row11.HeadingFormat = true;
            row11.Format.Alignment = ParagraphAlignment.Left;

            row11.Cells[0].AddParagraph("Admin PF & EDLI");
            row11.Cells[1].AddParagraph(Oflet.ResForOfferLet.PFAdmin + Oflet.ResForOfferLet.EDLIEmployer + "/-");

            //////////////////Added By Abhilash on 13 Oct 2020
            Row row12 = Project.AddRow();
            row12.HeadingFormat = true;
            row12.Format.Alignment = ParagraphAlignment.Left;
            //row17.Format.Font.Bold = true;
            row12.Cells[0].AddParagraph("LWF Company");
            row12.Cells[1].AddParagraph(Oflet.LWFCompany + "/-");


            Row row13 = Project.AddRow();
            row13.HeadingFormat = true;
            row13.Format.Alignment = ParagraphAlignment.Left;
            //row17.Format.Font.Bold = true;
            row13.Cells[0].AddParagraph("MedicalInsuranceV5");
            row13.Cells[1].AddParagraph(Oflet.MedicalInsuranceV5 + "/-");

            Row row14 = Project.AddRow();
            row14.HeadingFormat = true;
            row14.Format.Alignment = ParagraphAlignment.Left;

            row14.Cells[0].AddParagraph("PAI");
            // row13.Cells[1].AddParagraph(Oflet.MedicalInsuranceV5 + "/-");
            row14.Cells[1].AddParagraph(Oflet.PersonalAccidentInsurance + "/-");
            Row row15 = Project.AddRow();
            row15.HeadingFormat = true;
            row15.Format.Alignment = ParagraphAlignment.Left;

            row15.Cells[0].AddParagraph("Gratuity");
            // row13.Cells[1].AddParagraph(Oflet.MedicalInsuranceV5 + "/-");
            row15.Cells[1].AddParagraph(Oflet.GratuityAmount + "/-");

            Row row16 = Project.AddRow();
            row16.HeadingFormat = true;
            row16.Format.Alignment = ParagraphAlignment.Left;
            row16.Format.Font.Bold = true;

            row16.Cells[0].AddParagraph("Cost to Company");
            //  row14.Cells[1].AddParagraph((Oflet.ResForOfferLet.Gross + StatutoryAmount) + "/-");
            // row13.Cells[1].AddParagraph((Oflet.ResForOfferLet.Gross + StatutoryAmount+ Oflet.MedicalInsuranceV5) + "/-");

            row16.Cells[1].AddParagraph((Oflet.ResForOfferLet.Gross + StatutoryAmount + Oflet.MedicalInsuranceV5 + Oflet.LWFCompany + Oflet.MonthlyVariableNoESIC) + "/-");
            // row11.Cells[1].AddParagraph((Oflet.ResForOfferLet.CTC  + "/-"));


            Row row17 = Project.AddRow();
            row17.HeadingFormat = true;
            row17.Format.Alignment = ParagraphAlignment.Left;
            //row17.Format.Font.Bold = true;
            row17.Cells[0].AddParagraph("MediclaimV5");
            row17.Cells[1].AddParagraph(Oflet.MediclaimV5 + "/-");

            Row row18 = Project.AddRow();
            row18.HeadingFormat = true;
            row18.Format.Alignment = ParagraphAlignment.Left;
            row18.Cells[0].AddParagraph("Employee PF");
            row18.Cells[1].AddParagraph(Oflet.ResForOfferLet.PFEmployee + "/-");

            Row row19 = Project.AddRow();
            row19.HeadingFormat = true;
            row19.Format.Alignment = ParagraphAlignment.Left;
            row19.Cells[0].AddParagraph("Employee ESIC");
            row19.Cells[1].AddParagraph(Oflet.ResForOfferLet.ESICEmployee + "/-");

            ////Row InvisibleRow1 = Project.AddRow();
            ////InvisibleRow1.HeadingFormat = true;
            ////InvisibleRow1.Borders.Visible = false;
            ////InvisibleRow1.Cells[0].Borders.Visible = false;
            ////InvisibleRow1.Cells[1].Borders.Visible = false;
            ////InvisibleRow1.Cells[0].AddParagraph();
            ////InvisibleRow1.Cells[1].AddParagraph();
            ////InvisibleRow1.Borders.Top.Visible = false;


            ////Row InvisibleRow2 = Project.AddRow();
            ////InvisibleRow2.HeadingFormat = true;
            ////InvisibleRow2.Borders.Visible = false;
            ////InvisibleRow2.Cells[0].Borders.Visible = false;
            ////InvisibleRow2.Cells[1].Borders.Visible = false;
            ////InvisibleRow2.Cells[0].AddParagraph();
            ////InvisibleRow2.Cells[1].AddParagraph();

            ////Row InvisibleRow3 = Project.AddRow();
            ////InvisibleRow3.HeadingFormat = true;
            ////InvisibleRow3.Borders.Visible = false;
            ////InvisibleRow3.Cells[0].Borders.Visible = false;
            ////InvisibleRow3.Cells[1].Borders.Visible = false;
            ////InvisibleRow3.Cells[0].AddParagraph();
            ////InvisibleRow3.Cells[1].AddParagraph();

            ////Row InvisibleRow4 = Project.AddRow();
            ////InvisibleRow4.HeadingFormat = true;
            ////InvisibleRow4.Borders.Visible = false;
            ////InvisibleRow4.Cells[0].Borders.Visible = false;
            ////InvisibleRow4.Cells[1].Borders.Visible = false;
            ////InvisibleRow4.Cells[0].AddParagraph();
            ////InvisibleRow4.Cells[1].AddParagraph();

            ////Row InvisibleRow5 = Project.AddRow();
            ////InvisibleRow5.HeadingFormat = true;
            ////InvisibleRow5.Borders.Visible = false;
            ////InvisibleRow5.Cells[0].Borders.Visible = false;
            ////InvisibleRow5.Cells[1].Borders.Visible = false;
            ////InvisibleRow5.Cells[0].AddParagraph();
            ////InvisibleRow5.Cells[1].AddParagraph();

            ////Row InvisibleRow6 = Project.AddRow();
            ////InvisibleRow6.HeadingFormat = true;
            ////InvisibleRow6.Borders.Visible = false;
            ////InvisibleRow6.Cells[0].Borders.Visible = false;
            ////InvisibleRow6.Cells[1].Borders.Visible = false;
            ////InvisibleRow6.Cells[0].AddParagraph();
            ////InvisibleRow6.Cells[1].AddParagraph();

            Row row20 = Project.AddRow();
            row20.HeadingFormat = true;
            row20.Format.Alignment = ParagraphAlignment.Left;

            row20.Cells[0].AddParagraph("Professional Tax");
            row20.Cells[1].AddParagraph(Oflet.ResForOfferLet.ProfessionalTax + "/-");

            Row row21 = Project.AddRow();
            row21.HeadingFormat = true;
            row21.Format.Alignment = ParagraphAlignment.Left;
            //ro17.Format.Font.Bold = true;
            row21.Cells[0].AddParagraph("InsuranceV5");
            row21.Cells[1].AddParagraph(Oflet.InsuranceV5 + "/-");

            Row row22 = Project.AddRow();
            row22.HeadingFormat = true;
            row22.Format.Alignment = ParagraphAlignment.Left;
            //row17.Format.Font.Bold = true;
            row22.Cells[0].AddParagraph("LWF Employee");
            row22.Cells[1].AddParagraph(Oflet.LWFEmployee + "/-");

            Row row23 = Project.AddRow();
            row23.HeadingFormat = true;
            row23.Format.Alignment = ParagraphAlignment.Left;
            row23.Format.Font.Bold = true;
            row23.Cells[0].AddParagraph("In Hand Salary");
            row23.Cells[1].AddParagraph(Oflet.ResForOfferLet.Net + "/-");
            Row row24 = Project.AddRow();
            row24.HeadingFormat = true;
            row24.Format.Alignment = ParagraphAlignment.Left;
            row24.Format.Font.Bold = true;
            row24.Cells[0].AddParagraph("Monthly Variable");
            row24.Cells[1].AddParagraph(Oflet.MonthlyVariable + "/-");

            Row row25 = Project.AddRow();
            row25.HeadingFormat = true;
            row25.Format.Alignment = ParagraphAlignment.Left;
            row25.Format.Font.Bold = true;
            row25.Cells[0].AddParagraph("Monthly Variable - CTC");
            row25.Cells[1].AddParagraph(Oflet.MonthlyVariableNoESIC + "/-");

            Row row26 = Project.AddRow();
            row26.HeadingFormat = true;
            row26.Format.Alignment = ParagraphAlignment.Left;
            row26.Format.Font.Bold = true;
            row26.Cells[0].AddParagraph("Retention Bonus - CTC");
            row26.Cells[1].AddParagraph(Oflet.RetentionBonusCTC + "/-");

            return "";
        }

        private string FillinProjectDetails(NewSalaryComponents salComps)
        {
            Table Project = CurrentSection.AddTable();
            Project.Borders.Color = Colors.Gray;
            Project.Borders.Width = 0.25;
            Project.Borders.Left.Width = 0.5;
            Project.Borders.Right.Width = 0.5;
            Project.Rows.LeftIndent = 0;

            Column column1 = Project.AddColumn("5cm");
            Column column2 = Project.AddColumn("5cm");
            Column column3 = Project.AddColumn("5cm");

            Row row = Project.AddRow();
            row.HeadingFormat = true;
            row.Format.Alignment = ParagraphAlignment.Center;
            row.Format.Font.Bold = true;

            row.Cells[0].AddParagraph("Details");
            row.Cells[1].AddParagraph("Previous");
            row.Cells[2].AddParagraph("New");

            Row row1 = Project.AddRow();
            row1.HeadingFormat = true;
            row1.Format.Alignment = ParagraphAlignment.Center;

            row1.Cells[0].AddParagraph("Designation");

            if (SalaryComps.Designation == SalaryComps.PreviousDesignation)
            {
                row1.Cells[1].AddParagraph(SalaryComps.PreviousDesignation);
                row1.Cells[2].AddParagraph(SalaryComps.Designation);
            }
            else if (SalaryComps.PreviousDesignation != "")
            {
                row1.Cells[1].AddParagraph(SalaryComps.PreviousDesignation);
                row1.Cells[2].AddParagraph(SalaryComps.Designation);
            }
            else
            {
                row1.Cells[1].AddParagraph(SalaryComps.Designation);
                row1.Cells[2].AddParagraph(SalaryComps.PreviousDesignation);
            }

            Row row2 = Project.AddRow();
            row2.HeadingFormat = true;
            row2.Format.Alignment = ParagraphAlignment.Center;

            row2.Cells[0].AddParagraph("Project");
            if (SalaryComps.ClientName == SalaryComps.PreviousClientName)
            {
                row2.Cells[1].AddParagraph(SalaryComps.PreviousClientName);
                row2.Cells[2].AddParagraph("");
            }
            else if (SalaryComps.PreviousClientName != "")
            {
                row2.Cells[1].AddParagraph(SalaryComps.PreviousClientName);
                row2.Cells[2].AddParagraph(SalaryComps.ClientName);
            }
            else
            {
                row2.Cells[1].AddParagraph(SalaryComps.ClientName);
                row2.Cells[2].AddParagraph(SalaryComps.PreviousClientName);
            }
            Row row3 = Project.AddRow();
            row3.HeadingFormat = true;
            row3.Format.Alignment = ParagraphAlignment.Center;

            row3.Cells[0].AddParagraph("Work Location");

            if (SalaryComps.Location == SalaryComps.PreviousWorkLocation)
            {
                row3.Cells[1].AddParagraph(SalaryComps.PreviousWorkLocation);
                row3.Cells[2].AddParagraph(SalaryComps.Location);
            }
            else if (SalaryComps.PreviousWorkLocation != "")
            {
                row3.Cells[1].AddParagraph(SalaryComps.PreviousWorkLocation);
                row3.Cells[2].AddParagraph(SalaryComps.Location);
            }
            else
            {
                row3.Cells[1].AddParagraph(SalaryComps.Location);
                row3.Cells[2].AddParagraph(SalaryComps.PreviousWorkLocation);
            }
            return "";
        }
        private string FillinLocationDetails(NewSalaryComponents salComps)
        {
            Table Project = CurrentSection.AddTable();
            Project.Borders.Color = Colors.Gray;
            Project.Borders.Width = 0.25;
            Project.Borders.Left.Width = 0.5;
            Project.Borders.Right.Width = 0.5;
            Project.Rows.LeftIndent = 0;

            Column column1 = Project.AddColumn("5cm");
            Column column2 = Project.AddColumn("5cm");
            Column column3 = Project.AddColumn("5cm");

            Row row = Project.AddRow();
            row.HeadingFormat = true;
            row.Format.Alignment = ParagraphAlignment.Center;
            row.Format.Font.Bold = true;

            row.Cells[0].AddParagraph("Details");
            row.Cells[1].AddParagraph("Current");
            row.Cells[2].AddParagraph("New");

            Row row1 = Project.AddRow();
            row1.HeadingFormat = true;
            row1.Format.Alignment = ParagraphAlignment.Center;

            row1.Cells[0].AddParagraph("Work Location");
            ////row1.Cells[1].AddParagraph(SalaryComps.Location);
            ////row1.Cells[2].AddParagraph(SalaryComps.NewWorkLocation);

            if (SalaryComps.Location == SalaryComps.PreviousWorkLocation)
            {
                row1.Cells[1].AddParagraph(SalaryComps.PreviousWorkLocation);
                row1.Cells[2].AddParagraph("");
            }
            else if (SalaryComps.PreviousWorkLocation != "")
            {
                row1.Cells[1].AddParagraph(SalaryComps.PreviousWorkLocation);
                row1.Cells[2].AddParagraph(SalaryComps.Location);
            }
            else
            {
                row1.Cells[1].AddParagraph(SalaryComps.Location);
                row1.Cells[2].AddParagraph(SalaryComps.PreviousWorkLocation);
            }

            return "";
        }

        private string FindTokens(String text)
        {
            MatchEvaluator matchEval = match => ReplaceTokenValue(match.Groups[1].Value);
            String retHtml = TokenMatchRx.Replace(text, matchEval);
            return retHtml;
            /*
            foreach (Match match in TokenMatchRx.Matches(text))
            {
                string ss = match.Value.ToString();

            }*/
        }
        private string FillinV5SalaryDetailsPromotion(NewSalaryComponents salComps)
        {
            DriveRepository obj = new DriveRepository();
            OffereLetter Oflet = new OffereLetter();
            string SalaryCode = obj.GetSalaryCode(salComps.SalaryId);
            Oflet.LoadSalDeta(SalaryCode);
            double StatutoryAmount = /*Oflet.ResForOfferLet.AllStatutoryAllowances + */Oflet.ResForOfferLet.StatutorySub;

            Table Project = CurrentSection.AddTable();
            Project.Borders.Color = Colors.Gray;
            Project.Borders.Width = 0.25;
            Project.Borders.Left.Width = 0.5;
            Project.Borders.Right.Width = 0.5;
            Project.Rows.LeftIndent = 0;

            Column column1 = Project.AddColumn("10cm");
            Column column2 = Project.AddColumn("5cm");

            Row row = Project.AddRow();
            row.HeadingFormat = true;
            row.Format.Alignment = ParagraphAlignment.Center;
            row.Format.Font.Bold = true;

            row.Cells[0].AddParagraph("Particulars");
            row.Cells[1].AddParagraph("Revised Package(P.M.)");

            Row row1 = Project.AddRow();
            row1.HeadingFormat = true;
            row1.Format.Alignment = ParagraphAlignment.Left;

            row1.Cells[0].AddParagraph("Basic");
            row1.Cells[1].AddParagraph(Oflet.ResForOfferLet.Basic + "/-");


            Row row2 = Project.AddRow();
            row2.HeadingFormat = true;
            row2.Format.Alignment = ParagraphAlignment.Left;

            row2.Cells[0].AddParagraph("HRA");
            row2.Cells[1].AddParagraph(Oflet.ResForOfferLet.HRA + "/-");

            Char BonusTypes = Oflet.BonusType;
            if (BonusTypes == 'G')
            {
                Row row7 = Project.AddRow();
                row7.HeadingFormat = true;
                row7.Format.Alignment = ParagraphAlignment.Left;
                row7.Cells[0].AddParagraph("Bonus");
                row7.Cells[1].AddParagraph(Oflet.ResForOfferLet.Bonus + "/-");
            }

            Row row3 = Project.AddRow();
            row3.HeadingFormat = true;
            row3.Format.Alignment = ParagraphAlignment.Left;

            row3.Cells[0].AddParagraph("SpclPF");
            row3.Cells[1].AddParagraph(Oflet.SpecialAllowanceMH + "/-");

            ///
            Row row4 = Project.AddRow();
            row4.HeadingFormat = true;
            row4.Format.Alignment = ParagraphAlignment.Left;

            row4.Cells[0].AddParagraph("OtherAllowance");
            row4.Cells[1].AddParagraph(Oflet.ResForOfferLet.OtherAllowance + "/-");
            ///

            Row row5 = Project.AddRow();
            row5.HeadingFormat = true;
            row5.Format.Alignment = ParagraphAlignment.Left;
            row5.Format.Font.Bold = true;
            row5.Cells[0].AddParagraph("Total salary");
            Char BonusType = Oflet.BonusType;
            if (BonusType == 'G')
            {
                row5.Cells[1].AddParagraph(Oflet.ResForOfferLet.Gross + "/-");
            }
            else
            {
                //row6.Cells[1].AddParagraph(Oflet.ResForOfferLet.Gross + Oflet.BonusValue + "/-");
                row5.Cells[1].AddParagraph(Oflet.ResForOfferLet.Gross + "/-");
            }

            Row row6 = Project.AddRow();
            row6.HeadingFormat = true;
            row6.Format.Alignment = ParagraphAlignment.Left;
            row6.Format.Font.Bold = true;

            row6.Cells[0].AddParagraph("Gross");
            if (BonusType == 'G')
            {
                row6.Cells[1].AddParagraph(Oflet.ResForOfferLet.Gross + "/-");
            }
            else
            {

                //row7.Cells[1].AddParagraph(Oflet.ResForOfferLet.Gross + Oflet.BonusValue + "/-");
                row6.Cells[1].AddParagraph(Oflet.ResForOfferLet.Gross + "/-");
            }

            if (BonusType == 'B')
            {
                Row row7 = Project.AddRow();
                row7.HeadingFormat = true;
                row7.Format.Alignment = ParagraphAlignment.Left;
                row7.Cells[0].AddParagraph("Bonus");
                row7.Cells[1].AddParagraph(Oflet.ResForOfferLet.Bonus + "/-");
            }
            Row row8 = Project.AddRow();
            row8.HeadingFormat = true;
            row8.Format.Alignment = ParagraphAlignment.Left;

            row8.Cells[0].AddParagraph("Employer ESIC");
            row8.Cells[1].AddParagraph(Oflet.ResForOfferLet.ESICEmployer + "/-");


            Row row9 = Project.AddRow();
            row9.HeadingFormat = true;
            row9.Format.Alignment = ParagraphAlignment.Left;

            row9.Cells[0].AddParagraph("Employer PF");
            row9.Cells[1].AddParagraph(Oflet.ResForOfferLet.PFEmployer + "/-");

            Row row10 = Project.AddRow();
            row10.HeadingFormat = true;
            row10.Format.Alignment = ParagraphAlignment.Left;

            row10.Cells[0].AddParagraph("Admin PF & EDLI");
            row10.Cells[1].AddParagraph(Oflet.ResForOfferLet.PFAdmin + Oflet.ResForOfferLet.EDLIEmployer + "/-");

            Row row11 = Project.AddRow();
            row11.HeadingFormat = true;
            row11.Format.Alignment = ParagraphAlignment.Left;
            //row17.Format.Font.Bold = true;
            row11.Cells[0].AddParagraph("LWF Company");
            row11.Cells[1].AddParagraph(Oflet.LWFCompany + "/-");


            Row row12 = Project.AddRow();
            row12.HeadingFormat = true;
            row12.Format.Alignment = ParagraphAlignment.Left;
            //row17.Format.Font.Bold = true;
            row12.Cells[0].AddParagraph("MedicalInsuranceV5");
            row12.Cells[1].AddParagraph(Oflet.MedicalInsuranceV5 + "/-");

            Row row13 = Project.AddRow();
            row13.HeadingFormat = true;
            row13.Format.Alignment = ParagraphAlignment.Left;

            row13.Cells[0].AddParagraph("PAI");
            // row13.Cells[1].AddParagraph(Oflet.MedicalInsuranceV5 + "/-");
            row13.Cells[1].AddParagraph(Oflet.PersonalAccidentInsurance + "/-");
            Row row14 = Project.AddRow();
            row14.HeadingFormat = true;
            row14.Format.Alignment = ParagraphAlignment.Left;

            row14.Cells[0].AddParagraph("Gratuity");
            // row13.Cells[1].AddParagraph(Oflet.MedicalInsuranceV5 + "/-");
            row14.Cells[1].AddParagraph(Oflet.GratuityAmount + "/-");

            Row row15 = Project.AddRow();
            row15.HeadingFormat = true;
            row15.Format.Alignment = ParagraphAlignment.Left;
            row15.Format.Font.Bold = true;

            row15.Cells[0].AddParagraph("Cost to Company");
            //  row14.Cells[1].AddParagraph((Oflet.ResForOfferLet.Gross + StatutoryAmount) + "/-");
            // row13.Cells[1].AddParagraph((Oflet.ResForOfferLet.Gross + StatutoryAmount+ Oflet.MedicalInsuranceV5) + "/-");
            if (BonusType == 'G')
            {
                row15.Cells[1].AddParagraph((Oflet.ResForOfferLet.Gross + StatutoryAmount + Oflet.MedicalInsuranceV5 + Oflet.LWFCompany) + "/-");
            }
            else
            {
                row15.Cells[1].AddParagraph((Oflet.ResForOfferLet.Gross + StatutoryAmount + Oflet.MedicalInsuranceV5 + Oflet.LWFCompany) + "/-");
                // row15.Cells[1].AddParagraph((Oflet.ResForOfferLet.Gross + StatutoryAmount + Oflet.MedicalInsuranceV5 + Oflet.LWFCompany + Oflet.BonusValue) + "/-");
            }
            // row11.Cells[1].AddParagraph((Oflet.ResForOfferLet.CTC  + "/-"));


            Row row16 = Project.AddRow();
            row16.HeadingFormat = true;
            row16.Format.Alignment = ParagraphAlignment.Left;
            //row17.Format.Font.Bold = true;
            row16.Cells[0].AddParagraph("MediclaimV5");
            row16.Cells[1].AddParagraph(Oflet.MediclaimV5 + "/-");

            Row row17 = Project.AddRow();
            row17.HeadingFormat = true;
            row17.Format.Alignment = ParagraphAlignment.Left;
            row17.Cells[0].AddParagraph("Employee PF");
            row17.Cells[1].AddParagraph(Oflet.ResForOfferLet.PFEmployee + "/-");

            Row row18 = Project.AddRow();
            row18.HeadingFormat = true;
            row18.Format.Alignment = ParagraphAlignment.Left;
            row18.Cells[0].AddParagraph("Employee ESIC");
            row18.Cells[1].AddParagraph(Oflet.ResForOfferLet.ESICEmployee + "/-");

            Row InvisibleRow1 = Project.AddRow();
            InvisibleRow1.HeadingFormat = true;
            InvisibleRow1.Borders.Visible = false;
            InvisibleRow1.Cells[0].Borders.Visible = false;
            InvisibleRow1.Cells[1].Borders.Visible = false;
            InvisibleRow1.Cells[0].AddParagraph();
            InvisibleRow1.Cells[1].AddParagraph();
            InvisibleRow1.Borders.Top.Visible = false;


            Row InvisibleRow2 = Project.AddRow();
            InvisibleRow2.HeadingFormat = true;
            InvisibleRow2.Borders.Visible = false;
            InvisibleRow2.Cells[0].Borders.Visible = false;
            InvisibleRow2.Cells[1].Borders.Visible = false;
            InvisibleRow2.Cells[0].AddParagraph();
            InvisibleRow2.Cells[1].AddParagraph();

            Row InvisibleRow3 = Project.AddRow();
            InvisibleRow3.HeadingFormat = true;
            InvisibleRow3.Borders.Visible = false;
            InvisibleRow3.Cells[0].Borders.Visible = false;
            InvisibleRow3.Cells[1].Borders.Visible = false;
            InvisibleRow3.Cells[0].AddParagraph();
            InvisibleRow3.Cells[1].AddParagraph();

            Row InvisibleRow4 = Project.AddRow();
            InvisibleRow4.HeadingFormat = true;
            InvisibleRow4.Borders.Visible = false;
            InvisibleRow4.Cells[0].Borders.Visible = false;
            InvisibleRow4.Cells[1].Borders.Visible = false;
            InvisibleRow4.Cells[0].AddParagraph();
            InvisibleRow4.Cells[1].AddParagraph();

            Row InvisibleRow5 = Project.AddRow();
            InvisibleRow5.HeadingFormat = true;
            InvisibleRow5.Borders.Visible = false;
            InvisibleRow5.Cells[0].Borders.Visible = false;
            InvisibleRow5.Cells[1].Borders.Visible = false;
            InvisibleRow5.Cells[0].AddParagraph();
            InvisibleRow5.Cells[1].AddParagraph();

            Row InvisibleRow6 = Project.AddRow();
            InvisibleRow6.HeadingFormat = true;
            InvisibleRow6.Borders.Visible = false;
            InvisibleRow6.Cells[0].Borders.Visible = false;
            InvisibleRow6.Cells[1].Borders.Visible = false;
            InvisibleRow6.Cells[0].AddParagraph();
            InvisibleRow6.Cells[1].AddParagraph();


            Row row19 = Project.AddRow();
            row19.HeadingFormat = true;
            row19.Format.Alignment = ParagraphAlignment.Left;

            row19.Cells[0].AddParagraph("Professional Tax");
            row19.Cells[1].AddParagraph(Oflet.ResForOfferLet.ProfessionalTax + "/-");

            Row row20 = Project.AddRow();
            row20.HeadingFormat = true;
            row20.Format.Alignment = ParagraphAlignment.Left;
            //ro17.Format.Font.Bold = true;
            row20.Cells[0].AddParagraph("InsuranceV5");
            row20.Cells[1].AddParagraph(Oflet.InsuranceV5 + "/-");

            Row row21 = Project.AddRow();
            row21.HeadingFormat = true;
            row21.Format.Alignment = ParagraphAlignment.Left;
            //row17.Format.Font.Bold = true;
            row21.Cells[0].AddParagraph("LWF Employee");
            row21.Cells[1].AddParagraph(Oflet.LWFEmployee + "/-");

            Row row22 = Project.AddRow();
            row22.HeadingFormat = true;
            row22.Format.Alignment = ParagraphAlignment.Left;
            row22.Format.Font.Bold = true;
            row22.Cells[0].AddParagraph("In Hand Salary");
            row22.Cells[1].AddParagraph(Oflet.ResForOfferLet.Net + "/-");
            Row row23 = Project.AddRow();
            row23.HeadingFormat = true;
            row23.Format.Alignment = ParagraphAlignment.Left;
            row23.Format.Font.Bold = true;
            row23.Cells[0].AddParagraph("Monthly Variable");
            row23.Cells[1].AddParagraph(Oflet.MonthlyVariable + "/-");


            Row row24 = Project.AddRow();
            row24.HeadingFormat = true;
            row24.Format.Alignment = ParagraphAlignment.Left;
            row24.Format.Font.Bold = true;
            row24.Cells[0].AddParagraph("Monthly Variable - CTC");
            row24.Cells[1].AddParagraph(Oflet.MonthlyVariableNoESIC.ToString() + "/-");

            return "";
        }

        private string FillinV5NapsSalaryDetails(NewSalaryComponents salComps)
        {
            DriveRepository obj = new DriveRepository();
            OffereLetter Oflet = new OffereLetter();
            string SalaryCode = obj.GetSalaryCode(salComps.SalaryId);
            Oflet.LoadSalDeta(SalaryCode);
            double StatutoryAmount = /*Oflet.ResForOfferLet.AllStatutoryAllowances + */Oflet.ResForOfferLet.StatutorySub;

            Table Project = CurrentSection.AddTable();
            Project.Borders.Color = Colors.Gray;
            Project.Borders.Width = 0.25;
            Project.Borders.Left.Width = 0.5;
            Project.Borders.Right.Width = 0.5;
            Project.Rows.LeftIndent = 0;

            Column column1 = Project.AddColumn("10cm");
            Column column2 = Project.AddColumn("5cm");

            Row row = Project.AddRow();
            row.HeadingFormat = true;
            row.Format.Alignment = ParagraphAlignment.Center;
            row.Format.Font.Bold = true;

            row.Cells[0].AddParagraph("Particulars");
            row.Cells[1].AddParagraph("Revised Package(P.M.)");

            Row row1 = Project.AddRow();
            row1.HeadingFormat = true;
            row1.Format.Alignment = ParagraphAlignment.Left;

            row1.Cells[0].AddParagraph("Monthly Fixed Stipend");
            row1.Cells[1].AddParagraph(Oflet.ResForOfferLet.BasicWithDA + "/-");

            Row row2 = Project.AddRow();
            row2.HeadingFormat = true;
            row2.Format.Alignment = ParagraphAlignment.Left;
            row2.Format.Font.Bold = true;
            row2.Cells[0].AddParagraph("Gross Stipend");
            row2.Cells[1].AddParagraph(Oflet.ResForOfferLet.Gross + "/-");


            Row row3 = Project.AddRow();
            row3.HeadingFormat = true;
            row3.Format.Alignment = ParagraphAlignment.Left;

            row3.Cells[0].AddParagraph("MedicalInsuranceV5");
            row3.Cells[1].AddParagraph(Oflet.MedicalInsuranceV5 + "/-");


            Row row4 = Project.AddRow();
            row4.HeadingFormat = true;
            row4.Format.Alignment = ParagraphAlignment.Left;

            row4.Cells[0].AddParagraph("PAI");
            row4.Cells[1].AddParagraph(Oflet.PersonalAccidentInsurance + "/-");

            Row row5 = Project.AddRow();
            row5.HeadingFormat = true;
            row5.Format.Alignment = ParagraphAlignment.Left;
            row5.Format.Font.Bold = true;

            row5.Cells[0].AddParagraph("Cost To Company");
            row5.Cells[1].AddParagraph(Oflet.ResForOfferLet.Gross + Oflet.MedicalInsuranceV5 + Oflet.PersonalAccidentInsurance + "/-");

            Row row6 = Project.AddRow();
            row6.HeadingFormat = true;
            row6.Format.Alignment = ParagraphAlignment.Left;
            //row17.Format.Font.Bold = true;
            row6.Cells[0].AddParagraph("MediclaimV5");
            row6.Cells[1].AddParagraph(Oflet.MediclaimV5 + "/-");

            ///
            Row row7 = Project.AddRow();
            row7.HeadingFormat = true;
            row7.Format.Alignment = ParagraphAlignment.Left;

            row7.Cells[0].AddParagraph("Professional Tax");
            row7.Cells[1].AddParagraph(Oflet.ResForOfferLet.ProfessionalTax + "/-");

            Row row8 = Project.AddRow();
            row8.HeadingFormat = true;
            row8.Format.Alignment = ParagraphAlignment.Left;
            //ro17.Format.Font.Bold = true;
            row8.Cells[0].AddParagraph("InsuranceV5");
            row8.Cells[1].AddParagraph(Oflet.InsuranceV5 + "/-");
            Row row9 = Project.AddRow();
            row9.HeadingFormat = true;
            row9.Format.Alignment = ParagraphAlignment.Left;
            row9.Format.Font.Bold = true;

            row9.Cells[0].AddParagraph("In Hand Stipend");
            row9.Cells[1].AddParagraph(Oflet.ResForOfferLet.Net + "/-");


            //Row row1 = Project.AddRow();
            //row1.HeadingFormat = true;
            //row1.Format.Alignment = ParagraphAlignment.Left;

            //row1.Cells[0].AddParagraph("Basic");
            //row1.Cells[1].AddParagraph(Oflet.ResForOfferLet.Basic + "/-");


            //Row row2 = Project.AddRow();
            //row2.HeadingFormat = true;
            //row2.Format.Alignment = ParagraphAlignment.Left;

            //row2.Cells[0].AddParagraph("HRA");
            //row2.Cells[1].AddParagraph(Oflet.ResForOfferLet.HRA + "/-");


            //Row row3 = Project.AddRow();
            //row3.HeadingFormat = true;
            //row3.Format.Alignment = ParagraphAlignment.Left;

            //row3.Cells[0].AddParagraph("Bonus");
            //row3.Cells[1].AddParagraph(Oflet.ResForOfferLet.Bonus + "/-");

            //Row row4 = Project.AddRow();
            //row4.HeadingFormat = true;
            //row4.Format.Alignment = ParagraphAlignment.Left;

            //row4.Cells[0].AddParagraph("SpclPF");
            //row4.Cells[1].AddParagraph(Oflet.SpecialAllowanceMH + "/-");

            /////
            //Row row5 = Project.AddRow();
            //row5.HeadingFormat = true;
            //row5.Format.Alignment = ParagraphAlignment.Left;

            //row5.Cells[0].AddParagraph("OtherAllowance");
            //row5.Cells[1].AddParagraph(Oflet.ResForOfferLet.OtherAllowance + "/-");
            /////

            //Row row6 = Project.AddRow();
            //row6.HeadingFormat = true;
            //row6.Format.Alignment = ParagraphAlignment.Left;
            //row6.Format.Font.Bold = true;


            //row6.Cells[0].AddParagraph("Total salary");

            ////if (BonusType = "G" )
            ////{
            //row6.Cells[1].AddParagraph(Oflet.ResForOfferLet.Gross + "/-");
            ////}


            //Row row7 = Project.AddRow();
            //row7.HeadingFormat = true;
            //row7.Format.Alignment = ParagraphAlignment.Left;
            //row7.Format.Font.Bold = true;

            //row7.Cells[0].AddParagraph("Gross");
            //row7.Cells[1].AddParagraph(Oflet.ResForOfferLet.Gross + "/-");

            //Row row8 = Project.AddRow();
            //row8.HeadingFormat = true;
            //row8.Format.Alignment = ParagraphAlignment.Left;

            //row8.Cells[0].AddParagraph("Employer ESIC");
            //row8.Cells[1].AddParagraph(Oflet.ResForOfferLet.ESICEmployer + "/-");


            //Row row9 = Project.AddRow();
            //row9.HeadingFormat = true;
            //row9.Format.Alignment = ParagraphAlignment.Left;

            //row9.Cells[0].AddParagraph("Employer PF");
            //row9.Cells[1].AddParagraph(Oflet.ResForOfferLet.PFEmployer + "/-");

            ////Added By Rahul on 10-Feb-2021

            //Row InvisibleRow1 = Project.AddRow();
            //InvisibleRow1.HeadingFormat = true;
            //InvisibleRow1.Borders.Visible = false;
            //InvisibleRow1.Cells[0].Borders.Visible = false;
            //InvisibleRow1.Cells[1].Borders.Visible = false;
            //InvisibleRow1.Cells[0].AddParagraph();
            //InvisibleRow1.Cells[1].AddParagraph();

            //Row InvisibleRow2 = Project.AddRow();
            //InvisibleRow2.HeadingFormat = true;
            //InvisibleRow2.Borders.Visible = false;
            //InvisibleRow2.Cells[0].Borders.Visible = false;
            //InvisibleRow2.Cells[1].Borders.Visible = false;
            //InvisibleRow2.Cells[0].AddParagraph();
            //InvisibleRow2.Cells[1].AddParagraph();

            //Row InvisibleRow3 = Project.AddRow();
            //InvisibleRow3.HeadingFormat = true;
            //InvisibleRow3.Borders.Visible = false;
            //InvisibleRow3.Cells[0].Borders.Visible = false;
            //InvisibleRow3.Cells[1].Borders.Visible = false;
            //InvisibleRow3.Cells[0].AddParagraph();
            //InvisibleRow3.Cells[1].AddParagraph();

            //Row InvisibleRow4 = Project.AddRow();
            //InvisibleRow4.HeadingFormat = true;
            //InvisibleRow4.Borders.Visible = false;
            //InvisibleRow4.Cells[0].Borders.Visible = false;
            //InvisibleRow4.Cells[1].Borders.Visible = false;
            //InvisibleRow4.Cells[0].AddParagraph();
            //InvisibleRow4.Cells[1].AddParagraph();

            //Row InvisibleRow5 = Project.AddRow();
            //InvisibleRow5.HeadingFormat = true;
            //InvisibleRow5.Borders.Visible = false;
            //InvisibleRow5.Cells[0].Borders.Visible = false;
            //InvisibleRow5.Cells[1].Borders.Visible = false;
            //InvisibleRow5.Cells[0].AddParagraph();
            //InvisibleRow5.Cells[1].AddParagraph();

            //Row InvisibleRow6 = Project.AddRow();
            //InvisibleRow6.HeadingFormat = true;
            //InvisibleRow6.Borders.Visible = false;
            //InvisibleRow6.Cells[0].Borders.Visible = false;
            //InvisibleRow6.Cells[1].Borders.Visible = false;
            //InvisibleRow6.Cells[0].AddParagraph();
            //InvisibleRow6.Cells[1].AddParagraph();

            //Row row10 = Project.AddRow();
            //row10.HeadingFormat = true;
            //row10.Format.Alignment = ParagraphAlignment.Left;

            //row10.Cells[0].AddParagraph("Admin PF & EDLI");
            //row10.Cells[1].AddParagraph(Oflet.ResForOfferLet.PFAdmin + Oflet.ResForOfferLet.EDLIEmployer + "/-");

            //Row row11 = Project.AddRow();
            //row11.HeadingFormat = true;
            //row11.Format.Alignment = ParagraphAlignment.Left;
            ////row17.Format.Font.Bold = true;
            //row11.Cells[0].AddParagraph("LWF Company");
            //row11.Cells[1].AddParagraph(Oflet.LWFCompany + "/-");


            //Row row12 = Project.AddRow();
            //row12.HeadingFormat = true;
            //row12.Format.Alignment = ParagraphAlignment.Left;
            ////row17.Format.Font.Bold = true;
            //row12.Cells[0].AddParagraph("MedicalInsuranceV5");
            //row12.Cells[1].AddParagraph(Oflet.MedicalInsuranceV5 + "/-");

            //Row row13 = Project.AddRow();
            //row13.HeadingFormat = true;
            //row13.Format.Alignment = ParagraphAlignment.Left;

            //row13.Cells[0].AddParagraph("PAI");
            //// row13.Cells[1].AddParagraph(Oflet.MedicalInsuranceV5 + "/-");
            //row13.Cells[1].AddParagraph(Oflet.PersonalAccidentInsurance + "/-");
            //Row row14 = Project.AddRow();
            //row14.HeadingFormat = true;
            //row14.Format.Alignment = ParagraphAlignment.Left;

            //row14.Cells[0].AddParagraph("Gratuity");
            //// row13.Cells[1].AddParagraph(Oflet.MedicalInsuranceV5 + "/-");
            //row14.Cells[1].AddParagraph(Oflet.GratuityAmount + "/-");
            /////////// End By Abhilash on 27th Jan 201

            //Row row15 = Project.AddRow();
            //row15.HeadingFormat = true;
            //row15.Format.Alignment = ParagraphAlignment.Left;
            //row15.Format.Font.Bold = true;

            //row15.Cells[0].AddParagraph("Cost to Company");
            ////  row14.Cells[1].AddParagraph((Oflet.ResForOfferLet.Gross + StatutoryAmount) + "/-");Commneted By Abhilash on 17th Oct 2020
            //// row13.Cells[1].AddParagraph((Oflet.ResForOfferLet.Gross + StatutoryAmount+ Oflet.MedicalInsuranceV5) + "/-");
            //row15.Cells[1].AddParagraph((Oflet.ResForOfferLet.Gross + StatutoryAmount + Oflet.MedicalInsuranceV5 + Oflet.LWFCompany) + "/-");
            //// row11.Cells[1].AddParagraph((Oflet.ResForOfferLet.CTC  + "/-"));


            //Row row16 = Project.AddRow();
            //row16.HeadingFormat = true;
            //row16.Format.Alignment = ParagraphAlignment.Left;
            ////row17.Format.Font.Bold = true;
            //row16.Cells[0].AddParagraph("MediclaimV5");
            //row16.Cells[1].AddParagraph(Oflet.MediclaimV5 + "/-");

            //Row row17 = Project.AddRow();
            //row17.HeadingFormat = true;
            //row17.Format.Alignment = ParagraphAlignment.Left;
            //row17.Cells[0].AddParagraph("Employee PF");
            //row17.Cells[1].AddParagraph(Oflet.ResForOfferLet.PFEmployee + "/-");

            //Row row18 = Project.AddRow();
            //row18.HeadingFormat = true;
            //row18.Format.Alignment = ParagraphAlignment.Left;
            //row18.Cells[0].AddParagraph("Employee ESIC");
            //row18.Cells[1].AddParagraph(Oflet.ResForOfferLet.ESICEmployee + "/-");

            //Row row19 = Project.AddRow();
            //row19.HeadingFormat = true;
            //row19.Format.Alignment = ParagraphAlignment.Left;

            //row19.Cells[0].AddParagraph("Professional Tax");
            //row19.Cells[1].AddParagraph(Oflet.ResForOfferLet.ProfessionalTax + "/-");

            //Row row20 = Project.AddRow();
            //row20.HeadingFormat = true;
            //row20.Format.Alignment = ParagraphAlignment.Left;
            ////ro17.Format.Font.Bold = true;
            //row20.Cells[0].AddParagraph("InsuranceV5");
            //row20.Cells[1].AddParagraph(Oflet.InsuranceV5 + "/-");
            ////////////////////Added By Abhilash on 23rd Sep 2020

            //Row row21 = Project.AddRow();
            //row21.HeadingFormat = true;
            //row21.Format.Alignment = ParagraphAlignment.Left;
            ////row17.Format.Font.Bold = true;
            //row21.Cells[0].AddParagraph("LWF Employee");
            //row21.Cells[1].AddParagraph(Oflet.LWFEmployee + "/-");
            ////////////////////Added By Abhilash on 23rd Sep 2020

            //Row row22 = Project.AddRow();
            //row22.HeadingFormat = true;
            //row22.Format.Alignment = ParagraphAlignment.Left;
            //row22.Format.Font.Bold = true;
            //row22.Cells[0].AddParagraph("In Hand Stipend");
            //row22.Cells[1].AddParagraph(Oflet.ResForOfferLet.Net + "/-");
            ////Added on 31Dec 2020by Abhilash
            //Row row23 = Project.AddRow();
            //row23.HeadingFormat = true;
            //row23.Format.Alignment = ParagraphAlignment.Left;
            //row23.Format.Font.Bold = true;
            //row23.Cells[0].AddParagraph("Monthly Variable");
            //row23.Cells[1].AddParagraph(Oflet.MonthlyVariable + "/-");

            /////


            return "";
        }

        private string FillinV5SalaryDetailsDemotion(NewSalaryComponents salComps)
        {
            DriveRepository obj = new DriveRepository();
            OffereLetter Oflet = new OffereLetter();
            string SalaryCode = obj.GetSalaryCode(salComps.SalaryId);
            Oflet.LoadSalDeta(SalaryCode);
            double StatutoryAmount = /*Oflet.ResForOfferLet.AllStatutoryAllowances + */Oflet.ResForOfferLet.StatutorySub;

            Table Project = CurrentSection.AddTable();
            Project.Borders.Color = Colors.Gray;
            Project.Borders.Width = 0.25;
            Project.Borders.Left.Width = 0.5;
            Project.Borders.Right.Width = 0.5;
            Project.Rows.LeftIndent = 0;

            Column column1 = Project.AddColumn("10cm");
            Column column2 = Project.AddColumn("5cm");

            Row row = Project.AddRow();
            row.HeadingFormat = true;
            row.Format.Alignment = ParagraphAlignment.Center;
            row.Format.Font.Bold = true;

            row.Cells[0].AddParagraph("Particulars");
            row.Cells[1].AddParagraph("Revised Package(P.M.)");

            Row row1 = Project.AddRow();
            row1.HeadingFormat = true;
            row1.Format.Alignment = ParagraphAlignment.Left;

            row1.Cells[0].AddParagraph("Basic");
            row1.Cells[1].AddParagraph(Oflet.ResForOfferLet.Basic + "/-");


            Row row2 = Project.AddRow();
            row2.HeadingFormat = true;
            row2.Format.Alignment = ParagraphAlignment.Left;

            row2.Cells[0].AddParagraph("HRA");
            row2.Cells[1].AddParagraph(Oflet.ResForOfferLet.HRA + "/-");


            Row row3 = Project.AddRow();
            row3.HeadingFormat = true;
            row3.Format.Alignment = ParagraphAlignment.Left;

            row3.Cells[0].AddParagraph("Bonus");
            row3.Cells[1].AddParagraph(Oflet.ResForOfferLet.Bonus + "/-");

            Row row4 = Project.AddRow();
            row4.HeadingFormat = true;
            row4.Format.Alignment = ParagraphAlignment.Left;

            row4.Cells[0].AddParagraph("SpclPF");
            row4.Cells[1].AddParagraph(Oflet.SpecialAllowanceMH + "/-");

            ///
            Row row5 = Project.AddRow();
            row5.HeadingFormat = true;
            row5.Format.Alignment = ParagraphAlignment.Left;

            row5.Cells[0].AddParagraph("OtherAllowance");
            row5.Cells[1].AddParagraph(Oflet.ResForOfferLet.OtherAllowance + "/-");
            ///

            Row row6 = Project.AddRow();
            row6.HeadingFormat = true;
            row6.Format.Alignment = ParagraphAlignment.Left;
            row6.Format.Font.Bold = true;
            row6.Cells[0].AddParagraph("Total salary");
            Char BonusType = Oflet.BonusType;
            if (BonusType == 'G')
            {
                row6.Cells[1].AddParagraph(Oflet.ResForOfferLet.Gross + "/-");
            }
            else
            {
                //row6.Cells[1].AddParagraph(Oflet.ResForOfferLet.Gross + Oflet.BonusValue + "/-");
                row6.Cells[1].AddParagraph(Oflet.ResForOfferLet.Gross + "/-");
            }

            Row row7 = Project.AddRow();
            row7.HeadingFormat = true;
            row7.Format.Alignment = ParagraphAlignment.Left;
            row7.Format.Font.Bold = true;

            row7.Cells[0].AddParagraph("Gross");
            if (BonusType == 'G')
            {
                row7.Cells[1].AddParagraph(Oflet.ResForOfferLet.Gross + "/-");
            }
            else
            {

                //row7.Cells[1].AddParagraph(Oflet.ResForOfferLet.Gross + Oflet.BonusValue + "/-");
                row7.Cells[1].AddParagraph(Oflet.ResForOfferLet.Gross + "/-");
            }


            Row row8 = Project.AddRow();
            row8.HeadingFormat = true;
            row8.Format.Alignment = ParagraphAlignment.Left;

            row8.Cells[0].AddParagraph("Employer ESIC");
            row8.Cells[1].AddParagraph(Oflet.ResForOfferLet.ESICEmployer + "/-");


            Row row9 = Project.AddRow();
            row9.HeadingFormat = true;
            row9.Format.Alignment = ParagraphAlignment.Left;

            row9.Cells[0].AddParagraph("Employer PF");
            row9.Cells[1].AddParagraph(Oflet.ResForOfferLet.PFEmployer + "/-");

            Row row10 = Project.AddRow();
            row10.HeadingFormat = true;
            row10.Format.Alignment = ParagraphAlignment.Left;

            row10.Cells[0].AddParagraph("Admin PF & EDLI");
            row10.Cells[1].AddParagraph(Oflet.ResForOfferLet.PFAdmin + Oflet.ResForOfferLet.EDLIEmployer + "/-");

            //////////////////Added By Abhilash on 13 Oct 2020
            Row row11 = Project.AddRow();
            row11.HeadingFormat = true;
            row11.Format.Alignment = ParagraphAlignment.Left;
            //row17.Format.Font.Bold = true;
            row11.Cells[0].AddParagraph("LWF Company");
            row11.Cells[1].AddParagraph(Oflet.LWFCompany + "/-");


            Row row12 = Project.AddRow();
            row12.HeadingFormat = true;
            row12.Format.Alignment = ParagraphAlignment.Left;
            //row17.Format.Font.Bold = true;
            row12.Cells[0].AddParagraph("MedicalInsuranceV5");
            row12.Cells[1].AddParagraph(Oflet.MedicalInsuranceV5 + "/-");
            //////////////////Added By Abhilash on 13 Oct 2020

            ////////Added By Abhilash on 27th Jan 2021
            Row row13 = Project.AddRow();
            row13.HeadingFormat = true;
            row13.Format.Alignment = ParagraphAlignment.Left;

            row13.Cells[0].AddParagraph("PAI");
            // row13.Cells[1].AddParagraph(Oflet.MedicalInsuranceV5 + "/-");
            row13.Cells[1].AddParagraph(Oflet.PersonalAccidentInsurance + "/-");
            ///////// End By Abhilash on 27th Jan 201
            ////////Added By Abhilash on 27th Jan 2021
            Row row14 = Project.AddRow();
            row14.HeadingFormat = true;
            row14.Format.Alignment = ParagraphAlignment.Left;

            row14.Cells[0].AddParagraph("Gratuity");
            // row13.Cells[1].AddParagraph(Oflet.MedicalInsuranceV5 + "/-");
            row14.Cells[1].AddParagraph(Oflet.GratuityAmount + "/-");
            ///////// End By Abhilash on 27th Jan 201

            Row row15 = Project.AddRow();
            row15.HeadingFormat = true;
            row15.Format.Alignment = ParagraphAlignment.Left;
            row15.Format.Font.Bold = true;

            row15.Cells[0].AddParagraph("Cost to Company");
            //  row14.Cells[1].AddParagraph((Oflet.ResForOfferLet.Gross + StatutoryAmount) + "/-");Commneted By Abhilash on 17th Oct 2020
            // row13.Cells[1].AddParagraph((Oflet.ResForOfferLet.Gross + StatutoryAmount+ Oflet.MedicalInsuranceV5) + "/-");
            if (BonusType == 'G')
            {
                row15.Cells[1].AddParagraph((Oflet.ResForOfferLet.Gross + StatutoryAmount + Oflet.MedicalInsuranceV5 + Oflet.LWFCompany) + "/-");
            }
            else
            {
                row15.Cells[1].AddParagraph((Oflet.ResForOfferLet.Gross + StatutoryAmount + Oflet.MedicalInsuranceV5 + Oflet.LWFCompany) + "/-");
                // row15.Cells[1].AddParagraph((Oflet.ResForOfferLet.Gross + StatutoryAmount + Oflet.MedicalInsuranceV5 + Oflet.LWFCompany + Oflet.BonusValue) + "/-");
            }
            // row11.Cells[1].AddParagraph((Oflet.ResForOfferLet.CTC  + "/-"));

            Row row16 = Project.AddRow();
            row16.HeadingFormat = true;
            row16.Format.Alignment = ParagraphAlignment.Left;
            //row17.Format.Font.Bold = true;
            row16.Cells[0].AddParagraph("MediclaimV5");
            row16.Cells[1].AddParagraph(Oflet.MediclaimV5 + "/-");


            Row InvisibleRow1 = Project.AddRow();
            InvisibleRow1.HeadingFormat = true;
            InvisibleRow1.Borders.Visible = false;
            InvisibleRow1.Cells[0].Borders.Visible = false;
            InvisibleRow1.Cells[1].Borders.Visible = false;
            InvisibleRow1.Cells[0].AddParagraph();
            InvisibleRow1.Cells[1].AddParagraph();
            InvisibleRow1.Borders.Top.Visible = false;


            Row InvisibleRow2 = Project.AddRow();
            InvisibleRow2.HeadingFormat = true;
            InvisibleRow2.Borders.Visible = false;
            InvisibleRow2.Cells[0].Borders.Visible = false;
            InvisibleRow2.Cells[1].Borders.Visible = false;
            InvisibleRow2.Cells[0].AddParagraph();
            InvisibleRow2.Cells[1].AddParagraph();

            Row InvisibleRow3 = Project.AddRow();
            InvisibleRow3.HeadingFormat = true;
            InvisibleRow3.Borders.Visible = false;
            InvisibleRow3.Cells[0].Borders.Visible = false;
            InvisibleRow3.Cells[1].Borders.Visible = false;
            InvisibleRow3.Cells[0].AddParagraph();
            InvisibleRow3.Cells[1].AddParagraph();

            Row InvisibleRow4 = Project.AddRow();
            InvisibleRow4.HeadingFormat = true;
            InvisibleRow4.Borders.Visible = false;
            InvisibleRow4.Cells[0].Borders.Visible = false;
            InvisibleRow4.Cells[1].Borders.Visible = false;
            InvisibleRow4.Cells[0].AddParagraph();
            InvisibleRow4.Cells[1].AddParagraph();

            Row InvisibleRow5 = Project.AddRow();
            InvisibleRow5.HeadingFormat = true;
            InvisibleRow5.Borders.Visible = false;
            InvisibleRow5.Cells[0].Borders.Visible = false;
            InvisibleRow5.Cells[1].Borders.Visible = false;
            InvisibleRow5.Cells[0].AddParagraph();
            InvisibleRow5.Cells[1].AddParagraph();

            Row InvisibleRow6 = Project.AddRow();
            InvisibleRow6.HeadingFormat = true;
            InvisibleRow6.Borders.Visible = false;
            InvisibleRow6.Cells[0].Borders.Visible = false;
            InvisibleRow6.Cells[1].Borders.Visible = false;
            InvisibleRow6.Cells[0].AddParagraph();
            InvisibleRow6.Cells[1].AddParagraph();


            Row row17 = Project.AddRow();
            row17.HeadingFormat = true;
            row17.Format.Alignment = ParagraphAlignment.Left;
            row17.Cells[0].AddParagraph("Employee PF");
            row17.Cells[1].AddParagraph(Oflet.ResForOfferLet.PFEmployee + "/-");

            Row row18 = Project.AddRow();
            row18.HeadingFormat = true;
            row18.Format.Alignment = ParagraphAlignment.Left;
            row18.Cells[0].AddParagraph("Employee ESIC");
            row18.Cells[1].AddParagraph(Oflet.ResForOfferLet.ESICEmployee + "/-");

            Row row19 = Project.AddRow();
            row19.HeadingFormat = true;
            row19.Format.Alignment = ParagraphAlignment.Left;

            row19.Cells[0].AddParagraph("Professional Tax");
            row19.Cells[1].AddParagraph(Oflet.ResForOfferLet.ProfessionalTax + "/-");


            Row row20 = Project.AddRow();
            row20.HeadingFormat = true;
            row20.Format.Alignment = ParagraphAlignment.Left;
            //ro17.Format.Font.Bold = true;
            row20.Cells[0].AddParagraph("InsuranceV5");
            row20.Cells[1].AddParagraph(Oflet.InsuranceV5 + "/-");
            //////////////////Added By Abhilash on 23rd Sep 2020

            Row row21 = Project.AddRow();
            row21.HeadingFormat = true;
            row21.Format.Alignment = ParagraphAlignment.Left;
            //row17.Format.Font.Bold = true;
            row21.Cells[0].AddParagraph("LWF Employee");
            row21.Cells[1].AddParagraph(Oflet.LWFEmployee + "/-");
            //////////////////Added By Abhilash on 23rd Sep 2020

            Row row22 = Project.AddRow();
            row22.HeadingFormat = true;
            row22.Format.Alignment = ParagraphAlignment.Left;
            row22.Format.Font.Bold = true;
            row22.Cells[0].AddParagraph("In Hand Salary");
            row22.Cells[1].AddParagraph(Oflet.ResForOfferLet.Net + "/-");
            //Added on 31Dec 2020by Abhilash
            Row row23 = Project.AddRow();
            row23.HeadingFormat = true;
            row23.Format.Alignment = ParagraphAlignment.Left;
            row23.Format.Font.Bold = true;
            row23.Cells[0].AddParagraph("Monthly Variable");
            row23.Cells[1].AddParagraph(Oflet.MonthlyVariable + "/-");

            ///


            return "";
        }
        private string BankDetail(NewSalaryComponents salComps)
        {
            Table Project = CurrentSection.AddTable();
            Project.Borders.Color = Colors.Gray;
            Project.Borders.Width = 0.25;
            Project.Borders.Left.Width = 0.5;
            Project.Borders.Right.Width = 0.5;
            Project.Rows.LeftIndent = 0;

            Column column1 = Project.AddColumn("5cm");
            Column column2 = Project.AddColumn("5cm");


            Row row = Project.AddRow();
            row.HeadingFormat = true;
            row.Format.Alignment = ParagraphAlignment.Center;

            row.Cells[0].AddParagraph("Name of the Account Holder ");
            row.Cells[1].AddParagraph("V5 Global Services Private Limited ");

            Row row1 = Project.AddRow();
            row1.HeadingFormat = true;
            row1.Format.Alignment = ParagraphAlignment.Center;

            row1.Cells[0].AddParagraph("Type of Account ");
            row1.Cells[1].AddParagraph("Current");

            Row row2 = Project.AddRow();
            row2.HeadingFormat = true;
            row2.Format.Alignment = ParagraphAlignment.Center;

            row2.Cells[0].AddParagraph("Name of The Bank ");
            row2.Cells[1].AddParagraph("Standard Chartered Bank ");

            Row row3 = Project.AddRow();
            row3.HeadingFormat = true;
            row3.Format.Alignment = ParagraphAlignment.Center;

            row3.Cells[0].AddParagraph("Bank Current Account No. ");
            row3.Cells[1].AddParagraph("52305270547");

            Row row4 = Project.AddRow();
            row4.HeadingFormat = true;
            row4.Format.Alignment = ParagraphAlignment.Center;

            row4.Cells[0].AddParagraph("IFSC Code");
            row4.Cells[1].AddParagraph("SCBL0036021");

            return "";
        }
        private string PIPLertter()
        {
            var D1 = Convert.ToDateTime(SalaryComps.PIPEndDate);
            var D2 = Convert.ToDateTime(SalaryComps.PIPStartDate).AddDays(-1);
            int d3 = (int)(D1 - D2).TotalDays;
            //DateTime D1 = SalaryComps.EndDate;
            //DateTime D2 = SalaryComps.StartDate.AddDays(-1);
            //int d3 = (int)(D1 - D2).TotalDays;
            ///////
            Table Project = CurrentSection.AddTable();
            Project.Borders.Color = Colors.Gray;
            Project.Borders.Width = 0.25;
            Project.Borders.Left.Width = 0.5;
            Project.Borders.Right.Width = 0.5;
            Project.Rows.LeftIndent = 0;

            Column column1 = Project.AddColumn("9cm");
            Column column2 = Project.AddColumn("9cm");

            Row row = Project.AddRow();
            row.HeadingFormat = true;
            row.Format.Alignment = ParagraphAlignment.Center;

            row.Cells[0].AddParagraph().AddFormattedText("PIP Duration/Timeline", "Heading4");
            row.Cells[1].AddParagraph().AddFormattedText("Target", "Heading4");

            Row row1 = Project.AddRow();
            row1.HeadingFormat = true;
            row1.Format.Alignment = ParagraphAlignment.Center;

            row1.Cells[0].AddParagraph(d3 + " " + "Days");////chnage
            row1.Cells[1].AddParagraph(SalaryComps.Target);

            return "";
        }
        //private string PIPWarningLetter1()
        //{
        //    //var D1 = Convert.ToDateTime(SalaryComps.PIPEndDate);
        //    //var D2 = Convert.ToDateTime(SalaryComps.PIPStartDate).AddDays(-1);
        //    //int d3 = (int)(D1 - D2).TotalDays;
        //    //DateTime D1 = SalaryComps.EndDate;
        //    //DateTime D2 = SalaryComps.StartDate.AddDays(-1);
        //    //int d3 = (int)(D1 - D2).TotalDays;
        //    ///////
        //    Table Project = CurrentSection.AddTable();
        //    Project.Borders.Color = Colors.Gray;
        //    Project.Borders.Width = 0.25;
        //    Project.Borders.Left.Width = 0.5;
        //    Project.Borders.Right.Width = 0.5;
        //    Project.Rows.LeftIndent = 0;

        //    Column column1 = Project.AddColumn("3cm");
        //    Column column2 = Project.AddColumn("3cm");
        //    Column column3 = Project.AddColumn("3cm");
        //    Column column4 = Project.AddColumn("3cm");

        //    Row row = Project.AddRow();
        //    row.HeadingFormat = true;
        //    row.Format.Alignment = ParagraphAlignment.Center;

        //    row.Cells[0].AddParagraph("Month");
        //    row.Cells[1].AddParagraph("Target");
        //    row.Cells[2].AddParagraph("Achievement");
        //    row.Cells[3].AddParagraph("Achievement%age");

        //    Row row1 = Project.AddRow();
        //    Row row2 = Project.AddRow();
        //    Row row3 = Project.AddRow();
        //    row1.HeadingFormat = true;
        //    row1.Format.Alignment = ParagraphAlignment.Center;
        //    row2.Format.Alignment = ParagraphAlignment.Center;
        //    row3.Format.Alignment = ParagraphAlignment.Center;

        //    row1.Cells[0].AddParagraph(SalaryComps.FirstMonth);////chnage
        //    row1.Cells[1].AddParagraph(SalaryComps.Target1);
        //    row1.Cells[2].AddParagraph(SalaryComps.Achievement1);
        //    row1.Cells[3].AddParagraph(SalaryComps.Achievement2);

        //    row2.Cells[0].AddParagraph(SalaryComps.SecondMonth);////chnage
        //    row2.Cells[1].AddParagraph(SalaryComps.Target2);
        //    row2.Cells[2].AddParagraph(SalaryComps.Achievement3);
        //    row2.Cells[3].AddParagraph(SalaryComps.AchievementPercentage1);

        //    row3.Cells[0].AddParagraph(SalaryComps.ThirdMonth);////chnage
        //    row3.Cells[1].AddParagraph(SalaryComps.Target3);
        //    row3.Cells[2].AddParagraph(SalaryComps.AchievementPercentage2);
        //    row3.Cells[3].AddParagraph(SalaryComps.AchievementPercentage3);

        //    return "";
        //}
        public string PIPWarningLetter1(int AssociateLegalLetterId)
        {
            try
            {
                NewLegalLetterServices Services = new NewLegalLetterServices();
                var results = Services.GetPIPWarningDetails(AssociateLegalLetterId);

                Table table = CurrentSection.AddTable();
                table.Borders.Color = Colors.Black;
                table.Borders.Width = 0.25;
                table.Borders.Left.Width = 0.5;
                table.Borders.Right.Width = 0.5;
                table.Rows.LeftIndent = 0;

                Column AddColumn = new Column();
                AddColumn = table.AddColumn("3.5cm");
                AddColumn = table.AddColumn("3.5cm");
                AddColumn = table.AddColumn("3.5cm");
                AddColumn = table.AddColumn("3.5cm");
                AddColumn = table.AddColumn("3.5cm");

                Row row = new Row();
                row.Format.Alignment = ParagraphAlignment.Center;

                row = table.AddRow();
                row.Cells[0].AddParagraph().AddFormattedText("Month", "Heading4");
                row.Cells[1].AddParagraph().AddFormattedText("Year", "Heading4");
                row.Cells[2].AddParagraph().AddFormattedText("Target", "Heading4");
                row.Cells[3].AddParagraph().AddFormattedText("Achievement", "Heading4");
                row.Cells[4].AddParagraph().AddFormattedText("Achievement%age", "Heading4");

                foreach (var item in results)
                {
                    row = table.AddRow();


                    row.Cells[0].AddParagraph().AddFormattedText((item.Month).ToString());
                    row.Cells[1].AddParagraph().AddFormattedText((item.Year).ToString());
                    row.Cells[2].AddParagraph().AddFormattedText((item.Target).ToString());
                    row.Cells[3].AddParagraph().AddFormattedText((item.Achievement).ToString());
                    row.Cells[4].AddParagraph().AddFormattedText((item.AchievementPercentage).ToString());


                }

                for (int r = 1; r < table.Rows.Count - 1; r++)
                {
                    table.Rows[r].Height = 15;
                }

                for (int r = 0; r < table.Rows.Count; r++)
                {
                    for (int c = 0; c < table.Rows[r].Cells.Count; c++)
                    {
                        table.Rows[r].Cells[c].Borders.Visible = true;
                        table.Rows[r].Cells[c].Borders.Color = Colors.Black;
                        table.Rows[r].Cells[c].Borders.Style = BorderStyle.Single;
                        table.Rows[r].Cells[c].Borders.Distance = 5;
                        table.Rows[r].Cells[c].Borders.Width = 0.25;
                    }
                }
                return "";
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private string PIPWarningLetterTbl()
        {
            //var D1 = Convert.ToDateTime(SalaryComps.PIPEndDate);
            //var D2 = Convert.ToDateTime(SalaryComps.PIPStartDate).AddDays(-1);
            //int d3 = (int)(D1 - D2).TotalDays;
            //DateTime D1 = SalaryComps.EndDate;
            //DateTime D2 = SalaryComps.StartDate.AddDays(-1);
            //int d3 = (int)(D1 - D2).TotalDays;
            ///////
            Table Project = CurrentSection.AddTable();
            Project.Borders.Color = Colors.Gray;
            Project.Borders.Width = 0.25;
            Project.Borders.Left.Width = 0.5;
            Project.Borders.Right.Width = 0.5;
            Project.Rows.LeftIndent = 0;

            Column column1 = Project.AddColumn("3.5cm");
            column1.Borders.Right.Clear();
            Column column2 = Project.AddColumn("3.5cm");
            Column column3 = Project.AddColumn("3.5cm");
            Column column4 = Project.AddColumn("3.5cm");
            Column column5 = Project.AddColumn("3.5cm");


            Row row = Project.AddRow();
            row.HeadingFormat = true;
            row.Format.Alignment = ParagraphAlignment.Center;
            row.Format.Font.Bold = true;

            row.Cells[0].AddParagraph("PERFORMANCE IMPROVEMENT PLAN");
            row.Cells[0].MergeRight = 4;
            //row.Cells[3].AddParagraph("PIP StartDate & EndDate");
            //row.Cells[3].MergeRight = 3;
            row.Cells[1].AddParagraph("Target");
            row.Cells[2].AddParagraph("Achievement");
            row.Cells[3].AddParagraph("Achievement%age");


            Row row1 = Project.AddRow();
            Row row2 = Project.AddRow();
            Row row3 = Project.AddRow();
            Row row4 = Project.AddRow();
            Row row5 = Project.AddRow();
            Row row6 = Project.AddRow();
            Row row7 = Project.AddRow();
            row1.HeadingFormat = true;
            row1.Format.Alignment = ParagraphAlignment.Center;
            row2.Format.Alignment = ParagraphAlignment.Center;
            row3.Format.Alignment = ParagraphAlignment.Center;
            row4.Format.Alignment = ParagraphAlignment.Center;
            row5.Format.Alignment = ParagraphAlignment.Center;
            row6.Format.Alignment = ParagraphAlignment.Center;
            row7.Format.Alignment = ParagraphAlignment.Center;

            row1.Cells[0].AddParagraph("Name");
            row1.Cells[2].AddParagraph("Location/Circle");
            //row1.Cells[2].MergeRight = 2;
            row2.Cells[0].AddParagraph("Employee ID");
            row2.Cells[2].AddParagraph("Business Unit");
            row3.Cells[0].AddParagraph("Role Name");
            row3.Cells[2].AddParagraph("Reporting Manager Name/Emp Id");

            row5.Cells[0].AddParagraph("S No.");
            row5.Cells[1].AddParagraph("Deliverables");
            row5.Cells[2].AddParagraph("Target(s)");
            row5.Cells[3].AddParagraph("Achievement");
            row5.Cells[4].AddParagraph("RM Comments");
            row7.Cells[0].AddParagraph("RM’s Final Comments – ");
            //row7.Cells[0].MergeRight = 4;

            row1.Cells[1].AddParagraph(SalaryComps.EmployeeName);
            row1.Cells[3].AddParagraph(SalaryComps.Location);
            row1.Cells[3].MergeRight = 1;
            row2.Cells[3].MergeRight = 1;
            row3.Cells[3].MergeRight = 1;
            row2.Cells[1].AddParagraph(SalaryComps.EmpCode);
            row3.Cells[1].AddParagraph(SalaryComps.Designation);
            row2.Cells[3].AddParagraph(SalaryComps.BusinessUnitName);
            row3.Cells[3].AddParagraph(SalaryComps.ReportingManagerName);
            row4.Cells[0].AddParagraph("Start Date: " + SalaryComps.PIPStartDate + " End Date: " + SalaryComps.PIPEndDate);  //Modified by neerajk on 23-04-2024
            //row4.Cells[0].AddParagraph("&");
            //row4.Cells[0].AddParagraph(SalaryComps.PIPEndDate);
            row4.Cells[0].MergeRight = 4;
            //row3.Cells[3].AddParagraph(SalaryComps.Reportingperson);
            row7.Cells[0].AddParagraph(SalaryComps.RMCommentsFinal);
            row7.Cells[0].MergeRight = 4;

            row6.Cells[0].AddParagraph("1");
            row6.Cells[1].AddParagraph(SalaryComps.Deliverables);
            row6.Cells[2].AddParagraph(SalaryComps.Target);
            row6.Cells[3].AddParagraph(SalaryComps.Achievement);
            row6.Cells[4].AddParagraph(SalaryComps.RMComments);

            return "";
            //End by vikas
        }
        private string FillInV5SalaryDetailsDynamic(NewSalaryComponents salComps)
        {
            DriveRepository obj = new DriveRepository();
            OffereLetter Oflet = new OffereLetter();
            string SalaryCode = obj.GetSalaryCode(salComps.SalaryId);
            Oflet.LoadSalDeta(SalaryCode);
            double StatutoryAmount = /*Oflet.ResForOfferLet.AllStatutoryAllowances + */Oflet.ResForOfferLet.StatutorySub;

            var deducationlist = Oflet.DeductionsList.ToList();
            var StatutoryList = Oflet.StatutoryList.ToList();
            var GrossList = Oflet.GrossList.ToList();
            var BasicAndDA = Oflet.Basic + Oflet.DA;
            var HRAT2 = Oflet.HRAValue;
            var OtherAllowance = Oflet.ResForOfferLet.OtherAllowance;

            int RowCount = 0;

            Table Project = CurrentSection.AddTable();
            Project.Borders.Color = Colors.Gray;
            Project.Borders.Width = 0.25;
            Project.Borders.Left.Width = 0.5;
            Project.Borders.Right.Width = 0.5;
            Project.Rows.LeftIndent = 0;

            Column column1 = Project.AddColumn("10cm");
            Column column2 = Project.AddColumn("5cm");

            Row row = Project.AddRow();
            row.HeadingFormat = true;
            row.Format.Alignment = ParagraphAlignment.Center;
            row.Format.Font.Bold = true;

            row.Cells[0].AddParagraph("Particulars");
            row.Cells[1].AddParagraph("Revised Package(P.M.)");
            RowCount = 1;

            double GrossTotal = 0;
            foreach (var items in GrossList)
            {
                GrossTotal = GrossTotal + items.Amount;
                Row GrossRow = Project.AddRow();
                GrossRow.HeadingFormat = true;
                GrossRow.Format.Alignment = ParagraphAlignment.Left;
                GrossRow.Cells[0].AddParagraph(items.CompCode);
                GrossRow.Cells[1].AddParagraph(items.Amount.ToString() + "/-");
                RowCount++;
                RowCount = AddInvisibleRow(RowCount, Project, false);
            }

            Row TotalSalaryRow = Project.AddRow();
            TotalSalaryRow.HeadingFormat = true;
            TotalSalaryRow.Format.Alignment = ParagraphAlignment.Left;
            TotalSalaryRow.Format.Font.Bold = true;
            TotalSalaryRow.Cells[0].AddParagraph("Total Salary");
            TotalSalaryRow.Cells[1].AddParagraph(GrossTotal.ToString() + "/-");
            RowCount++;
            RowCount = AddInvisibleRow(RowCount, Project, false);

            Row TotalGrossRow = Project.AddRow();
            TotalGrossRow.HeadingFormat = true;
            TotalGrossRow.Format.Alignment = ParagraphAlignment.Left;
            TotalGrossRow.Format.Font.Bold = true;
            TotalGrossRow.Cells[0].AddParagraph("Gross");
            TotalGrossRow.Cells[1].AddParagraph(GrossTotal.ToString() + "/-");
            RowCount++;
            RowCount = AddInvisibleRow(RowCount, Project, false);

            double StatutoryTotal = 0;
            foreach (var items in StatutoryList)
            {
                StatutoryTotal = StatutoryTotal + items.Amount;
                Row StatutoryRow = Project.AddRow();
                StatutoryRow.HeadingFormat = true;
                StatutoryRow.Format.Alignment = ParagraphAlignment.Left;
                StatutoryRow.Cells[0].AddParagraph(items.CompCode);
                StatutoryRow.Cells[1].AddParagraph(items.Amount.ToString() + "/-");
                RowCount++;
                RowCount = AddInvisibleRow(RowCount, Project, false);
            }

            double CTCTotal = 0;
            CTCTotal = GrossTotal + StatutoryTotal;

            Row CostToCompanyRow = Project.AddRow();
            CostToCompanyRow.HeadingFormat = true;
            CostToCompanyRow.Format.Alignment = ParagraphAlignment.Left;
            CostToCompanyRow.Format.Font.Bold = true;
            CostToCompanyRow.Cells[0].AddParagraph("Cost To Company");
            CostToCompanyRow.Cells[1].AddParagraph(CTCTotal.ToString() + "/-");
            RowCount++;
            RowCount = AddInvisibleRow(RowCount, Project, false);

            double deducationTotal = 0;
            foreach (var items in deducationlist)
            {
                deducationTotal = deducationTotal + items.Amount;
                Row DeducationRow = Project.AddRow();
                DeducationRow.HeadingFormat = true;
                DeducationRow.Format.Alignment = ParagraphAlignment.Left;
                DeducationRow.Cells[0].AddParagraph(items.CompCode);
                DeducationRow.Cells[1].AddParagraph(items.Amount.ToString() + "/-");
                RowCount++;
                RowCount = AddInvisibleRow(RowCount, Project, false);
            }

            deducationTotal = GrossTotal - deducationTotal;
            Row InHandSalaryRow = Project.AddRow();
            InHandSalaryRow.HeadingFormat = true;
            InHandSalaryRow.Format.Alignment = ParagraphAlignment.Left;
            InHandSalaryRow.Format.Font.Bold = true;
            InHandSalaryRow.Cells[0].AddParagraph("In Hand Salary");
            InHandSalaryRow.Cells[1].AddParagraph(deducationTotal.ToString() + "/-");
            RowCount++;
            RowCount = AddInvisibleRow(RowCount, Project, false);

            Row MonthlyVariableRow = Project.AddRow();
            MonthlyVariableRow.HeadingFormat = true;
            MonthlyVariableRow.Format.Alignment = ParagraphAlignment.Left;
            MonthlyVariableRow.Format.Font.Bold = true;
            MonthlyVariableRow.Cells[0].AddParagraph("Monthly Variable");
            MonthlyVariableRow.Cells[1].AddParagraph(Oflet.MonthlyVariable.ToString() + "/-");
            RowCount++;
            RowCount = AddInvisibleRow(RowCount, Project, false);

            Row MonthlyVariableCTCRow = Project.AddRow();
            MonthlyVariableCTCRow.HeadingFormat = true;
            MonthlyVariableCTCRow.Format.Alignment = ParagraphAlignment.Left;
            MonthlyVariableCTCRow.Format.Font.Bold = true;
            MonthlyVariableCTCRow.Cells[0].AddParagraph("Monthly Variable - CTC");
            MonthlyVariableCTCRow.Cells[1].AddParagraph(Oflet.MonthlyVariableNoESIC.ToString() + "/-");
            RowCount++;
            RowCount = AddInvisibleRow(RowCount, Project, false);

            Row RetentionBonusCTCRow = Project.AddRow();
            RetentionBonusCTCRow.HeadingFormat = true;
            RetentionBonusCTCRow.Format.Alignment = ParagraphAlignment.Left;
            RetentionBonusCTCRow.Format.Font.Bold = true;
            RetentionBonusCTCRow.Cells[0].AddParagraph("Retention Bonus - CTC");
            RetentionBonusCTCRow.Cells[1].AddParagraph(Oflet.RetentionBonusCTC.ToString() + "/-");
            RowCount++;
            RowCount = AddInvisibleRow(RowCount, Project, true);

            return "";
        }

        private int AddInvisibleRow(int RowCount, Table Project, bool IsLastPage)
        {
            if (RowCount >= 29)             //In one page, 29 Rows can properly fit
            {
                for (int InvisibleRowCount = 1; InvisibleRowCount <= 6; InvisibleRowCount++)
                {
                    Row InvisibleRow = Project.AddRow();
                    InvisibleRow.HeadingFormat = true;
                    InvisibleRow.Borders.Visible = false;
                    InvisibleRow.Cells[0].Borders.Visible = false;
                    InvisibleRow.Cells[1].Borders.Visible = false;
                    InvisibleRow.Cells[0].AddParagraph();
                    InvisibleRow.Cells[1].AddParagraph();
                    InvisibleRow.Borders.Top.Visible = false;
                }

                return 0;
            }
            else if (RowCount >= 20 && RowCount < 29 && IsLastPage)
            {
                while (IsLastPage)                       //Thank you, company name, singature etc take 9 rows in comparisions.
                {
                    Row InvisibleRow = Project.AddRow();
                    InvisibleRow.HeadingFormat = true;
                    InvisibleRow.Borders.Visible = false;
                    InvisibleRow.Cells[0].Borders.Visible = false;
                    InvisibleRow.Cells[1].Borders.Visible = false;
                    InvisibleRow.Cells[0].AddParagraph();
                    InvisibleRow.Cells[1].AddParagraph();
                    InvisibleRow.Borders.Top.Visible = false;

                    RowCount++;

                    if (RowCount == 35)
                    {
                        IsLastPage = false;
                    }

                }

                return 0;
            }
            else
            {
                return RowCount;
            }
        }
        public string SalaryIncrementTable(NewSalaryComponents salComps)
        {
            try
            {
                SalaryRevisionService Services = new SalaryRevisionService();
                var results = Services.GetSalaryDetails(salComps.SalaryId);

                Table table = CurrentSection.AddTable();
                table.Borders.Color = Colors.Black;
                table.Borders.Width = 0.25;
                table.Borders.Left.Width = 0.5;
                table.Borders.Right.Width = 0.5;
                table.Rows.LeftIndent = 0;

                Column AddColumn = new Column();
                AddColumn = table.AddColumn("60mm");
                AddColumn = table.AddColumn("60mm");
                AddColumn = table.AddColumn("60mm");

                Row row = new Row();
                row.Format.Alignment = ParagraphAlignment.Center;

                row = table.AddRow();
                row.Cells[0].AddParagraph().AddFormattedText("Particulars", "Heading4");
                row.Cells[1].AddParagraph().AddFormattedText("Amount (P.M.)", "Heading4");
                row.Cells[2].AddParagraph().AddFormattedText("Amount (P.A.)", "Heading4");

                foreach (var item in results)
                {
                    row = table.AddRow();
                    if (item.IsBold)
                    {
                        row.Cells[0].AddParagraph().AddFormattedText(item.SalaryComponentName, "Heading4");
                        row.Cells[1].AddParagraph().AddFormattedText("Rs. " + item.SalaryPackageMonthly, "Heading4");
                        row.Cells[2].AddParagraph().AddFormattedText("Rs. " + item.SalaryPackageYearly, "Heading4");
                    }
                    else
                    {
                        row.Cells[0].AddParagraph().AddFormattedText(item.SalaryComponentName, "Normal");
                        row.Cells[1].AddParagraph().AddFormattedText("Rs. " + item.SalaryPackageMonthly, "Normal");
                        row.Cells[2].AddParagraph().AddFormattedText("Rs. " + item.SalaryPackageYearly, "Normal");
                    }
                }

                for (int r = 1; r < table.Rows.Count - 1; r++)
                {
                    table.Rows[r].Height = 15;
                }

                for (int r = 0; r < table.Rows.Count; r++)
                {
                    for (int c = 0; c < table.Rows[r].Cells.Count; c++)
                    {
                        table.Rows[r].Cells[c].Borders.Visible = true;
                        table.Rows[r].Cells[c].Borders.Color = Colors.Black;
                        table.Rows[r].Cells[c].Borders.Style = BorderStyle.Single;
                        table.Rows[r].Cells[c].Borders.Distance = 5;
                        table.Rows[r].Cells[c].Borders.Width = 0.5;
                    }
                }
                return "";
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public string WayOfWorkingDetails(int AssociateLegalLetterId)
        {

            List<LegelLetterDynamicFields> DynamicFieldsValueList = new List<LegelLetterDynamicFields>();

            using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["InnovOneEntities1"].ConnectionString))
            {
                try
                {
                    con.Open();
                    DataTable dt = new DataTable();
                    using (SqlCommand cmd = con.CreateCommand())
                    {
                        string Sql = "";
                        Sql = @"select * from [ufn_GetWayOfWorkingDetails](@AssociateLegalLetterId);";
                        cmd.CommandText = Sql;
                        cmd.Parameters.AddWithValue("@AssociateLegalLetterId", AssociateLegalLetterId);
                        SqlDataAdapter sda = new SqlDataAdapter(cmd);
                        sda.Fill(dt);
                        if (dt.Rows.Count > 0)
                        {
                            foreach (DataRow dr in dt.Rows)
                            {
                                LegelLetterDynamicFields List = new LegelLetterDynamicFields();
                                List.Warnings = dr["Warnings"].ToString();
                                List.WayOfWorking = dr["WayOfWorking"].ToString();
                                List.LegalLetterTypeId = Convert.ToInt32(dr["LegalLetterTypeId"]);
                                List.ShowCauseContent = dr["ShowCauseContent"].ToString();
                                DynamicFieldsValueList.Add(List);
                            }
                        }

                    }
                }
                catch (Exception ex) { con.Close(); }
                con.Close();
            }
            if (DynamicFieldsValueList.Count > 0)
            {
                int i = 0;
                int SrNo = 1;
                if (DynamicFieldsValueList.FirstOrDefault().LegalLetterTypeId == 41)
                {
                    Table table = CurrentSection.AddTable();
                    table.Borders.Visible = false;
                    Column AddColumn = new Column();
                    AddColumn = table.AddColumn("60mm");
                    Row row = new Row();
                    row = table.AddRow();
                    row.Format.Alignment = ParagraphAlignment.Left;
                    foreach (var item in DynamicFieldsValueList)
                    {
                        row.Cells[i].AddParagraph().AddFormattedText(SrNo + ". " + item.WayOfWorking);
                        SrNo++;
                    }
                }
                else if (DynamicFieldsValueList.FirstOrDefault().LegalLetterTypeId == 42)
                {
                    Table table = CurrentSection.AddTable();
                    table.Borders.Visible = false;
                    Column AddColumn = new Column();
                    AddColumn = table.AddColumn("60mm");
                    Row row = new Row();
                    row = table.AddRow();
                    row.Format.Alignment = ParagraphAlignment.Left;
                    foreach (var item in DynamicFieldsValueList)
                    {
                        row.Cells[i].AddParagraph().AddFormattedText(SrNo + ". " + item.Warnings);
                        SrNo++;
                    }
                }
                else if (DynamicFieldsValueList.FirstOrDefault().LegalLetterTypeId == 39)
                {
                    Table table = CurrentSection.AddTable();
                    table.Borders.Visible = false;
                    Column AddColumn = new Column();
                    AddColumn = table.AddColumn("60mm");
                    Row row = new Row();
                    row = table.AddRow();
                    row.Format.Alignment = ParagraphAlignment.Left;
                    foreach (var item in DynamicFieldsValueList)
                    {
                        row.Cells[i].AddParagraph().AddFormattedText(SrNo + ". " + item.ShowCauseContent);
                        SrNo++;
                    }
                }
            }
            return "";
        }
    }
}


Answers (1)