示例#1
0
        public async Task <IActionResult> Edit(int id, [Bind("PaymentID,InvoiceID,PaymentMethod,PaymentType,PaymentAmount")] Payment payment)
        {
            if (id != payment.PaymentID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(payment);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PaymentExists(payment.PaymentID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["InvoiceID"] = new SelectList(_context.Invoice, "InvocieID", "InvocieID", payment.InvoiceID);
            return(View(payment));
        }
 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) }));
 }
        public async Task <IActionResult> Edit(int id, [Bind("InvoiceID,ItemID")] InvoiceItem invoiceItem)
        {
            if (id != invoiceItem.InvoiceID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(invoiceItem);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!InvoiceItemExists(invoiceItem.InvoiceID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                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));
        }
 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) }));
 }
示例#5
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) }));
 }
示例#7
0
        public async Task <IActionResult> Edit(int id, [Bind("JobID,CustomerId,DoctorID,JobDate,Branch")] Job job)
        {
            if (id != job.JobID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(job);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!JobExists(job.JobID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CustomerId"] = new SelectList(_context.Customer, "CustomerID", "Address", job.CustomerId);
            ViewData["DoctorID"]   = new SelectList(_context.Doctor, "DoctorID", "Address", job.DoctorID);
            return(View(job));
        }