public static Boolean CreateDataLogger(DataLogger logger) { Boolean flag = false; if (!(IsExistingDataLogger(logger))) { using (TransactionScope scope = new TransactionScope()) { using (var context = new SycousCon()) { try { context.DataLoggers.AddObject(logger); context.SaveChanges(); scope.Complete(); context.AcceptAllChanges(); flag = true; } catch (Exception ex) { context.Dispose(); throw; } }// }// using }//if return flag; }
public bool UpdateRecord(Object loggerobj) { Boolean flag = false; DataLoggerMaster logger = (DataLoggerMaster)loggerobj; try { DataLogger _Logger = new DataLogger(); _Logger.ID = Convert.ToInt32(logger.ID); if (logger.DataCollectorMake != null) { _Logger.DataCollectorMake = logger.DataCollectorMake.Trim(); } if (logger.DataCollectorModel != null) { _Logger.DataCollectorModel = logger.DataCollectorModel.Trim(); } if (logger.SerialNumber != null) { _Logger.SerialNumber = logger.SerialNumber.Trim(); } if (logger.SimNumber != null) { _Logger.SimNumber = logger.SimNumber.Trim(); } if (logger.Telephone != null) { _Logger.Telephone = logger.Telephone.Trim(); } if (logger.Location != null) { _Logger.Location = logger.Location.Trim(); } if (logger.RetrievalID != null) { _Logger.RetrievalID = logger.RetrievalID; } if (logger.IPAddress != null) { _Logger.IPAddress = logger.IPAddress.Trim(); } _Logger.ModifyBy = logger.modifyBy; _Logger.ModifyDate = DateTime.Now; if (_Logger.ID != null) { flag = DAL.DALDataLogger.UpdateDataLogger(_Logger); } } catch (Exception ex) { throw; } return flag; }
public static Boolean UpdateDataLogger(DataLogger logger) { using (TransactionScope scope = new TransactionScope()) { Boolean bol = false; using (var context = new SycousCon()) { try { var Update = context.DataLoggers.Where(c => c.ID == logger.ID); foreach (DataLogger p in Update) { if (logger.DataCollectorMake != null) { p.DataCollectorMake = logger.DataCollectorMake; } if (logger.DataCollectorModel != null) { p.DataCollectorModel = logger.DataCollectorModel; } if (logger.SerialNumber != null) { p.SerialNumber = logger.SerialNumber; } if (logger.Communication != null) { p.Communication = logger.Communication; } if (logger.SimNumber != null) { p.SimNumber = logger.SimNumber; } if (logger.Telephone != null) { p.Telephone = logger.Telephone; } if (logger.Location != null) { p.Location = logger.Location; } if (logger.RetrievalID != null) { p.RetrievalID = logger.RetrievalID; } if (logger.IPAddress != null) { p.IPAddress = logger.IPAddress; } p.ModifyBy = logger.ModifyBy; p.ModifyBy = logger.ModifyBy; }// context.SaveChanges(); context.AcceptAllChanges(); scope.Complete(); context.Dispose(); bol = true; } catch (Exception ex) { context.Dispose(); throw; } }// using return bol; } //trans }
public static bool IsExistingDataLogger(DataLogger logger) { using (var context = new SycousCon()) { try { DataLogger objlogger = context.DataLoggers.SingleOrDefault(p => p.SerialNumber.ToUpper() == logger.SerialNumber.ToUpper()); if (objlogger != null) { return true; } else { return false; } } catch (Exception ex) { context.Dispose(); throw; } } }
public static DataLogger EditDataLogger(Int32 loggerid) { DataLogger Logger = new DataLogger(); using (var context = new SycousCon()) { try { Logger = context.DataLoggers.SingleOrDefault(s => s.ID == loggerid); } catch (Exception ex) { context.Dispose(); throw; } } return Logger; }
/// <summary> /// Deprecated Method for adding a new object to the DataLoggers EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToDataLoggers(DataLogger dataLogger) { base.AddObject("DataLoggers", dataLogger); }
/// <summary> /// Create a new DataLogger object. /// </summary> /// <param name="id">Initial value of the ID property.</param> /// <param name="isDeleted">Initial value of the IsDeleted property.</param> /// <param name="isActive">Initial value of the IsActive property.</param> public static DataLogger CreateDataLogger(global::System.Int32 id, global::System.Int32 isDeleted, global::System.Boolean isActive) { DataLogger dataLogger = new DataLogger(); dataLogger.ID = id; dataLogger.IsDeleted = isDeleted; dataLogger.IsActive = isActive; return dataLogger; }