示例#1
0
        private void buy_Click(object sender, RoutedEventArgs e)
        {
            if (credit.IsChecked == true && crcNumber == 0)
            {
                string s = onTimeCredit.Text;
                if (s.Length < 16)
                {
                    MessageBox.Show("Your credit card Number must Be 16 digits");
                    return;
                }
                try
                {
                    Transaction t = new Transaction(receipt, "Credit");
                    t.CrcNum = Convert.ToInt64(s);
                    itsBL.add(t);
                    updateStock();
                    if (clbMember != null)
                    {
                        clbMember.addTransactionToHistory(t.TransactionID);
                        itsBL.edit(clbMember);
                    }
                    itsBL.saveDataToFile();

                    this.receipt = new Receipt();
                    this.recieptGrid.ItemsSource = receipt.Data;
                    MessageBox.Show("Transaction has been successful");
                    return;
                }
                catch (Exception)
                {
                    MessageBox.Show("Your credit card Number must be a number smartAss");
                    return;
                }
            }
            else
            {
                if (credit.IsChecked == true)
                {
                    Transaction t = new Transaction(receipt, "Credit");
                    t.CrcNum = crcNumber;
                    itsBL.add(t);
                    updateStock();
                    if (clbMember != null)
                    {
                        clbMember.addTransactionToHistory(t.TransactionID);
                        itsBL.edit(clbMember);
                    }
                    itsBL.saveDataToFile();
                    this.receipt = new Receipt();
                    MessageBox.Show("Transaction has been successful");
                    return;
                }
                else if (cash.IsChecked == true)
                {
                    {
                        Transaction t = new Transaction(receipt, "Cash");
                        itsBL.add(t);
                        updateStock();
                        if (clbMember != null)
                        {
                            clbMember.addTransactionToHistory(t.TransactionID);
                            itsBL.edit(clbMember);
                        }

                        itsBL.saveDataToFile();
                        this.receipt = new Receipt();
                        this.recieptGrid.ItemsSource = receipt.Data;
                        payScreen.clearReceipt();
                        //  payScreen.receiptDTG
                        MessageBox.Show("Transaction has been successful");
                        return;
                    }
                }
                else if (check.IsChecked == true)
                {
                    {
                        Transaction t = new Transaction(receipt, "Check");
                        itsBL.add(t);
                        updateStock();
                        if (clbMember != null)
                        {
                            clbMember.addTransactionToHistory(t.TransactionID);
                            itsBL.edit(clbMember);
                        }
                        itsBL.saveDataToFile();
                        this.receipt = new Receipt();
                        MessageBox.Show("Transaction has been successful");
                        return;
                    }
                }
            }
        }
示例#2
0
文件: Edit.cs 项目: Landy-man/Intro
        public void editClubMember(ClubMember premember)                            /////club member
        {
            Console.Clear();
            ClubMember newClubMember = new ClubMember(premember);

            Console.WriteLine("you choose to edit the next club member: ");
            Console.WriteLine(premember.toString() + "\n");
            bool ans = true;

            while (ans)
            {
                string cmd;
                Console.WriteLine("Choose the field you want to change: ");
                Console.WriteLine("\t1. Club member's first name ");
                Console.WriteLine("\t2. Club member's last name ");
                Console.WriteLine("\t3. Club member's transaction history ");
                cmd = Console.ReadLine();

                switch (cmd)
                {
                case "1":
                    Console.WriteLine("enter the new first name: ");
                    string first = Console.ReadLine();
                    if (first.Length < 1)
                    {
                        Console.WriteLine("Invalid First Name, Must Have Atleast One Character");
                    }
                    else
                    {
                        newClubMember.FirstName = first;
                    }

                    break;

                case "2":
                    Console.WriteLine("enter the new last name: ");
                    string last = Console.ReadLine();
                    if (last.Length < 1)
                    {
                        Console.WriteLine("Invalid last Name, Must Have Atleast One Character");
                    }
                    else
                    {
                        newClubMember.LastName = last;
                    }

                    break;

                case "3":
                    Console.WriteLine("press 1 to add transaction to club member's transaction history ");
                    Console.WriteLine("press 2 to remove transaction from club member's transaction history ");
                    string next = Console.ReadLine();
                    switch (next)
                    {
                    case "1":
                        Console.WriteLine("enter transaction ID for add it to the history (notice! must be numbers): ");
                        string tranID = Console.ReadLine();
                        while (!(InputCheck.isInt(tranID)))
                        {
                            Console.WriteLine("The transaction ID must be a positive number");
                            Console.WriteLine("enter transaction ID (notice! must be numbers): ");
                            tranID = Console.ReadLine();
                        }
                        int add = Convert.ToInt32(tranID);
                        try
                        {
                            newClubMember.addTransactionToHistory(add);
                        }
                        catch (Exception e)
                        {
                            print(e.Message, "ERROR: ");
                            Console.ReadKey();
                        }
                        break;

                    case "2":
                        Console.WriteLine("enter transaction to remove fron the history");
                        string remove = Console.ReadLine();
                        while (!(InputCheck.isInt(remove)))
                        {
                            Console.WriteLine("The transaction ID must be a positive number");
                            Console.WriteLine("enter transaction ID (notice! must be numbers): ");
                            tranID = Console.ReadLine();
                        }
                        int toRemove = Convert.ToInt32(remove);
                        try{
                            newClubMember.removeTransactionHostory(toRemove);
                        }
                        catch (Exception e)
                        {
                            print(e.Message, "ERROR: ");
                            Console.ReadKey();
                        }

                        break;

                    default:
                        Console.WriteLine(" You have performed an illegal move ");
                        break;
                    }
                    break;
                }

                Console.WriteLine("In order to continue edit the same club member press  1 ");
                Console.WriteLine("if you finish press any other key ");
                string indicate = Console.ReadLine();
                if (indicate != "1")
                {
                    ans = false;
                    try
                    {
                        itsBL.edit(newClubMember);
                        Console.WriteLine("Changes have been done");
                        Thread.Sleep(2000);
                        saveAndBack();
                    }
                    catch (Exception e)
                    {
                        print(e.Message, "ERROR: ");
                        Console.ReadKey();
                    }
                }
            }
        }