public static Boolean CreateUnOccupiedProperty(UnOccupiedProperty UnOccupied) { Boolean flag = false; if (!(IsExistingUnOccupiedProperty(UnOccupied))) { using (TransactionScope scope = new TransactionScope()) { using (var context = new SycousCon()) { try { context.UnOccupiedProperties.AddObject(UnOccupied); context.SaveChanges(); scope.Complete(); context.AcceptAllChanges(); flag = true; } catch (Exception ex) { context.Dispose(); throw; } }// }// using }//if return flag; }
public static UnOccupiedProperty EditUnOccupiedProperty(Int64 UnOccupiedID) { UnOccupiedProperty occupied = new UnOccupiedProperty(); using (var context = new SycousCon()) { try { occupied = context.UnOccupiedProperties.SingleOrDefault(s => s.ID == UnOccupiedID); } catch (Exception ex) { context.Dispose(); throw; } } return occupied; }
public static bool IsExistingUnOccupiedProperty(UnOccupiedProperty UnOccupied) { using (var context = new SycousCon()) { try { UnOccupiedProperty objoccupied = context.UnOccupiedProperties.SingleOrDefault(p => p.ClientID == UnOccupied.ClientID && p.SiteID == UnOccupied.SiteID && p.SupplierID == UnOccupied.SupplierID); if (objoccupied != null) { return true; } else { return false; } } catch (Exception ex) { context.Dispose(); throw; } } }
public static Boolean UpdateUnOccupiedProperty(UnOccupiedProperty UnOccupied) { using (TransactionScope scope = new TransactionScope()) { Boolean bol = false; using (var context = new SycousCon()) { try { var Update = context.UnOccupiedProperties.Where(c => c.ID == UnOccupied.ID); foreach (UnOccupiedProperty p in Update) { if (UnOccupied.ClientID != null) { p.ClientID = UnOccupied.ClientID; } if (UnOccupied.SiteID != null) { p.SiteID = UnOccupied.SiteID; } if (UnOccupied.SupplierID != null) { p.SupplierID = UnOccupied.SupplierID; } if (UnOccupied.PropertyID != null) { p.PropertyID = UnOccupied.PropertyID; } if (UnOccupied.ConsumptionValue != null) { p.ConsumptionValue = UnOccupied.ConsumptionValue; } else { p.ConsumptionValue = null; } if (UnOccupied.RollingPeriod != null) { p.RollingPeriod = UnOccupied.RollingPeriod; } else { p.RollingPeriod = null; } if (UnOccupied.FormDate != null) { p.FormDate = UnOccupied.FormDate; } else { p.FormDate = null; } if (UnOccupied.ToDate != null) { p.ToDate = UnOccupied.FormDate; } else { p.ToDate = null; } p.ModifyBy = UnOccupied.ModifyBy; p.ModifyDate = DateTime.Now; }// context.SaveChanges(); context.AcceptAllChanges(); scope.Complete(); context.Dispose(); bol = true; } catch (Exception ex) { context.Dispose(); throw; } }// using return bol; } //trans }
/// <summary> /// Create a new UnOccupiedProperty object. /// </summary> /// <param name="id">Initial value of the ID property.</param> /// <param name="isDeleted">Initial value of the IsDeleted property.</param> public static UnOccupiedProperty CreateUnOccupiedProperty(global::System.Int64 id, global::System.Int32 isDeleted) { UnOccupiedProperty unOccupiedProperty = new UnOccupiedProperty(); unOccupiedProperty.ID = id; unOccupiedProperty.IsDeleted = isDeleted; return unOccupiedProperty; }
/// <summary> /// Deprecated Method for adding a new object to the UnOccupiedProperties EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToUnOccupiedProperties(UnOccupiedProperty unOccupiedProperty) { base.AddObject("UnOccupiedProperties", unOccupiedProperty); }
public bool CreateRecord(Object _UnOccupiedobj) { Boolean flag = false; UnOccupiedPropertyClass UnOccupied = (UnOccupiedPropertyClass)_UnOccupiedobj; try { DAL.UnOccupiedProperty _UnOccupied = new UnOccupiedProperty(); if (UnOccupied.ClientID != null) { _UnOccupied.ClientID = Convert.ToInt64(UnOccupied.ClientID); } if (UnOccupied.SiteID != null) { _UnOccupied.SiteID = Convert.ToInt64(UnOccupied.SiteID); } if (UnOccupied.PropertyID != null) { _UnOccupied.PropertyID = Convert.ToInt64(UnOccupied.PropertyID); } if (UnOccupied.SupplierID != null) { _UnOccupied.SupplierID = Convert.ToInt64(UnOccupied.SupplierID); } if (UnOccupied.ConsumptionValue != null) { _UnOccupied.ConsumptionValue = Convert.ToDecimal(UnOccupied.ConsumptionValue); } if (UnOccupied.RollingPeriod != null) { _UnOccupied.RollingPeriod = Convert.ToInt32(UnOccupied.RollingPeriod); } if (UnOccupied.FromDate != null) { _UnOccupied.FormDate = BAL.Common.DateGB(UnOccupied.FromDate); } else { _UnOccupied.FormDate = null; } if (UnOccupied.ToDate != null) { _UnOccupied.ToDate = BAL.Common.DateGB(UnOccupied.ToDate); } else { _UnOccupied.ToDate = null; } _UnOccupied.CreateBy = UnOccupied.CreateBy; _UnOccupied.CreateDate = DateTime.Now; if ((UnOccupied.ClientID != null)&&(UnOccupied.SiteID !=null)&&(UnOccupied.SupplierID != null)) { flag = DAL.DALUnOccupiedProperty.CreateUnOccupiedProperty(_UnOccupied); } } catch (Exception ex) { throw; } return flag; }