Exemplo n.º 1
0
        public bool editBill(int id)
        {
            DataClasses1DataContext db = new DataClasses1DataContext();
            //Bill_Item item = db.Bill_Items.Single(p => p.Id == id) ?? return false;
            //Needs work

            return false;
        }
Exemplo n.º 2
0
        public void doStuff()
        {
            DataClasses1DataContext db = new DataClasses1DataContext();
            //Bill_Item item = db.Bill_Items.Single(p => p.Title == "123") ?? null;

            //item.Description = "This was changed! Yay";
            //item._Title = "No work";

            db.SubmitChanges();
            List<Bill_Item> billList = getAllBills();
        }
Exemplo n.º 3
0
        public bool deleteBill(int billId , DataClasses1DataContext db)
        {
            //DataClasses1DataContext db = new DataClasses1DataContext();
            var deleteB = getBillById(billId);
            db.Bill_Items.DeleteOnSubmit(deleteB);

            try
            {
                db.SubmitChanges();
            }catch (Exception e)
            {
                Console.Write(e);
                return false;
            }
            return true;
        }
Exemplo n.º 4
0
 public bool addNewBill()
 {
     DataClasses1DataContext db = new DataClasses1DataContext();
     db.Bill_Items.InsertOnSubmit(this);
     try
     {
         db.SubmitChanges();
     }
     catch (Exception ex)
     {
         Console.Write(ex);
     }
     //BillModel
     //Bill_Item item = new Bill_Item();
     return false;
 }
Exemplo n.º 5
0
 //
 // GET: /Bill/Delete/5
 public ActionResult Delete(int id)
 {
     try
     {
         DataClasses1DataContext db = new DataClasses1DataContext();
         Bill_Item bill = db.Bill_Items.Single(p => p.Id == id);
         db.Bill_Items.DeleteOnSubmit(bill);
         db.SubmitChanges();
         return RedirectToAction("Index");
     }
     catch (Exception e)
     {
         Console.Write(e.StackTrace);
         return View("Index"); //TODO: Return Error view
     }
 }
Exemplo n.º 6
0
 public Bill_Item getBillById(int id)
 {
     DataClasses1DataContext db = new DataClasses1DataContext();
     return db.Bill_Items.Single<Bill_Item>(p => p.Id == id);
 }
Exemplo n.º 7
0
 public List<Bill_Item> getAllBills()
 {
     DataClasses1DataContext db = new DataClasses1DataContext();
     return db.Bill_Items.ToList();
 }
Exemplo n.º 8
0
 public ActionResult Edit(BillModel model)
 {
     try
     {
         DataClasses1DataContext db = new DataClasses1DataContext();
         BudgetGuru.DataLayer.Bill_Item bill = new Bill_Item();
         Bill_Item item = db.Bill_Items.Single(p => p.Id == model.billId); //Load by primary key. Ideal way to update using Linq-SQL
         //bill.Id = model.billId;
         item.Title = model.billTitle ?? string.Empty;
         item.Description = model.billDescription ?? string.Empty;
         item.DueDate = Convert.ToDateTime(model.datepicker);
         item.Amout = Convert.ToDecimal(model.billAmt);
         db.SubmitChanges();
         //bill.updateBill(model.billId);
         return RedirectToAction("Index");
     }
     catch (Exception e)
     {
         return View();
     }
 }