Exemplo n.º 1
0
        public static Boolean UpdateConsumerTemplate(ConsumerTemplate consumer)
        {
            using (TransactionScope scope = new TransactionScope())
            {
                Boolean bol = false;
                using (var context = new SycousCon())
                {
                    try
                    {
                        var Update = context.ConsumerTemplates.Where(c => c.ID == consumer.ID);

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

                            if (consumer.Telephone != null)
                            {
                                p.Telephone = consumer.Telephone;
                            }
                            else { p.Telephone = null; }
                            if (consumer.Email != null)
                            {
                                p.Email = consumer.Email;
                            }
                            else { p.Email = null; }

                            if (consumer.OpeningHoursFrom != null)
                            {
                                p.OpeningHoursFrom = consumer.OpeningHoursFrom;
                            }
                            else
                            {
                                p.OpeningHoursFrom = null;

                            }

                            if (consumer.OpeningHoursEnd != null)
                            {
                                p.OpeningHoursEnd = consumer.OpeningHoursEnd;
                            }
                            else
                            { p.OpeningHoursEnd = null; }

                            if (consumer.Address != null)
                            {
                                p.Address = consumer.Address;
                            }
                            else
                            {
                                p.Address = null;
                            }

                            if (consumer.Address2 != null)
                            {
                                p.Address2 = consumer.Address2;
                            }
                            else { p.Address2 = null; }

                            if (consumer.County != null)
                            {
                                p.County = consumer.County;
                            }
                            else
                            { p.County = null; }

                            if (consumer.City != null)
                            {
                                p.City = consumer.City;
                            }
                            else { p.City = null; }
                            if (consumer.ZipCode != null)
                            {
                                p.ZipCode = consumer.ZipCode;
                            }
                            else { p.ZipCode = null; }

                            if (consumer.SupplierID != null)
                            {
                                p.SupplierID = consumer.SupplierID;
                            }

                            p.DirectDebit = consumer.DirectDebit;
                            p.PayPoint = consumer.PayPoint;
                            p.PayZone = consumer.PayZone;
                            p.PostOffice = consumer.PostOffice;
                            p.BankTransfer = consumer.BankTransfer;
                            p.OnlinePay = consumer.OnlinePay;
                            p.TelephonePay = consumer.TelephonePay;
                            p.OnlineNTelephonePay = consumer.OnlineNTelephonePay;
                            p.CashPayments = consumer.CashPayments;
                            p.AppNSMS = consumer.AppNSMS;
                            p.WebsitePayments = consumer.WebsitePayments;

                            if (consumer.PaymentTelephoneNo != null)
                            {
                                p.PaymentTelephoneNo = consumer.PaymentTelephoneNo;
                            }
                            else
                            {
                                p.PaymentTelephoneNo = null;
                            }

                            if (consumer.SortCode != null)
                            {
                                p.SortCode = consumer.SortCode;
                            }
                            else
                            {
                                p.SortCode = null;
                            }//

                            if (consumer.AccountNumber != null)
                            {
                                p.AccountNumber = consumer.AccountNumber;
                            }
                            else
                            {
                                p.AccountNumber = null;
                            }//

                            if (consumer.WebsiteAddress != null)
                            {
                                p.WebsiteAddress = consumer.WebsiteAddress;
                            }
                            else
                            {
                                p.WebsiteAddress = null;
                            }

                            p.ModifyBy = consumer.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
        }
Exemplo n.º 2
0
 public static bool IsExistingConsumerTemplate(ConsumerTemplate consumer)
 {
     using (var context = new SycousCon())
     {
         try
         {
             ConsumerTemplate objconsumer = context.ConsumerTemplates.SingleOrDefault(p => p.ClientID == consumer.ClientID && p.SiteID == consumer.SiteID && p.IsDeleted == 0);
             if (objconsumer != null)
             { return true; }
             else
             {
                 return false;
             }
         }
         catch (Exception ex)
         {
             context.Dispose();
             throw;
         }
     }
 }
Exemplo n.º 3
0
 public static ConsumerTemplate EditConsumerTemplate(Int64 ID)
 {
     ConsumerTemplate consumer = new ConsumerTemplate();
     using (var context = new SycousCon())
     {
         try
         {
             consumer = context.ConsumerTemplates.SingleOrDefault(s => s.ID == ID && s.IsDeleted == 0);
         }
         catch (Exception ex)
         {
             context.Dispose();
             throw;
         }
     }
     return consumer;
 }
Exemplo n.º 4
0
 public static Boolean CreateConsumerTemplate(ConsumerTemplate consumer)
 {
     Boolean flag = false;
     if (!(IsExistingConsumerTemplate(consumer)))
     {
         using (TransactionScope scope = new TransactionScope())
         {
             using (var context = new SycousCon())
             {
                 try
                 {
                     context.ConsumerTemplates.AddObject(consumer);
                     context.SaveChanges();
                     scope.Complete();
                     context.AcceptAllChanges();
                     flag = true;
                 }
                 catch (Exception ex)
                 {
                     context.Dispose();
                     throw;
                 }
             }
         }
     }
     return flag;
 }
Exemplo n.º 5
0
 /// <summary>
 /// Create a new ConsumerTemplate object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 /// <param name="isDeleted">Initial value of the IsDeleted property.</param>
 /// <param name="directDebit">Initial value of the DirectDebit property.</param>
 /// <param name="payPoint">Initial value of the PayPoint property.</param>
 /// <param name="payZone">Initial value of the PayZone property.</param>
 /// <param name="postOffice">Initial value of the PostOffice property.</param>
 /// <param name="bankTransfer">Initial value of the BankTransfer property.</param>
 /// <param name="onlinePay">Initial value of the OnlinePay property.</param>
 /// <param name="telephonePay">Initial value of the TelephonePay property.</param>
 /// <param name="onlineNTelephonePay">Initial value of the OnlineNTelephonePay property.</param>
 /// <param name="cashPayments">Initial value of the CashPayments property.</param>
 /// <param name="appNSMS">Initial value of the AppNSMS property.</param>
 /// <param name="websitePayments">Initial value of the WebsitePayments property.</param>
 public static ConsumerTemplate CreateConsumerTemplate(global::System.Int64 id, global::System.Int32 isDeleted, global::System.Int32 directDebit, global::System.Int32 payPoint, global::System.Int32 payZone, global::System.Int32 postOffice, global::System.Int32 bankTransfer, global::System.Int32 onlinePay, global::System.Int32 telephonePay, global::System.Int32 onlineNTelephonePay, global::System.Int32 cashPayments, global::System.Int32 appNSMS, global::System.Int32 websitePayments)
 {
     ConsumerTemplate consumerTemplate = new ConsumerTemplate();
     consumerTemplate.ID = id;
     consumerTemplate.IsDeleted = isDeleted;
     consumerTemplate.DirectDebit = directDebit;
     consumerTemplate.PayPoint = payPoint;
     consumerTemplate.PayZone = payZone;
     consumerTemplate.PostOffice = postOffice;
     consumerTemplate.BankTransfer = bankTransfer;
     consumerTemplate.OnlinePay = onlinePay;
     consumerTemplate.TelephonePay = telephonePay;
     consumerTemplate.OnlineNTelephonePay = onlineNTelephonePay;
     consumerTemplate.CashPayments = cashPayments;
     consumerTemplate.AppNSMS = appNSMS;
     consumerTemplate.WebsitePayments = websitePayments;
     return consumerTemplate;
 }
Exemplo n.º 6
0
 /// <summary>
 /// Deprecated Method for adding a new object to the ConsumerTemplates EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToConsumerTemplates(ConsumerTemplate consumerTemplate)
 {
     base.AddObject("ConsumerTemplates", consumerTemplate);
 }