public static int GetCustomerCount(DateTime d1, DateTime d2, bool isclose, bool useconstr = false, string newconstr = "p") { var ret = 0; var ta = new SalesAmountDetailsTableAdapter { Connection = { ConnectionString = useconstr ? newconstr : _constr } }; if (!isclose) ret = (int) (ta.GetInvoiceCount() ?? 0); else ret = (int) (ta.GetInvoiceCountByDate(d1, d2) ?? 0); return (int) ret; }