如何按生日搜索人?
我已经找到这个方法了,还有其他更简单的吗?
ClienteAdapter cliente = Cache.CacheManager.Get<ClienteAdapter>();
DataTable dt = cliente.GetDataTable();
DateTime dta = DateTime.Today;
String dia = dta.Day.ToString();
if (dta.Day < 10)
dia = '0'+dia;
String mes = dta.Month.ToString();
if (dta.Month < 10)
mes = '0'+mes;
String aniversario = String.Format("{0}-{1}", dia, mes);
dt = cliente.Get(dt, String.Format("WHERE dtNascCli LIKE '%{0}%'", aniversario));
if (dt.Rows.Count>0) {
String aniversariantes = "Aniversariantes do dia:\n";
for (int i = 0; i < dt.Rows.Count; i++)
{
aniversariantes += ((dt.Rows[i]["nmComprador"] != null) : dt.Rows[i]["nmComprador"] ? dt.Rows[i]["nmRazao"]) + "\n";
}
I've found this way, is there any other simplier?
ClienteAdapter cliente = Cache.CacheManager.Get<ClienteAdapter>();
DataTable dt = cliente.GetDataTable();
DateTime dta = DateTime.Today;
String dia = dta.Day.ToString();
if (dta.Day < 10)
dia = '0'+dia;
String mes = dta.Month.ToString();
if (dta.Month < 10)
mes = '0'+mes;
String aniversario = String.Format("{0}-{1}", dia, mes);
dt = cliente.Get(dt, String.Format("WHERE dtNascCli LIKE '%{0}%'", aniversario));
if (dt.Rows.Count>0) {
String aniversariantes = "Aniversariantes do dia:\n";
for (int i = 0; i < dt.Rows.Count; i++)
{
aniversariantes += ((dt.Rows[i]["nmComprador"] != null) : dt.Rows[i]["nmComprador"] ? dt.Rows[i]["nmRazao"]) + "\n";
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论
评论(2)
LINQ 可以帮助您入门。
这会生成一个
IEnumerable
,您可以使用foreach
对其进行迭代。编辑:合并了对前几年的困惑评论。
LINQ could get you started.
That yields an
IEnumerable<DataRow>
, which you could iterate over with aforeach
.EDIT: Incorporated bemused's comment regarding previous years.
您可以将其简化
为
:这不会改变这样一个事实:这不是存储或搜索日期的好方法,但它是一个很好的起点。
除了 Jim Dagg 的 LINQ 示例之外,这就是我得到的全部内容。
You could simplify this:
Into this:
This doesn't change the fact that this isn't a good way to store or search for dates, but its a good place to start.
That's all I got, besides Jim Dagg's LINQ example.