public static CategoryWiseSearchResult SearchCard(string searchBy, string searchText, string searchCatId, bool fetchOnlyRecentData = false)
        {
            ErrorEnum errType      = ErrorEnum.Other;
            string    errMsg       = string.Empty;
            bool      isSuccess    = false;
            Exception errObj       = new Exception();
            int       convertedNum = 0;
            var       result       = new CategoryWiseSearchResult();

            result.CardSearchResult = new List <RationCardDetail>();
            try
            {
                DataSet ds = DBoperationsManager.SearchCard(searchBy, searchText, searchCatId, out errType, out errMsg, out isSuccess, out errObj);

                if ((ds != null) && (ds.Tables.Count > 0) && (ds.Tables[0].Rows.Count > 0))
                {
                    int count = 1;
                    result.CardCountOfCategory = int.TryParse(ds.Tables[1].Rows[0]["RECORD_COUNT"].ToString(), out convertedNum) ? convertedNum : 0;
                    result.CategoryOfCard      = MasterData.Categories.Data.FirstOrDefault(i => i.Cat_Id == searchCatId);
                    foreach (DataRow r in ds.Tables[0].Rows)
                    {
                        result.CardSearchResult.Add(new RationCardDetail
                        {
                            SlNo              = count,
                            Number            = r["RATIONCARD_NO"].ToString(),
                            Adhar_No          = r["Adhar_No"].ToString(),
                            Mobile_No         = r["Mobile_No"].ToString(),
                            Hof_Name          = r["HOF_NAME"].ToString(),
                            Name              = r["Name"].ToString(),
                            Age               = r["Age"].ToString(),
                            Address           = r["Address"].ToString(),
                            CardStatus        = (r["STATUS"].ToString() == "True") ? "Active" : "",
                            ActiveCard        = r["STATUS"].ToString() == "True",
                            Card_Created_Date = r["Created_Date"].ToString(),
                            Cat_Desc          = r["Cat_Desc"].ToString(),
                            Customer_Id       = r["Customer_Id"].ToString(),
                            Hof_Flag          = r["Hof_Flag"].ToString(),
                            Hof_Id            = r["Hof_Id"].ToString(),
                            RationCard_Id     = r["RationCard_Id"].ToString(),
                            Cat_Id            = r["Cat_Id"].ToString(),
                            Card_Category_Id  = r["Cat_Id"].ToString(),
                            Remarks           = r["Remarks"].ToString(),
                            Relation_With_Hof = r["Relation_With_Hof"].ToString(),
                            Gaurdian_Relation = r["Gaurdian_Relation"].ToString(),
                            Gaurdian_Name     = r["Gaurdian_Name"].ToString(),
                            FamilyCount       = ds.Tables[0].AsEnumerable().Count(
                                i => i["Hof_Id"].ToString() == r["Hof_Id"].ToString()).ToString(),
                            CardCount = ds.Tables[0].AsEnumerable().Count(
                                i => i["Hof_Id"].ToString() == r["Hof_Id"].ToString() &&
                                (r["STATUS"].ToString() == "True")).ToString()
                        });
                        count++;
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.LogError(ex);
            }
            return(result);
        }