当前位置: 首页>>代码示例>>C#>>正文


C# Company.Save方法代码示例

本文整理汇总了C#中Company.Save方法的典型用法代码示例。如果您正苦于以下问题:C# Company.Save方法的具体用法?C# Company.Save怎么用?C# Company.Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Company的用法示例。


在下文中一共展示了Company.Save方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GenerateCompany

 public static void GenerateCompany(int count)
 {
     for (int i = 0; i < count; i++)
     {
         Company c = new Company();
         c.CompanyName = RandomString(20);
         c.Save();
     }
 }
开发者ID:nopower0,项目名称:DataViewer,代码行数:9,代码来源:Program.cs

示例2: UpdateDatabaseAfterUpdateSchema

        public override void UpdateDatabaseAfterUpdateSchema()
        {
            base.UpdateDatabaseAfterUpdateSchema();
            Employee userAdmin = Session.FindObject<Employee>(new BinaryOperator("UserName", "Admin"));
            if (new XPCollection<Company>(Session).Count == 0)
            {
                using (Role administratorRole = new Role(Session) { Name = "Administrator role" })
                {
                    administratorRole.AddPermission(new EditModelPermission());
                    administratorRole.AddPermission(new ObjectAccessPermission(typeof(object), ObjectAccess.AllAccess));
                    administratorRole.Save();
                    using (Role userRole = new Role(Session) { Name = "User" })
                    {
                        userRole.AddPermission(new ObjectAccessPermission(typeof(object), ObjectAccess.Navigate));
                        userRole.AddPermission(new ObjectAccessPermission(typeof(object), ObjectAccess.Read));
                        userRole.Save();
                    }
                    userAdmin = new Employee(Session);
                    userAdmin.UserName = "Admin";
                    userAdmin.FirstName = "Admin";
                    userAdmin.LastName = "";
                    userAdmin.Roles.Add(administratorRole);
                    userAdmin.Save();
                    using (Branch branch1 = new Branch(Session) { Acronym = "WTPR", Branchname = "Roadmax Head Office" })
                    {
                        using (Company company1 = new Company(Session) { CompanyName = "Roadmax Marketing Inc.", Acronym = "WTPR" })
                        {
                            company1.Employees.Add(userAdmin);
                            company1.Branches.Add(branch1);
                            company1.Save();
                            ImportData(company1);
                        }
                    }
                }

                using (Currency curr = new Currency(Session) { CurrencyName = "Peso", CurrencyRate = 1 })
                {
                    curr.Save();
                }

                using (VatCategory vat = new VatCategory(Session) { Acronym = "VAT", Description = "Vatable", Rate = 12 })
                {
                    vat.Save();
                }

            }
            //importReport("SOHeaderPrintOut");
        }
开发者ID:ViniciusConsultor,项目名称:roadmaxweberp,代码行数:48,代码来源:Updater.cs

示例3: TestCompanyCRUD

        public void TestCompanyCRUD()
        {
            List<Company> list = Company.Query("code = 'testcode'");
            foreach (Company c in list)
            {
                c.Destory();
            }

            list = Company.Query();
            long count = list.Count;

            Company com = new Company();
            com.Code = "testcode";
            com.Name = "testname";
            com.Doc = "沪";
            com.Input = "X";
            com.Output = "X";
            com.ParentID = Company.Query("input <> 'X' and output <> 'X'")[0].ID;

            for (int i = 0; i < 10; i++)
            {
                CompanyDetail d = new CompanyDetail();
                d.BankID = Bank.Query()[0].ID;
                d.Account = i.ToString();
                d.Balance = i;
                d.Credit = i;
                com.DetailList.Add(d);
            }
            Assert.IsTrue(com.Save());
            Assert.IsTrue(com.ID > 0);

            Company q = Company.CreateByID(com.ID);
            Assert.IsTrue(q.ID == com.ID);
            Assert.IsTrue(q.DetailList.Count == 10);
            q.DetailList.RemoveAt(0);
            q.Save();

            list = q.Find("code = 'testcode'");
            Assert.IsTrue(list.Count == 1);
            Assert.IsTrue(list[0].DetailList.Count == 9);

            list = Company.Query();
            Assert.IsTrue(list.Count == count + 1);

            com.Destory();
            list = Company.Query();
            Assert.IsTrue(list.Count == count);
        }
开发者ID:hmxiaoxiao,项目名称:haimenlg,代码行数:48,代码来源:TestCompany.cs

示例4: ComponentAttribute

        public void ComponentAttribute()
        {
            Company company = new Company("Castle Corp.");
            company.Address = new PostalAddress(
                "Embau St., 102", "Sao Paulo", "SP", "040390-060");
            company.Save();

            Company[] companies = Company.FindAll();
            Assert.IsNotNull(companies);
            Assert.AreEqual(1, companies.Length);

            Company corp = companies[0];
            Assert.IsNotNull(corp.Address);
            Assert.AreEqual(corp.Address.Address, company.Address.Address);
            Assert.AreEqual(corp.Address.City, company.Address.City);
            Assert.AreEqual(corp.Address.State, company.Address.State);
            Assert.AreEqual(corp.Address.ZipCode, company.Address.ZipCode);
        }
开发者ID:zhoufoxcn,项目名称:ActiveRecord,代码行数:18,代码来源:ActiveRecordGenericsTestCase.cs

示例5: ProgrammerTest

        public void ProgrammerTest()
        {
            var address = new Address("56 Main St", "Mesa", "AZ", "85225");
            var customer = new Customer("John", "Doe", address);
            var company = new Company("Alliance Reservations Network", address);

            Assert.IsNullOrEmpty(customer.Id);
            customer.Save();
            Assert.IsNotNullOrEmpty(customer.Id);

            Assert.IsNullOrEmpty(company.Id);
            company.Save();
            Assert.IsNotNullOrEmpty(company.Id);

            Customer savedCustomer = Customer.Find(customer.Id);
            Assert.IsNotNull(savedCustomer);
            Assert.AreSame(customer.Address, address);
            Assert.AreEqual(savedCustomer.Address, address);
            Assert.AreEqual(customer.Id, savedCustomer.Id);
            Assert.AreEqual(customer.FirstName, savedCustomer.FirstName);
            Assert.AreEqual(customer.LastName, savedCustomer.LastName);
            Assert.AreEqual(customer, savedCustomer);
            Assert.AreNotSame(customer, savedCustomer);

            Company savedCompany = Company.Find(company.Id);
            Assert.IsNotNull(savedCompany);
            Assert.AreSame(company.Address, address);
            Assert.AreEqual(savedCompany.Address, address);
            Assert.AreEqual(company.Id, savedCompany.Id);
            Assert.AreEqual(company.Name, savedCompany.Name);
            Assert.AreEqual(company, savedCompany);
            Assert.AreNotSame(company, savedCompany);

            customer.Delete();
            Assert.IsNullOrEmpty(customer.Id);
            Assert.IsNull(Customer.Find(customer.Id));

            company.Delete();
            Assert.IsNullOrEmpty(company.Id);
            Assert.IsNull(Company.Find(company.Id));
        }
开发者ID:mferster,项目名称:AddressBook,代码行数:41,代码来源:Program.cs

示例6: ComponentAttribute

        public void ComponentAttribute()
        {
            using (new SessionScope()) {

                var company = new Company("Castle Corp.") {
                    Address = new PostalAddress(
                        "Embau St., 102", "Sao Paulo", "SP", "040390-060")
                };
                company.Save();

                var companies = Company.FindAll().ToArray();
                Assert.IsNotNull(companies);
                Assert.AreEqual(1, companies.Length);

                var corp = companies.First();
                Assert.IsNotNull(corp.Address);
                Assert.AreEqual(corp.Address.Address, company.Address.Address);
                Assert.AreEqual(corp.Address.City, company.Address.City);
                Assert.AreEqual(corp.Address.State, company.Address.State);
                Assert.AreEqual(corp.Address.ZipCode, company.Address.ZipCode);
            }
        }
开发者ID:shosca,项目名称:ActiveRecord,代码行数:22,代码来源:ActiveRecordTestCase.cs

示例7: HasManyAndBelongsToMany

        public void HasManyAndBelongsToMany()
        {
            long id;
            using (new SessionScope()) {
                var company = new Company("Castle Corp.") {
                    Address =
                        new PostalAddress("Embau St., 102", "Sao Paulo", "SP", "040390-060")
                };

                var person = new Person {Name = "ayende"};

                company.People.Add(person);
                person.Save();
                company.Save();
                id = company.Id;
            }

            using (new SessionScope()) {
                var fromDB = Company.Find(id);
                Assert.AreEqual(1, fromDB.People.Count);

                Assert.AreEqual("ayende", fromDB.People.First().Name);
            }
        }
开发者ID:shosca,项目名称:ActiveRecord,代码行数:24,代码来源:ActiveRecordTestCase.cs

示例8: HasManyAndBelongsToMany

		public void HasManyAndBelongsToMany()
		{
			Company company = new Company("Castle Corp.");
			company.Address = new PostalAddress(
				"Embau St., 102", "Sao Paulo", "SP", "040390-060");
			company.Save();

			Person person = new Person();
			person.Name = "ayende";
			person.Companies.Add(company);
			company.People.Add(person);

			person.Save();

			Company fromDB = Company.FindFirst();
			Assert.AreEqual(1, fromDB.People.Count);

			Assert.AreEqual("ayende", new List<Person>(fromDB.People)[0].Name);
		}
开发者ID:ralescano,项目名称:castle,代码行数:19,代码来源:ActiveRecordBaseGenericsTestCase.cs


注:本文中的Company.Save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。