Beispiel #1
0
        private void FisherDeviceAssignmentCollection_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            _editSuccess = false;
            switch (e.Action)
            {
            case NotifyCollectionChangedAction.Add:
            {
                int newIndex = e.NewStartingIndex;
                FisherDeviceAssignment newFDA = FisherDeviceAssignmentCollection[newIndex];

                _editSuccess = FisherDeivieAssignments.Add(newFDA);
                if (_editSuccess)
                {
                    CurrentEntity = newFDA;
                }
            }
            break;

            case NotifyCollectionChangedAction.Remove:
            {
                List <FisherDeviceAssignment> tempListOfRemovedItems = e.OldItems.OfType <FisherDeviceAssignment>().ToList();
                _editSuccess = FisherDeivieAssignments.Delete(tempListOfRemovedItems[0].RowID);
            }
            break;

            case NotifyCollectionChangedAction.Replace:
            {
                List <FisherDeviceAssignment> tempList = e.NewItems.OfType <FisherDeviceAssignment>().ToList();
                _editSuccess = FisherDeivieAssignments.Update(tempList[0]);
            }
            break;
            }
        }
Beispiel #2
0
        private List <FisherDeviceAssignment> getFisherDeviceAssignments()
        {
            List <FisherDeviceAssignment> list = new List <FisherDeviceAssignment>();
            var dt = new DataTable();

            using (var conection = new OleDbConnection(Global.ConnectionString))
            {
                try
                {
                    conection.Open();
                    string query = $"Select * from FisherDeviceAssignment";


                    var adapter = new OleDbDataAdapter(query, conection);
                    adapter.Fill(dt);
                    if (dt.Rows.Count > 0)
                    {
                        list.Clear();
                        foreach (DataRow dr in dt.Rows)
                        {
                            FisherDeviceAssignment fda = new FisherDeviceAssignment();
                            fda.RowID        = (int)dr["RowID"];
                            fda.Fisher       = Entities.FisherViewModel.GetFisher((int)dr["FisherID"]);
                            fda.DeviceID     = dr["DeviceID"].ToString();
                            fda.AssignedDate = (DateTime)dr["DateAssigned"];
                            if (dr["DateReturned"] != null)
                            {
                                fda.RetunDate = (DateTime)dr["DateReturned"];
                            }
                            list.Add(fda);
                        }
                    }
                }
                catch (OleDbException dbex)
                {
                    switch (dbex.ErrorCode)
                    {
                    case -2147217904:
                        //No value given for one or more required parameters.
                        break;

                    case -2147217865:
                        //table not found
                        CreateTable();
                        break;
                    }
                }
                catch (Exception ex)
                {
                    Logger.Log(ex);
                }
            }
            return(list);
        }
Beispiel #3
0
        public bool AddRecordToRepo(FisherDeviceAssignment fda)
        {
            if (fda == null)
            {
                throw new ArgumentNullException("Error: The argument is Null");
            }

            FisherDeviceAssignmentCollection.Add(fda);

            return(_editSuccess);
        }
Beispiel #4
0
        public bool UpdateRecordInRepo(FisherDeviceAssignment fda)
        {
            if (fda == null)
            {
                throw new Exception("Error: The argument is Null");
            }

            int index = 0;

            while (index < FisherDeviceAssignmentCollection.Count)
            {
                if (FisherDeviceAssignmentCollection[index].RowID == fda.RowID)
                {
                    FisherDeviceAssignmentCollection[index] = fda;
                    break;
                }
                index++;
            }
            return(_editSuccess);
        }
Beispiel #5
0
 public bool Update(FisherDeviceAssignment fda)
 {
     return(true);
 }
Beispiel #6
0
 public bool Add(FisherDeviceAssignment fda)
 {
     return(true);
 }