Example #1
0
        public static Boolean CreateTemperatureDifference(TemperatureDifference Temperature)
        {
            Boolean flag = false;
            if (!(IsExistingTemperatureDifference(Temperature)))
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    using (var context = new SycousCon())
                    {
                        try
                        {
                            context.TemperatureDifferences.AddObject(Temperature);
                            context.SaveChanges();
                            scope.Complete();
                            context.AcceptAllChanges();
                            flag = true;
                        }
                        catch (Exception ex)
                        {
                            context.Dispose();
                            throw;
                        }
                    }//
                }// using
            }//if

            return flag;
        }
Example #2
0
        public bool CreateRecord(Object _Temperatureobj)
        {
            Boolean flag = false;
            TemperatureClass Temperature = (TemperatureClass)_Temperatureobj;
            try
            {
                DAL.TemperatureDifference _Temperature = new TemperatureDifference();

                if (Temperature.ClientID != null)
                {
                    _Temperature.ClientID = Convert.ToInt64(Temperature.ClientID);
                }
                if (Temperature.SiteID != null)
                {
                    _Temperature.SiteID = Convert.ToInt64(Temperature.SiteID);
                }

                if (Temperature.Variance != null)
                {
                    _Temperature.Variance = Convert.ToDecimal(Temperature.Variance);
                }

                if (Temperature.FromDate != null)
                {
                    _Temperature.FormDate = BAL.Common.DateGB(Temperature.FromDate);
                }
                else
                {
                    _Temperature.FormDate = null;
                }

                if (Temperature.ToDate != null)
                {
                    _Temperature.ToDate = BAL.Common.DateGB(Temperature.ToDate);
                }
                else
                {
                    _Temperature.ToDate = null;
                }

                _Temperature.CreateBy = Temperature.CreateBy;
                _Temperature.CreateDate = DateTime.Now;

                if ((_Temperature.ClientID != null) && (_Temperature.SiteID != null) )
                {
                    flag = DAL.DALTemperature.CreateTemperatureDifference(_Temperature);
                }
            }
            catch (Exception ex)
            {
                throw;
            }

            return flag;
        }
Example #3
0
 public static TemperatureDifference EditTemperatureDifference(Int64 tempID)
 {
     TemperatureDifference Temp = new TemperatureDifference();
     using (var context = new SycousCon())
     {
         try
         {
             Temp = context.TemperatureDifferences.SingleOrDefault(s => s.ID == tempID);
         }
         catch (Exception ex)
         {
             context.Dispose();
             throw;
         }
     }
     return Temp;
 }
Example #4
0
 public static bool IsExistingTemperatureDifference(TemperatureDifference Temperature)
 {
     using (var context = new SycousCon())
     {
         try
         {
             TemperatureDifference objTemperature = context.TemperatureDifferences.SingleOrDefault(p => p.ClientID == Temperature.ClientID && p.SiteID == Temperature.SiteID );
             if (objTemperature != null)
             { return true; }
             else
             {
                 return false;
             }
         }
         catch (Exception ex)
         {
             context.Dispose();
             throw;
         }
     }
 }
Example #5
0
        public static Boolean UpdateTemperatureDifference(TemperatureDifference Temperature)
        {
            using (TransactionScope scope = new TransactionScope())
            {
                Boolean bol = false;
                using (var context = new SycousCon())
                {
                    try
                    {
                        var Update = context.TemperatureDifferences.Where(c => c.ID == Temperature.ID);

                        foreach (TemperatureDifference p in Update)
                        {
                            if (Temperature.ClientID != null)
                            {
                                p.ClientID = Temperature.ClientID;
                            }
                            if (Temperature.SiteID != null)
                            {
                                p.SiteID = Temperature.SiteID;
                            }

                            if (Temperature.Variance!= null)
                            {
                                p.Variance = Temperature.Variance;
                            }
                            else
                            {
                                p.Variance = null;
                            }
                            if (Temperature.FormDate != null)
                            {
                                p.FormDate = Temperature.FormDate;
                            }
                            else
                            {
                                p.FormDate = null;
                            }

                            if (Temperature.ToDate != null)
                            {
                                p.ToDate = Temperature.ToDate;
                            }
                            else
                            {
                                p.ToDate = null;
                            }

                            p.ModifyBy = Temperature.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 TemperatureDifference object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 /// <param name="isDeleted">Initial value of the IsDeleted property.</param>
 public static TemperatureDifference CreateTemperatureDifference(global::System.Int64 id, global::System.Int32 isDeleted)
 {
     TemperatureDifference temperatureDifference = new TemperatureDifference();
     temperatureDifference.ID = id;
     temperatureDifference.IsDeleted = isDeleted;
     return temperatureDifference;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the TemperatureDifferences EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToTemperatureDifferences(TemperatureDifference temperatureDifference)
 {
     base.AddObject("TemperatureDifferences", temperatureDifference);
 }