/// <summary> /// Finds the record based on id of the EquipmentMaintenance. /// </summary> /// <param name="filePath"></param> /// <param name="equipMaintenanceID"></param> /// <returns></returns> public EquipmentMaintenance Find(int equipMaintenanceID) { FileOperations objEquipMaintenanceDB = new FileOperations(); EquipmentMaintenance objEquipMaintenance = new EquipmentMaintenance(); List<EquipmentMaintenance> objEquipMaintenanceColl = SelectAllData(); return objEquipMaintenanceColl.FirstOrDefault(equipMaintenance => equipMaintenance.MaintenanceWorkId == equipMaintenanceID); }
public bool AddRecord(EquipmentMaintenance objEquipMaintenance) { FileOperations objEquipMaintenanceDB = new FileOperations(); string data = (GetMaxID() + 1).ToString() + "," + objEquipMaintenance.Date.Date.ToString("dd/MM/yyyy") +","+ objEquipMaintenance.Time+","+objEquipMaintenance.WorksDescription+","+objEquipMaintenance.ObjEquip.ID.ToString()+"," +objEquipMaintenance.TimeTaken.ToString(); return objEquipMaintenanceDB.Add(EquipmentMaintenaceFilePath, data); }
/// <summary> /// Returns EquipmentMaintenace object /// </summary> /// <param name="MaintenanceWorkId"></param> /// <param name="Date"></param> /// <param name="Time"></param> /// <param name="WorksDescription"></param> /// <param name="EquipmentId"></param> /// <param name="TimeTaken"></param> /// <returns></returns> public EquipmentMaintenance GetEquipmentMaintenace(string MaintenanceWorkId, string Date, string Time, string WorksDescription, string EquipmentId, string TimeTaken) { EquipmentMaintenance objEquipmentMaintenace = new EquipmentMaintenance(); EquipmentBL objEquipBL = new EquipmentBL(EquipmentFilePath); Equipment objEquip = objEquipBL.Find(int.Parse(EquipmentId)); objEquipmentMaintenace.MaintenanceWorkId = int.Parse(MaintenanceWorkId); objEquipmentMaintenace.Date = DateTime.ParseExact(Date, "d/MM/yyyy", null); objEquipmentMaintenace.TimeTaken = int.Parse(TimeTaken); objEquipmentMaintenace.Time = Time; objEquipmentMaintenace.WorksDescription = WorksDescription; if (objEquip == null) objEquipmentMaintenace.ObjEquip = new Equipment(); else objEquipmentMaintenace.ObjEquip = objEquip; return objEquipmentMaintenace; }
/// <summary> /// Searches required string by ID and then replaces old value with new value. /// </summary> /// <param name="filePath"></param> /// <param name="objEquipMaintenance"></param> /// <returns></returns> private ArrayList Edit( EquipmentMaintenance objNewEquipMaintenance) { FileOperations objEquipMaintenaceDB = new FileOperations(); List<EquipmentMaintenance> objEquipMaintenaceColl = SelectAllData(); ArrayList lines = new ArrayList(); lines.Add("MaintenanceWorkId,Date,Time,WorksDescription,EquipmentId,TimeTaken"); foreach (EquipmentMaintenance equipMaintenace in objEquipMaintenaceColl) { if (equipMaintenace.MaintenanceWorkId == objNewEquipMaintenance.MaintenanceWorkId) lines.Add(objNewEquipMaintenance.ToString()); else lines.Add(equipMaintenace.ToString()); } return lines; }
public bool UpdateRecord( EquipmentMaintenance objEquipMaintenance) { FileOperations objEquipMaintenanceDB = new FileOperations(); ArrayList lines = Edit( objEquipMaintenance); //This searches the targeted id and replaces name string. return objEquipMaintenanceDB.Update(EquipmentMaintenaceFilePath, lines); }