Beispiel #1
0
        static void StartPrintJungsan(JObject json)
        {
#if DEBUG
            printer = new TestSerialPrinter(portName: "COM1", baudRate: 9600);
#else
            printer = new SerialPrinter(portName: "COM1", baudRate: 9600);
#endif

            printer.Write(
                ByteSplicer.Combine(
                    e.CenterAlign(),
                    e.SetStyles(PrintStyle.FontB | PrintStyle.DoubleHeight | PrintStyle.DoubleWidth | PrintStyle.Bold),
                    e.PrintLine("판매집계표"),
                    e.SetStyles(PrintStyle.None),
                    e.PrintLine("--------------------------"),
                    e.SetStyles(PrintStyle.FontB | PrintStyle.DoubleHeight),
                    e.PrintLine(json["date"].ToString()),
                    e.SetStyles(PrintStyle.None),
                    e.PrintLine("--------------------------")
                    ));
            printer.Write(
                ByteSplicer.Combine(
                    e.SetStyles(PrintStyle.FontB | PrintStyle.DoubleHeight | PrintStyle.DoubleWidth),
                    e.LeftAlign(),
                    e.PrintLine("구분 \t\t 건수 \t\t 금액"),
                    e.PrintLine("--------------------------"),
                    e.PrintLine("총매출액 \t\t\t" + json["totalCnt"] + " \t\t " + json["totalPrice"]),
                    e.PrintLine("텀블러할인 \t\t\t" + json["discountCnt"] + " \t\t " + json["discountPrice"]),
                    e.PrintLine("취소 \t\t\t" + json["canceledCnt"] + " \t\t " + json["canceledPrice"]),
                    e.PrintLine("--------------------------"),
                    e.PrintLine("순매출액 \t\t\t" + json["sunCnt"] + " \t\t " + json["sunPrice"]),
                    e.FeedLines(3),
                    e.FullCut()
                    ));

            printer.Dispose();
        }
Beispiel #2
0
        // 직원용프린트 함수
        static void StartPrint(JObject json)
        {
            //프린터 연결
#if DEBUG
            printer = new TestSerialPrinter(portName: "COM1", baudRate: 9600);
#else
            printer = new SerialPrinter(portName: "COM1", baudRate: 9600);
#endif

            // 메뉴 해쉬코드 - 내용 딕셔너리
            Dictionary <int, JToken> menuDictionary = new Dictionary <int, JToken>();

            // 각 메뉴마다 수량 겟하고 내용 저장
            foreach (var menu in json["menus"])
            {
                int menuHash = menu.ToString().GetHashCode();

                if (menuDictionary.ContainsKey(menuHash))
                {
                    menuDictionary[menuHash]["quantity"] = menuDictionary[menuHash]["quantity"].ToObject <int>() + 1;
                }
                else
                {
                    menu["quantity"] = 1;

                    var option = menu["options"].First;

                    // 옵션 확인하고 수량 없으면 삭제
                    while (option != null)
                    {
                        var currentOption = option;
                        option = currentOption.Next;
                        if (currentOption["quantity"].ToObject <int>() <= 0)
                        {
                            currentOption.Remove();
                        }
                    }

                    menuDictionary.Add(menuHash, menu);
                }
            }

            string orderNum = json["orderNum"].ToString();

            printer.Write(
                ByteSplicer.Combine(
                    e.FeedLines(1),
                    e.CenterAlign(),
                    e.SetStyles(PrintStyle.FontB | PrintStyle.DoubleHeight | PrintStyle.DoubleWidth | PrintStyle.Bold),
                    e.PrintLine("주문번호: " + orderNum),
                    e.SetStyles(PrintStyle.None),
                    e.PrintLine("--------------------------"),
                    e.PrintLine(System.DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss")),//시간
                    e.PrintLine("--------------------------")
                    ));

            byte[] bodyBytes = e.FeedLines(1);
            foreach (var menu in menuDictionary.Values)
            {
                string menu_pojang   = menu["isTakeOut"].Value <bool>() ? "포장" : "테이블";
                string menu_name     = menu["name"].ToString();
                string menu_tumbler  = menu["isTumbler"].Value <bool>() ? "텀블러" : null;
                string menu_temp     = menu["temp"].ToString(); // 아이스, 핫
                int    menu_quantity = menu["quantity"].ToObject <int>();

                // (온도) 메뉴이름 (포장여부)
                string menu_name_line = "(" + menu_temp + ") " + menu_name + " (" + menu_pojang + ")";

                byte[] menuBytes = ByteSplicer.Combine(
                    e.SetStyles(PrintStyle.FontB | PrintStyle.DoubleHeight | PrintStyle.DoubleWidth | PrintStyle.Bold),
                    e.PrintLine(menu_name_line),
                    e.PrintLine("수량 : " + menu_quantity)
                    );
                if (menu["options"].Any())
                {
                    menuBytes = ByteSplicer.Combine(menuBytes,
                                                    e.SetStyles(PrintStyle.FontB | PrintStyle.DoubleHeight | PrintStyle.DoubleWidth)
                                                    // , e.PrintLine("옵션")
                                                    );
                    JArray optionsArray = menu["options"].ToObject <JArray>();

                    foreach (var option in optionsArray)
                    {
                        menuBytes = ByteSplicer.Combine(menuBytes,
                                                        e.PrintLine(option["name"].ToString() + " : " + option["quantity"].ToString())
                                                        );
                    }
                }

                bodyBytes = ByteSplicer.Combine(bodyBytes, menuBytes, e.FeedLines(1));
            }

            printer.Write(bodyBytes);

            printer.Write(
                ByteSplicer.Combine(e.FeedLines(3)));

            printer.Write(
                ByteSplicer.Combine(
                    e.FullCut()
                    )
                );
            //프린터 해제
            printer.Dispose();
        }
Beispiel #3
0
        // 다시 프린트
        static void StartLongPrint(JObject json)
        {
            //프린터 연결
#if DEBUG
            printer = new TestSerialPrinter(portName: "COM1", baudRate: 9600);
#else
            printer = new SerialPrinter(portName: "COM1", baudRate: 9600);
#endif

            // 메뉴 해쉬코드 - 내용 딕셔너리
            Dictionary <string, JToken> menuDictionary = new Dictionary <string, JToken>();
            Dictionary <string, int>    menuPriceTable = new Dictionary <string, int>();

            // 각 메뉴마다 수량 겟하고 내용 저장
            foreach (var menu in json["menus"])
            {
                string menuName  = menu["name"].ToString();
                int    menuPrice = menu["totalPrice"].ToObject <int>();

                if (menuDictionary.ContainsKey(menuName))
                {
                    menuDictionary[menuName]["quantity"] = menuDictionary[menuName]["quantity"].ToObject <int>() + 1;
                    menuPriceTable[menuName]            += menuPrice;
                }
                else
                {
                    menu["quantity"] = 1;

                    var option = menu["options"].First;

                    // 옵션 확인하고 수량 없으면 삭제
                    while (option != null)
                    {
                        var currentOption = option;
                        option = currentOption.Next;
                        if (currentOption["quantity"].ToObject <int>() <= 0)
                        {
                            currentOption.Remove();
                        }
                    }

                    menuDictionary.Add(menuName, menu);
                    menuPriceTable.Add(menuName, menuPrice);
                }
            }

            string orderNum = json["orderNum"].ToString();

            printer.Write(
                ByteSplicer.Combine(
                    e.FeedLines(1),
                    e.CenterAlign(),
                    e.SetStyles(PrintStyle.FontB | PrintStyle.DoubleHeight | PrintStyle.DoubleWidth | PrintStyle.Bold),
                    e.PrintLine("주문번호: " + orderNum),
                    e.SetStyles(PrintStyle.FontB | PrintStyle.Bold),
                    e.FeedLines(1),
                    e.PrintLine("11호관 커피숍"),
                    e.PrintLine("울산시 남구 대학로 93 11호관 305호"),
                    e.PrintLine("TEL.052-220-5757"),
                    e.SetStyles(PrintStyle.FontB | PrintStyle.Bold | PrintStyle.DoubleWidth),
                    e.PrintLine("---------------------------"),
                    e.SetStyles(PrintStyle.FontB | PrintStyle.Bold),
                    e.LeftAlign(),
                    e.PrintLine("  메뉴\t\t\t\t수량\t\t가격"),
                    e.SetStyles(PrintStyle.FontB | PrintStyle.Bold | PrintStyle.DoubleWidth),
                    e.PrintLine("---------------------------")
                    ));

            byte[] bodyBytes = e.FeedLines(1);
            foreach (var menu in menuDictionary.Values)
            {
                int    menu_quantity = menu["quantity"].ToObject <int>();
                string menu_price    = menu["totalPrice"].ToString();
                string menu_name     = menu["name"].ToString();

                // (온도) 메뉴이름 (포장여부)
                string menu_name_line = menu_name;

                byte[] menuBytes = ByteSplicer.Combine(
                    e.SetStyles(PrintStyle.FontB | PrintStyle.Bold),
                    e.PrintLine("  " + menu_name_line + "\t\t\t\t" + menu_quantity + "\t\t" + menuPriceTable[menu_name])
                    );
                bodyBytes = ByteSplicer.Combine(bodyBytes, menuBytes, e.FeedLines(1));
            }

            printer.Write(bodyBytes);

            string orderPrice  = json["totalPrice"].ToString();
            int    supplyPrice = (int)(json["totalPrice"].ToObject <int>() / 1.1);
            int    tax         = json["totalPrice"].ToObject <int>() - supplyPrice;

            printer.Write(ByteSplicer.Combine(
                              e.FeedLines(1),
                              e.RightAlign(),
                              e.SetStyles(PrintStyle.FontB | PrintStyle.DoubleHeight | PrintStyle.DoubleWidth | PrintStyle.Bold),
                              e.PrintLine("합계금액 : " + orderPrice + " 원"),
                              e.PrintLine("공급가액 : " + supplyPrice + " 원"),
                              e.PrintLine("부가세 : " + tax + " 원"),
                              e.LeftAlign(),
                              e.SetStyles(PrintStyle.FontB | PrintStyle.Bold | PrintStyle.DoubleWidth),
                              e.PrintLine("---------------------------")
                              ));

            printer.Write(ByteSplicer.Combine(
                              e.FeedLines(1),
                              e.CenterAlign(),
                              e.SetStyles(PrintStyle.FontB | PrintStyle.DoubleHeight | PrintStyle.Bold),
                              e.PrintLine("신용카드 승인 정보"),
                              e.SetStyles(PrintStyle.FontB | PrintStyle.Bold),
                              e.PrintLine("카드명: " + json["cardCompany"].ToString()),
                              e.PrintLine("카드번호: " + json["cardNumber"].ToString() + "**********"),
                              e.PrintLine("매입사명: " + json["aqCompany"].ToString()),
                              e.FeedLines(1),
                              e.PrintLine("사업자:  691-85-00176 엄문호"),
                              e.PrintLine("가맹점명:  11호관 커피숍"),
                              e.PrintLine("가맹번호:  157431024"),
                              e.PrintLine("승인일시:  " + json["ApprovalDate"].ToString()),
                              e.PrintLine("승인번호:  " + json["ApprovalNumber"].ToString()),
                              e.PrintLine("승인금액:  " + orderPrice + "원"),
                              e.FeedLines(1),
                              e.PrintLine("11호관 카페를 이용해주셔서 감사합니다.")
                              ));

            printer.Write(
                ByteSplicer.Combine(e.FeedLines(3)));

            printer.Write(
                ByteSplicer.Combine(
                    e.FullCut()
                    )
                );
            //프린터 해제
            printer.Dispose();
        }