/// <summary> /// Get list of the MR assets items /// </summary> /// <returns></returns> public IList <AssetItem> Get() { try { IList <AssetItem> _mr = new List <AssetItem>(); using (var _con = new SqlConnection(FixedAssets.Context)) { _con.Open(); _mr = lIMRs.Get(_con); } return(_mr); } catch (Exception ex) { throw ex; } }
/// <summary> /// Export to excel /// </summary> /// <param name="pFrom"></param> /// <param name="pTo"></param> /// <returns></returns> public Stream RptExportExcel(DateTime pFrom, DateTime pTo) { using (ReportDocument _rd = new ReportDocument()) { try { string _path = HttpContext.Current.Server.MapPath("~/Report/AssignedItem.rpt"); _rd.Load(_path); IList <AssetItem> _asset = new List <AssetItem>(); using (var _con = new SqlConnection(FixedAssets.Context)) { _con.Open(); _asset = pFrom.Date.Equals(DefaultValue.datetime.Date) ? lIMRs.Get(_con) : lIMRs.Get(pFrom, pTo, _con); } string _type = pFrom.Date < DefaultValue.datetime.Date ? "All Assigned Fixed Assets" : pFrom.ToShortDateString() + " - " + pTo.ToShortDateString(); _rd.SetDataSource(_asset); _rd.SetParameterValue("pType", _type); return(_rd.ExportToStream(ExportFormatType.Excel)); } catch (Exception ex) { throw ex; } } }