public IActionResult Index() { ViewBag.data = HttpContext.Session.GetObject(SD.Sessionname); ViewBag.branch = HttpContext.Session.GetObject(SD.Statusbranch); ViewBag.roll = HttpContext.Session.GetString("roll"); string Branch = ViewBag.branch; loadtemp load = new loadtemp(); var billno = _context.purchaseinvoicesummeries.OrderByDescending(i => i.Billid).Where(i => i.Branch == Branch).FirstOrDefault(); if (billno != null) { ViewBag.Billno = billno.Billid + 1; } else { ViewBag.Billno = 1; } int bill = ViewBag.Billno; var tmp = _context.tmppurchases.Where(i => i.Branch == Branch).ToList(); foreach (var item in tmp) { load.tmppurchases.Add(item); } return(View(load)); }
public IActionResult Index() { ViewBag.data = HttpContext.Session.GetObject(SD.Sessionname); ViewBag.branch = HttpContext.Session.GetObject(SD.Statusbranch); ViewBag.roll = HttpContext.Session.GetObject(SD.Statusroll); string Branch = ViewBag.branch; loadtemp load = new loadtemp(); ViewBag.Branch = _context.branch.Where(i => i.Branchname == Branch).FirstOrDefault(); var billno = _context.salesinvoicesummery.OrderByDescending(i => i.Billid).Where(i => i.Branch == Branch).FirstOrDefault(); //bill No if (billno != null) { ViewBag.Billno = billno.Billid + 1; } else { ViewBag.Billno = 1; } int bill = ViewBag.Billno; //for print if (bill != 0) { int bi = bill - 1; var tmp = _context.tempseccions.Where(i => i.Branch == Branch).ToList(); var tmpsale = _context.salesinvoices.Where(i => i.Branch == Branch && i.Billno == bi).ToList(); if (tmp.Count != 0) { foreach (var item in tmp) { load.tempseccions.Add(item); } } else { foreach (var item in tmpsale) { load.salesinvoices.Add(item); } var tmpsummery = _context.salesinvoicesummery.Where(i => i.Billid == bi && i.Branch == Branch).ToList(); if (tmpsummery != null) { foreach (var item in tmpsummery) { // var istdate = TimeZoneInfo.ConvertTimeFromUtc(item.Billdate, TimeZoneInfo.FindSystemTimeZoneById("India Standard Time")); TimeZoneInfo timeZone = TZConvert.GetTimeZoneInfo("India Standard Time"); var isdate = TimeZoneInfo.ConvertTime(item.Billdate, timeZone); ViewBag.billdate = isdate; load.salesinvoicesummeries.Add(item); } } } } return(View(load)); }