using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using WangWei.DBUtility;
public partial class QueryDepertPOS : WangWei.Common.BasePage
{
string strWhere = "";
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
try
{
this.U_DocDate.Text = DateTime.Now.ToShortDateString();
this.U_EDate.Text = DateTime.Now.ToShortDateString();
strWhere = GetstrWhere();
this.BindData(strWhere);
}
catch (Exception ex)
{
throw ex;
}
}
} protected void GetSaleTotal(string strWhere)
{
string sql = " select sum(T0.docTotal) as total from oinv T0 " + strWhere;
DataSet ds1 = new DataSet();
ds1 = WangWei.DBUtility.DbHelperSQLSAP.Query(sql);
if (ds1.Tables[0].Rows.Count > 0)
this.lbSum.Text = ds1.Tables[0].Rows[0][0].ToString();
} protected void BindData(string where)
{
GetSaleTotal(where);
int count = 0;
string strSql = " select count(1) from oinv T0 " + where;
DataSet ds = new DataSet();
ds = WangWei.DBUtility.DbHelperSQLSAP.Query(strSql); count = Convert.ToInt32(ds.Tables[0].Rows[0][0].ToString());
ds = WangWei.DBUtility.DbHelperSQLSAP.GetListPage(" SELECT T0.DocEntry, T0.CardCode,T0.CardName,T0.U_DocDate, T0.DocTotal from oinv T0 "
+ where, pager.CurrentPageIndex, pager.PageSize, "DocEntry ", "DocEntry DESC "); Repeater.DataSource = ds;
Repeater.DataBind(); pager.RecordCount = count; pager.CustomInfoText = "记录总数:<font color=\"blue\"><b>" + count.ToString() + "</b></font>";
pager.CustomInfoText += " 总页数:<font color=\"blue\"><b>" + pager.PageCount.ToString() + "</b></font>";
pager.CustomInfoText += " 当前页:<font color=\"red\"><b>" + pager.CurrentPageIndex.ToString() + "</b></font>"; } protected string GetLineID()
{
return this.txtLineID.Text.ToString();
}
protected string GetWhsCode(string strCode)
{
WangWei.Model.Depart m_Depart = new WangWei.Model.Depart();
WangWei.DAL.Depart o_Depart = new WangWei.DAL.Depart();
m_Depart = o_Depart.GetModel(Convert.ToInt32(strCode));
return m_Depart.Store;
} protected void ChangePage(object src, Wuqi.Webdiyer.PageChangedEventArgs e)
{
pager.CurrentPageIndex = e.NewPageIndex;
strWhere = GetstrWhere();
BindData(strWhere);
} protected string GetstrWhere()
{
string sql = "";
string str1 = "";
string strBeginDate = "2008-01-01";
string strEndDate = "2100-01-01"; if (this.U_DocDate.Text != "")
strBeginDate = this.U_DocDate.Text;
if (this.U_EDate.Text != "")
strEndDate = this.U_EDate.Text; sql = " where (cast( T0.U_docdate as datetime)-40)>='" + strBeginDate + "' and cast( T0.U_EDate as datetime)<='" + strEndDate + "' "; if (this.DropDownList1.SelectedValue == "All")
{
return sql;
}
if (this.DropDownList2.SelectedValue == "=")
str1 = "=";
if (this.DropDownList2.SelectedValue == ">")
str1 = ">";
if (this.DropDownList2.SelectedValue == "<")
str1 = "<";
if (this.DropDownList2.SelectedValue == "")
str1 = "like ";
if (this.TextBox1.Text == "")
{
AddLoadMessage("请填写参数");
return sql;
}
str1 = this.DropDownList2.SelectedValue;
if (str1.ToLower() == "like")
{
sql = sql + " and " + this.DropDownList1.SelectedValue + " " + this.DropDownList2.SelectedValue + " '%" + this.TextBox1.Text + "%' ";
}
else
{
sql = sql + " and " + this.DropDownList1.SelectedValue + " " + this.DropDownList2.SelectedValue + " '" + this.TextBox1.Text + "' ";
}
return sql;
} protected void Button1_Click(object sender, EventArgs e)
{
strWhere = GetstrWhere();
BindData(strWhere);
}
}
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using WangWei.DBUtility;
public partial class QueryDepertPOS : WangWei.Common.BasePage
{
string strWhere = "";
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
try
{
this.U_DocDate.Text = DateTime.Now.ToShortDateString();
this.U_EDate.Text = DateTime.Now.ToShortDateString();
strWhere = GetstrWhere();
this.BindData(strWhere);
}
catch (Exception ex)
{
throw ex;
}
}
} protected void GetSaleTotal(string strWhere)
{
string sql = " select sum(T0.docTotal) as total from oinv T0 " + strWhere;
DataSet ds1 = new DataSet();
ds1 = WangWei.DBUtility.DbHelperSQLSAP.Query(sql);
if (ds1.Tables[0].Rows.Count > 0)
this.lbSum.Text = ds1.Tables[0].Rows[0][0].ToString();
} protected void BindData(string where)
{
GetSaleTotal(where);
int count = 0;
string strSql = " select count(1) from oinv T0 " + where;
DataSet ds = new DataSet();
ds = WangWei.DBUtility.DbHelperSQLSAP.Query(strSql); count = Convert.ToInt32(ds.Tables[0].Rows[0][0].ToString());
ds = WangWei.DBUtility.DbHelperSQLSAP.GetListPage(" SELECT T0.DocEntry, T0.CardCode,T0.CardName,T0.U_DocDate, T0.DocTotal from oinv T0 "
+ where, pager.CurrentPageIndex, pager.PageSize, "DocEntry ", "DocEntry DESC "); Repeater.DataSource = ds;
Repeater.DataBind(); pager.RecordCount = count; pager.CustomInfoText = "记录总数:<font color=\"blue\"><b>" + count.ToString() + "</b></font>";
pager.CustomInfoText += " 总页数:<font color=\"blue\"><b>" + pager.PageCount.ToString() + "</b></font>";
pager.CustomInfoText += " 当前页:<font color=\"red\"><b>" + pager.CurrentPageIndex.ToString() + "</b></font>"; } protected string GetLineID()
{
return this.txtLineID.Text.ToString();
}
protected string GetWhsCode(string strCode)
{
WangWei.Model.Depart m_Depart = new WangWei.Model.Depart();
WangWei.DAL.Depart o_Depart = new WangWei.DAL.Depart();
m_Depart = o_Depart.GetModel(Convert.ToInt32(strCode));
return m_Depart.Store;
} protected void ChangePage(object src, Wuqi.Webdiyer.PageChangedEventArgs e)
{
pager.CurrentPageIndex = e.NewPageIndex;
strWhere = GetstrWhere();
BindData(strWhere);
} protected string GetstrWhere()
{
string sql = "";
string str1 = "";
string strBeginDate = "2008-01-01";
string strEndDate = "2100-01-01"; if (this.U_DocDate.Text != "")
strBeginDate = this.U_DocDate.Text;
if (this.U_EDate.Text != "")
strEndDate = this.U_EDate.Text; sql = " where (cast( T0.U_docdate as datetime)-40)>='" + strBeginDate + "' and cast( T0.U_EDate as datetime)<='" + strEndDate + "' "; if (this.DropDownList1.SelectedValue == "All")
{
return sql;
}
if (this.DropDownList2.SelectedValue == "=")
str1 = "=";
if (this.DropDownList2.SelectedValue == ">")
str1 = ">";
if (this.DropDownList2.SelectedValue == "<")
str1 = "<";
if (this.DropDownList2.SelectedValue == "")
str1 = "like ";
if (this.TextBox1.Text == "")
{
AddLoadMessage("请填写参数");
return sql;
}
str1 = this.DropDownList2.SelectedValue;
if (str1.ToLower() == "like")
{
sql = sql + " and " + this.DropDownList1.SelectedValue + " " + this.DropDownList2.SelectedValue + " '%" + this.TextBox1.Text + "%' ";
}
else
{
sql = sql + " and " + this.DropDownList1.SelectedValue + " " + this.DropDownList2.SelectedValue + " '" + this.TextBox1.Text + "' ";
}
return sql;
} protected void Button1_Click(object sender, EventArgs e)
{
strWhere = GetstrWhere();
BindData(strWhere);
}
}
返回跨两个指定日期的日期和时间边界数。 语法
DATEDIFF ( datepart , startdate , enddate ) 参数
datepart是规定了应在日期的哪一部分计算差额的参数。下表列出了 Microsoft® SQL Server™ 识别的日期部分和缩写。日期部分 缩写
year yy, yyyy
quarter qq, q
Month mm, m
dayofyear dy, y
Day dd, d
Week wk, ww
Hour hh
minute mi, n
second ss, s
millisecond ms
startdate是计算的开始日期。startdate 是返回 datetime 或 smalldatetime 值或日期格式字符串的表达式。
SELECT * FROM titles where DATEDIFF(day, pubdate, getdate())<=40
ds = WangWei.DBUtility.DbHelperSQLSAP.GetListPage(" SELECT T0.DocEntry, T0.CardCode,T0.CardName,T0.U_DocDate, T0.DocTotal from oinv T0 "
+ where, pager.CurrentPageIndex, pager.PageSize, "DocEntry ", "DocEntry DESC ");
该这里 你先查看下这个方法的参数 ,然后把datediff 加到合适的地方