public void InsertCustomer(Customer customer) { _entities.Customers.AddObject(customer); _entities.SaveChanges(); var id = customer.Id; customer.Code = string.Format(Constant.CUSTOMER_CODE, id.ToString("000000")); _entities.SaveChanges(); }
public void UpdateCustomer(Customer customer) { var u = _entities.Customers.FirstOrDefault(i => i.Id == customer.Id); u.Name = customer.Name; u.Code = customer.Code; u.CustomerType = customer.CustomerType; u.PhoneNumber1 = customer.PhoneNumber1; u.PhoneNumber2 = customer.PhoneNumber2; u.Email = customer.Email; u.FaxNumber = customer.FaxNumber; u.Address = customer.Address; u.CityId = customer.CityId; u.Note = customer.Note; u.ReferUserId = customer.ReferUserId; u.ApprovedUserId = customer.ApprovedUserId; u.Status = customer.Status; u.LastModifiedBy = customer.LastModifiedBy; u.LastModifiedDate = DateTime.Now; _entities.SaveChanges(); }
/// <summary> /// Deprecated Method for adding a new object to the Customers EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToCustomers(Customer customer) { base.AddObject("Customers", customer); }
public void DeleteCustomer(Customer customer) { var u = _entities.Customers.FirstOrDefault(i => i.Id == customer.Id); _entities.DeleteObject(u); _entities.SaveChanges(); }
/// <summary> /// Create a new Customer object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="name">Initial value of the Name property.</param> /// <param name="code">Initial value of the Code property.</param> /// <param name="customerType">Initial value of the CustomerType property.</param> /// <param name="address">Initial value of the Address property.</param> /// <param name="cityId">Initial value of the CityId property.</param> /// <param name="referUserId">Initial value of the ReferUserId property.</param> /// <param name="approvedUserId">Initial value of the ApprovedUserId property.</param> /// <param name="status">Initial value of the Status property.</param> /// <param name="lastModifiedBy">Initial value of the LastModifiedBy property.</param> /// <param name="lastModifiedDate">Initial value of the LastModifiedDate property.</param> public static Customer CreateCustomer(global::System.Int32 id, global::System.String name, global::System.String code, global::System.Int32 customerType, global::System.String address, global::System.Int32 cityId, global::System.Int32 referUserId, global::System.Int32 approvedUserId, global::System.Int32 status, global::System.Int32 lastModifiedBy, global::System.DateTime lastModifiedDate) { Customer customer = new Customer(); customer.Id = id; customer.Name = name; customer.Code = code; customer.CustomerType = customerType; customer.Address = address; customer.CityId = cityId; customer.ReferUserId = referUserId; customer.ApprovedUserId = approvedUserId; customer.Status = status; customer.LastModifiedBy = lastModifiedBy; customer.LastModifiedDate = lastModifiedDate; return customer; }