예제 #1
0
 public async Task <IActionResult> AddOrEdit(int id, [Bind("CustomerID,CustomerType,CustomerName,Gender,BirthDate,Address,ContactNumber,EmailAddress")] Customer customer)
 {
     if (ModelState.IsValid)
     {
         if (id == 0)
         {
             _context.Add(customer);
             await _context.SaveChangesAsync();
         }
         else
         {
             try
             {
                 _context.Update(customer);
                 await _context.SaveChangesAsync();
             }
             catch (DbUpdateConcurrencyException)
             {
                 if (!CustomerExists(customer.CustomerID))
                 {
                     return(NotFound());
                 }
                 else
                 {
                     throw;
                 }
             }
         }
         return(Json(new { isValid = true, html = Helper.RenderRazorViewToString(this, "_ViewAll", _context.Customer.ToList()) }));
     }
     return(Json(new { isValid = false, html = Helper.RenderRazorViewToString(this, "AddOrEdit", customer) }));
 }
예제 #2
0
 public async Task <IActionResult> AddOrEdit(int id, [Bind("DoctorID,DoctorName,Address,ContactNumber,Designation,EmailAddress")] Doctor doctor)
 {
     if (ModelState.IsValid)
     {
         if (id == 0)
         {
             _context.Add(doctor);
             await _context.SaveChangesAsync();
         }
         else
         {
             try
             {
                 _context.Update(doctor);
                 await _context.SaveChangesAsync();
             }
             catch (DbUpdateConcurrencyException)
             {
                 if (!DoctorExists(doctor.DoctorID))
                 {
                     return(NotFound());
                 }
                 else
                 {
                     throw;
                 }
             }
         }
         return(Json(new { isValid = true, html = Helper.RenderRazorViewToString(this, "_ViewAll", _context.Doctor.ToList()) }));
     }
     return(Json(new { isValid = false, html = Helper.RenderRazorViewToString(this, "AddOrEdit", doctor) }));
 }
예제 #3
0
 public async Task <IActionResult> AddOrEdit(int id, [Bind("ItemID,ItemName,ItemCatergory,UOM,ItemPrice")] Item item)
 {
     if (ModelState.IsValid)
     {
         if (id == 0)
         {
             _context.Add(item);
             await _context.SaveChangesAsync();
         }
         else
         {
             try
             {
                 _context.Update(item);
                 await _context.SaveChangesAsync();
             }
             catch (DbUpdateConcurrencyException)
             {
                 if (!ItemExists(item.ItemID))
                 {
                     return(NotFound());
                 }
                 else
                 {
                     throw;
                 }
             }
         }
         return(Json(new { isValid = true, html = Helper.RenderRazorViewToString(this, "_ViewAll", _context.Item.ToList()) }));
     }
     return(Json(new { isValid = false, html = Helper.RenderRazorViewToString(this, "AddOrEdit", item) }));
 }
 public async Task <IActionResult> AddOrEdit(int id, [Bind("TestComponentID,ItemID,ComponentName,UOM,RefRange,Percentage,CTM,CMax,CMin")] TestComponent testComponent)
 {
     if (ModelState.IsValid)
     {
         if (id == 0)
         {
             _context.Add(testComponent);
             await _context.SaveChangesAsync();
         }
         else
         {
             try
             {
                 _context.Update(testComponent);
                 await _context.SaveChangesAsync();
             }
             catch (DbUpdateConcurrencyException)
             {
                 if (!TestComponentExists(testComponent.TestComponentID))
                 {
                     return(NotFound());
                 }
                 else
                 {
                     throw;
                 }
             }
         }
         return(Json(new { isValid = true, html = Helper.RenderRazorViewToString(this, "_ViewAll", _context.TestComponent.ToList()) }));
     }
     ViewData["ItemID"] = new SelectList(_context.Item, "ItemID", "ItemName", testComponent.ItemID);
     return(Json(new { isValid = false, html = Helper.RenderRazorViewToString(this, "AddOrEdit", testComponent) }));
 }
예제 #5
0
        public async Task <IActionResult> Create([Bind("PaymentID,InvoiceID,PaymentMethod,PaymentType,PaymentAmount")] Payment payment)
        {
            if (ModelState.IsValid)
            {
                _context.Add(payment);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index", "Invoices"));
            }
            ViewData["InvoiceID"] = new SelectList(_context.Invoice, "InvocieID", "InvocieID", payment.InvoiceID);
            return(View(payment));
        }
        public async Task <IActionResult> Create([Bind("InvoiceID,ItemID")] InvoiceItem invoiceItem)
        {
            if (ModelState.IsValid)
            {
                _context.Add(invoiceItem);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["InvoiceID"] = new SelectList(_context.Invoice, "InvocieID", "InvocieID", invoiceItem.InvoiceID);
            ViewData["ItemID"]    = new SelectList(_context.Item, "ItemID", "ItemID", invoiceItem.ItemID);
            return(View(invoiceItem));
        }
예제 #7
0
        public async Task <IActionResult> Create([Bind("JobID,CustomerId,DoctorID,JobDate,Branch")] Job job)
        {
            if (ModelState.IsValid)
            {
                _context.Add(job);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Create", "Invoices", new { id = job.JobID }));
            }
            ViewData["CustomerId"] = new SelectList(_context.Customer, "CustomerID", "CustomerName", job.CustomerId);
            ViewData["DoctorID"]   = new SelectList(_context.Doctor, "DoctorID", "DoctorName", job.DoctorID);
            return(View(job));
        }
예제 #8
0
        public async Task <IActionResult> Create([Bind("InvocieID,JobID,InvoiceData,InvoiceState,InvoiceTotal")] Invoice invoice, string[] selectedItems)
        {
            ViewBag.invoiceTotal = null;

            if (selectedItems != null)
            {
                invoice.InvoiceItem = new List <InvoiceItem>();
                foreach (var item in selectedItems)
                {
                    var itemToAdd = new InvoiceItem {
                        InvoiceID = invoice.InvocieID, ItemID = int.Parse(item)
                    };
                    invoice.InvoiceItem.Add(itemToAdd);
                }
            }

            var jobCommision = new JobCommision
            {
                JobID       = invoice.JobID,
                CreatedDate = invoice.InvoiceData,
                Earning     = invoice.InvoiceTotal * 3 / 100
            };

            if (ModelState.IsValid)
            {
                _context.Add(invoice);
                await _context.SaveChangesAsync();

                _context.Add(jobCommision);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["JobID"] = new SelectList(_context.Job, "JobID", "JobID", invoice.JobID);
            PopulateInvoiceItems(invoice);

            return(View(invoice));
        }