Exemplo n.º 1
0
        public IHttpActionResult PutLocation(int id, Location location)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != location.LocationId)
            {
                return(BadRequest());
            }

            db.Entry(location).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!LocationExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 2
0
        public IHttpActionResult PutSubCategory(int locationId, int departmentId, int categoryId, int subCategoryId, SubCategory subCategory)
        {
            if (subCategory.CategoryId != categoryId)
            {
                return(Ok("different category values"));
            }

            InventoryAgent ia = new InventoryAgent();

            if (ia.SubCategoryExists(locationId, departmentId, categoryId, subCategoryId))
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                if (subCategoryId != subCategory.SubCategoryId)
                {
                    return(BadRequest());
                }

                db.Entry(subCategory).State = EntityState.Modified;

                try
                {
                    db.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SubCategoryExists(subCategoryId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }

                return(StatusCode(HttpStatusCode.NoContent));
            }
            else
            {
                return(Ok("data not found"));
            }
        }
Exemplo n.º 3
0
        public IHttpActionResult PutDepartment(int locationId, int departmentId, Department department)
        {
            if (department.LocationId != locationId)
            {
                return(Ok("different location values"));
            }

            InventoryAgent ia = new InventoryAgent();

            if (ia.DepartmentExists(locationId, departmentId))
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                if (departmentId != department.DepartmentId)
                {
                    return(BadRequest());
                }

                db.Entry(department).State = EntityState.Modified;

                try
                {
                    db.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DepartmentExists(departmentId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }

                return(StatusCode(HttpStatusCode.NoContent));
            }
            else
            {
                return(Ok("data not found"));
            }
        }
Exemplo n.º 4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            receipt.Bill = (Bill)cmbBills.SelectedItem;
            double amount;
            bool   result = Double.TryParse(txtAmount.Text, out amount);

            receipt.Amount = result ? amount : 0;
            receipt.Date   = dtDate.Value.Date;
            context.SaveChanges();

            InitializeData();
        }
Exemplo n.º 5
0
 public ActionResult Edit(int id, DokumentFakture dokument)
 {
     try
     {
         // TODO: Add update logic here
         using (LocalDBEntities dbEntity = new LocalDBEntities())
         {
             string idStr = id.ToString();
             dbEntity.Entry(dokument).State = System.Data.EntityState.Modified;
             dbEntity.SaveChanges();
         }
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Exemplo n.º 6
0
 public ActionResult Create(DokumentFakture dokument)
 {
     // TODO: Add insert logic here
     try
     {
         using (LocalDBEntities dBEntity = new LocalDBEntities())
         {
             dBEntity.DokumentFaktures.Add(dokument);
             dBEntity.SaveChanges();
         }
         return(RedirectToAction("Index"));
     }
     catch
     {
         System.Windows.Forms.MessageBox.Show("Faktura nije dodata!");
         return(View());
     }
 }
Exemplo n.º 7
0
 public ActionResult Delete(string id, FormCollection collection)
 {
     try
     {
         // TODO: Add delete logic here
         using (LocalDBEntities dbEntity = new LocalDBEntities())
         {
             DokumentFakture dokument = dbEntity.DokumentFaktures.Where(x => x.RedniBroj == id).FirstOrDefault();
             dbEntity.DokumentFaktures.Remove(dokument);
             dbEntity.SaveChanges();
         }
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Exemplo n.º 8
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            order.Date = txtDate.Value.Date;
            Func <Customer> createCustomer =
                () => {
                Customer c = new Customer();
                c.Name = cmbCustomerName.Text;
                context.Customers.AddObject(c);
                return(c);
            };

            order.Customer = cmbCustomerName.SelectedValue == null?createCustomer() : (Customer)cmbCustomerName.SelectedValue;

            order.Venue = txtVenue.Text;
            order.Customer.ContactNo = txtContactNo.Text;
            order.Note = txtNote.Text;
            context.SaveChanges(SaveOptions.AcceptAllChangesAfterSave);
            MessageBox.Show("Saved Successfully");
            InitializeData();
            grdOrders_SelectionChanged(null, null);
        }
Exemplo n.º 9
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     //put the line level info into the bill lines
     foreach (DataGridViewRow row in grdBillLines.Rows)
     {
         double amount;
         //new rows
         if (row.Cells["BillLineId"].Value == null ||
             row.Cells["BillLineId"].Value.ToString() == "" ||
             row.Cells["BillLineId"].Value.ToString() == "0")
         {
             BillLine line = new BillLine();
             if (!Double.TryParse(row.Cells["AmountShown"].Value.ToString(), out amount))
             {
                 amount = 0;
             }
             line.Amount      = amount;
             line.OrderItemId = Convert.ToInt32(row.Cells["ItemId"].Value);
             bill.BillLines.Add(line);
         }
         else
         {
             //existing bill lines
             int      billLineId = Convert.ToInt32(row.Cells["BillLineId"].Value);
             BillLine line       = bill.BillLines.Where(p => p.Id == billLineId).First();
             if (!Double.TryParse(row.Cells["AmountShown"].Value.ToString(), out amount))
             {
                 amount = 0;
             }
             line.Amount = amount;
         }
     }
     if (bill.Id == 0)
     {
         context.Bills.AddObject(bill);
     }
     context.SaveChanges(SaveOptions.AcceptAllChangesAfterSave);
     MessageBox.Show("Saved Successfully");
     InitializeData();
 }