public
DataView GetDailyStoreReport(DateTime currentdate, DateTime lastdate,
int
cparentID,
int
companyID)
{
// 定义数据库的Connection and Command
SqlConnection con = SalePerporse.SaleConn; // 公共连接属性
SqlCommand cmd = new SqlCommand( " GetDailyStoreReport " ,con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add( " @current " , SqlDbType.DateTime);
cmd.Parameters[ " @current " ].Value = currentdate;
cmd.Parameters.Add( " @last " , SqlDbType.DateTime);
cmd.Parameters[ " @last " ].Value = lastdate;
cmd.Parameters.Add( " @CParentID " , SqlDbType.Int);
cmd.Parameters[ " @CParentID " ].Value = cparentID;
cmd.Parameters.Add( " @CompanyID " , SqlDbType.Int);
cmd.Parameters[ " @CompanyID " ].Value = companyID;
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;
DataSet ds = new DataSet();
DataView dv = null ;
try
{
// 打开数据库的连接
con.Open();
// 执行数据库的存储过程(访问数据库)
da.Fill(ds);
dv = ds.Tables[ 0 ].DefaultView;
con.Close();
}
catch // (Exception ex)
{
SalePerporse.MyErr(ex.Message); // 公共错误方法
}
return dv;
}
{
// 定义数据库的Connection and Command
SqlConnection con = SalePerporse.SaleConn; // 公共连接属性
SqlCommand cmd = new SqlCommand( " GetDailyStoreReport " ,con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add( " @current " , SqlDbType.DateTime);
cmd.Parameters[ " @current " ].Value = currentdate;
cmd.Parameters.Add( " @last " , SqlDbType.DateTime);
cmd.Parameters[ " @last " ].Value = lastdate;
cmd.Parameters.Add( " @CParentID " , SqlDbType.Int);
cmd.Parameters[ " @CParentID " ].Value = cparentID;
cmd.Parameters.Add( " @CompanyID " , SqlDbType.Int);
cmd.Parameters[ " @CompanyID " ].Value = companyID;
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;
DataSet ds = new DataSet();
DataView dv = null ;
try
{
// 打开数据库的连接
con.Open();
// 执行数据库的存储过程(访问数据库)
da.Fill(ds);
dv = ds.Tables[ 0 ].DefaultView;
con.Close();
}
catch // (Exception ex)
{
SalePerporse.MyErr(ex.Message); // 公共错误方法
}
return dv;
}