Пример #1
0
        public static Boolean CreateTariff(Tariff tariff)
        {
            Boolean flag = false;
               if (!(IsExistingTariff(tariff)))
               {
               using (TransactionScope scope = new TransactionScope())
               {
                   using (var context = new SycousCon())
                   {
                       try
                       {
                           context.Tariffs.AddObject(tariff);
                           context.SaveChanges();
                           scope.Complete();
                           context.AcceptAllChanges();
                           flag = true;
                       }
                       catch (Exception ex)
                       {
                           context.Dispose();
                           throw;
                       }
                   }//
               }// using
               }//if

               return flag;
        }
Пример #2
0
 public static Tariff EditTariff(Int32 tariffID)
 {
     Tariff tariff = new Tariff();
        using (var context = new SycousCon())
        {
        try
        {
            tariff = context.Tariffs.SingleOrDefault(s => s.ID == tariffID);
        }
        catch (Exception ex)
        {
            context.Dispose();
            throw;
        }
        }
        return tariff;
 }
Пример #3
0
        public static Boolean UpdateTariff(Tariff tariff)
        {
            using (TransactionScope scope = new TransactionScope())
               {
               Boolean bol = false;
               using (var context = new SycousCon())
               {
                   try
                   {
                       var Update = context.Tariffs.Where(c => c.ID == tariff.ID);

                       foreach (Tariff p in Update)
                       {

                           if (tariff.ClientID!= null)
                           {
                               p.ClientID = tariff.ClientID;
                           }
                           if (tariff.SiteID != null)
                           {
                               p.SiteID = tariff.SiteID;
                           }
                           if (tariff.TariffTypeID != null)
                           {
                               p.TariffTypeID = tariff.TariffTypeID;
                           }
                           if (tariff.SupplierID != null)
                           {
                               p.SupplierID = tariff.SupplierID;
                           }
                           if (tariff.AllSite != null)
                           {
                               p.AllSite = tariff.AllSite;
                           }
                           if (tariff.PopBandID != null)
                           {
                               p.PopBandID = tariff.PopBandID;
                           }
                           if (tariff.TariffName != null)
                           {
                               p.TariffName = tariff.TariffName;
                           }
                           if (tariff.TariffCode != null)
                           {
                               p.TariffCode = tariff.TariffCode;
                           }
                           if (tariff.UnitPrefix != null)
                           {
                               p.UnitPrefix = tariff.UnitPrefix;
                           }
                           if (tariff.UnitRate != null)
                           {
                               p.UnitRate = tariff.UnitRate;
                           }
                           if (tariff.VatRate != null)
                           {
                               p.VatRate = tariff.VatRate;
                           }
                           if (tariff.FromDate != null)
                           {
                               p.FromDate = tariff.FromDate;
                           }
                           if (tariff.EndDate != null)
                           {
                               p.EndDate = tariff.EndDate;
                           }
                           if (tariff.StartTime != null)
                           {
                               p.StartTime = tariff.StartTime;
                           }
                           if (tariff.EndTime != null)
                           {
                               p.EndTime = tariff.EndTime;
                           }
                           p.IsDailyBasic = tariff.IsDailyBasic;
                           p.ModifyDate = DateTime.Now;
                           p.ModifyBy = tariff.ModifyBy;
                       }//
                       context.SaveChanges();
                       context.AcceptAllChanges();
                       scope.Complete();
                       context.Dispose();
                       bol = true;
                   }
                   catch (Exception ex)
                   {
                       context.Dispose();
                       throw;
                   }

               }// using
               return bol;
               } //trans
        }
Пример #4
0
 public static bool IsExistingTariff(Tariff tariff)
 {
     using (var context = new SycousCon())
        {
        try
        {
            Tariff objtariff = context.Tariffs.SingleOrDefault(p => p.TariffCode.ToUpper() == tariff.TariffCode.ToUpper() && p.ClientID == tariff.ClientID && p.SiteID == tariff.ClientID && p.PopBandID == tariff.PopBandID);
            if (objtariff != null)
            { return true; }
            else
            {
                return false;
            }
        }
        catch (Exception ex)
        {
            context.Dispose();
            throw;
        }
        }
 }
Пример #5
0
        public bool UpdateRecord(Object tariffobj)
        {
            Boolean flag = false;
            TariffMaster tariff = (TariffMaster)tariffobj;
            try
            {
                Tariff _tariff = new Tariff();
                _tariff.ID = Convert.ToInt32(tariff.ID);
                if (tariff.TariffTypeID != null)
                {
                    _tariff.TariffTypeID = tariff.TariffTypeID;
                    if (tariff.TariffTypeID == 1)
                    {
                        _tariff.SupplierID = 0;
                    }
                    else
                    {
                        if (tariff.SupplierID != null)
                        {
                            _tariff.SupplierID = tariff.SupplierID;
                        }
                    }

                }

                if (tariff.ClientID != null)
                {
                    _tariff.ClientID = tariff.ClientID;
                }
                if (tariff.SiteID != null)
                {
                    _tariff.SiteID = tariff.SiteID;
                }
                //if (tariff.SupplierID != null)
                //{
                //    _tariff.SupplierID = tariff.SupplierID;
                //}
                if (tariff.AllSite != null)
                {
                    _tariff.AllSite = tariff.AllSite;
                }
                if (tariff.PopBandID!= null)
                {
                    _tariff.PopBandID = tariff.PopBandID;
                }
                if (tariff.TariffName != null)
                {
                    _tariff.TariffName = tariff.TariffName.Trim();
                }
                if (tariff.TariffCode != null)
                {
                    _tariff.TariffCode = tariff.TariffCode.Trim().ToUpper();
                }
                if (tariff.UnitPrefix != null)
                {
                    _tariff.UnitPrefix = tariff.UnitPrefix.Trim();
                }
                if (tariff.UnitRate != null)
                {
                    _tariff.UnitRate = Convert.ToDecimal(tariff.UnitRate.Trim());
                }
                if (tariff.VatRate != null)
                {
                    _tariff.VatRate = Convert.ToDecimal(tariff.VatRate.Trim());
                }
                if (tariff.FromDate != null)
                {
                    _tariff.FromDate = Common.DateGB(tariff.FromDate.Trim());
                }
                if (tariff.EndDate != null)
                {
                    _tariff.EndDate = Common.DateGB(tariff.EndDate.Trim());
                }
                if (tariff.StartTime != null)
                {
                    _tariff.StartTime = Common.TimeGB(tariff.StartTime.Trim());
                }
                if (tariff.EndTime != null)
                {
                    _tariff.EndTime = Common.TimeGB(tariff.EndTime.Trim());
                }
                _tariff.IsDailyBasic = tariff.IsDailyBasic;
                _tariff.ModifyBy = tariff.modifyBy;
                _tariff.ModifyDate = DateTime.Now;
                if (_tariff.ID != null)
                {
                    flag = DAL.DALTariff.UpdateTariff(_tariff);
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            return flag;
        }
Пример #6
0
 /// <summary>
 /// Create a new Tariff object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 /// <param name="allSite">Initial value of the AllSite property.</param>
 /// <param name="isDailyBasic">Initial value of the IsDailyBasic property.</param>
 /// <param name="isDeleted">Initial value of the IsDeleted property.</param>
 /// <param name="isDiscount">Initial value of the IsDiscount property.</param>
 public static Tariff CreateTariff(global::System.Int32 id, global::System.Boolean allSite, global::System.Boolean isDailyBasic, global::System.Int32 isDeleted, global::System.Int32 isDiscount)
 {
     Tariff tariff = new Tariff();
     tariff.ID = id;
     tariff.AllSite = allSite;
     tariff.IsDailyBasic = isDailyBasic;
     tariff.IsDeleted = isDeleted;
     tariff.IsDiscount = isDiscount;
     return tariff;
 }
Пример #7
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Tariffs EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToTariffs(Tariff tariff)
 {
     base.AddObject("Tariffs", tariff);
 }