private void CreateBatchBtn_Click_1(object sender, RoutedEventArgs e) { if (cashier == null) { MessageBox.Show("Cashier not found. Please contact the administrator"); return; } if (station == null) { MessageBox.Show("Station not found. Please contact the administrator"); return; } if (batch == null) { using (var ctx = new RMSModel()) { batch = new Batch() { OpeningCash = System.Convert.ToDouble(OpeningAmountTxt.Text), OpeningTime = DateTime.Now, Status = "Open", StationId = station.StationId, OpeningCashier = cashier.Id, TrackingState = TrackingState.Added //, OpenCashier = cashier //,Station = station }; ctx.ApplyChanges(batch); // ctx.Batches.Add(batch); OpenDrawerGrd.DataContext = batch; ctx.SaveChanges(); batch.AcceptChanges(); } } else { OpenDrawerGrd.DataContext = batch; MessageBox.Show("Batch already open. Please close batch before proceding!"); return; } }