cs ①
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Acction;
using System.Data;
public partial class Query_Business : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Init_Page();
BindData();
}
}
protected void Init_Page()
{
double startdate = 0.0;
startdate = (-1) * Convert.ToDouble(System.Configuration.ConfigurationManager.AppSettings["startdate"].ToString());
this.txt_SDate.Value = DateTime.Now.AddDays(startdate).ToShortDateString();
this.txt_EDate.Value = DateTime.Now.ToShortDateString();
}
protected void btn_Query_Click(object sender, EventArgs e)
{
BindData();
}
private void BindData()
{
double startdate = 0.0;
startdate = (-1) * Convert.ToDouble(System.Configuration.ConfigurationManager.AppSettings["startdate"].ToString());
string sdate = (txt_SDate.Value == "" ? DateTime.Now.AddDays(startdate).ToShortDateString() : txt_SDate.Value);
string edate = (txt_EDate.Value == "" ? DateTime.Now.ToShortDateString() : txt_EDate.Value);
string Name = txt_Name.Value;
string type = sl_Way.Items[sl_Way.SelectedIndex].Value.ToString();
Ac_Query query = new Ac_Query ();
DataTable dt =query .Query_Business (Name,sdate ,edate ,type );
rp_list.DataSource = dt;
rp_list.DataBind();
}
}
Acction ②
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using PublicClass;
using BLL;
namespace Acction
{
public class Ac_Query
{
DataTable dt = new DataTable();
OperateBusi ob = new OperateBusi();
/// <summary>
/// 查询Business
/// </summary>
/// <param name="Name">模糊匹配</param>
/// <param name="SDate">起始时间</param>
/// <param name="EDate">结束时间</param>
/// <returns></returns>
public DataTable Query_Business(string Name, string SDate, string EDate,string type)
{
string sql = "Query_Business ";
sql += "'" + Name + "',";
sql += "'" + SDate + "',";
sql += "'" + EDate + "',";
sql += type;
dt = ob.ExecBusiOrder(sql);
return dt;
}
}
}
Proc ③
if exists (select * from sys.objects where object_id = object_id ('Query_Business') and type in ('P','FN'))
drop proc Query_Business
go
create proc Query_Business
@Name varchar(300), --模糊匹配
@StartDate datetime , --起始时间
@EndDate datetime, --结束时间
@Type int
as
set nocount on
set @EndDate =@EndDate +1
select *
from dbo.Cooperation
where (F_Name like '%'+@Name+'%' or L_Name like '%'+@Name+'%' or Co_Content like '%'+@Name+'%')
and Sub_Date >=@StartDate
and Sub_Date <@EndDate
and Type = @Type
go