公共类返回 DataView类型

本文介绍了一个C#方法,用于通过调用存储过程获取指定日期范围内的门店销售报告。该方法接收当前日期、最后日期、父类别ID及公司ID作为参数,并返回数据视图。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


     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;

    }
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值