Exemple #1
0
            public Customer UpdateCustomer(Customer customer)
            {
                if (customer == Customer.Null)
                    return Customer.Null;

                if (customer.Id == 0)
                {
                    using (var workspace = WorkspaceFactory.Create())
                    {
                        workspace.Add(customer);
                        workspace.CommitChanges();
                    }
                    return customer;
                }

                var result = _workspace.Single<Customer>(
                        x => x.Id == customer.Id
                        && x.Name == customer.Name
                        && x.Address == customer.Address
                        && x.PhoneNumber == customer.PhoneNumber
                        && x.Note == customer.Note);

                if (result == null)
                {
                    result = _workspace.Single<Customer>(x => x.Id == customer.Id);
                    Debug.Assert(result != null);
                    result.Address = customer.Address;
                    result.Name = customer.Name;
                    result.PhoneNumber = customer.PhoneNumber;
                    result.Note = customer.Note;
                }
                return result;
            }
Exemple #2
0
 public void UpdateCustomer(Customer customer)
 {
     if (customer == Customer.Null)
     {
         CustomerId = 0;
         CustomerName = "";
         CustomerGroupCode = "";
     }
     else
     {
         CustomerId = customer.Id;
         CustomerName = customer.Name.Trim();
        // CustomerGroupCode = (customer.GroupCode ?? "").Trim();
     }
 }
Exemple #3
0
 public void AssignCustomerToTicket(Ticket ticket, Customer customer)
 {
     Debug.Assert(ticket != null);
     ticket.UpdateCustomer(_ticketWorkspace.UpdateCustomer(customer));
 }
Exemple #4
0
 public void AssignCustomerToSelectedTicket(Customer customer)
 {
     if (SelectedTicket == null)
     {
         CreateNewTicket();
     }
     AssignCustomerToTicket(SelectedTicket, customer);
 }
 private void OnCreateCustomer(string obj)
 {
     FoundCustomers.Clear();
     var c = new Customer
                 {
                     Address = AddressSearchText,
                     Name = CustomerNameSearchText,
                     PhoneNumber = PhoneNumberSearchText
                 };
     FoundCustomers.Add(new CustomerViewModel(c));
     SelectedView = 1;
     RaisePropertyChanged("SelectedCustomer");
 }
 internal void DisplayCustomerAccount(Customer customer)
 {
     FoundCustomers.Clear();
     if (customer != null)
         FoundCustomers.Add(new CustomerViewModel(customer));
     RaisePropertyChanged("SelectedCustomer");
     OnDisplayCustomerAccount("");
 }
Exemple #7
0
        public void CanFormatTicket()
        {
            WorkspaceFactory.SetDefaultConnectionString("c:\\testData.txt");
            IWorkspace workspace = WorkspaceFactory.Create();
            Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;

            var user = new User("Emre", "1");
            workspace.Add(user);

            var menuItem1 = MenuItem.Create();
            menuItem1.Name = "Kurufasülye";
            menuItem1.Portions[0].Price.Amount = 5;

            var menuItem2 = MenuItem.Create();
            menuItem2.Name = "Pilav";
            menuItem2.Portions[0].Price.Amount = 3;

            menuItem2.AddPortion("Az", 1, "TL");

            workspace.Add(menuItem1);
            workspace.Add(menuItem2);

            var d = new Department();
            var ticket = Ticket.Create(d);

            ticket.AddTicketItem(user.Id, menuItem1, "Normal");
            ticket.AddTicketItem(user.Id, menuItem2, "Normal");
            ticket.Date = new DateTime(2010, 1, 1);
            ticket.AddTicketDiscount(DiscountType.Amount, 1, user.Id);

            var template = new PrinterTemplate();

            template.HeaderTemplate = @"SAMBA
Adisyon Tarihi:{ADİSYON TARİH}
[Müşteri Adı:
{MÜŞTERİ ADI}]";
            template.LineTemplate = @"{MİKTAR} {ÜRÜN} {FİYAT}";
            template.FooterTemplate = @"{VARSA İSKONTO}
[<C>İkram: {TOPLAM İKRAM}, teşekkürler]
[Toplam: {TOPLAM BAKİYE}]";

            var formatResult = TicketFormatter.GetFormattedTicket(ticket, ticket.GetUnlockedLines(), template);

            var expectedResult = @"SAMBA
Adisyon Tarihi:01.01.2010
1 Kurufasülye 5,00
1 Pilav 3,00
Belge TOPLAMI:|8,00
<J>İskonto:|1,00
Toplam: 7,00";

            var result = string.Join("\r\n", formatResult);

            Assert.IsTrue(result == expectedResult);

            template.MergeLines = true;
            formatResult = TicketFormatter.GetFormattedTicket(ticket, ticket.GetUnlockedLines(), template);
            result = string.Join("\r\n", formatResult);
            Assert.AreEqual(expectedResult, result);

            var l1 = ticket.AddTicketItem(user.Id, menuItem1, "Normal");
            l1.Quantity = 5;
            var l2 = ticket.AddTicketItem(user.Id, menuItem2, "Az");
            formatResult = TicketFormatter.GetFormattedTicket(ticket, ticket.GetUnlockedLines(), template);
            result = string.Join("\r\n", formatResult);
            expectedResult = @"SAMBA
Adisyon Tarihi:01.01.2010
1 Pilav 3,00
6 Kurufasülye 5,00
1 Pilav.Az 1,00
Belge TOPLAMI:|34,00
<J>İskonto:|1,00
Toplam: 33,00";

            Assert.AreEqual(expectedResult, result);

            var c = new Customer { Name = "Emre EREN" };
            workspace.Add(c);

            ticket.CustomerId = c.Id;
            ticket.CustomerName = c.Name;

            ticket.AddTicketDiscount(DiscountType.Amount, 0, user.Id);
            formatResult = TicketFormatter.GetFormattedTicket(ticket, ticket.GetUnlockedLines(), template);

            expectedResult = @"SAMBA
Adisyon Tarihi:01.01.2010
Müşteri Adı:
Emre EREN
1 Pilav 3,00
6 Kurufasülye 5,00
1 Pilav.Az 1,00
Toplam: 34,00";

            result = string.Join("\r\n", formatResult);
            Assert.IsTrue(result == expectedResult);

            l2.Gifted = true;
            template.GiftLineTemplate = "{MİKTAR} {ÜRÜN} İKRAM";

            expectedResult = @"SAMBA
Adisyon Tarihi:01.01.2010
Müşteri Adı:
Emre EREN
1 Pilav 3,00
6 Kurufasülye 5,00
1 Pilav.Az İKRAM
<C>İkram: 1,00, teşekkürler
Toplam: 33,00";

            formatResult = TicketFormatter.GetFormattedTicket(ticket, ticket.GetUnlockedLines(), template);
            result = string.Join("\r\n", formatResult);
            Assert.IsTrue(result == expectedResult);
        }
Exemple #8
0
 public CustomerViewModel(Customer model)
 {
     Model = model;
 }
Exemple #9
0
 internal void GetPaymentFromCustomer(Customer customer)
 {
     ResetTransactionData(TransactionType.Income);
     SelectedCustomer = new CustomerViewModel(customer);
 }
Exemple #10
0
 internal void AddReceivableAmount(Customer customer)
 {
     ResetTransactionData(TransactionType.Receivable);
     SelectedCustomer = new CustomerViewModel(customer);
 }
Exemple #11
0
 internal void AddLiabilityAmount(Customer customer)
 {
     ResetTransactionData(TransactionType.Liability);
     SelectedCustomer = new CustomerViewModel(customer);
 }
Exemple #12
0
 public void MakePaymentToCustomer(Customer customer)
 {
     ResetTransactionData(TransactionType.Expense);
     SelectedCustomer = new CustomerViewModel(customer);
 }