Example #1
0
        public int ReportGeneration(ReportModel reportModel)
        {
            try
            {
                string d1, d2;
                string rdate = reportModel.receivingDate;
                string cdate = reportModel.cancelDate;
                d1 = rdate.Replace("-", "");
                d2 = cdate.Replace("-", "");

                d1 = d1.Substring(2);
                d2 = d2.Substring(2);

                ReportDto newReport = new ReportDto
                {
                    pONumber      = reportModel.pONumber,
                    storeNumber   = reportModel.storeNumber,
                    vendorCode    = reportModel.vendorCode,
                    receivingDate = d1,
                    cancelDate    = d2,
                    login_dto     = new LoginDto
                    {
                        servername = Session["servername"].ToString(),
                        username   = Session["username"].ToString(),
                        password   = Session["password"].ToString(),
                        dBname     = Session["databasename"].ToString()
                    },
                };

                var report = _reportServices.ReportAll(newReport);
                IEnumerable <ReportDto> newreportList = report.Select(a => new ReportDto
                {
                    report_id     = Session["reportId"].ToString(),
                    pONumber      = a.pONumber,
                    rANumber      = a.rANumber,
                    aSAuto        = a.aSAuto,
                    storeNumber   = a.storeNumber,
                    storeName     = a.storeName,
                    vendorCode    = a.vendorCode,
                    vendorName    = a.vendorName,
                    receivingDate = a.receivingDate,
                    cancelDate    = a.cancelDate,
                    ti            = a.ti,
                    hi            = a.hi,
                    Location      = a.Location,
                    iNumber       = a.iNumber,
                    iDecription   = a.iDecription,
                    upc           = a.upc,
                    um            = a.um,
                    orderQty      = a.orderQty
                });


                _reportServices.Add(newreportList);
                var reportcount = newreportList.Count();

                if (reportcount > 0)
                {
                    return(1);
                }
                else
                {
                    return(0);
                }
            }
            catch (Exception ex)
            {
                TempData["errorMessage"] = "System Error: " + ex.Message;
                return(0);
            }
        }