コード例 #1
0
    public Dictionary <string, TransactionSummaryGameObjectList> ExpandCollapseSecondPanel(bool shouldExpandPanel, TransactionSummarySecondSubData 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("SecondSubPanel_" + parentKey + "_" + selectedTransSubData.GetPrimaryKey()).gameObject;

            TransactionSummaryGameObjectList transactionGameObjects = new TransactionSummaryGameObjectList(parentKey + "_" + selectedTransSubData.GetPrimaryKey(), selectedSubPanel);
            transactionGameObjects.SetExpandedFlag(true);
            transactionGameObjectDict.Add(parentKey + "_" + selectedTransSubData.GetPrimaryKey(), transactionGameObjects);

            foreach (TransactionSummarySubDetailsData tsSubDetailsData in selectedTransSubData.GetTransactionSummarySubDetailsData())
            {
                GameObject  tempThirdSubPanel = (GameObject)Instantiate(thirdSubPanel, transform.position, transform.rotation);
                Transform[] ts = tempThirdSubPanel.transform.GetComponentsInChildren <Transform>();
                tempThirdSubPanel.name = "ThirdSubPanel_" + parentKey + "_" + selectedTransSubData.GetPrimaryKey() + "_" + tsSubDetailsData.GetPrimaryKey();


                string firstSubPanelSubText   = "";
                bool   shouldSubTextBeVisible = false;
                if (isOrderByDate)
                {
                    firstSubPanelSubText   = tsSubDetailsData.GetPrimaryKey().Substring(0, 1);
                    shouldSubTextBeVisible = true;
                }

                foreach (Transform t in ts)
                {
                    switch (t.gameObject.name)
                    {
                    case "ThirdSubPanelMainText":
                        t.gameObject.GetComponent <Text>().text = tsSubDetailsData.GetPrimaryKey();
                        break;

                    case "ThirdSubPanelSubTextImage":
                        t.gameObject.GetComponent <Button>().GetComponentInChildren <Text>().text = firstSubPanelSubText;
                        t.gameObject.GetComponent <Button>().gameObject.SetActive(shouldSubTextBeVisible);
                        break;

                    case "ThirdSubPanelPrice":
                        t.gameObject.GetComponent <Text>().text = "$" + tsSubDetailsData.GetTotalPrice();
                        break;
                    }
                }

                tempThirdSubPanel.SetActive(true);
                tempThirdSubPanel.transform.SetParent(selectedSubPanel.transform, false);
                transactionGameObjects.GetTransactionSummaryGameObjects().Add(tempThirdSubPanel);
            }
        }
        return(transactionGameObjectDict);
    }
コード例 #2
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);
    }