public string GetStartEndDate()
        {
            Global obj_global = new Global();
            string date       = obj_global.ACYR_START_DATE(DateTime.Now.Date).ToString("yyyy-MM-dd") + " % " + obj_global.ACYR_END_DATE(DateTime.Now.Date).AddDays(1).ToString("yyyy-MM-dd");

            return(date);
        }
        public List <PartyLdgr> GetPartyLedger(string pcode, DateTime frmdate, DateTime todate, bool IsOPBalInclude, bool IsSummary)
        {
            if ((new Global()).CheckStarterService())
            {
                try
                {
                    Global obj_global = new Global();
                    if (frmdate == null)
                    {
                        frmdate = obj_global.ACYR_START_DATE(DateTime.Now.Date);
                    }
                    if (todate == null)
                    {
                        todate = obj_global.ACYR_END_DATE(DateTime.Now.Date);
                    }
                    double?   opBal;
                    double?   TDrAmt = 0;
                    double?   TCrAmt = 0;
                    double?   DrAmt  = 0;
                    double?   CrAmt  = 0;
                    double?   Bal    = 0;
                    GBCDbConn GbcCon = new GBCDbConn();
                    string    name   = GbcCon.Database.Connection.Database + ".dbo.";
                    //PartyLdgr obj_Party = new PartyLdgr();
                    ////get op balance
                    name = name.Replace(obj_global.ACYR_START_DATE(DateTime.Now.Date).Year.ToString().Trim(), obj_global.ACYR_START_DATE(Convert.ToDateTime(frmdate)).Year.ToString().Trim());
                    if (IsOPBalInclude)
                    {
                        opBal = GetOpBal(pcode, frmdate, name);
                        if (opBal < 0)
                        {
                            TCrAmt = opBal * -1;
                        }
                        else
                        {
                            TDrAmt = opBal;
                        }
                    }
                    else
                    {
                        opBal  = 0;
                        TCrAmt = 0;
                        TDrAmt = 0;
                    }

                    //get party ledger
                    string             SQL            = objRpt.ShowLedgerSummary_Query(false, true, 0, 0, "", false, "", "General Ledger", "", "", "'" + pcode + "'", name, frmdate.ToString("dd/MM/yyyy"), todate.ToString("dd/MM/yyyy"), "All", "");
                    List <PartyLdgr>   list_partyLdgr = new List <PartyLdgr>();
                    List <PartyLedger> list_partyLdgr1;
                    list_partyLdgr1 = gbc_con.Database.SqlQuery <PartyLedger>(SQL).ToList();
                    double?Opbal   = 0;
                    double?balance = 0;
                    string AmtType;
                    for (int i = 0; i <= list_partyLdgr1.Count - 1; i++)
                    {
                        if (i == 0)
                        {
                            Opbal = list_partyLdgr1[i].OPBalance;
                        }
                        if (i != 0)
                        {
                            PartyLdgr obj = new PartyLdgr();
                            obj.Description = "";
                            string dt    = (list_partyLdgr1[i].Mdate == null) ? "" : list_partyLdgr1[i].Mdate;
                            string Line1 = "";

                            if (dt != "")
                            {
                                string[] SplStr = dt.Split('-');
                                dt = dt.Substring(0, 3) + "-" + SplStr[1].ToString();
                            }

                            string InsStr = (list_partyLdgr1[i].Insno == "") ? "" : list_partyLdgr1[i].InsType + " No." + list_partyLdgr1[i].Insno + "  Dt." + list_partyLdgr1[i].InsDate;
                            Line1           = list_partyLdgr1[i].Name;
                            Line1           = Line1 + " " + list_partyLdgr1[i].Narr1 + " " + list_partyLdgr1[i].Narr2 + " " + InsStr;
                            obj.Description = Line1;
                            obj.dramt       = (list_partyLdgr1[i].Debit == null) ? 0 : list_partyLdgr1[i].Debit;
                            DrAmt           = obj.dramt;
                            TDrAmt          = TDrAmt + DrAmt;
                            obj.cramt       = (list_partyLdgr1[i].Credit == null) ? 0 : list_partyLdgr1[i].Credit;
                            CrAmt           = obj.cramt;
                            TCrAmt          = TCrAmt + CrAmt;
                            if (TCrAmt < TDrAmt)
                            {
                                Bal     = TDrAmt - TCrAmt;
                                AmtType = " Dr";
                            }
                            else
                            {
                                Bal     = TCrAmt - TDrAmt;
                                AmtType = " Cr";
                            }
                            obj.Dt      = dt;
                            obj.Balance = Bal;
                            balance     = obj.Balance;
                            list_partyLdgr.Add(obj);
                        }
                    }

                    PartyLdgr obj_last = new PartyLdgr();
                    obj_last.Description = "Total";
                    obj_last.cramt       = TCrAmt;
                    obj_last.dramt       = TDrAmt;
                    obj_last.Balance     = balance;
                    obj_last.OPBalance   = Opbal;
                    list_partyLdgr.Add(obj_last);


                    return(list_partyLdgr);
                }
                catch (Exception ex)
                {
                    List <PartyLdgr> list_partyLdgr = new List <PartyLdgr>();
                    PartyLdgr        obj            = new PartyLdgr();
                    obj.Error       = "1";
                    obj.Description = ex.Message;
                    list_partyLdgr.Add(obj);
                    return(list_partyLdgr);
                }
            }
            else
            {
                return(null);
            }
        }