Beispiel #1
0
        public static Boolean UpdateBulkMeter(BulkMeter _bulk)
        {
            using (TransactionScope scope = new TransactionScope())
            {
                Boolean bol = false;
                using (var context = new SycousCon())
                {
                    try
                    {
                        var Update = context.BulkMeters.Where(c => c.ID == _bulk.ID);

                        foreach (BulkMeter p in Update)
                        {
                            if (_bulk.ClientID != null)
                            {
                                p.ClientID = _bulk.ClientID;
                            }

                            if (_bulk.SiteID != null)
                            {
                                p.SiteID = _bulk.SiteID;
                            }

                            if (_bulk.SupplyID != null)
                            {
                                p.SupplyID = _bulk.SupplyID;
                            }
                            if (_bulk.DeviceID != null)
                            {
                                p.DeviceID = _bulk.DeviceID;
                            }

                            if (_bulk.StartDate != null)
                            {
                                p.StartDate = _bulk.StartDate;
                            }
                            else { p.StartDate = null; }

                            if (_bulk.EndDate != null)
                            {
                                p.EndDate= _bulk.EndDate;
                            }
                            else { p.EndDate = null; }

                            if (_bulk.Warrenty != null)
                            {
                                p.Warrenty = _bulk.Warrenty;
                            }
                            else { p.Warrenty = null; }

                            if (_bulk.OpeningReading != null)
                            {
                                p.OpeningReading = _bulk.OpeningReading;
                            }
                            else { p.OpeningReading = null; }

                            p.ModifyBy = _bulk.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
        }
Beispiel #2
0
        public bool CreateRecord(Object BulkMeterobj)
        {
            Boolean flag = false;
            BulkMeterMaster Bulk = (BulkMeterMaster)BulkMeterobj;
            try
            {
                BulkMeter _Bulk = new BulkMeter();
                if (Bulk.ClientID != null)
                {
                    _Bulk.ClientID = Convert.ToInt64(Bulk.ClientID);
                }

                if (Bulk.SiteID != null)
                {
                    _Bulk.SiteID = Convert.ToInt64(Bulk.SiteID);
                }
                if (Bulk.SupplyID != null)
                {
                    _Bulk.SupplyID= Convert.ToInt64(Bulk.SupplyID);
                }
                if (Bulk.DeviceID != null)
                {
                    _Bulk.DeviceID = Bulk.DeviceID;
                }
                if (Bulk.StartDate != null)
                {
                    _Bulk.StartDate = Common.DateGB(Bulk.StartDate);
                }
                if (Bulk.EndDate != null)
                {
                    _Bulk.EndDate = Common.DateGB(Bulk.EndDate);
                }

                if (Bulk.Warrenty != null)
                {
                    _Bulk.Warrenty = Common.DateGB(Bulk.Warrenty);
                }
                if (Bulk.OpeningReading!= null)
                {
                    _Bulk.OpeningReading = Bulk.OpeningReading.Trim();
                }

                _Bulk.CreateBy = Bulk.CreateBy;
                _Bulk.CreateDate = DateTime.Now;
                if (_Bulk.DeviceID != null)
                {
                    flag = DAL.DALBulkMeter.CreateBulkMeter(_Bulk);
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            return flag;
        }
Beispiel #3
0
 public static bool IsExistingBulkMeter(BulkMeter bulkmeter)
 {
     using (var context = new SycousCon())
     {
         try
         {
      BulkMeter objmeter = context.BulkMeters.SingleOrDefault(p => p.DeviceID.ToUpper().Trim() == bulkmeter.DeviceID.ToUpper().Trim());
         if (objmeter != null)
             { return true; }
             else
             {
                 return false;
             }
         }
         catch (Exception ex)
         {
             context.Dispose();
             throw;
         }
     }
 }
Beispiel #4
0
 public static BulkMeter EditBulkMeter(Int64 bulkmeterID)
 {
     BulkMeter Bulk = new BulkMeter();
     using (var context = new SycousCon())
     {
         try
         {
             Bulk = context.BulkMeters.SingleOrDefault(s => s.ID == bulkmeterID);
         }
         catch (Exception ex)
         {
             context.Dispose();
             throw;
         }
     }
     return Bulk;
 }
Beispiel #5
0
 public static Boolean CreateBulkMeter(BulkMeter _bulk)
 {
     Boolean flag = false;
     if (!(IsExistingBulkMeter(_bulk)))
     {
         using (TransactionScope scope = new TransactionScope())
         {
             using (var context = new SycousCon())
             {
                 try
                 {
                     context.BulkMeters.AddObject(_bulk);
                     context.SaveChanges();
                     scope.Complete();
                     context.AcceptAllChanges();
                     flag = true;
                 }
                 catch (Exception ex)
                 {
                     context.Dispose();
                     throw;
                 }
             }//
         }// using
     }//if
     return flag;
 }
 /// <summary>
 /// Create a new BulkMeter object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 /// <param name="isDeleted">Initial value of the IsDeleted property.</param>
 public static BulkMeter CreateBulkMeter(global::System.Int64 id, global::System.Int32 isDeleted)
 {
     BulkMeter bulkMeter = new BulkMeter();
     bulkMeter.ID = id;
     bulkMeter.IsDeleted = isDeleted;
     return bulkMeter;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the BulkMeters EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToBulkMeters(BulkMeter bulkMeter)
 {
     base.AddObject("BulkMeters", bulkMeter);
 }