Beispiel #1
0
    public List <GameManager.OrderList> LoadOrderList(string path)
    {
        var result = new List <GameManager.OrderList>();

        if (GetComponent <DataLoader>().checkExist(path))
        {
            using (TextReader fileReader = File.OpenText(@path))
            {
                using (var csv = new CsvReader(fileReader, System.Globalization.CultureInfo.InvariantCulture))
                {
                    csv.Configuration.HasHeaderRecord = true;
                    csv.Configuration.RegisterClassMap <GameManager.OrderListMapper>();
                    csv.Read();
                    csv.ReadHeader();
                    while (csv.Read())
                    {
                        var record = new GameManager.OrderList
                        {
                            Name     = csv.GetField("Name"),
                            Category = int.Parse(csv.GetField("Category")),
                            Number   = int.Parse(csv.GetField("Number")),
                            Amount   = int.Parse(csv.GetField("Amount")),
                            Price    = int.Parse(csv.GetField("Price")),
                        };

                        result.Add(record);
                    }
                    fileReader.Close();
                }
            }
        }

        return(result);
    }
Beispiel #2
0
    public void 注文完了レシート(string templateDir, string PrinterName, List <GameManager.OrderList> _list, GameManager.OrderList 注文情報, int 割引額, int 現金, int Count)
    {
        DateTime   time      = DateTime.Now;
        DataLoader c         = GetComponent <DataLoader>();
        int        Tax       = GetComponent <DataLoader>().LoadConfig().Tax;
        string     StoreName = GetComponent <DataLoader>().LoadConfig().StoreName;

        try
        {
            string[]      del  = { "\r\n" };
            List <string> Text = new List <string>();
            var           t    = GetComponent <DataLoader>().loadFile(FormatDataDirectory + templateDir);

            //タグ (STORE_NAME, DATE, TIME)
            t = t.Replace(Environment.NewLine, "<n>");

            t = t.Replace("<tSTORE_NAME>", GetComponent <DataLoader>().LoadConfig().StoreName);
            t = t.Replace("<tDATE>", DateTime.Now.ToString(GetComponent <DataLoader>().LoadConfig().FormatDate));
            t = t.Replace("<tTIME>", DateTime.Now.ToString(GetComponent <DataLoader>().LoadConfig().FormatTime));

            t = t.Replace("<tAMOUNT_TOTAL>", Number.MarkDecimal(注文情報.Amount));                           //商品数
            t = t.Replace("<tPRICE_TOTAL>", Number.MarkDecimal(注文情報.Price));                             //小計(割引額を含まない総額)
            t = t.Replace("<tDISCOUNT>", Number.MarkDecimal(割引額));                                       //割引額
            t = t.Replace("<tTOTAL>", Number.MarkDecimal(注文情報.Price - 割引額));                             //合計金額
            t = t.Replace("<tINSIDE_TAX>", Number.MarkDecimal(Number.InsideTax(注文情報.Price - 割引額, Tax))); //内税
            t = t.Replace("<tPRICE_KEEP>", Number.MarkDecimal(現金));                                      //お預かり
            t = t.Replace("<tPRICE_RETURN>", Number.MarkDecimal(現金 - (注文情報.Price - 割引額)));               //お釣り
            t = t.Replace("<tNUMBER>", Count.ToString());                                                //レシート番号

            string Tag;
            bool   flag = false;
            for (int i = 0; i < t.Length; i++)
            {
                string loopText;
                if (i + 2 < t.Length)
                {
                    Tag = t.Substring(i, 2);
                }
                else
                {
                    break;
                }

                switch (Tag)
                {
                case "<l":
                    if (GetComponent <Printer>().GetTag(t, i, "string") == "GOODS")
                    {
                        string TempTag;
                        for (int j = i; j < t.Length; j++)
                        {
                            if (j + 2 < t.Length)
                            {
                                TempTag = t.Substring(j, 3);
                            }
                            else
                            {
                                break;
                            }

                            switch (TempTag)
                            {
                            case "<l>":
                                int dif = GetComponent <Printer>().GetTag(t, i, "string").Length + 3;
                                loopText = t.Substring(i + dif, j - i - dif);

                                string tempText = "";
                                foreach (var record in _list)
                                {
                                    string m = loopText;
                                    m = m.Replace("<mGOODS_NAME>", record.Name);
                                    m = m.Replace("<mPRICE>", Number.MarkDecimal(record.Price));
                                    m = m.Replace("<mGOODS_PRICE>", Number.MarkDecimal(record.Price / record.Amount));
                                    m = m.Replace("<mAMOUNT>", Number.MarkDecimal(record.Amount));

                                    tempText += m;
                                }

                                t    = t.Replace("<l" + GetComponent <Printer>().GetTag(t, i, "string") + ">" + loopText + "<l>", tempText);
                                flag = true;
                                break;
                            }
                        }
                        if (flag)
                        {
                            break;
                        }
                    }
                    break;
                }
            }

            foreach (var record in t.Split(del, StringSplitOptions.None))
            {
                Text.Add(record);
            }

            GenerateReceipt(PrinterName, Text, GetComponent <DataLoader>().LoadConfig().LINENotifyPurchaseNotice);
        }
        catch (Exception e)
        {
            Debug.LogError("Failed to print! :" + e);
        }
    }
Beispiel #3
0
 public void 注文完了レシート(List <GameManager.OrderList> _list, GameManager.OrderList 注文情報, int 割引額, int 現金, int Count)
 {
     注文完了レシート("order.txt", GetComponent <DataLoader>().LoadConfig().PrinterName, _list, 注文情報, 割引額, 現金, Count);
 }
Beispiel #4
0
 public void 注文伝票レシート(string PrinterName, List <GameManager.OrderList> _list, GameManager.OrderList 注文情報, int 割引額, int 現金, int Number)
 {
     注文完了レシート("order_list.txt", PrinterName, _list, 注文情報, 割引額, 現金, Number);
 }