public List<VIEW_CUST_CUSTOMER_MASTER> GetCust(int startIndex, int maximumRows, string sortExpression, string filterExpression, string scomapany, string scity, string scode, string stype, string sbranch, string semp, string scommode, string suniquetid, string sfname, string slname, string semail, string smob, string stele)
        {
                                                                                                                                                            
            if (!String.IsNullOrEmpty(filterExpression))
            {
                Cust = Cust.Where(filterExpression);
            }
            if (!String.IsNullOrEmpty(sortExpression))
            {
                Cust = Cust.OrderBy(sortExpression);
            }
            if (!String.IsNullOrEmpty(scomapany))
            {
                CustomerMasterDataContext db = new CustomerMasterDataContext();
                Cust = db.VIEW_CUST_CUSTOMER_MASTERs.Where(p => (p.CUST_COMPANY_NAME.Contains(scomapany)));
            }
            if (!String.IsNullOrEmpty(scity))
            {
                CustomerMasterDataContext db = new CustomerMasterDataContext();
                Cust = db.VIEW_CUST_CUSTOMER_MASTERs.Where(p => (p.CITY_NAME.Contains(scity)));
            }
            if (!String.IsNullOrEmpty(scode))
            {
                CustomerMasterDataContext db = new CustomerMasterDataContext();
                Cust = db.VIEW_CUST_CUSTOMER_MASTERs.Where(p => (p.CUST_CODE_NAME.Contains(scode)));
            }
            if (!String.IsNullOrEmpty(stype))
            {
                CustomerMasterDataContext db = new CustomerMasterDataContext();
                Cust = db.VIEW_CUST_CUSTOMER_MASTERs.Where(p => (p.CUST_TYPE_NAME.Contains(stype)));
            }
            if (!String.IsNullOrEmpty(sbranch))
            {
                CustomerMasterDataContext db = new CustomerMasterDataContext();
                Cust = db.VIEW_CUST_CUSTOMER_MASTERs.Where(p => (p.BRANCH.Contains(sbranch)));
            }
            if (!String.IsNullOrEmpty(semp))
            {
                CustomerMasterDataContext db = new CustomerMasterDataContext();
                Cust = db.VIEW_CUST_CUSTOMER_MASTERs.Where(p => (p.EMPLOYEE.Contains(semp)));
            }
            if (!String.IsNullOrEmpty(scommode))
            {
                CustomerMasterDataContext db = new CustomerMasterDataContext();
                Cust = db.VIEW_CUST_CUSTOMER_MASTERs.Where(p => (p.COMMUNICATION_MODE_NAME.Contains(scommode)));
            }
            //if (!String.IsNullOrEmpty(srelation))
            //{
            //    CustomerMasterDataContext db = new CustomerMasterDataContext();
            //    Cust = db.VIEW_CUST_CUSTOMER_MASTERs.Where(p => (p.RELATION_DESC.Contains(srelation)));
            //}
            if (!String.IsNullOrEmpty(suniquetid))
            {
                CustomerMasterDataContext db = new CustomerMasterDataContext();
                Cust = db.VIEW_CUST_CUSTOMER_MASTERs.Where(p => (p.CUST_UNQ_ID.Contains(suniquetid)));
            }
            if (!String.IsNullOrEmpty(sfname))
            {
                CustomerMasterDataContext db = new CustomerMasterDataContext();
                Cust = db.VIEW_CUST_CUSTOMER_MASTERs.Where(p => (p.CUST_SURNAME.Contains(sfname)));
            }
            if (!String.IsNullOrEmpty(slname))
            {
                CustomerMasterDataContext db = new CustomerMasterDataContext();
                Cust = db.VIEW_CUST_CUSTOMER_MASTERs.Where(p => (p.CUST_NAME.Contains(slname)));
            }
            if (!String.IsNullOrEmpty(semail))
            {
                CustomerMasterDataContext db = new CustomerMasterDataContext();
                Cust = db.VIEW_CUST_CUSTOMER_MASTERs.Where(p => (p.CUST_REL_EMAIL.Contains(semail)));
            }
            if (!String.IsNullOrEmpty(smob))
            {
                CustomerMasterDataContext db = new CustomerMasterDataContext();
                Cust = db.VIEW_CUST_CUSTOMER_MASTERs.Where(p => (p.CUST_REL_MOBILE.Contains(smob)));
            }
            if (!String.IsNullOrEmpty(stele))
            {
                CustomerMasterDataContext db = new CustomerMasterDataContext();
                Cust = db.VIEW_CUST_CUSTOMER_MASTERs.Where(p => (p.CUST_REL_PHONE.Contains(stele)));
            }
            // if ((!String.IsNullOrEmpty(sfname)) || (!String.IsNullOrEmpty(slname)) || (!String.IsNullOrEmpty(semail)) || (!String.IsNullOrEmpty(smob)) || (!String.IsNullOrEmpty(stele)))
            //{
                 
            //    CustomerMasterDataContext db = new CustomerMasterDataContext();
            //    Cust = db.VIEW_CUST_CUSTOMER_MASTERs.Where(p => (p.CUST_SURNAME.Contains(sfname)) || (p.CUST_NAME.Contains(slname)) || (p.CUST_REL_EMAIL.Contains(semail)) || (p.CUST_REL_PHONE.Contains(stele)) || (p.CUST_REL_MOBILE.Contains(smob)));
            //}
                //DateTime startDateRange = new DateTime();
                //DateTime endDateRange = new DateTime(); 

                // if (chkdate.Checked && DateTime.TryParse(filterBirthDateStart.Text, out startDateRange) && DateTime.TryParse(filterBirthDateEnd.Text, out endDateRange)) {
                //      Cust = Cust.And(e => e.BirthDate.Value >= startDateRange && e.BirthDate.Value <= endDateRange);


            else
            {
                Cust = Cust.OrderBy("CUST_ID");
            }
            return Cust.Skip(startIndex).Take(maximumRows).ToList();
        }
        public List<VIEW_CUST_CUSTOMER_MASTER> GetCustomer(int startIndex, int maximumRows, string sortExpression, string filterExpression, string scomapany, string scity, string scode, string stype, string sbranch, string semp, string scommode, string srelation, string suniquetid, string sfname, string slname, string semail, string smob, string stele)
        {
            if (!String.IsNullOrEmpty(filterExpression))
            {
                Customer = Customer.Where(filterExpression);
            }
            if (!String.IsNullOrEmpty(sortExpression))
            {
                Customer = Customer.OrderBy(sortExpression);
            }
            if (!String.IsNullOrEmpty(scomapany))
            {
                CustomerMasterDataContext db = new CustomerMasterDataContext();
                Customer = db.VIEW_CUST_CUSTOMER_MASTERs.Where(p => (p.CUST_COMPANY_NAME.Contains(scomapany)));
            }
            if (!String.IsNullOrEmpty(scity))
            {
                CustomerMasterDataContext db = new CustomerMasterDataContext();
                Customer = db.VIEW_CUST_CUSTOMER_MASTERs.Where(p => (p.CITY_NAME.Contains(scity)));
            }
            if (!String.IsNullOrEmpty(scode))
            {
                CustomerMasterDataContext db = new CustomerMasterDataContext();
                Customer = db.VIEW_CUST_CUSTOMER_MASTERs.Where(p => (p.CUST_CODE_NAME.Contains(scode)));
            }
            if (!String.IsNullOrEmpty(stype))
            {
                CustomerMasterDataContext db = new CustomerMasterDataContext();
                Customer = db.VIEW_CUST_CUSTOMER_MASTERs.Where(p => (p.CUST_TYPE_NAME.Contains(stype)));
            }
            if (!String.IsNullOrEmpty(sbranch))
            {
                CustomerMasterDataContext db = new CustomerMasterDataContext();
                Customer = db.VIEW_CUST_CUSTOMER_MASTERs.Where(p => (p.BRANCH.Contains(sbranch)));
            }
            if (!String.IsNullOrEmpty(semp))
            {
                CustomerMasterDataContext db = new CustomerMasterDataContext();
                Customer = db.VIEW_CUST_CUSTOMER_MASTERs.Where(p => (p.EMPLOYEE.Contains(semp)));
            }
            if (!String.IsNullOrEmpty(scommode))
            {
                CustomerMasterDataContext db = new CustomerMasterDataContext();
                Customer = db.VIEW_CUST_CUSTOMER_MASTERs.Where(p => (p.COMMUNICATION_MODE_NAME.Contains(scommode)));
            }
            if (!String.IsNullOrEmpty(srelation))
            {
                CustomerMasterDataContext db = new CustomerMasterDataContext();
                Customer = db.VIEW_CUST_CUSTOMER_MASTERs.Where(p => (p.RELATION_DESC.Contains(srelation)));
            }
            if (!String.IsNullOrEmpty(suniquetid))
            {
                CustomerMasterDataContext db = new CustomerMasterDataContext();
                Customer = db.VIEW_CUST_CUSTOMER_MASTERs.Where(p => (p.CUST_UNQ_ID.Contains(suniquetid)));
            }
            if (!String.IsNullOrEmpty(sfname))
            {
                CustomerMasterDataContext db = new CustomerMasterDataContext();
                Customer = db.VIEW_CUST_CUSTOMER_MASTERs.Where(p => (p.CUST_SURNAME.Contains(sfname)));
            }
            if (!String.IsNullOrEmpty(slname))
            {
                CustomerMasterDataContext db = new CustomerMasterDataContext();
                Customer = db.VIEW_CUST_CUSTOMER_MASTERs.Where(p => (p.CUST_NAME.Contains(slname)));
            }
            if (!String.IsNullOrEmpty(semail))
            {
                CustomerMasterDataContext db = new CustomerMasterDataContext();
                Customer = db.VIEW_CUST_CUSTOMER_MASTERs.Where(p => (p.CUST_REL_EMAIL.Contains(semail)));
            }
            if (!String.IsNullOrEmpty(smob))
            {
                CustomerMasterDataContext db = new CustomerMasterDataContext();
                Customer = db.VIEW_CUST_CUSTOMER_MASTERs.Where(p => (p.CUST_REL_MOBILE.Contains(smob)));
            }
            if (!String.IsNullOrEmpty(stele))
            {
                CustomerMasterDataContext db = new CustomerMasterDataContext();
                Customer = db.VIEW_CUST_CUSTOMER_MASTERs.Where(p => (p.CUST_REL_PHONE.Contains(stele)));
            }

            else
            {
                Customer = Customer.OrderBy("CUST_ID");
            }

            return Customer.Skip(startIndex).Take(maximumRows).ToList();
        }
 public List<VIEW_CUST_CUSTOMER_RELATION> RelGrid(string CHAIN_SR_NO, string scity, string suniquetid, string sfname,string slname,string semail,string smob,string stele)
 {
     if (!String.IsNullOrEmpty(suniquetid))
     {
         CustomerMasterDataContext db = new CustomerMasterDataContext();
         Cust = db.VIEW_CUST_CUSTOMER_MASTERs.Where(p => (p.CUST_UNQ_ID.Contains(suniquetid)));
     }
     if (!String.IsNullOrEmpty(sfname))
     {
         CustomerMasterDataContext db = new CustomerMasterDataContext();
         Cust = db.VIEW_CUST_CUSTOMER_MASTERs.Where(p => (p.CUST_SURNAME.Contains(sfname)));
     }
     if (!String.IsNullOrEmpty(slname))
     {
         CustomerMasterDataContext db = new CustomerMasterDataContext();
         Cust = db.VIEW_CUST_CUSTOMER_MASTERs.Where(p => (p.CUST_NAME.Contains(slname)));
     }
     if (!String.IsNullOrEmpty(semail))
     {
         CustomerMasterDataContext db = new CustomerMasterDataContext();
         Cust = db.VIEW_CUST_CUSTOMER_MASTERs.Where(p => (p.CUST_REL_EMAIL.Contains(semail)));
     }
     if (!String.IsNullOrEmpty(smob))
     {
         CustomerMasterDataContext db = new CustomerMasterDataContext();
         Cust = db.VIEW_CUST_CUSTOMER_MASTERs.Where(p => (p.CUST_REL_MOBILE.Contains(smob)));
     }
     if (!String.IsNullOrEmpty(stele))
     {
         CustomerMasterDataContext db = new CustomerMasterDataContext();
         Cust = db.VIEW_CUST_CUSTOMER_MASTERs.Where(p => (p.CUST_REL_PHONE.Contains(stele)));
     }
     else
     {
         //rel = rel.Where(String.Format(@"CUST_ID == {0}", CUST_ID));
        
     }
     rel = rel.Where(String.Format(@"CHAIN_SR_NO == {0}", CHAIN_SR_NO));
     return rel.ToList();
 }