/// <summary> /// Валидация /// </summary> /// <param name="element"></param> /// <returns></returns> public ValidationResult Validate(CustomerLegal element) { //if (string.IsNullOrEmpty(element.Name)) //{ // return new ValidationResult(ValidatorResources.ExpositionValidator_NameIsNull); //} return(new ValidationResult()); }
/// <summary> /// Добавить юр клиентов /// </summary> private void AddCustomerLegal() { using (var uf = new ApplicationDbContext()) { var basisAction = new BasisAction() { Guid = Guid.NewGuid(), Name = "Какое-то действие", }; uf.Set <BasisAction>().Add(basisAction); uf.SaveChanges(); var client = new CustomerLegal() { Guid = Guid.NewGuid(), Address = "г. Саратов, ул. Техническая", Name = "Пиво балтика", Phone = "(8452)11-11-11", BasisActionId = basisAction.Id, DocDate = DateTime.Now, DocNumber = "# 123456", Face = "Директор", Inn = "123456", Kpp = "654321", Position = "Директор" }; uf.Set <CustomerLegal>().Add(client); uf.SaveChanges(); var client2 = new CustomerLegal() { Guid = Guid.NewGuid(), Address = "г. Энгельс, ул. Техническая", Name = "ООО керамика", Phone = "(8453)22-11-11", BasisActionId = basisAction.Id, DocDate = DateTime.Now, DocNumber = "# авввву", Face = "Директор", Inn = "123456", Kpp = "654321", Position = "Директор" }; uf.Set <CustomerLegal>().Add(client2); uf.SaveChanges(); } }
/// <summary> /// Сохранить нового клиента /// </summary> public void SaveNewClient() { _customer = new CustomerLegal() { Guid = Guid.NewGuid(), BasisAction = _customerLegalView.BasisAction, DocDate = _customerLegalView.DocDate, DocNumber = _customerLegalView.DocNumber, Face = _customerLegalView.Face, Inn = _customerLegalView.Inn, Kpp = _customerLegalView.Kpp, Position = _customerLegalView.Position, Address = _customerLegalView.Address, Name = _customerLegalView.Name, Phone = _customerLegalView.Phone, }; }
public void TestInsertCustomer1() { var usoEntities = new USOEntities(); //法人 var customerLegal = new CustomerLegal { LegalNumber = "0000001", CustomerName = "邛崃市正大电器公司", LegalPerson = "张三", BisinessLicense = "00000000000000001", Contact = "028-88888888" }; usoEntities.CustomerLegals.Add(customerLegal); var org = usoEntities.Organizations.Find(8); //法人组织 var customerLegalOrg = new CustomerLegalOrg { CustomerLegal = customerLegal, Organization = org, }; usoEntities.CustomerLegalOrgs.Add(customerLegalOrg); //门店1 var customerStore = new CustomerStore { CustomerLegal = customerLegal, StoreName = "邛崃东街经营部", StoreAddress = "邛崃市东街101号", StoreType = usoEntities.Dictionaries.Where(p => p.FieldName == "StoreType" && p.FieldValue == "1").FirstOrDefault().Id }; usoEntities.CustomerStores.Add(customerStore); //法人集团关系 var r3ProductCompany1 = usoEntities.Organizations.FirstOrDefault(p => p.OrganizationType == OrganizationType.Head); var r3CustomerLegal = new R3CustomerLegal { CustomerLegal = customerLegal, Organization = r3ProductCompany1, R3CustomerCode = "000001", }; usoEntities.R3CustomerLegals.Add(r3CustomerLegal); //法人门店集团关系 //var r3ProductCompany2 = usoEntities.R3ProductCompanys.Find(1); // var r3CustomerStore = new R3CustomerStore // { // CustomerStore = customerStore, // R3ProductCompany = r3ProductCompany2, // R3CustomerCode = "000001001" // }; // usoEntities.R3CustomerStores.Add(r3CustomerStore); //法人账号(管理员) var customerUserAdmin = new CustomerUser { CustomerLegal = customerLegal, UserName = "******", Password = "******", CustomerRole = CustomerRole.Administrator, CustomerUserStatus = CustomerUserStatus.Valid, }; usoEntities.CustomerUsers.Add(customerUserAdmin); //法人账号(产品经理) var customerUserProductManager = new CustomerUser { CustomerLegal = customerLegal, UserName = "******", Password = "******", CustomerRole = CustomerRole.ProductManager, CustomerUserStatus = CustomerUserStatus.Valid, }; usoEntities.CustomerUsers.Add(customerUserProductManager); //法人账号(店员) var customerUserShopAssistant = new CustomerUser { CustomerLegal = customerLegal, UserName = "******", Password = "******", CustomerRole = CustomerRole.ShopAssistant, CustomerUserStatus = CustomerUserStatus.Valid, }; usoEntities.CustomerUsers.Add(customerUserShopAssistant); usoEntities.SaveChanges(); }