Example #1
0
        public void InsertOrUpdate(Employee employee)
        {
            if (employee.EmployeeId == default(int))
            {
                context.Entry(employee).State = EntityState.Added;
            }

            else
            {
                context.Entry(employee).State = EntityState.Modified;
            }
        }
Example #2
0
 public void InsertOrUpdate(Inventory inventory)
 {
     if (inventory.OrderReceiptID == default(int))
     {
         context.Entry(inventory).State = EntityState.Added;
         context.Inventory.Add(inventory);
     }
     else
     {
         context.Entry(inventory).State = EntityState.Modified;
     }
 }
Example #3
0
 public void InsertOrUpdate(PurchaseOrder order)
 {
     if (order.OrderNum == default(int))
     {
         context.Entry(order).State = EntityState.Added;
         context.PurchaseOrder.Add(order);
     }
     else
     {
         context.PurchaseOrder.Attach(order);
     }
 }
Example #4
0
 private void BsAssemblies_AddingNew(object sender, AddingNewEventArgs e)
 {
     if (_selectedJob != null)
     {
         Assembly newAssembly = new Assembly {
             JobID = _selectedJob.JobId, Depth = 0.0m, Height = 0.0m, Width = 0.0m
         };
         _context.Entry(newAssembly).State = Microsoft.EntityFrameworkCore.EntityState.Added;
         e.NewObject = newAssembly;
     }
 }
 public void InsertOrUpdate(OrderReciept orderReciept)
 {
     if (orderReciept.OrderReceiptId == default(int))
     {
         context.OrderReciept.Add(orderReciept);
     }
     else
     {
         context.Entry(orderReciept).State = EntityState.Modified;
     }
 }
Example #6
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            // If the part is new-detached
            if (_context.Entry(_part).State == EntityState.Detached)
            {
                _context.Part.Add(_part);
            }

            // Date and Name stamp modifications --
            var user = Globals.CurrentLoggedUserID;

            _part.ModifiedBy   = Globals.CurrentUserName;
            _part.ModifiedDate = DateTime.Today;
            //-------------------------------------
            _context.SaveChanges();

            _isDirty = false;
            TabPage    tabpage    = (TabPage)this.Parent;
            TabControl tabControl = (TabControl)tabpage.Parent;

            tabControl.TabPages.Remove(tabpage);
        }
Example #7
0
 private void AddPartbyNumber(Part part)
 {
     if (part != null)
     {
         var newLine = new PurchaseLineItem
         {
             Description     = part.ItemDescription,
             PartID          = part.PartID,
             UnitCost        = part.Cost,
             Uom             = part.UID,
             Qnty            = 1.0m,
             Extended        = 0.0m,
             AmountReceived  = 0.0m,
             PurchaseOrderId = 5000
         };
         ctx.Entry(newLine).State = Microsoft.EntityFrameworkCore.EntityState.Added;
         var addLine = new PurchaseLineItemWrapper(newLine);
         bsLineItems.Add(addLine);
         _isDirty        = true;
         btnSave.Enabled = _isDirty;
     }
 }