private void strategyPatternBtn_Click(object sender, RoutedEventArgs e) { // Prepare strategies IBillingStrategy normalStrategy = new NormalStrategy(); IBillingStrategy happyHourStrategy = new HappyHourStrategy(); Customer firstCustomer = new Customer(normalStrategy); // Normal billing firstCustomer.Add(1.0, 1); // Start Happy Hour firstCustomer.Strategy = happyHourStrategy; firstCustomer.Add(1.0, 2); // New Customer Customer secondCustomer = new Customer(happyHourStrategy); secondCustomer.Add(0.8, 1); // The Customer pays firstCustomer.PrintBill(); // End Happy Hour secondCustomer.Strategy = normalStrategy; secondCustomer.Add(1.3, 2); secondCustomer.Add(2.5, 1); secondCustomer.PrintBill(); }
public void CustomerTest() { Customer ct = new Customer(); string res = ct.Add(FirstName, LastName); Assert.AreEqual(rs, CustomerName); }
private void btnBridge_Click(object sender, EventArgs e) { // ------------------------------------------------------------------------ // Bridge Pattern // https://dofactory.com/net/bridge-design-pattern // Frequency of use: 3 - Medium txtOutput.Text = ""; // Create RefinedAbstraction Customer customer = new Customer("Chicago"); // Set ConcreteImplementor customer.Data = new CustomersData(); // Exercise the bridge customer.Show(); customer.Next(); customer.Show(); customer.Next(); customer.Show(); customer.Add("Henry Velasquez"); customer.ShowAll(); }
private void Button_Customer_Save_Click(object sender, RoutedEventArgs e) { Customer Customer = new Customer { //id = this.Data.id, NameFirst = this.ClientDataNameFirst.Text, NameMiddle = this.ClientDataNameMiddle.Text, NameLast = this.ClientDataNameLast.Text, Phone = this.ClientDataPhone.Text, CreditScore = int.Parse(this.ClientDataCreditScore.Text), }; if (this.Data.id == 0) { Customer.Add(); } else { Customer.id = this.Data.id; Customer.Save(); } this.MainWindow.Reload(); this.Close(); }
private void buttonStartTicket_Click(object sender, RoutedEventArgs e) { char? middleInitial; string firstName, lastName; ParseName(textBoxCustomerName.Text, out firstName, out middleInitial, out lastName); if (SelectedCustomer == null) { PhoneNumber phoneNumber = PhoneNumber.Add(phoneNumberEditControl.Text, null); Person person = Person.Add(firstName, middleInitial, lastName, textBoxStreetAddress.Text, textBoxStreetAddress2.Text, GetZipCode(), phoneNumber.Id, 0, 0, 0, 0, 0, null); SelectedCustomer = Customer.Add(person.Id, null); } else { Person person = Person.Get(SelectedCustomer.PersonId); person.SetAddressLine1(textBoxStreetAddress.Text); person.SetAddressLine2(textBoxStreetAddress2.Text); person.SetFirstName(firstName); person.SetLastName(lastName); person.SetMiddleInitial(middleInitial); person.SetZipCodeId(GetZipCode()); person.Update(); } if (ActiveTicket != null) { ActiveTicket.SetCustomerId(SelectedCustomer.Id); ActiveTicket.Update(); } // Closes the dialog window, so the carryout ticket can be created Window.GetWindow(this).Close(); }
static void Main(string[] args) { Customer customer = new Customer(new Oracle()); customer.Add(); Console.ReadKey(); }
public void GetData(string SqlString) { string connectionString = @"Data Source=.\SQLEXPRESS;Initial Catalog=Products;Integrated Security=True;Pooling=False"; SqlConnection conn = new SqlConnection(connectionString); conn.Open(); SqlCommand command = new SqlCommand(SqlString, conn); using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { string UserId = reader["CustomerId"].ToString(); string productId = reader["ProductId"].ToString(); string rating = reader["rating"].ToString(); Review r = new Review(productId, UserId, int.Parse(rating)); Review t = new Review(productId, UserId, int.Parse(rating)); Reviews.Add(r); Customer c = new Customer(UserId); Product p = new Product(productId); c.Add(Customers); p.Add(Products); } } }
public HttpResponseMessage add(Customer post) { // Check for errors if (post == null) { return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The post is null")); } else if (Language.MasterPostExists(post.language_id) == false) { return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The language does not exist")); } else if (Country.MasterPostExists(post.invoice_country) == false) { return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The invoice country does not exist")); } else if (Country.MasterPostExists(post.delivery_country) == false) { return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The delivery country does not exist")); } // Make sure that the data is valid post.email = AnnytabDataValidation.TruncateString(post.email, 100); post.customer_password = PasswordHash.CreateHash(post.customer_password); post.org_number = AnnytabDataValidation.TruncateString(post.org_number, 20); post.vat_number = AnnytabDataValidation.TruncateString(post.vat_number, 20); post.contact_name = AnnytabDataValidation.TruncateString(post.contact_name, 100); post.phone_number = AnnytabDataValidation.TruncateString(post.phone_number, 100); post.mobile_phone_number = AnnytabDataValidation.TruncateString(post.mobile_phone_number, 100); post.invoice_name = AnnytabDataValidation.TruncateString(post.invoice_name, 100); post.invoice_address_1 = AnnytabDataValidation.TruncateString(post.invoice_address_1, 100); post.invoice_address_2 = AnnytabDataValidation.TruncateString(post.invoice_address_2, 100); post.invoice_post_code = AnnytabDataValidation.TruncateString(post.invoice_post_code, 100); post.invoice_city = AnnytabDataValidation.TruncateString(post.invoice_city, 100); post.delivery_name = AnnytabDataValidation.TruncateString(post.delivery_name, 100); post.delivery_address_1 = AnnytabDataValidation.TruncateString(post.delivery_address_1, 100); post.delivery_address_2 = AnnytabDataValidation.TruncateString(post.delivery_address_2, 100); post.delivery_post_code = AnnytabDataValidation.TruncateString(post.delivery_post_code, 100); post.delivery_city = AnnytabDataValidation.TruncateString(post.delivery_city, 100); post.facebook_user_id = AnnytabDataValidation.TruncateString(post.facebook_user_id, 50); post.google_user_id = AnnytabDataValidation.TruncateString(post.google_user_id, 50); // Get a customer on the email address Customer customerOnEmail = Customer.GetOneByEmail(post.email); // Check if the email exists if (customerOnEmail != null && post.id != customerOnEmail.id) { return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The email is not unique")); } // Add the post Int32 insertId = (Int32)Customer.Add(post); // Update the password Customer.UpdatePassword(insertId, post.customer_password); // Return the success response return(Request.CreateResponse <string>(HttpStatusCode.OK, "The post has been added")); } // End of the add method
public static void Run() { Customer c = new Customer("Almacen"); c.Data = new CustomerData(); c.Add("Juan Pedro"); c.Show(); }
public void TestCustomerAdd() { INotiificationService notify = new Email(); Customer cust = new Customer(notify); var result = cust.Add(); Assert.AreEqual(result, true); }
static void Main(string[] args) { Customer customer = new Customer(); customer.Logger = new DatabaseLogger(); customer.Add(); Console.ReadLine(); }
// e.g. private void ManipulateCustomers() { var database = new Database(); var customer = new Customer(); customer.Add(database); // Old functionality, works fine var readCustomer = new CustomerWithRead(); readCustomer.Read(); // Good! New functionalty is separate from existing customers }
public void Demo() { IDatabase i = new Customer(); // 1000 happy old clients not touched i.Add(); IDatabaseV1 iv1 = new CustomerwithRead(); // new clients iv1.Read(); }
private void btnSave_Click(object sender, EventArgs e) { try { if (txtAddress.Text == null || txtAddress.Text == "" || txtSupName.Text == null || txtSupName.Text == "" || txtContactNo.Text == null || txtContactNo.Text == "" || txtCompany.Text == "" || txtCompany.Text == null) { MessageBox.Show("Please enter valid data"); return; } string NIC = txtSupName.Text; Customer supObj = new Customer();; bool isExist = supObj.checkNameExit(NIC, con); if (isExist) { PopupNotifier pop = new PopupNotifier(); pop.ContentText = "Customer Name already exist "; pop.TitleText = "Redundancy Error"; pop.Image = Resources.warning_sign_48; // or Image.FromFile(--Path--) pop.IsRightToLeft = false; pop.ContentHoverColor = Color.OrangeRed; pop.BodyColor = Color.White; pop.HeaderColor = Color.Teal; pop.Popup(); return; } supObj.Name = txtSupName.Text; supObj.Address = txtAddress.Text; supObj.Contact = txtContactNo.Text; supObj.NIC = txtCompany.Text; if (supObj.Add(con)) { MetroMessageBox.Show(this, "Customer Data Stored Successfully", "System Message", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); PopupNotifier pop = new PopupNotifier(); pop.ContentText = "Customer Data Added Successfully"; pop.TitleText = "Saved"; pop.Image = Resources.success_48; // or Image.FromFile(--Path--) pop.IsRightToLeft = false; pop.ContentHoverColor = Color.OrangeRed; pop.BodyColor = Color.White; pop.HeaderColor = Color.Teal; pop.Popup(); LoadCartInitial(); } } catch (Exception ex) { MetroMessageBox.Show(this, ex.Message, "System Error!", MessageBoxButtons.OKCancel, MessageBoxIcon.Error); } }
public StubDataCustomerRepository(MemoryRepository <Customer> memRepository) { this.memRepository = memRepository; Customer customer = Customer.Create(new Guid("5D5020DA-47DF-4C82-A722-C8DEAF06AE23"), "john", "smith", "*****@*****.**", Country.Create(new Guid("229074BD-2356-4B5A-8619-CDEBBA71CC21"), "United Kingdom")); customer.Add(CreditCard.Create(customer, "MR J SMITH", 123122131, DateTime.Today.AddDays(1))); this.memRepository.Add(customer); }
static void Main(string[] args) { #region AggergateAndIteratorUse var customer = new Customer(); try { customer.Add(new Address() { Type = "o" }); customer.Add(new Address() { Type = "h" }); } catch (Exception e) { Console.WriteLine(e.Message + " " + e.StackTrace); } foreach (var item in customer.GetAddresses()) { Console.WriteLine(item.Type); } Console.Read(); #endregion #region AdapterPatternUse IExport rep = new WorReport(); rep.Export(); rep = new ExcelReport(); rep.Export(); rep = new AdapterPdf(); rep.Export(); #endregion }
public void SingleNewReleaseStatement() { customer.Add(new Rental(new Movie("The Cell", Movie.NewRelease), 3)); Assert.Equal( "Rental Record for Fred" + Env.NewLine + TAB + "The Cell" + TAB + "9.00" + Env.NewLine + "You owed 9.00" + Env.NewLine + "You earned 2 frequent renter points" + Env.NewLine, customer.Statement()); }
static void Main(string[] args) { Account a1 = new Account() { Balance = 5 }; Account a2 = new Account() { Balance = 10 }; Account a3 = new Account() { Balance = 15 }; Customer c1 = new Customer(); c1.Add(a1); c1.Add(a2); Customer c2 = new Customer(); c2.Add(a3); Bank b = new Bank(); b.Add(c1); b.Add(c2); Console.WriteLine(); a1.Balance += 100; }
//UI static void Main(string[] args) { IUnityContainer objContainer = new UnityContainer(); objContainer.RegisterType <Customer>(); objContainer.RegisterType <IDal, SqlserverDAl>(); //objContainer.RegisterType<IDal, OracleDal>(); Customer obj = objContainer.Resolve <Customer>(); obj.CustomerName = "test"; obj.Add(); }
public void AddTest() { Customer customer = new Customer(); try { customer.Add(new Database()); Assert.ReferenceEquals(new Customer(), customer); } catch (Exception ex) { Assert.Fail(); } }
public void Test_Execute() { // Prepare strategies IBillingStrategy normalStrategy = new NormalStrategy(); IBillingStrategy happyHourStrategy = new HappyHourStrategy(); Customer firstCustomer = new Customer(normalStrategy); // Normal billing firstCustomer.Add(1.0, 1); // Start Happy Hour firstCustomer.Strategy = happyHourStrategy; firstCustomer.Add(1.0, 2); // New Customer Customer secondCustomer = new Customer(happyHourStrategy); secondCustomer.Add(0.8, 1); // End Happy Hour secondCustomer.Strategy = normalStrategy; secondCustomer.Add(1.3, 2); secondCustomer.Add(2.5, 1); // Check calculated bill Assert.Equal(2.0, firstCustomer.GetCurrentBill()); Assert.Equal(5.5, secondCustomer.GetCurrentBill()); // The Customers pay, clear bill firstCustomer.PrintBill(); secondCustomer.PrintBill(); // Check bill cleared Assert.Equal(0, firstCustomer.GetCurrentBill()); Assert.Equal(0, secondCustomer.GetCurrentBill()); }
private void Insert_Customer() { var repository = new Customer(); if (repository.Add(get_Data_From_Form())) { this.ShowSuccessfulNotification("Customer added successfully."); clear_form(); Load_Data_Grid(); } else { this.ShowErrorNotification("Error occured."); } }
public static void Run() { Customer firstCustomer = new Customer(new NormalStrategy()); // Normal billing firstCustomer.Add(1.0, 1); // Start Happy Hour firstCustomer.Strategy = new HappyHourStrategy(); firstCustomer.Add(1.0, 2); // New Customer Customer secondCustomer = new Customer(new HappyHourStrategy()); secondCustomer.Add(0.8, 1); // The Customer pays firstCustomer.PrintBill(); // End Happy Hour secondCustomer.Strategy = new NormalStrategy(); secondCustomer.Add(1.3, 2); secondCustomer.Add(2.5, 1); secondCustomer.PrintBill(); }
static void Main(string[] args) { //This code is complex. Customer UI developer has to be aware that VALIDATE() should be called befor ADD() //Customer UI developer has to know too much about this components //What if he forgets to call Validate() and calls Add() directly? Customer obj = new Customer(); //As Validate() is now private thier is no more need to call this here also it's not accessible anymore //obj.Validate();//Validates //obj.Validate1(); //Not accessible as it's protected //obj.Validate2();//Not accessible as it's internal //obj.Validate3();//Not accessible as it's protected internal //As Add() is public it's accessible anywhere obj.Add();//Insert this data }
static void Main(string[] args) { // From Data out Customer obj = new Customer(); List <CustomerDTO> oCustomers = obj.getCustomers(); // Data in Customer objCust = new Customer(); objCust.CustomerCode = "c001"; objCust.CustomerName = "Shivprasad"; AddressEntity objAddress = new AddressEntity(); objAddress.Address1 = "Mumbai"; objCust.Add(objAddress); }
private void btnAdd_Click(object sender, EventArgs e) { // Kiểm tra mã CustomerID xem đã tồn tại hay chưa Customer newCus = Customer.Single(txtCustomerID.Text); if (newCus != null) { MessageBox.Show("This customer ID is exted!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); btnAdd.Enabled = false; return; } newCus = customerLoad(); Customer.Add(newCus); MessageBox.Show("Adding is successful!", "Message Box!", MessageBoxButtons.OK, MessageBoxIcon.Information); this.DialogResult = System.Windows.Forms.DialogResult.OK; }
static void Main(string[] args) { IUnityContainer container = new UnityContainer(); /* * Registers all the dependencies */ container.RegisterType <Customer>(); container.RegisterType <Idal, SQLServer>(); //container.RegisterType<Idal, Oracle>(); /* * Resolves the depedencies */ Customer customer = container.Resolve <Customer>(); customer.Add(); Console.ReadKey(); }
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { var temp = serializer.Deserialize <Dictionary <string, object> >(reader); var eobj = new Customer(); foreach (var key in temp.Keys) { if (key == "Id") { eobj.Id = (Guid)temp[key]; } else { eobj.Add(key, temp[key]); } } return(eobj); }
static void Main(string[] args) { IUnityContainer objContainer = new UnityContainer(); objContainer.RegisterType <IDal, Oracle>(); objContainer.RegisterType <IDal, SQLServer>("MsSQL"); objContainer.RegisterType <IDal, PostgresSQL>("PostgresSQL"); // Registers Customer type objContainer.RegisterType <Customer>("MsSQLCustomer", new InjectionConstructor(objContainer.Resolve <IDal>("MsSQL"))); objContainer.RegisterType <Customer>("PostgresSQLCustomer", new InjectionConstructor(objContainer.Resolve <IDal>("PostgresSQL"))); Customer customer = objContainer.Resolve <Customer>(); Customer customer1 = objContainer.Resolve <Customer>("MsSQLCustomer"); Customer customer2 = objContainer.Resolve <Customer>("PostgresSQLCustomer"); customer.Name = "Alberto"; customer.Add(); }
static void Main(string[] args) { //Circle c = new Circle(); //c.Age = 20; //Setter part executes here //int StudentAge = c.Age; //Getter part executes here //Console.WriteLine("Enter the Score"); //c.Score = Convert.ToInt32(Console.ReadLine()); //Console.WriteLine($"You have entered score : {c.Score}"); //c.ShowAge(); //Constructor //Example e = new Example(2); //e.DisplayUserID(); //student std = new student(); //Employee emp; //Shape s = new Shape(); //s.Add(20, 30); //s.Sub(50, 20);i //s.CircleArea(4); Consume c = new Consume(1); c.Add(); c.Multiply(); c.Jack(); Customer cs = new Customer(1); cs.Add(); int a = 4; int k = a.Square(); k = a.Tri(4); double d = 2; double res = d.Area(); Console.ReadKey(); }
private void Task_ImportCustomers(Objsearch oQuery, Quickbooks oQuickbooks) { try { oQuery.OpenQBConnection(); oQuery.QBXMLVersion = "5.0"; oQuery.QueryType = ObjsearchQueryTypes.qtCustomerSearch; CustomerResult oCustomerResult = oQuickbooks.GetCustomers(); List<int> oSMSIDImported = new List<int>(); if (oCustomerResult.IsSuccessfull) { m_iTotal = oCustomerResult.Customers.Count(); m_iCurrent = 0; int customerCount = 0; int importedCount = 0; int duplicateNameCount = 0; int errorCount = 0; customerCount = oCustomerResult.Customers.Count; foreach (var oCustomer in oCustomerResult.Customers) { oQuery.SearchCriteria = new SearchCriteria(); oQuery.SearchCriteria.NameStartsWith = oCustomer.Name; oQuery.Search(); CompanyUniqueness companyUnique = this.IsUniqueCustomerName(oCustomer.Name, oQuery.Results); if (companyUnique == CompanyUniqueness.Unique) { // Add new customer into Quickbooks Customer oQuickbooksCustomer = new Customer(); oQuickbooksCustomer.OpenQBConnection(); oQuickbooksCustomer.CustomerName = oCustomer.Name; oQuickbooksCustomer.CompanyName = oCustomer.Name; oQuickbooksCustomer.AltContactName = oCustomer.BillingName; oQuickbooksCustomer.AltPhone = oCustomer.BillingPhone; oQuickbooksCustomer.ContactName = oCustomer.Contact; oQuickbooksCustomer.Phone = oCustomer.Phone; oQuickbooksCustomer.Fax = oCustomer.Fax; if (oCustomer.ShippingCountry == "United States") { oQuickbooksCustomer.ShippingAddress = string.Format("<Addr1>{0}</Addr1><Addr2>{1}</Addr2><Addr3>{2}</Addr3><City>{3}</City><State>{4}</State><PostalCode>{5}</PostalCode><Country>{6}</Country>", oCustomer.Name, oCustomer.ShippingAddressLine1, oCustomer.ShippingAddressLine2, oCustomer.ShippingCity, oCustomer.ShippingState, oCustomer.ShippingZip, oCustomer.ShippingCountry); } else { // Not the United States, ignore the state value completely oQuickbooksCustomer.ShippingAddress = string.Format("<Addr1>{0}</Addr1><Addr2>{1}</Addr2><Addr3>{2}</Addr3><City>{3}</City><PostalCode>{4}</PostalCode><Country>{5}</Country>", oCustomer.Name, oCustomer.ShippingAddressLine1, oCustomer.ShippingAddressLine2, oCustomer.ShippingCity, oCustomer.ShippingZip, oCustomer.ShippingCountry); } if (oCustomer.BillingCountry == "United States") { oQuickbooksCustomer.BillingAddress = string.Format("<Addr1>{0}</Addr1><Addr2>{1}</Addr2><Addr3>{2}</Addr3><City>{3}</City><State>{4}</State><PostalCode>{5}</PostalCode><Country>{6}</Country>", oCustomer.Name, oCustomer.BillingAddressLine1, oCustomer.BillingAddressLine2, oCustomer.BillingCity, oCustomer.BillingState, oCustomer.BillingZip, oCustomer.BillingCountry); } else { // Not the United States, ignore the state value completely oQuickbooksCustomer.BillingAddress = string.Format("<Addr1>{0}</Addr1><Addr2>{1}</Addr2><Addr3>{2}</Addr3><City>{3}</City><PostalCode>{4}</PostalCode><Country>{5}</Country>", oCustomer.Name, oCustomer.BillingAddressLine1, oCustomer.BillingAddressLine2, oCustomer.BillingCity, oCustomer.BillingZip, oCustomer.BillingCountry); } oQuickbooksCustomer.Email = oCustomer.InvoiceEmails.Replace(",", ";"); oQuickbooksCustomer.TermsName = "NET 30 DAYS"; oQuickbooksCustomer.Config(string.Format("FirstName={0}", oCustomer.Name)); oQuickbooksCustomer.Config("LastName="); try { oQuickbooksCustomer.Add(); oQuickbooksCustomer.SetCustomField("SMSID", oCustomer.SMSID.ToString()); oSMSIDImported.Add(oCustomer.SMSID); importedCount += 1; } catch (Exception oException) { errorCount += 1; MessageBox.Show(oException.Message + System.Environment.NewLine + System.Environment.NewLine + oException.StackTrace); } finally { oQuickbooksCustomer.CloseQBConnection(); } } else if (companyUnique == CompanyUniqueness.DuplicateMarkImported) { oSMSIDImported.Add(oCustomer.SMSID); duplicateNameCount += 1; } else { duplicateNameCount += 1; } this.UpdateProgress(); if (m_oWorkerProcess.CancellationPending) { break; } } if (customerCount > 0) { MessageBox.Show("Customer import results:" + System.Environment.NewLine + " Attempted: " + customerCount.ToString() + System.Environment.NewLine + " Imported: " + importedCount.ToString() + System.Environment.NewLine + " Duplicates: " + duplicateNameCount.ToString() + System.Environment.NewLine + " Errors: " + errorCount.ToString(), "Import Results"); } } else { MessageBox.Show(oCustomerResult.ErrorMessage, "API/Service Error"); } oQuickbooks.UpdateWebServiceOfImportedCustomer(oSMSIDImported); m_oWorkerProcess.ReportProgress(100); } catch (Exception e) { MessageBox.Show(e.Message + System.Environment.NewLine + System.Environment.NewLine + e.StackTrace); } finally { oQuery.CloseQBConnection(); } }