Exemple #1
0
 /// <summary>
 /// Get list of assets items
 /// </summary>
 /// <returns></returns>
 public IList <AssetItem> Get()
 {
     try
     {
         using (var _con = new SqlConnection(FixedAssets.Context))
         {
             _con.Open();
             return(lIAssetsItems.Get(_con));
         }
     }
     catch (Exception ex) { throw ex; }
 }
Exemple #2
0
        /// <summary>
        /// Generate MR report
        /// </summary>
        /// <param name="pTransDate"></param>
        /// <param name="pName"></param>
        /// <param name="pPosition"></param>
        /// <param name="pPrepared"></param>
        /// <param name="pFFormat"></param>
        /// <param name="pObj"></param>
        /// <returns></returns>
        public Stream RptMR(DateTime pTransDate, string pName, string pPosition, string pPrepared, string pFFormat, IList <AssetItem> pObj)
        {
            try
            {
                string            _content   = MRContent();
                string            _json      = JsonConvert.SerializeObject(pObj.Select(s => new { AssetItemId = s.AssetItemId }).ToList());
                IList <AssetItem> _assetItem = new List <AssetItem>();
                using (ReportDocument _rd = new ReportDocument())
                {
                    try
                    {
                        string _path = HttpContext.Current.Server.MapPath("~/Report/MR.rpt");
                        _rd.Load(_path);
                        using (var _con = new SqlConnection(FixedAssets.Context))
                        {
                            _con.Open();
                            _assetItem = lIAssetsItems.Get(_json, _con);
                        }
                        _rd.SetDataSource(_assetItem);
                        _rd.SetParameterValue("pTransDate", pTransDate.ToShortDateString());
                        _rd.SetParameterValue("pName", pName);
                        _rd.SetParameterValue("pPosition", pPosition);
                        _rd.SetParameterValue("pPrepared", pPrepared);
                        _rd.SetParameterValue("pMRContent", _content);

                        return(_rd.ExportToStream(pFFormat == "PDF" ? ExportFormatType.PortableDocFormat : ExportFormatType.Excel));
                    }
                    catch (Exception ex) { throw ex; }
                }
            }
            catch (Exception ex) { throw ex; }
        }