关于.NET MVC 5 C的Crystal报告# [英] Crystal report on .NET MVC 5 C#

查看:67
本文介绍了关于.NET MVC 5 C的Crystal报告#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用.net mvc 5 c#repository模式,数据库第一种方法,在我的服务层,我在那里计算和应用group by条件并将这些数据传递给viewmodel和razor视图,

my问题是我可以使用此viewmodel(带数据)从此viewmodel创建水晶报表吗?水晶报告安装在visual studio(2015)上。代码信息是



控制器上的代码是



公共ActionResult Top20SupplierReport()

{

var AllSupplier = _supplier.Top20Supplier();

}

服务层代码是



公开列表Top20Supplier()

{

var AllSupplier = //从数据库获取所有供应商列表的代码

var groupByData =来自AllSupplier的sup

group sup by sup .cf02supplier_Name into g

let TotalVol = g.Sum(x => x.cf08collection_Received_Volume)

let TotalAmount = g.Sum(x => x.cf08collection_Balance)

orderby TotalVol降序

选择新的GroupBySupplierVM

{

Key = g.Key,

值= g.ToList(),

TotalReceivedVolume = Convert.ToDouble(TotalVol),

TotalBalance = TotalAmount

};

返回groupByData.Take(20).ToList();

}



ViewModel是





公共类GroupBySupplierVM

{

public string Key;

public List Values;

[Display(Name =Total)]

public double TotalReceivedVolume {get;组; }

公开双倍? TotalBalance {get;组; }



}





公共类别SupplierVM

{



public int cf02supplier_Id {get;组; } $ / $


public string cf02supplier_Address {get;组; }



public string cf02supplier_Name {get;组; }



公共字符串cf02supplier_City_Id {get;组; }



public string cf02supplier_Telephone {get;组; }



public string cf02supplier_MobileNo {get;组; }



公共小数cf02supplier_Balance {get;组; }

......

//其他实体也在那里



}



我可以从GroupBySupplierVM创建水晶报告吗?如果是如何使用水晶报告以及如何在视图页面上显示?

任何人都知道如何使用水晶报告。请帮帮我...



我尝试过:



我试着从正常情况下得到水晶报告但是我想要这个条件如何解决?

I use for .net mvc 5 c# repository pattern with database first approach, In my Service layer i calculate and apply group by condition on there and pass this data into viewmodel and razor view,
my question is can i used this viewmodel (with data) for creating the crystal report from this viewmodel ? crystal report is installed on visual studio (2015). code information are

code on controller are

public ActionResult Top20SupplierReport()
{
var AllSupplier = _supplier.Top20Supplier();
}
Service layer code are

public List Top20Supplier()
{
var AllSupplier = //code for get all supplier list from database
var groupByData = from sup in AllSupplier
group sup by sup .cf02supplier_Name into g
let TotalVol = g.Sum(x => x.cf08collection_Received_Volume)
let TotalAmount = g.Sum(x => x.cf08collection_Balance)
orderby TotalVol descending
select new GroupBySupplierVM
{
Key = g.Key,
Values = g.ToList(),
TotalReceivedVolume = Convert.ToDouble(TotalVol),
TotalBalance = TotalAmount
};
return groupByData.Take(20).ToList();
}

ViewModel are


public class GroupBySupplierVM
{
public string Key;
public List Values;
[Display(Name = "Total")]
public double TotalReceivedVolume { get; set; }
public double? TotalBalance { get; set; }

}
and

public class SupplierVM
{

public int cf02supplier_Id { get; set; }

public string cf02supplier_Address { get; set; }

public string cf02supplier_Name { get; set; }

public string cf02supplier_City_Id { get; set; }

public string cf02supplier_Telephone { get; set; }

public string cf02supplier_MobileNo { get; set; }

public decimal cf02supplier_Balance { get; set; }
......
// other Entity are also there

}

can i create crystal report from the GroupBySupplierVM ? if yes how to use on crystal report and how to show on view page ?
anybody have knowledge about this how to use on crystal report. Please help me...

What I have tried:

I try to get crystal report from normally but i want to this condition how to solve?

推荐答案

你可以直接将你的对象集合绑定到水晶报告。请遵循以下参考:

如何使用ASP.NET自定义对象集合生成Crystal报表

从应用程序中的对象列表动态创建Crystal报表文档数据库

创建水晶ASP.Net中的报告报告



希望这个帮助...
You can directly bind your collection of object to crystal report. Please follow below references:
How to Generate Crystal Report Using Custom Object Collection with ASP.NET
Create Crystal Report Document Dynamically from List of Objects in Applications without Database
Create Crystal Reports Report in ASP.Net

Hope this help..


你必须要为水晶创建数据集报告并使用您的数据实体配置它们,同时从DAL(数据访问层)返回数据。当您创建水晶报告时,它会询问dataSet,然后选择您为该报告创建的相应数据集,在创建之后,该数据集将在您的字段探索中列出以供使用。
You must have to create dataSet for crystal report and configure them with your data entities, while return data from your DAL(Data Access layer). When you will create crystal report, it will ask for dataSet, then select the appropriate dataSet you have created for that report, asfter creation, that dataSet will be listed in your field explore for use.


这篇关于关于.NET MVC 5 C的Crystal报告#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆