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; } }
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); } }
public static CustomerCustomerDemo New(Customer myCustomer, CustomerDemographic myCustomerDemographic) { CustomerCustomerDemo tmp = CustomerCustomerDemo.New(); tmp._MyCustomer = myCustomer; tmp._MyCustomerDemographic = myCustomerDemographic; return(tmp); }
private CustomerCustomerCustomerDemo(CustomerDemographic myCustomerDemographic) { MarkAsChild(); // TODO: Add any initialization & defaults _MyCustomerDemographic = myCustomerDemographic; ValidationRules.CheckRules(); }
public static void Refresh(CustomerDemographic myCustomerDemographic, CustomerDemographicCustomerCustomerDemo tmp) { CustomerCustomerDemoInfo tmpInfo = GetExistingByPrimaryKey(tmp.CustomerID, myCustomerDemographic.CustomerTypeID); if (tmpInfo == null) { return; } tmpInfo.RefreshFields(tmp); }
public bool ContainsDeleted(CustomerDemographic myCustomerDemographic) { foreach (CustomerCustomerCustomerDemo customerCustomerDemo in DeletedList) { if (customerCustomerDemo.CustomerTypeID == myCustomerDemographic.CustomerTypeID) { return(true); } } return(false); }
public void Remove(CustomerDemographic myCustomerDemographic) { foreach (CustomerCustomerCustomerDemo customerCustomerDemo in this) { if (customerCustomerDemo.CustomerTypeID == myCustomerDemographic.CustomerTypeID) { Remove(customerCustomerDemo); break; } } }
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(); }
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"); } }
// 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(); }
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); }
internal static CustomerCustomerCustomerDemo New(CustomerDemographic myCustomerDemographic) { return(new CustomerCustomerCustomerDemo(myCustomerDemographic)); }
private void RefreshFields(CustomerDemographic tmp) { _CustomerDesc = tmp.CustomerDesc; _CustomerDemographicInfoExtension.Refresh(this); OnChange(); // raise an event }
public virtual CustomerDemographic Get() { return(_Editable = CustomerDemographic.Get(_CustomerTypeID)); }