private void RepeaterDataBind()
{
//DateTime bgTime=DateTime.Now;
//DateTime edTime=DateTime.Now;
string bgTime="";
string enTime="";
//if (txtBeginTime.Text.Trim() != "") { bgTime= DateTime.Parse(txtBeginTime.Text.Trim());}
//if (txtOverTime.Text.Trim() != "") { edTime = DateTime.Parse(txtOverTime.Text.Trim());}
if (txtBeginTime.Text.Trim() != "") { bgTime = txtBeginTime.Text.Trim().ToString;}
if (txtOverTime.Text.Trim() != "") { edTime = txtOverTime.Text.Trim().ToString();}
if (bgTime != null)
{
if (!string.IsNullOrEmpty(strSQL))
{
strSQL = strSQL + " and ";
}
if (edTime != null)
{
strSQL = strSQL + " addtime between '" + bgTime + "' and '" + edTime + "'";
}
else
{
strSQL = strSQL + " addtime between '" + bgTime + "' and getdate() ";
}
}
} rplist.DataSource = dal.GetModelList(PageSize, PageIndex, strSQL, ref recordCount, ref pageCount);
rplist.DataBind();
SetPagingState();
}就保留了相关代码
前台是用的js控件 格式为:2009-12-03
这样查询查不出结果来啊?大家帮指点一下
{
//DateTime bgTime=DateTime.Now;
//DateTime edTime=DateTime.Now;
string bgTime="";
string enTime="";
//if (txtBeginTime.Text.Trim() != "") { bgTime= DateTime.Parse(txtBeginTime.Text.Trim());}
//if (txtOverTime.Text.Trim() != "") { edTime = DateTime.Parse(txtOverTime.Text.Trim());}
if (txtBeginTime.Text.Trim() != "") { bgTime = txtBeginTime.Text.Trim().ToString;}
if (txtOverTime.Text.Trim() != "") { edTime = txtOverTime.Text.Trim().ToString();}
if (bgTime != null)
{
if (!string.IsNullOrEmpty(strSQL))
{
strSQL = strSQL + " and ";
}
if (edTime != null)
{
strSQL = strSQL + " addtime between '" + bgTime + "' and '" + edTime + "'";
}
else
{
strSQL = strSQL + " addtime between '" + bgTime + "' and getdate() ";
}
}
} rplist.DataSource = dal.GetModelList(PageSize, PageIndex, strSQL, ref recordCount, ref pageCount);
rplist.DataBind();
SetPagingState();
}就保留了相关代码
前台是用的js控件 格式为:2009-12-03
这样查询查不出结果来啊?大家帮指点一下
private void RepeaterDataBind()
{
string strSQL = "";
string keysStr = txtKeyWord.Text.Trim();
string orderNum = txtOrderNum.Text.Trim();
string userName = txtUserName.Text.Trim();
string bgTime="";
string edTime = "";
if (txtBeginTime.Text.Trim() != "") { bgTime=DateTime.Parse(txtBeginTime.Text.Trim()).ToString();}
if (txtOverTime.Text.Trim() != "") { edTime =DateTime.Parse(txtOverTime.Text.Trim()).ToString();} if (chkAll.Checked != true)
{
if (bgTime != "")
{
if (!string.IsNullOrEmpty(strSQL))
{
strSQL = strSQL + " and ";
}
if (edTime != "")
{
strSQL = strSQL + " addtime between '" + bgTime + "' and '" + edTime + "'";
}
else
{
strSQL = strSQL + " addtime between '" + bgTime + "' and getdate() ";
}
}
} rplist.DataSource = dal.GetModelList(PageSize, PageIndex, strSQL, ref recordCount, ref pageCount);
rplist.DataBind();
SetPagingState();
}
这样是没问题的
private void RepeaterDataBind()
{
string strSQL = "";
string keysStr = txtKeyWord.Text.Trim();
string orderNum = txtOrderNum.Text.Trim();
string userName = txtUserName.Text.Trim();
string bgTime=txtBeginTime.Text.Trim();
string edTime = txtOverTime.Text.Trim(); if (chkAll.Checked != true)
{
int userId = User_InfoManager.GetUserIdByName(userName);
if (!string.IsNullOrEmpty(keysStr))
{
if (userId != -1)
{
strSQL = strSQL + " (OrderNum like '%" + keysStr + "%' or Userid like'%" + userId + "%')";
}
else {
strSQL = strSQL + " (OrderNum like '%" + keysStr+"%')";
}
} if (orderNum != "")
{
int _num = 0;
try { _num = int.Parse(orderNum); }
catch (Exception) { Response.Write("<script>alert('订单号输入有误');location.href='OrderByLesson.aspx';</script>"); ; }
if (!string.IsNullOrEmpty(strSQL))
{
strSQL = strSQL + " and ";
}
strSQL = strSQL + " OrderNum = " + _num + " ";
}
if (userName != "")
{
if (userId != -1)
{
if (!string.IsNullOrEmpty(strSQL))
{
strSQL = strSQL + " and ";
}
strSQL = strSQL + " UserId = '" + userId + "'";
}
}
if (bgTime != "")
{
if (!string.IsNullOrEmpty(strSQL))
{
strSQL = strSQL + " and ";
}
if (edTime != "")
{
strSQL = strSQL + " addtime between '" + DateTime.Parse(bgTime) + "' and '" + DateTime.Parse(edTime) + "'";
}
else
{
strSQL = strSQL + " addtime between '" + bgTime + "' and getdate() ";
}
}
} rplist.DataSource = dal.GetModelList(PageSize, PageIndex, strSQL, ref recordCount, ref pageCount);
rplist.DataBind();
SetPagingState();
}
结贴