internal void Update(CustomerDemographic customerDemographic)
 {
     this.RaiseListChangedEvents = false;
     try
     {
         // update (thus deleting) any deleted child objects
         foreach (CustomerDemographicCustomerCustomerDemo obj in DeletedList)
         {
             obj.Delete();                    // TODO: Should this be SQLDelete
         }
         // now that they are deleted, remove them from memory too
         DeletedList.Clear();
         // add/update any current child objects
         foreach (CustomerDemographicCustomerCustomerDemo obj in this)
         {
             if (obj.IsNew)
             {
                 obj.Insert(customerDemographic);
             }
             else
             {
                 obj.Update(customerDemographic);
             }
         }
     }
     finally
     {
         this.RaiseListChangedEvents = true;
     }
 }
コード例 #2
0
 public static void Update(SqlConnection cn, Customer myCustomer, CustomerDemographic myCustomerDemographic)
 {
     Database.LogInfo("CustomerCustomerDemo.Update", 0);
     try
     {
         using (SqlCommand cm = cn.CreateCommand())
         {
             cm.CommandType = CommandType.StoredProcedure;
             cm.CommandText = "updateCustomerCustomerDemo";
             // Input All Fields - Except Calculated Columns
             cm.Parameters.AddWithValue("@CustomerID", myCustomer.CustomerID);
             cm.Parameters.AddWithValue("@CustomerTypeID", myCustomerDemographic.CustomerTypeID);
             // Output Calculated Columns
             // TODO: Define any additional output parameters
             cm.ExecuteNonQuery();
             // Save all values being returned from the Procedure
             // No Timestamp value to return
         }
     }
     catch (Exception ex)
     {
         Database.LogException("CustomerCustomerDemo.Update", ex);
         throw new DbCslaException("CustomerCustomerDemo.Update", ex);
     }
 }
コード例 #3
0
        public static CustomerCustomerDemo New(Customer myCustomer, CustomerDemographic myCustomerDemographic)
        {
            CustomerCustomerDemo tmp = CustomerCustomerDemo.New();

            tmp._MyCustomer            = myCustomer;
            tmp._MyCustomerDemographic = myCustomerDemographic;
            return(tmp);
        }
コード例 #4
0
        private CustomerCustomerCustomerDemo(CustomerDemographic myCustomerDemographic)
        {
            MarkAsChild();
            // TODO: Add any initialization & defaults

            _MyCustomerDemographic = myCustomerDemographic;
            ValidationRules.CheckRules();
        }
コード例 #5
0
        public static void Refresh(CustomerDemographic myCustomerDemographic, CustomerDemographicCustomerCustomerDemo tmp)
        {
            CustomerCustomerDemoInfo tmpInfo = GetExistingByPrimaryKey(tmp.CustomerID, myCustomerDemographic.CustomerTypeID);

            if (tmpInfo == null)
            {
                return;
            }
            tmpInfo.RefreshFields(tmp);
        }
コード例 #6
0
 public bool ContainsDeleted(CustomerDemographic myCustomerDemographic)
 {
     foreach (CustomerCustomerCustomerDemo customerCustomerDemo in DeletedList)
     {
         if (customerCustomerDemo.CustomerTypeID == myCustomerDemographic.CustomerTypeID)
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #7
0
 public void Remove(CustomerDemographic myCustomerDemographic)
 {
     foreach (CustomerCustomerCustomerDemo customerCustomerDemo in this)
     {
         if (customerCustomerDemo.CustomerTypeID == myCustomerDemographic.CustomerTypeID)
         {
             Remove(customerCustomerDemo);
             break;
         }
     }
 }
コード例 #8
0
 public CustomerCustomerCustomerDemo GetItem(CustomerDemographic myCustomerDemographic)
 {
     foreach (CustomerCustomerCustomerDemo customerCustomerDemo in this)
     {
         if (customerCustomerDemo.CustomerTypeID == myCustomerDemographic.CustomerTypeID)
         {
             return(customerCustomerDemo);
         }
     }
     return(null);
 }
        internal void Update(CustomerDemographic myCustomerDemographic)
        {
            // if we're not dirty then don't update the database
            if (!this.IsDirty)
            {
                return;
            }
            SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];

            CustomerCustomerDemo.Update(cn, _MyCustomer, myCustomerDemographic);
            MarkOld();
        }
コード例 #10
0
 public CustomerCustomerCustomerDemo Add(CustomerDemographic myCustomerDemographic)        // Many to Many with required fields
 {
     if (!Contains(myCustomerDemographic))
     {
         CustomerCustomerCustomerDemo customerCustomerDemo = CustomerCustomerCustomerDemo.New(myCustomerDemographic);
         this.Add(customerCustomerDemo);
         return(customerCustomerDemo);
     }
     else
     {
         throw new InvalidOperationException("customerCustomerDemo already exists");
     }
 }
コード例 #11
0
 // Many To Many
 public CustomerCustomerCustomerDemo this[CustomerDemographic myCustomerDemographic]
 {
     get
     {
         foreach (CustomerCustomerCustomerDemo customerCustomerDemo in this)
         {
             if (customerCustomerDemo.CustomerTypeID == myCustomerDemographic.CustomerTypeID)
             {
                 return(customerCustomerDemo);
             }
         }
         return(null);
     }
 }
        internal void DeleteSelf(CustomerDemographic myCustomerDemographic)
        {
            // if we're not dirty then don't update the database
            if (!this.IsDirty)
            {
                return;
            }
            // if we're new then don't update the database
            if (this.IsNew)
            {
                return;
            }
            SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];

            CustomerCustomerDemo.Remove(cn, _CustomerID, myCustomerDemographic.CustomerTypeID);
            MarkNew();
        }
コード例 #13
0
        public static CustomerCustomerDemo MakeCustomerCustomerDemo(Customer myCustomer, CustomerDemographic myCustomerDemographic)
        {
            CustomerCustomerDemo tmp = CustomerCustomerDemo.New(myCustomer, myCustomerDemographic);

            if (tmp.IsSavable)
            {
                tmp = tmp.Save();
            }
            else
            {
                Csla.Validation.BrokenRulesCollection brc = tmp.ValidationRules.GetBrokenRules();
                tmp._ErrorMessage = "Failed Validation:";
                foreach (Csla.Validation.BrokenRule br in brc)
                {
                    tmp._ErrorMessage += "\r\n\tFailure: " + br.RuleName;
                }
            }
            return(tmp);
        }
コード例 #14
0
 internal static CustomerCustomerCustomerDemo New(CustomerDemographic myCustomerDemographic)
 {
     return(new CustomerCustomerCustomerDemo(myCustomerDemographic));
 }
コード例 #15
0
 private void RefreshFields(CustomerDemographic tmp)
 {
     _CustomerDesc = tmp.CustomerDesc;
     _CustomerDemographicInfoExtension.Refresh(this);
     OnChange();            // raise an event
 }
コード例 #16
0
 public virtual CustomerDemographic Get()
 {
     return(_Editable = CustomerDemographic.Get(_CustomerTypeID));
 }