// GET: Bill_Information/Create public async Task <IActionResult> Create() { var model = await _context.Bill_Information.ToListAsync(); string id = "BIJPS00" + (model.Count() + 1).ToString(); List <SeletedCustomer> temp_cust_list = new List <SeletedCustomer>(); var users = userManager.Users; foreach (var user in users) { SeletedCustomer _user = new SeletedCustomer { cust_id = user.Id }; temp_cust_list.Add(_user); } Bill_Information data = new Bill_Information { bill_id = id, date_generated = DateTime.Now, due_date = DateTime.Now.AddDays(10), cust_ids = temp_cust_list, cust_id = null, address = null, amount = null, premise_id = null, status = "PENDING" }; return(View(data)); }
// GET: Bill_Information/Details/5 public async Task <IActionResult> Details(string id) { if (id == null) { return(NotFound()); } var item = await _context.Bill_Information .FirstOrDefaultAsync(m => m.bill_id == id); Bill_Information bill_Information = new Bill_Information { address = item.address, amount = item.amount, bill_id = item.bill_id, cust_id = item.cust_id, date_generated = item.date_generated, due_date = item.due_date, premise_id = item.premise_id, status = item.status }; if (bill_Information == null) { return(NotFound()); } return(View(bill_Information)); }
public async Task <IActionResult> Create([Bind("bill_id,date_generated,due_date,cust_ids,cust_id,premise_id,address,amount,status")] Bill_Information bill_Information) { if (ModelState.IsValid) { JPSUser data = await userManager.FindByIdAsync(bill_Information.cust_id); bill_Information.premise_id = data.premise_number; var address = await _context.PREMISE_DETAILS.FirstOrDefaultAsync(m => m.ID == "PREPJPS200"); bill_Information.address = address.LOCATION_ADDRESS; BillDatabaseModel model = new BillDatabaseModel { address = bill_Information.address, amount = bill_Information.amount, bill_id = bill_Information.bill_id, cust_id = bill_Information.cust_id, date_generated = bill_Information.date_generated, due_date = bill_Information.due_date, premise_id = bill_Information.premise_id, status = bill_Information.status }; _context.Bill_Information.Add(model); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(bill_Information)); }
public List <Bill_Information> GetListBillInfo(int id) { List <Bill_Information> listBillInfo = new List <Bill_Information>(); DataTable data = DataProvider.Instance.ExecuteQuery("SELECT * FROM dbo.Bill_Information WHERE Id_Bill_Status = " + id); foreach (DataRow item in data.Rows) { Bill_Information bill_information = new Bill_Information(item); listBillInfo.Add(bill_information); } return(listBillInfo); }
public async Task <IActionResult> Edit(string id, [Bind("bill_id,date_generated,due_date,cust_id,premise_id,address,amount,status")] Bill_Information bill_Information) { if (id != bill_Information.bill_id) { return(NotFound()); } if (ModelState.IsValid) { try { BillDatabaseModel model = new BillDatabaseModel { address = bill_Information.address, amount = bill_Information.amount, bill_id = bill_Information.bill_id, cust_id = bill_Information.cust_id, date_generated = bill_Information.date_generated, due_date = bill_Information.due_date, premise_id = bill_Information.premise_id, status = bill_Information.status }; _context.Update(model); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!Bill_InformationExists(bill_Information.bill_id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(bill_Information)); }