public Dictionary <string, TransactionSummaryGameObjectList> ExpandCollapseThirdPanel(
        bool shouldExpandPanel, TransactionSummarySubDetailsData selectedTransSubData, string parentKey,
        Dictionary <string, TransactionSummaryGameObjectList> transactionGameObjectDict)
    {
        if (!shouldExpandPanel)
        {
            transactionGameObjectDict.Remove(parentKey + "_" + selectedTransSubData.GetPrimaryKey());
        }
        else
        {
            transactionGameObjectDict.Remove(parentKey + "_" + selectedTransSubData.GetPrimaryKey());

            GameObject parentGameObject = transactionGameObjectDict[parentKey].GetParentGameObject();

            GameObject selectedSubPanel = parentGameObject.transform.Find("ThirdSubPanel_" + parentKey + "_" + selectedTransSubData.GetPrimaryKey()).gameObject;
            TransactionSummaryGameObjectList transactionGameObjects = new TransactionSummaryGameObjectList(parentKey + "_" + selectedTransSubData.GetPrimaryKey(), selectedSubPanel);
            transactionGameObjects.SetExpandedFlag(true);
            transactionGameObjectDict.Add(parentKey + "_" + selectedTransSubData.GetPrimaryKey(), transactionGameObjects);

            foreach (TransactionSummaryDetailsData tsDetailsData in selectedTransSubData.getTransactionSummaryDetailsData())
            {
                GameObject  tempTransactionsPanel = (GameObject)Instantiate(transactionsPanel, transform.position, transform.rotation);
                Transform[] ts = tempTransactionsPanel.transform.GetComponentsInChildren <Transform>();
                tempTransactionsPanel.name = "TransactionsPanel_" + parentKey + "_" + selectedTransSubData.GetPrimaryKey() + "_" + tsDetailsData.GetPrimaryKey();

                foreach (Transform t in ts)
                {
                    switch (t.gameObject.name)
                    {
                    case "TransactionPanelMainText":
                        t.gameObject.GetComponent <Text>().text = "Transaction #" + tsDetailsData.GetPrimaryKey() + ", " + tsDetailsData.GetTransactionTime() + " - $" + tsDetailsData.GetTotalPrice();
                        break;

                    case "TransactionPanelSubText":
                        t.gameObject.GetComponent <Text>().text = "";
                        break;
                    }
                }

                tempTransactionsPanel.SetActive(true);
                tempTransactionsPanel.transform.SetParent(selectedSubPanel.transform, false);
                transactionGameObjects.GetTransactionSummaryGameObjects().Add(tempTransactionsPanel);
            }
        }
        return(transactionGameObjectDict);
    }
Exemplo n.º 2
0
    public void displayTransactionDetails(bool isAlreadyExpanded, string selectedPanelKey)
    {
        transactionDetailsList.RemoveAllRows();
        TransactionDetailsRow            row = transactionDetailsList.AddRow();
        TransactionSummaryGameObjectList transactionGameObjects = null;

        row.InitiateTransactionDetailsRow(selectedMainPanelKey);
        transactionGameObjectDict = row.expandCollapseTransactionDetailsRows(selectedMainPanelSubDetailsData, selectedMainPanelKey,
                                                                             true, transactionGameObjectDict);
        transactionGameObjects = transactionGameObjectDict[selectedMainPanelKey];
        GameObject transactionDetailsParentPanel = transactionGameObjects.GetParentGameObject();

        foreach (TransactionSummaryDetailsData tsDetailsData in selectedMainPanelSubDetailsData.getTransactionSummaryDetailsData())
        {
            string currentTransactionDetailsPanelkey = selectedMainPanelKey + "_" + tsDetailsData.GetPrimaryKey();
            bool   curTransactionPanelExpandedFlag   = false;

            if ((currentTransactionDetailsPanelkey).Equals(selectedPanelKey))
            {
                curTransactionPanelExpandedFlag = !isAlreadyExpanded;
            }
            else
            {
                if (transactionGameObjectDict.ContainsKey(currentTransactionDetailsPanelkey))
                {
                    transactionGameObjects          = transactionGameObjectDict[currentTransactionDetailsPanelkey];
                    curTransactionPanelExpandedFlag = transactionGameObjects.IsExpanded();

                    if (curTransactionPanelExpandedFlag)
                    {
                        //transactionGameObjectDict = row.ExpandCollapseThirdPanel(curFinalPanelExpandedFlag, tsSubDetailsData, currentSecondSubPanelkey, transactionGameObjectDict);
                    }
                }
            }

            GameObject transactionDetailsPanel = transactionDetailsParentPanel.transform.Find("TransactionsPanel_" + currentTransactionDetailsPanelkey).gameObject;
            //transactionDetailsPanel.GetComponentsInChildren<Button>()[0].onClick.AddListener(() => displayTransactionDetails(curTransactionPanelExpandedFlag, currentTransactionDetailsPanelkey));
            transactionDetailsPanel.GetComponentsInChildren <Button>()[0].onClick.AddListener(() => openTransactionReceipt(tsDetailsData));
        }
    }
Exemplo n.º 3
0
    /* Return sorted transaction list by date */
    public List <TransactionSummaryData> GetTransactionsSortedByDate()
    {
        List <Transaction>            transactionList            = transactionListContainer.transactionList;
        List <TransactionSummaryData> transactionSummaryDataList = new List <TransactionSummaryData>();

        Dictionary <string, TransactionSummaryData>           transactionSummaryDataDict           = new Dictionary <string, TransactionSummaryData>();
        Dictionary <string, TransactionSummaryFirstSubData>   transactionSummaryFirstSubDataDict   = new Dictionary <string, TransactionSummaryFirstSubData>();
        Dictionary <string, TransactionSummarySecondSubData>  transactionSummarySecondSubDataDict  = new Dictionary <string, TransactionSummarySecondSubData>();
        Dictionary <string, TransactionSummarySubDetailsData> transactionSummarySubDetailsDataDict = new Dictionary <string, TransactionSummarySubDetailsData>();

        TransactionSummaryData           transactionSummaryData;
        TransactionSummaryFirstSubData   transactionSummaryFirstSubData   = null;
        TransactionSummarySecondSubData  transactionSummarySecondSubData  = null;
        TransactionSummarySubDetailsData transactionSummarySubDetailsData = null;
        TransactionSummaryDetailsData    transactionSummaryDetailsData    = null;

        foreach (Transaction transaction in transactionList)
        {
            string date  = transaction.datetime.Substring(0, 11);
            string year  = date.Substring(7, 4);
            string month = date.Substring(3, 3);
            string day   = date.Substring(0, 2);
            string time  = transaction.datetime.Substring(12, 8);
            transactionSummaryDetailsData = null;

            transactionSummaryData = new TransactionSummaryData(year);

            foreach (ItemRowData itemRowData in transaction.itemListData.itemRowDataListContainer.itemRowDataList)
            {
                string owner = itemRowData.productOwner;

                if (transactionSummarySubDetailsDataDict.ContainsKey(year + month + day + owner))
                {
                    transactionSummarySubDetailsData = transactionSummarySubDetailsDataDict[year + month + day + owner];

                    if (transactionSummaryDetailsData == null)
                    {
                        transactionSummaryDetailsData = new TransactionSummaryDetailsData(transaction.GetTransactionID() + "");
                        Transaction tempTransaction = new Transaction(transaction.GetTransactionID());
                        tempTransaction.SetDateTime(transaction.datetime);
                        tempTransaction.SetPaymentMethod(transaction.paymentMethod);
                        tempTransaction.itemListData.itemRowDataListContainer.itemRowDataList.Add(itemRowData);
                        transactionSummaryDetailsData.getTransactionList().Add(tempTransaction);

                        transactionSummarySubDetailsData.getTransactionSummaryDetailsData().Add(transactionSummaryDetailsData);
                    }
                    else
                    {
                        transactionSummaryDetailsData.getTransactionList().First().itemListData.itemRowDataListContainer.itemRowDataList.Add(itemRowData);
                    }

                    transactionSummaryDetailsData.SetTotalPrice(transactionSummaryDetailsData.GetTotalPrice() + itemRowData.itemPrice * itemRowData.quantity);
                    transactionSummaryDetailsData.SetTransactionTime(time);

                    transactionSummarySecondSubData = transactionSummarySecondSubDataDict[year + month + day];
                    transactionSummaryFirstSubData  = transactionSummaryFirstSubDataDict[year + month];
                    transactionSummaryData          = transactionSummaryDataDict[year];

                    transactionSummarySubDetailsData.SetTotalPrice(transactionSummarySubDetailsData.GetTotalPrice() + (itemRowData.itemPrice * itemRowData.quantity));
                    transactionSummarySecondSubData.SetTotalPrice(transactionSummarySecondSubData.GetTotalPrice() + (itemRowData.itemPrice * itemRowData.quantity));
                    transactionSummaryFirstSubData.SetTotalPrice(transactionSummaryFirstSubData.GetTotalPrice() + (itemRowData.itemPrice * itemRowData.quantity));
                    transactionSummaryData.SetTotalPrice(transactionSummaryData.GetTotalPrice() + (itemRowData.itemPrice * itemRowData.quantity));
                }
                else if (transactionSummarySecondSubDataDict.ContainsKey(year + month + day))
                {
                    Transaction tempTransaction = new Transaction(transaction.GetTransactionID());
                    tempTransaction.SetDateTime(transaction.datetime);
                    tempTransaction.SetPaymentMethod(transaction.paymentMethod);
                    tempTransaction.itemListData.itemRowDataListContainer.itemRowDataList.Add(itemRowData);

                    transactionSummaryDetailsData = new TransactionSummaryDetailsData(transaction.GetTransactionID() + "");
                    transactionSummaryDetailsData.SetTotalPrice(itemRowData.itemPrice * itemRowData.quantity);
                    transactionSummaryDetailsData.SetTransactionTime(time);
                    transactionSummaryDetailsData.getTransactionList().Add(tempTransaction);

                    transactionSummarySubDetailsData = new TransactionSummarySubDetailsData(owner);
                    transactionSummarySubDetailsData.getTransactionSummaryDetailsData().Add(transactionSummaryDetailsData);
                    transactionSummarySubDetailsData.SetTotalPrice(itemRowData.itemPrice * itemRowData.quantity);

                    transactionSummarySecondSubData = transactionSummarySecondSubDataDict[year + month + day];
                    transactionSummaryFirstSubData  = transactionSummaryFirstSubDataDict[year + month];
                    transactionSummaryData          = transactionSummaryDataDict[year];

                    transactionSummarySecondSubData.GetTransactionSummarySubDetailsData().Add(transactionSummarySubDetailsData);

                    transactionSummarySecondSubData.SetTotalPrice(transactionSummarySecondSubData.GetTotalPrice() + (itemRowData.itemPrice * itemRowData.quantity));
                    transactionSummaryFirstSubData.SetTotalPrice(transactionSummaryFirstSubData.GetTotalPrice() + (itemRowData.itemPrice * itemRowData.quantity));
                    transactionSummaryData.SetTotalPrice(transactionSummaryData.GetTotalPrice() + (itemRowData.itemPrice * itemRowData.quantity));

                    transactionSummarySubDetailsDataDict.Add(year + month + day + owner, transactionSummarySubDetailsData);
                }
                else if (transactionSummaryFirstSubDataDict.ContainsKey(year + month))
                {
                    Transaction tempTransaction = new Transaction(transaction.GetTransactionID());
                    tempTransaction.SetDateTime(transaction.datetime);
                    tempTransaction.SetPaymentMethod(transaction.paymentMethod);
                    tempTransaction.itemListData.itemRowDataListContainer.itemRowDataList.Add(itemRowData);

                    transactionSummaryDetailsData = new TransactionSummaryDetailsData(transaction.GetTransactionID() + "");
                    transactionSummaryDetailsData.SetTotalPrice(itemRowData.itemPrice * itemRowData.quantity);
                    transactionSummaryDetailsData.SetTransactionTime(time);
                    transactionSummaryDetailsData.getTransactionList().Add(tempTransaction);

                    transactionSummarySubDetailsData = new TransactionSummarySubDetailsData(owner);
                    transactionSummarySubDetailsData.getTransactionSummaryDetailsData().Add(transactionSummaryDetailsData);
                    transactionSummarySubDetailsData.SetTotalPrice(itemRowData.itemPrice * itemRowData.quantity);

                    transactionSummarySecondSubData = new TransactionSummarySecondSubData(day);
                    transactionSummarySecondSubData.GetTransactionSummarySubDetailsData().Add(transactionSummarySubDetailsData);
                    transactionSummarySecondSubData.SetTotalPrice(itemRowData.itemPrice * itemRowData.quantity);

                    transactionSummaryFirstSubData = transactionSummaryFirstSubDataDict[year + month];
                    transactionSummaryData         = transactionSummaryDataDict[year];

                    transactionSummaryFirstSubData.GetTransactionSummarySecondSubDataList().Add(transactionSummarySecondSubData);
                    transactionSummaryFirstSubData.SetTotalPrice(transactionSummaryFirstSubData.GetTotalPrice() + (itemRowData.itemPrice * itemRowData.quantity));
                    transactionSummaryData.SetTotalPrice(transactionSummaryData.GetTotalPrice() + (itemRowData.itemPrice * itemRowData.quantity));

                    transactionSummarySubDetailsDataDict.Add(year + month + day + owner, transactionSummarySubDetailsData);
                    transactionSummarySecondSubDataDict.Add(year + month + day, transactionSummarySecondSubData);
                }
                else if (transactionSummaryDataDict.ContainsKey(year))
                {
                    Transaction tempTransaction = new Transaction(transaction.GetTransactionID());
                    tempTransaction.SetDateTime(transaction.datetime);
                    tempTransaction.SetPaymentMethod(transaction.paymentMethod);
                    tempTransaction.itemListData.itemRowDataListContainer.itemRowDataList.Add(itemRowData);

                    transactionSummaryDetailsData = new TransactionSummaryDetailsData(transaction.GetTransactionID() + "");
                    transactionSummaryDetailsData.SetTotalPrice(itemRowData.itemPrice * itemRowData.quantity);
                    transactionSummaryDetailsData.SetTransactionTime(time);
                    transactionSummaryDetailsData.getTransactionList().Add(tempTransaction);

                    transactionSummarySubDetailsData = new TransactionSummarySubDetailsData(owner);
                    transactionSummarySubDetailsData.getTransactionSummaryDetailsData().Add(transactionSummaryDetailsData);
                    transactionSummarySubDetailsData.SetTotalPrice(itemRowData.itemPrice * itemRowData.quantity);

                    transactionSummarySecondSubData = new TransactionSummarySecondSubData(day);
                    transactionSummarySecondSubData.GetTransactionSummarySubDetailsData().Add(transactionSummarySubDetailsData);
                    transactionSummarySecondSubData.SetTotalPrice(itemRowData.itemPrice * itemRowData.quantity);

                    transactionSummaryFirstSubData = new TransactionSummaryFirstSubData(month);
                    transactionSummaryFirstSubData.GetTransactionSummarySecondSubDataList().Add(transactionSummarySecondSubData);
                    transactionSummaryFirstSubData.SetTotalPrice(itemRowData.itemPrice * itemRowData.quantity);

                    transactionSummaryData = transactionSummaryDataDict[year];
                    transactionSummaryData.GetTransactionSummaryFirstSubDataList().Add(transactionSummaryFirstSubData);
                    transactionSummaryData.SetTotalPrice(transactionSummaryData.GetTotalPrice() + (itemRowData.itemPrice * itemRowData.quantity));

                    transactionSummarySubDetailsDataDict.Add(year + month + day + owner, transactionSummarySubDetailsData);
                    transactionSummarySecondSubDataDict.Add(year + month + day, transactionSummarySecondSubData);
                    transactionSummaryFirstSubDataDict.Add(year + month, transactionSummaryFirstSubData);
                }
                else
                {
                    Transaction tempTransaction = new Transaction(transaction.GetTransactionID());
                    tempTransaction.SetDateTime(transaction.datetime);
                    tempTransaction.SetPaymentMethod(transaction.paymentMethod);
                    tempTransaction.itemListData.itemRowDataListContainer.itemRowDataList.Add(itemRowData);

                    transactionSummaryDetailsData = new TransactionSummaryDetailsData(transaction.GetTransactionID() + "");
                    transactionSummaryDetailsData.SetTotalPrice(itemRowData.itemPrice * itemRowData.quantity);
                    transactionSummaryDetailsData.SetTransactionTime(time);
                    transactionSummaryDetailsData.getTransactionList().Add(tempTransaction);

                    transactionSummarySubDetailsData = new TransactionSummarySubDetailsData(owner);
                    transactionSummarySubDetailsData.getTransactionSummaryDetailsData().Add(transactionSummaryDetailsData);
                    transactionSummarySubDetailsData.SetTotalPrice(itemRowData.itemPrice * itemRowData.quantity);

                    transactionSummarySecondSubData = new TransactionSummarySecondSubData(day);
                    transactionSummarySecondSubData.GetTransactionSummarySubDetailsData().Add(transactionSummarySubDetailsData);
                    transactionSummarySecondSubData.SetTotalPrice(itemRowData.itemPrice * itemRowData.quantity);

                    transactionSummaryFirstSubData = new TransactionSummaryFirstSubData(month);
                    transactionSummaryFirstSubData.GetTransactionSummarySecondSubDataList().Add(transactionSummarySecondSubData);
                    transactionSummaryFirstSubData.SetTotalPrice(itemRowData.itemPrice * itemRowData.quantity);

                    transactionSummaryData = new TransactionSummaryData(year);
                    transactionSummaryData.GetTransactionSummaryFirstSubDataList().Add(transactionSummaryFirstSubData);
                    transactionSummaryData.SetTotalPrice(itemRowData.itemPrice * itemRowData.quantity);

                    transactionSummarySubDetailsDataDict.Add(year + month + day + owner, transactionSummarySubDetailsData);
                    transactionSummarySecondSubDataDict.Add(year + month + day, transactionSummarySecondSubData);
                    transactionSummaryFirstSubDataDict.Add(year + month, transactionSummaryFirstSubData);
                    transactionSummaryDataDict.Add(year, transactionSummaryData);
                }
            }
        }

        transactionSummaryDataList = transactionSummaryDataDict.Values.ToList().OrderByDescending(transactionSummaryData2 => DateTime.ParseExact(transactionSummaryData2.primaryKey, "yyyy", null)).ToList();

        return(transactionSummaryDataList);
    }