コード例 #1
0
        public SenVietVoucherObject(HttpRequestBase request)
        {
            this.InitObject();
            this._db         = new Models.WebAppAccEntities(Services.GlobalVariant.GetConnection());;
            this._request    = request;
            this._metaobject = Services.GlobalMeta.GetMetaObject(this._metaname);

            this._paramnamemasteroutput = this._keyfieldmaster;
            this._paramnamemasterupdate = string.Format("Original_{0}", this._keyfieldmaster);

            this._paramnamelineoutput = this._keyfieldline;
            this._paramnamelineupdate = string.Format("Original_{0}", this._keyfieldline);

            this._paramnamevatoutput = this._keyfieldvat;
            this._paramnamevatupdate = string.Format("Original_{0}", this._keyfieldvat);

            appajaxoption.ajaxoption.Add("ajaxupdateid", string.Format("{0}_container", this._metaname.ToLower()));
            appajaxoption.ajaxoption.Add("businesscode", this._businesscode);
            appajaxoption.ajaxoption.Add("metaname", this._metaname);
            appajaxoption.ajaxoption.Add("keyfield", this._keyfieldmaster);
            appajaxoption.ajaxoption.Add("action-return", this._request["action_return"]);

            this.sysbusiness = this._db.SysBusinesses.Where(m => m.BusinessCode == this._businesscode).SingleOrDefault();
            int roleid = Services.GlobalVariant.GetAppUser().RoleID;

            this.sysbusinessrole = this._db.SysBusinessRoles.Where(m => m.BusinessCode == this._businesscode & m.RoleID == roleid).SingleOrDefault();
        }
コード例 #2
0
        public static Models.SysReport GetReport(int SysReportID)
        {
            var db     = new Models.WebAppAccEntities(Services.GlobalVariant.GetConnection());
            var result = db.SysReports.Where(m => m.SysReportID == SysReportID).SingleOrDefault();

            return(result);
        }
コード例 #3
0
        public static bool CheckVoucherNumber(long DocumentID, int VoucherID, string VoucherNumber, DateTime VoucherDate)
        {
            //CheckVoucherNumber	int	0: Trùng cho lưu, 1: Trùng không cho lưu
            //CheckVoucherNumberBy	int	0: Không kiểm tra, 1: Kiểm tra toàn thời gian, 2: Theo năm, 3: Theo tháng

            var           db   = new Models.WebAppAccEntities(Services.GlobalVariant.GetConnection());
            bool          _ret = true;
            var           checkvouchernumberby = Services.GlobalVariant.GetSysOption()["CheckVoucherNumberBy"].ToString();
            List <string> result = null;

            if (checkvouchernumberby == "1")
            {
                result = db.Database.SqlQuery <string>(string.Format("Select top 1 value=VoucherNumber From AppDocumentTable Where DocumentID<>{0} And VoucherNumber='{1}' And VoucherID={2}", DocumentID, VoucherNumber, VoucherID)).ToList();
            }

            if (checkvouchernumberby == "2")
            {
                result = db.Database.SqlQuery <string>(string.Format("Select top 1 value=VoucherNumber From AppDocumentTable Where DocumentID<>{0} And Year(VoucherDate)={1} And VoucherNumber='{2}' And VoucherID={3}", DocumentID, VoucherDate.Year, VoucherNumber, VoucherID)).ToList();
            }

            if (checkvouchernumberby == "3")
            {
                result = db.Database.SqlQuery <string>(string.Format("Select top 1 value=VoucherNumber From AppDocumentTable Where DocumentID<>{0} And Year(VoucherDate)={1} And Month(VoucherDate)={2} And VoucherNumber='{3}' And VoucherID={4}", DocumentID, VoucherDate.Year, VoucherDate.Month, VoucherNumber, VoucherID)).ToList();
            }
            if (result != null)
            {
                _ret = result.Count == 0;
            }

            return(_ret);
        }
コード例 #4
0
        public ActionResult Edit2(FormCollection collection)
        {
            //string SysOptionName = collection["SysOptionName"].ToString();
            //var data = _dataobject._db.SysOptions.Where(m => m.SysOptionName == SysOptionName).SingleOrDefault();
            //data.SysOptionValue = collection["SysOptionValue"].ToString();

            var db           = new Models.WebAppAccEntities(Services.GlobalVariant.GetConnection());
            var lockdateyear = DateTime.Parse(Services.GlobalVariant.GetSysOption()["LockDate"].ToString()).Year;
            var thisyear     = int.Parse(collection["thisyear"].ToString());

            if (lockdateyear > thisyear)
            {
                ModelState.AddModelError("", "Năm đã khóa sổ không chuyển được.");
            }
            if (!ModelState.IsValid)
            {
                return(PartialView("Update2"));
            }

            try
            {
                db.Database.ExecuteSqlCommand(string.Format("sp_FcNextYear {0}", thisyear));
                ViewBag.FcNextYearMessage = "Đã chuyển thành công";
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
            }

            return(PartialView("Update2"));
        }
コード例 #5
0
        public SenVietReportObject(HttpRequestBase request)
        {
            this.InitObject();

            this._db             = new Models.WebAppAccEntities(Services.GlobalVariant.GetConnection());
            this._request        = request;
            this._metaobject     = Services.GlobalMeta.GetMetaObject(this._metaname);
            this._currentsession = HttpContext.Current.Session;

            this._sessionkeys       = string.Format("{0}.Model", this._businesscode);
            this._sessionparamskeys = string.Format("{0}.Params", this._businesscode);

            appajaxoption.ajaxoption.Add("ajaxupdateid", string.Format("{0}_container", this._metaname.ToLower()));
            appajaxoption.ajaxoption.Add("businesscode", this._businesscode);
            appajaxoption.ajaxoption.Add("metaname", this._metaname);
            appajaxoption.ajaxoption.Add("keyfield", this._keyfield);
            appajaxoption.ajaxoption.Add("action-return", this._request["action_return"]);

            this.sysreports  = this._db.SysReports.Where(m => m.BusinessCode == this._businesscode).OrderBy(m => m.IsDefault).ToList();
            this.sysbusiness = this._db.SysBusinesses.Where(m => m.BusinessCode == this._businesscode).SingleOrDefault();

            int roleid = Services.GlobalVariant.GetAppUser().RoleID;

            this.sysbusinessrole = this._db.SysBusinessRoles.Where(m => m.BusinessCode == this._businesscode & m.RoleID == roleid).SingleOrDefault();
        }
コード例 #6
0
        public static string GetControllerName(string VoucherCode)
        {
            var    db      = new Models.WebAppAccEntities(Services.GlobalVariant.GetConnection());
            string _ret    = "";
            var    voucher = db.AppVoucherViews.Where(m => m.VoucherCode == VoucherCode).SingleOrDefault();

            _ret = voucher.AssemblyName.Replace(".exe", "");
            return(_ret);
        }
コード例 #7
0
        public static string GetPostStoreProcedure(int VoucherID)
        {
            var    db = new Models.WebAppAccEntities(Services.GlobalVariant.GetConnection());
            string _GetPostStoreProcedure = "";
            var    row = db.AppVoucherTables.Where(m => m.VoucherID == VoucherID).SingleOrDefault();

            if (row != null)
            {
                _GetPostStoreProcedure = row.PostStoreProcedure;
            }
            return(_GetPostStoreProcedure);
        }
コード例 #8
0
        public static int GetVoucherID(string VoucherCode)
        {
            var db            = new Models.WebAppAccEntities(Services.GlobalVariant.GetConnection());
            int _GetVoucherID = 0;
            var row           = db.AppVoucherTables.Where(m => m.VoucherCode == VoucherCode).SingleOrDefault();

            if (row != null)
            {
                _GetVoucherID = row.VoucherID;
            }
            return(_GetVoucherID);
        }
コード例 #9
0
        public static int GetCurrencyIDByIsoCode(string IsoCode)
        {
            var db      = new Models.WebAppAccEntities(Services.GlobalVariant.GetConnection());
            int _result = 0;
            var result  = db.AppCurrencyTables.Where(m => m.IsoCode == IsoCode).SingleOrDefault();

            if (result != null)
            {
                _result = result.CurrencyID;
            }
            return(_result);
        }
コード例 #10
0
        public static int PostStoreProcedure(int VoucherID, long DocumentID)
        {
            string storename = GetPostStoreProcedure(VoucherID);

            if (!string.IsNullOrEmpty(storename))
            {
                storename = string.Format("{0} {1}", storename, DocumentID);
                var db = new Models.WebAppAccEntities(Services.GlobalVariant.GetConnection());
                return(db.Database.ExecuteSqlCommand(storename));
            }
            return(0);
        }
コード例 #11
0
        public static decimal GetUnitPriceSellFC2(int CustomerID, int ItemID, int UOMID, decimal Quantity0)
        {
            var db = new Models.WebAppAccEntities(Services.GlobalVariant.GetConnection());

            decimal _result = 0;
            var     result  = db.Database.SqlQuery <decimal>(string.Format("sp_FcGetUnitPriceSellFC2 {0},{1},{2},{3}", CustomerID, ItemID, UOMID, Quantity0)).ToList();

            if (result != null)
            {
                _result = result[0];
            }
            return(_result);
        }
コード例 #12
0
        public static string GetVATSerial(DateTime VoucherDate)
        {
            var    db      = new Models.WebAppAccEntities(Services.GlobalVariant.GetConnection());
            string _result = "";
            var    result  = db.Database.SqlQuery <string>(string.Format("select vatserial = dbo.fc_GetVATSerial('{0}')", VoucherDate.ToString("yyyyMMdd"))).ToList();

            if (result != null)
            {
                _result = result[0];
            }

            return(_result);
        }
コード例 #13
0
        public static decimal GetExchangeRateLine(DateTime VoucherDate, string CustomerCode, string DisplayNumber)
        {
            var     db      = new Models.WebAppAccEntities(Services.GlobalVariant.GetConnection());
            decimal _result = 1;
            var     result  = db.Database.SqlQuery <decimal>(string.Format("select value=dbo.fc_GetExchangeRateLine('{0}','{1}','{2}')", VoucherDate.ToString("yyyyMMdd"), CustomerCode, DisplayNumber)).ToList();

            if (result != null)
            {
                _result = result[0];
            }

            return(_result);
        }
コード例 #14
0
        public static decimal GetExchangeRate(int CurrencyID, DateTime VoucherDate)
        {
            var     db      = new Models.WebAppAccEntities(Services.GlobalVariant.GetConnection());
            decimal _result = 1;
            var     result  = db.AppExchangeRateViews.Where(m => m.CurrencyID == CurrencyID && m.FromDate <= VoucherDate).OrderByDescending(m => m.FromDate).Take(1).SingleOrDefault();

            if (result != null)
            {
                _result = result.Value;
            }

            return(_result);
        }
コード例 #15
0
        public static decimal GetUnitPriceFC(int ItemID, int CustomerID, DateTime VoucherDate)
        {
            var db = new Models.WebAppAccEntities(Services.GlobalVariant.GetConnection());

            decimal _result = 0;
            var     result  = db.Database.SqlQuery <decimal>(string.Format("sp_FcGetUnitPriceFC {0},{1},'{2}'", CustomerID, ItemID, VoucherDate.ToString("yyyyMMdd"))).ToList();

            if (result != null)
            {
                _result = result[0];
            }
            return(_result);
        }
コード例 #16
0
        public static string GetVoucherNumber(int VoucherID)
        {
            var    db = new Models.WebAppAccEntities(Services.GlobalVariant.GetConnection());
            string _GetVoucherNumber = "";
            int    _IntegerPart      = 0;
            var    row = db.AppVoucherTables.Where(m => m.VoucherID == VoucherID).SingleOrDefault();

            if (row != null)
            {
                _IntegerPart      = int.Parse(row.IntegerPart.ToString()) + 1;
                _GetVoucherNumber = row.AlphaPart + _IntegerPart.ToString();
            }
            return(_GetVoucherNumber);
        }
コード例 #17
0
        public ActionResult Login(Models.AppLoginModel model, string returnUrl)
        {
            try
            {
                if (String.IsNullOrEmpty(model.UserName) || String.IsNullOrEmpty(model.Password) || model.ServiceId == 0)
                {
                    throw new InvalidOperationException("Phải nhập tên đăng nhập và mật khẩu.");
                }

                WebApp.Models.SenContext sendb = new WebApp.Models.SenContext();
                var company = sendb.SenServices.Where(m => m.ServiceId == model.ServiceId && m.UserProfile.UserName == User.Identity.Name).FirstOrDefault();

                if (company.SenCompany.IsApproved != true)
                {
                    throw new InvalidOperationException("Doanh nghiệp đang chờ duyệt./n Không thể truy cập được.");
                }

                string cnn = company.SenCompany.ConnectionString;
                Models.WebAppAccEntities db = new Models.WebAppAccEntities(cnn);

                string CompanyName = db.SysCompanies.Where(m => m.EnumValue == "CompanyName").FirstOrDefault().EnumName;

                Services.GlobalVariant.SetConnection(cnn);
                Services.GlobalVariant.SetCompanyName(CompanyName);

                Services.GlobalVariant.SetCompanyId(company.CompanyId.ToString());

                if (!Services.User.Login(model.UserName, model.Password))
                {
                    throw new InvalidOperationException("Tên đăng nhập và mật khẩu không hợp lệ.");
                }

                WebApp.Services.GlobalUserContext.AddProfile(string.Format(pnameusername, model.ServiceId), model.UserName);
                WebApp.Services.GlobalUserContext.AddProfile(string.Format(pnamepassword, model.ServiceId), model.Password);


                company.SenCompany.LastLoginDate = DateTime.Now;

                sendb.Entry(company.SenCompany).State = System.Data.Entity.EntityState.Modified;
                sendb.SaveChanges();

                return(RedirectToLocal(returnUrl));
            }
            catch (Exception ex)
            {
                Services.GlobalErrors.Parse(ModelState, ex);
                return(View(model));
            }
        }
コード例 #18
0
        public static decimal GetMeasureRate(int?UOMID, int?ItemID)
        {
            var     db      = new Models.WebAppAccEntities(Services.GlobalVariant.GetConnection());
            decimal _Result = 1;
            var     _result = db.Database.SqlQuery <decimal>(string.Format("sp_FcGetMeasureRate '{0}','{1}'", UOMID, ItemID)).ToList();

            if (_result != null)
            {
                _Result = _result[0];
            }

            //_Result = _result.SingleOrDefault();
            //_Result = decimal.Parse(s);
            return(_Result);
        }
コード例 #19
0
        public static List <Models.SysReport> GetReports(string BusinessCode)
        {
            string sessionkeys = string.Format("sysreport.{0}", BusinessCode);

            if (HttpContext.Current.Session[sessionkeys] != null)
            {
                return((List <Models.SysReport>)HttpContext.Current.Session[sessionkeys]);
            }

            var db     = new Models.WebAppAccEntities(Services.GlobalVariant.GetConnection());
            var result = db.SysReports.Where(m => m.BusinessCode == BusinessCode).OrderByDescending(m => m.IsDefault).ToList();

            HttpContext.Current.Session[sessionkeys] = result;
            return(result);
        }
コード例 #20
0
        public static bool CheckLockDate(long DocumentID, DateTime VoucherDate)
        {
            //kiểm tra ngày khóa sổ có 2 trường hợp
            //trường hợp sửa nếu chứng từ đang sửa trước ngày khóa sổ thì không được phép
            //trường hợp tạo mới hoặc sửa chứng từ có ngày sau ngày và người dùng nhập ngày chứng từ nhỏ hơn ngày khóa sổ thì cũng không được phép
            var db       = new Models.WebAppAccEntities(Services.GlobalVariant.GetConnection());
            var lockdate = DateTime.Parse(Services.GlobalVariant.GetSysOption()["LockDate"].ToString());
            var result   = db.Database.SqlQuery <DateTime>(string.Format("Select value=VoucherDate From AppDocumentTable Where DocumentID={0}", DocumentID)).ToList();

            if (result != null && result.Count > 0)
            {
                VoucherDate = result[0];
            }
            return(VoucherDate > lockdate);
        }
コード例 #21
0
        //string usercachekey = "AppAccountingUserKey";
        public static bool Login(string username, string password)
        {
            string strPassword = Accounting.Services.MD5.GenerateHashDigest(username + password);


            Accounting.Models.WebAppAccEntities db = new Models.WebAppAccEntities(Services.GlobalVariant.GetConnection());

            var user = db.SysUserViews.Where(m => m.Name == username && m.Password == strPassword).FirstOrDefault();

            if (user != null)
            {
                //lưu user vào cache
                GlobalVariant.SetAppUser(user);
                return(true);
            }

            return(false);
        }
コード例 #22
0
        public SenVietGeneralObject(HttpRequestBase request, string businesscode)
        {
            this.InitObject();

            this._db           = new Models.WebAppAccEntities(Services.GlobalVariant.GetConnection());
            this._request      = request;
            this._businesscode = businesscode;

            appajaxoption.ajaxoption.Add("ajaxupdateid", string.Format("{0}_container", this._businesscode.ToLower()));
            appajaxoption.ajaxoption.Add("businesscode", this._businesscode);
            appajaxoption.ajaxoption.Add("metaname", this._businesscode);
            appajaxoption.ajaxoption.Add("keyfield", "");
            appajaxoption.ajaxoption.Add("action-return", this._request["action_return"]);

            this.sysbusiness = this._db.SysBusinesses.Where(m => m.BusinessCode == this._businesscode).SingleOrDefault();
            int roleid = Services.GlobalVariant.GetAppUser().RoleID;

            this.sysbusinessrole = this._db.SysBusinessRoles.Where(m => m.BusinessCode == this._businesscode & m.RoleID == roleid).SingleOrDefault();
        }
コード例 #23
0
        //public static Dictionary<string, List<SenViet.Areas.SysAdmin.Models.SysTableDetailView>> MetaData = new Dictionary<string, List<SenViet.Areas.SysAdmin.Models.SysTableDetailView>>();
        //public static Dictionary<string,SenViet.Models.MetaObject> MetaObjects = new Dictionary<string,Models.MetaObject>();

        public static void SetMetaObject(string tablename)
        {
            //Dictionary<string, SenViet.Models.MetaObject> MetaObjects = null;

            Dictionary <string, Models.MetaObject> MetaObjects = null;

            if (HttpContext.Current.Session[CacheKey.GlobalMetaKeys] == null)
            {
                MetaObjects = new Dictionary <string, Models.MetaObject>();
                HttpContext.Current.Session[CacheKey.GlobalMetaKeys] = MetaObjects;
            }
            else
            {
                MetaObjects = (Dictionary <string, Models.MetaObject>)HttpContext.Current.Session[CacheKey.GlobalMetaKeys];
            }


            if (!MetaObjects.ContainsKey(tablename))
            {
                var MetaObject = new Models.MetaObject();
                Models.WebAppAccEntities db = new Models.WebAppAccEntities(Services.GlobalVariant.GetConnection());

                MetaObject.MetaTable = db.SysTableDetailViews.Where(m => m.TableName == tablename).ToList();
                MetaObject.Paging    = new Models.Paging();

                MetaObjects.Add(tablename, MetaObject);
            }
            //else // dành cho phát triển sau này phải bỏ
            //{
            //    var MetaObject = new SenViet.Models.MetaObject();
            //    SenViet.Areas.SysAdmin.Models.SysAdminEntities _slmeta = new SenViet.Areas.SysAdmin.Models.SysAdminEntities();
            //    var _result = _slmeta.SysTableDetailViews.Where(m => m.TableName == tablename).ToList();
            //    MetaObject.MetaTable = _result;
            //    MetaObject.Paging = new Models.Paging();

            //    MetaObjects.Remove(tablename);
            //    MetaObjects.Add(tablename, MetaObject);
            //}
        }
コード例 #24
0
        public ActionResult GetRowByCode(string fieldname, string keyword, string tablename = "")
        {
            Models.WebAppAccEntities db = new Models.WebAppAccEntities(Services.GlobalVariant.GetConnection());
            //int maxRows = 1;
            object rows    = null;
            object results = null;

            switch (fieldname)
            {
            case "WarehouseLineCode":
            case "WarehouseCode":
                var warehousecode = db.Database.SqlQuery <Models.AppWarehouseTable>("Select * from AppWarehouseTable Where WarehouseCode={0}", keyword).SingleOrDefault();
                results = (new { rows = warehousecode });
                return(Json(results, JsonRequestBehavior.AllowGet));

            case "IsoCode":
                var isocode = db.Database.SqlQuery <Models.AppCurrencyTable>("Select * from AppCurrencyTable Where IsoCode={0}", keyword).SingleOrDefault();
                results = (new { rows = isocode });
                return(Json(results, JsonRequestBehavior.AllowGet));

            case "DisplayNumberLineCredit":
            case "DisplayNumberLineDebit":
            case "DisplayNumberCredit":
            case "DisplayNumberDebit":
            case "DisplayNumber":
                var displaynumber = db.Database.SqlQuery <Models.AppAccountView2>("Select * from AppAccountView2 Where DisplayNumber={0}", keyword).SingleOrDefault();
                results = (new { rows = displaynumber });
                return(Json(results, JsonRequestBehavior.AllowGet));

            case "ParentDisplayNumber":
                var parentdisplaynumber = db.Database.SqlQuery <Models.AppAccountView>("Select * from AppAccountView Where DisplayNumber={0}", keyword).SingleOrDefault();
                results = (new { rows = parentdisplaynumber });
                return(Json(results, JsonRequestBehavior.AllowGet));

            case "CustomerCode":
                var customercode = db.Database.SqlQuery <Models.AppCustomerView>("Select * from AppCustomerView Where CustomerCode={0}", keyword).SingleOrDefault();
                results = (new { rows = customercode });
                return(Json(results, JsonRequestBehavior.AllowGet));

            case "CustomerGroupCode":
                var customergroupcode = db.Database.SqlQuery <Models.AppCustomerGroupView>("Select * from AppCustomerGroupView Where CustomerGroupCode={0}", keyword).SingleOrDefault();
                results = (new { rows = customergroupcode });
                return(Json(results, JsonRequestBehavior.AllowGet));

            case "ItemGroupCode":
                var itemgroupcode = db.Database.SqlQuery <Models.AppItemGroupTable>("Select * from AppItemGroupTable Where ItemGroupCode={0}", keyword).SingleOrDefault();
                results = (new { rows = itemgroupcode });
                return(Json(results, JsonRequestBehavior.AllowGet));

            case "ItemCode":
                var itemcode = db.Database.SqlQuery <Models.AppItemView>("Select * from AppItemView Where ItemCode={0}", keyword).SingleOrDefault();
                results = (new { rows = itemcode });
                return(Json(results, JsonRequestBehavior.AllowGet));

            case "UOMLinkCode":
            case "UOMCode":
                var uomcode = db.Database.SqlQuery <Models.AppUnitOfMeasureTable>("Select * from AppUnitOfMeasureTable Where UOMCode={0}", keyword).SingleOrDefault();
                results = (new { rows = uomcode });
                return(Json(results, JsonRequestBehavior.AllowGet));

            case "ItemTypeName":
                var itemtypename = db.Database.SqlQuery <Models.AppItemTypeTable>("Select * from AppItemTypeTable Where EnumName={0}", keyword).SingleOrDefault();
                results = (new { rows = itemtypename });
                return(Json(results, JsonRequestBehavior.AllowGet));

            case "ItemMethodTypeName":
                var itemmethodtypename = db.Database.SqlQuery <Models.AppItemMethodTypeTable>("Select * from AppItemMethodTypeTable Where EnumName={0}", keyword).SingleOrDefault();
                results = (new { rows = itemmethodtypename });
                return(Json(results, JsonRequestBehavior.AllowGet));

            default:
                break;
            }
            return(Json(rows, JsonRequestBehavior.AllowGet));
        }
コード例 #25
0
 public AppVoucherTable(HttpRequestBase request)
 {
     this._db         = new Models.WebAppAccEntities(Services.GlobalVariant.GetConnection());;
     this._request    = request;
     this._metaobject = Services.GlobalMeta.GetMetaObject(this._metaname);
 }
コード例 #26
0
        //public static void MapView2Table(dynamic view, dynamic table, string businesscode)
        //{
        //    var metatable = Services.GlobalMeta.GetMetaObject(businesscode).MetaTable;//lấy meta của bảng gốc

        //    foreach (var item in metatable)
        //    {
        //        string fieldmap = string.Format("{0}", item.ColumnName.ToString());
        //        var value = view.GetType().GetProperty(fieldmap).GetValue(view, null);
        //        table.GetType().GetProperty(fieldmap).SetValue(table, value, null);
        //    }


        //}

        public static ActionResult PrintVoucher <T>(Controller controller, long documentid, int sysreportid, string reporttype = "PDF", System.Collections.Hashtable ReportParameter = null)
        {
            LocalReport localReport = new LocalReport();

            var reportinfo = Services.Report.Uti.GetReport(sysreportid);

            //localReport.ReportPath = controller.Server.MapPath(string.Format("~/Areas/Accounting/Reports/{0}", reportinfo.ReportName)); //Server.MapPath("~/Areas/ACC/Reports/RpInventorySummary1Report.rdlc");

            if (!string.IsNullOrEmpty(reportinfo.ReportPath))
            {
                localReport.ReportPath = controller.Server.MapPath(string.Format("~/Areas/Accounting/Reports/{0}/{1}", reportinfo.ReportPath, reportinfo.ReportName));
            }
            else
            {
                localReport.ReportPath = controller.Server.MapPath(string.Format("~/Areas/Accounting/Reports/{0}", reportinfo.ReportName)); //Server.MapPath("~/Areas/ACC/Reports/RpInventorySummary1Report.rdlc");
            }

            var    db             = new Models.WebAppAccEntities(Services.GlobalVariant.GetConnection());
            string storeprocedure = string.Format("{0} @Key", reportinfo.ProcedureName);

            //var reportdatasource = db.Database.SqlQuery<T>(storeprocedure, new System.Data.SqlClient.SqlParameter { ParameterName = "@Key", Value = string.Format("DocumentID='{0}'", documentid) }).ToList();

            var reportdatasource = db.Database.SqlQuery <T>(storeprocedure, new System.Data.SqlClient.SqlParameter {
                ParameterName = "@Key", Value = string.Format("DocumentID='{0}'", documentid)
            }).ToList();

            ReportDataSource reportDataSource = new ReportDataSource("DSPrint", reportdatasource);

            localReport.DataSources.Add(reportDataSource);

            //Gán giá trị tham số
            Services.Report.ReportUI.InitUIReport(localReport, reportinfo.TableName);

            if (ReportParameter["ReportTitle"] != null)
            {
                ReportParameter.Remove("ReportTitle");
            }
            ReportParameter.Add("ReportTitle", reportinfo.Title);

            Services.Report.ReportUI.SetReportParameter(localReport, ReportParameter);


            string deviceInfo = Services.Report.Uti.GetDeviceInfo(localReport);

            string reportType = reporttype;// Excel, PDF, Word, and Image.
            string mimeType;
            string encoding;
            string fileNameExtension;


            Warning[] warnings;
            string[]  streams;
            byte[]    renderedBytes;

            //Render the report
            renderedBytes = localReport.Render(
                reportType,
                deviceInfo,
                out mimeType,
                out encoding,
                out fileNameExtension,
                out streams,
                out warnings);

            System.Web.Mvc.FileContentResult F = new FileContentResult(renderedBytes, mimeType);

            return(F);
        }