• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Customer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Customer的典型用法代码示例。如果您正苦于以下问题:C# Customer类的具体用法?C# Customer怎么用?C# Customer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Customer类属于命名空间,在下文中一共展示了Customer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: CreateCustomer

        public void CreateCustomer(Customer customer)
        {
            using (TransactionScope scope = new TransactionScope())
            {
                try
                {
                    Log.Info($"Criando um novo usuário com o CPF {customer.CPF}");

                    if (this.ExistsCustomer(customer))
                        throw new Exception($"CPF {customer.CPF} já cadastrado");

                    var userId = Guid.NewGuid();
                    customer.Id = userId;
                    customer.Password = Infra.Utils.SecurityUtils.HashSHA1(customer.Password);

                    this.customerRepository.Save(customer);

                    if (!this.Login(customer.Email, customer.Password, true, false))
                        throw new Exception("Usuário não cadastrado, por favor tente mais tarde");

                }
                catch (Exception ex)
                {
                    Log.Error(ex.Message, ex);
                    this.LogOut();
                    throw;
                }
                finally
                {
                    Log.Info($"Finalizando a criação de um novo usuário com o CPF {customer.CPF}");
                    scope.Complete();
                }
            }
        }
开发者ID:rafaelcruz-net,项目名称:mundipagg,代码行数:34,代码来源:CustomerService.cs


示例2: ShowCustomerDetails

 private void ShowCustomerDetails(Customer customer)
 {
     hidCustomerID.Value = customer.ID;
     lblCustomerID.Text = customer.ID;
     txtCompanyName.Text = customer.CompanyName;
     txtContactName.Text = customer.ContactName;
 }
开发者ID:spib,项目名称:nhcontrib,代码行数:7,代码来源:EditCustomer.aspx.cs


示例3: Serialize

 public void Serialize(SerializedData data, Customer customer)
 {
     foreach (var formatter in _formatters)
     {
         formatter.Serialize(data, customer);
     }
 }
开发者ID:Confirmit,项目名称:Students,代码行数:7,代码来源:CompositeFormatter.cs


示例4: InsertCustomer

        public void InsertCustomer(Customer customer)
        {
            using (SqlConnection conn = CreateConnection())
            {
                try
                {
                    SqlCommand cmd = new SqlCommand("dbo.usp_createKund",conn);
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;

                    cmd.Parameters.Add("@Personnummer",SqlDbType.VarChar, 15).Value = customer.PersonalNumber;
                    cmd.Parameters.Add("@Förnamn",SqlDbType.VarChar,15).Value = customer.FirstName;
                    cmd.Parameters.Add("@Efternamn",SqlDbType.VarChar,40).Value = customer.LastName;
                    cmd.Parameters.Add("@Adress",SqlDbType.VarChar,6).Value = customer.PostalCode;
                    cmd.Parameters.Add("@Ort",SqlDbType.VarChar,20).Value = customer.Town;
                    cmd.Parameters.Add("@Epost",SqlDbType.VarChar,30).Value = customer.Email;

                    cmd.Parameters.Add("@KundID",SqlDbType.Int,4).Direction = ParameterDirection.Output;
                    conn.Open();
                    cmd.ExecuteNonQuery();
                    customer.CustomerID = (int)cmd.Parameters["@KundID"].Value;
                }
                catch
                {
                    throw new ApplicationException("Något gick fel när du försökte lägga till en ny kund");
                }
            }
        }
开发者ID:so222es,项目名称:1DV406,代码行数:27,代码来源:CustomerDAL.cs


示例5: Update

 //Update
 public static void Update(Customer customer, string lastName, string firstName, string telephone, string emailAddress)
 {
     customer.FirstName = firstName;
     customer.LastName = lastName;
     customer.TelephoneNumber = telephone;
     customer.EmailAddress = emailAddress;
 }
开发者ID:jkang027,项目名称:08-HotelOrigin,代码行数:8,代码来源:CustomerRepository.cs


示例6: RegisterCustomer

        public void RegisterCustomer(string name, CustomerType customerType)
        {            
            try
            {
                using (var transaction = new TransactionScope())
                {
                    Customer customer = new Customer();
                    customer.Name = name;
                    customer.Type = customerType;

                    customer.Agreements.Add(
                        new Agreement
                            {
                                Number = agreementManagementService.GenerateAgreementNumber(),
                                CreatedOn = DateTime.Now,
                                Customer = customer
                            });

                    repository.Save(customer);
                    repository.Commit();

                    transaction.Complete();
                }
            }
            catch (Exception ex)
            {                
                throw new RegistrationException(string.Format("Failed to register customer with name '{0}' and type {1}.", name, customerType), ex);
            }                                
        }
开发者ID:RytisCapas,项目名称:InventoryManagement,代码行数:29,代码来源:RegistrationService.cs


示例7: Create

 public ActionResult Create(Customer cs, FormCollection collection)
 {
     IFormatProvider iFP = new System.Globalization.CultureInfo("vi-VN", true);
     cs.CreateDate = DateTime.Parse(collection["CreateDate"], iFP);
     var result = CustomerBusiness.Insert(cs);
     return PartialView(cs);
 }
开发者ID:thuyenvinh,项目名称:qlvx,代码行数:7,代码来源:CustomerController.cs


示例8: Account

 protected Account(Customer customer, decimal balance, decimal interestRate, uint validityInMonths = 6)
 {
     this.Customer = customer;
     this.Balance = balance;
     this.InterestRate = interestRate;
     this.ValidityInMonths = validityInMonths;
 }
开发者ID:RuParusheva,项目名称:TelerikAcademy,代码行数:7,代码来源:Account.cs


示例9: Should_Return_The_Last_Inserted_Ids

        public void Should_Return_The_Last_Inserted_Ids()
        {
            // Arrange
            const string sql = @"
CREATE TABLE IF NOT EXISTS Customer
(
    CustomerId      INTEGER         NOT NULL    PRIMARY KEY     AUTOINCREMENT,
    FirstName       NVARCHAR(120)   NOT NULL,
    LastName        NVARCHAR(120)   NOT NULL,
    DateOfBirth     DATETIME        NOT NULL
);";
            var dbConnection = Sequelocity.CreateDbConnection( ConnectionStringsNames.SqliteInMemoryDatabaseConnectionString );

            new DatabaseCommand( dbConnection )
                .SetCommandText( sql )
                .ExecuteNonQuery( true );

            var customer1 = new Customer { FirstName = "Clark", LastName = "Kent", DateOfBirth = DateTime.Parse( "06/18/1938" ) };
            var customer2 = new Customer { FirstName = "Bruce", LastName = "Wayne", DateOfBirth = DateTime.Parse( "05/27/1939" ) };
            var customer3 = new Customer { FirstName = "Peter", LastName = "Parker", DateOfBirth = DateTime.Parse( "08/18/1962" ) };
            var list = new List<Customer> { customer1, customer2, customer3 };
            
            // Act
            var customerIds = new DatabaseCommand( dbConnection )
                .GenerateInsertsForSQLite( list )
                .ExecuteToList<long>();

            // Assert
            Assert.That( customerIds.Count == 3 );
            Assert.That( customerIds[0] == 1 );
            Assert.That( customerIds[1] == 2 );
            Assert.That( customerIds[2] == 3 );
        }
开发者ID:randyburden,项目名称:Sequelocity.NET,代码行数:33,代码来源:GenerateInsertsForSqLiteTests.cs


示例10: Main

    static void Main()
    {
        Customer examplePerson = new Customer("Example Person", CustomerType.Individual);
        Customer exampleCompany = new Customer("Example Company", CustomerType.Company);

        DepositAccount deposit = new DepositAccount(examplePerson, 1200, (decimal)0.02);
        int period = 2;
        Console.WriteLine("Interest for: {0}, account type: {1}, balance: {2}, period: {3} months, interest rate: {4}%\n{5}%",
            deposit.Customer, deposit.GetType(), deposit.Balance, period, deposit.IntrestRate, deposit.CalcInterestAmount(period));

        deposit.Withdraw(300);
        Console.WriteLine("Interest for: {0}, account type: {1}, balance: {2}, period: {3} months, interest rate: {4}%\n{5}%",
            deposit.Customer, deposit.GetType(), deposit.Balance, period, deposit.IntrestRate, deposit.CalcInterestAmount(period));

        deposit.Deposit(1000);
        Console.WriteLine("Test depositing money balance: {0}", deposit.Balance);

        period = 3;
        Loan loan = new Loan(examplePerson, 1200, (decimal)0.02);
        Console.WriteLine("Interest for: {0}, account type: {1}, balance: {2}, period: {3} months, interest rate: {4}%\n{5}%",
            loan.Customer, loan.GetType(), loan.Balance, period, loan.IntrestRate, loan.CalcInterestAmount(period));

        period = 4;
        Console.WriteLine("Interest for: {0}, account type: {1}, balance: {2}, period: {3} months, interest rate: {4}%\n{5}%",
            loan.Customer, loan.GetType(), loan.Balance, period, loan.IntrestRate, loan.CalcInterestAmount(period));

        loan.Deposit(1200);
        Console.WriteLine("After repaying the loan the balance is: {0}", loan.Balance);

        //invalid period test
        //Console.WriteLine(loan.CalcInterestAmount(-3));
    }
开发者ID:damy90,项目名称:Telerik-all,代码行数:32,代码来源:Program.cs


示例11: can_commit_multiple_db_operations

        public void can_commit_multiple_db_operations()
        {
            var customer = new Customer { FirstName = "John", LastName = "Doe" };
            var salesPerson = new SalesPerson { FirstName = "Jane", LastName = "Doe", SalesQuota = 2000 };

            using (var scope = new UnitOfWorkScope())
            {
                new EFRepository<Customer>().Add(customer);
                new EFRepository<SalesPerson>().Add(salesPerson);
                scope.Commit();
            }

            using (var ordersTestData = new EFTestData(OrdersContextProvider()))
            using (var hrTestData = new EFTestData(HRContextProvider()))
            {
                Customer savedCustomer = null;
                SalesPerson savedSalesPerson = null;
                ordersTestData.Batch(action => savedCustomer = action.GetCustomerById(customer.CustomerID));
                hrTestData.Batch(action => savedSalesPerson = action.GetSalesPersonById(salesPerson.Id));

                Assert.That(savedCustomer, Is.Not.Null);
                Assert.That(savedSalesPerson, Is.Not.Null);
                Assert.That(savedCustomer.CustomerID, Is.EqualTo(customer.CustomerID));
                Assert.That(savedSalesPerson.Id, Is.EqualTo(salesPerson.Id));
            }
        }
开发者ID:jordanyaker,项目名称:ncommon,代码行数:26,代码来源:EFRepositoryTransactionTests.cs


示例12: Charge

        public static bool Charge(Customer customer, CreditCard creditCard, decimal amount)
        {
            var chargeDetails = new StripeChargeCreateOptions();
            chargeDetails.Amount = (int)amount * 100;
            chargeDetails.Currency = "usd";

            chargeDetails.Source = new StripeSourceOptions
            {
                Object = "card",
                Number = creditCard.CcNumber,
                ExpirationMonth = creditCard.ExpireDate.Month.ToString(),
                ExpirationYear = creditCard.ExpireDate.Year.ToString(),
                Cvc = creditCard.CVCCode
            };

            var chargeService = new StripeChargeService(stripeApiKey);

            var response = chargeService.Create(chargeDetails);

            if(response.Paid == false)
            {
                throw new Exception(response.FailureMessage);
            }

            return response.Paid;
        }
开发者ID:tiana-pehle,项目名称:12-PaymentKiosk,代码行数:26,代码来源:MoneyService.cs


示例13: testThreeAcounts

 public void testThreeAcounts()
 {
     Customer oscar = new Customer("Oscar")
             .openAccount(new Account(Account.SAVINGS));
     oscar.openAccount(new Account(Account.CHECKING));
     Assert.AreEqual(3, oscar.getNumberOfAccounts());
 }
开发者ID:svishnevetsky,项目名称:abc-bank-c-sharp,代码行数:7,代码来源:CustomerTest.cs


示例14: testAppWithTransfer

        public void testAppWithTransfer()
        {
            Account checkingAccount = new Account(Account.CHECKING);
            Account savingsAccount = new Account(Account.SAVINGS);

            Customer henry = new Customer("Henry").openAccount(checkingAccount).openAccount(savingsAccount);

            checkingAccount.deposit(100.0, false);
            savingsAccount.deposit(4000.0, false);
            savingsAccount.withdraw(200.0, false);
            henry.transfer(savingsAccount, checkingAccount, 400);

            Assert.AreEqual("Statement for Henry\n" +
                    "\n" +
                    "Checking Account\n" +
                    "  deposit $100.00\n" +
                    "  transfer to $400.00\n" +
                    "Total $500.00\n" +
                    "\n" +
                    "Savings Account\n" +
                    "  deposit $4,000.00\n" +
                    "  withdrawal $200.00\n" +
                    "  transfer from $400.00\n" +
                    "Total $3,400.00\n" +
                    "\n" +
                    "Total In All Accounts $3,900.00", henry.getStatement());
        }
开发者ID:svishnevetsky,项目名称:abc-bank-c-sharp,代码行数:27,代码来源:CustomerTest.cs


示例15: AddCustomer

    private Customer AddCustomer()
    {
        Customer customer = new Customer()
        {
            Address = BillingAddressControl.Address,
            CellPhone = CellPhoneTextBox.Text,
            City = BillingAddressControl.City,
            Company = ComapnyTextBox.Text,
            CountryID = BillingAddressControl.CountryID,
            DateCreated = DateTime.Now,
            DateUpdated = DateTime.Now,
            DayPhone = DayPhoneTextBox.Text,
            Email = EmailTextBox.Text,
            EveningPhone = EveningPhoneTextBox.Text,
            Fax = FaxTextBox.Text,
            StateID = BillingAddressControl.StateID,
            FirstName = FirstNameTextBox.Text,
            LastName = LastNameTextBox.Text,
            ProvinceID = BillingAddressControl.ProvinceID,
            Zipcode = BillingAddressControl.Zipcode,
            Active = true
        };

        return CustomerManager.AddCustomer(customer);
    }
开发者ID:BritishBuddha87,项目名称:shopAlott,代码行数:25,代码来源:Register.aspx.cs


示例16: AddThreeItems_RemoveMiddleItem_CheckConsistency

        public void AddThreeItems_RemoveMiddleItem_CheckConsistency()
        {
            string path = AppDomain.CurrentDomain.BaseDirectory;
            BackingUnknownSize<Customer, string> backingFile = new BackingUnknownSize<Customer, string>(path, 100);
            MMFDictionary<Customer, string> dict = new MMFDictionary<Customer, string>(path, 1000);

            Customer c1 = new Customer {Name = "Mikael"};
            Customer c2 = new Customer {Name = "Svenson"};
            Customer c3 = new Customer {Name = "Boss"};

            dict.Add(c1, "test");
            dict.Add(c2, "test2");
            dict.Add(c3, "test3");

            var result = dict.Remove(c2);
            Assert.IsTrue(result);
            result = dict.Remove(c2);
            Assert.IsFalse(result);
            dict.Add(c2, "test2");
            result = dict.Remove(c2);
            Assert.IsTrue(result);

            var res2 = dict[c3];
            Assert.AreEqual("test3", res2);
        }
开发者ID:biantech,项目名称:MMFDataStructures,代码行数:25,代码来源:DictionaryTestUnknownSizeBacking.cs


示例17: Deposit

 public Deposit(Customer customer, decimal balance, decimal interestRate, byte months)
 {
     this.Customer = customer;
     this.Balance = balance;
     this.InterestRate = interestRate;
     this.Months = months;
 }
开发者ID:klimentt,项目名称:Telerik-Academy,代码行数:7,代码来源:Deposit.cs


示例18: CustomerRepo

		static void CustomerRepo()
		{
			var _repository = new CustomerRepository();

			var aCustomer = new Customer { Name = "ABC Rentals" };

			var aRetrievedCustomer = _repository.GetCustomerByNameAsync(aCustomer.Name).Result;
			if (aRetrievedCustomer == null)
			{
				var aKey = _repository.AddCustomer(aCustomer);

				var aSavedCustomer = _repository.GetCustomer(aKey);

				Console.WriteLine(aSavedCustomer.Id == aKey
					? "Customer was saved and retrieved successfully!"
					: $"Saved customer key was {aSavedCustomer.Id} and new customer key was {aKey}");
			}
			else
			{
				var aSavedCustomer = _repository.GetCustomer(aRetrievedCustomer.Id);

				Console.WriteLine(aSavedCustomer.Id == aRetrievedCustomer.Id
					? "Customer was already in the database and retrieved successfully!"
					: $"Saved customer key was {aSavedCustomer.Id} and new customer key was {aRetrievedCustomer.Id}");

			}
		}
开发者ID:gblosser,项目名称:FullStackReference,代码行数:27,代码来源:Program.cs


示例19: btnAdd_Click

 protected void btnAdd_Click(object sender, EventArgs e)
 {
     MealPlan mp = new MealPlan();
     mp.find("PlanID = '" + this.ddlMealPlan.Text + "'");
     this.customer = (Customer)ViewState["customer"];
     this.tbCurrentMeals.Text = (this.customer.CurrentMeals + mp.MealsPerWeek).ToString();
 }
开发者ID:geoffritchey,项目名称:cafeteria,代码行数:7,代码来源:Update.aspx.cs


示例20: Register

        public async Task<ActionResult> Register() {

            var pcats = CURTAPI.GetParentCategoriesAsync();
            await Task.WhenAll(new Task[] { pcats });
            ViewBag.parent_cats = await pcats;

            List<Country> countries = UDF.GetCountries();

            Customer cust = new Customer();
            Address billing = new Address();
            Address shipping = new Address();
            bool same = true;
            try {
                cust = (Customer)TempData["customer"];
                billing = (Address)TempData["billing"];
                shipping = (Address)TempData["customer"];
                same = (bool)TempData["same"];
            } catch (Exception) { }

            ViewBag.cust = cust;
            ViewBag.billing = billing;
            ViewBag.shipping = shipping;
            ViewBag.same = same;
            ViewBag.countries = countries;
            ViewBag.error = TempData["error"];
            return View();
        }
开发者ID:curt-labs,项目名称:CURTeCommerce,代码行数:27,代码来源:AuthenticateController.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# CustomerInfoValidator类代码示例发布时间:2022-05-24
下一篇:
C# Custom_Tracer类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap