Exemplo n.º 1
0
        /**
         * ออก VN
         */
        private async void button3_Click(object sender, EventArgs e)
        {
            button3.Enabled = false;
            loadingForm2.Show();
            Console.WriteLine("Button3(ออกvn) was clicked");
            if (appointCount > 1) // ถ้ามีนัด 2แพทย์
            {
                Console.WriteLine("แสดงข้อมูลแพทย์หลายคน");
                FormSelectDr frm = new FormSelectDr();
                frm.appoint    = appoint;
                frm.idcard     = idcard;
                frm.hosPtRight = hosPtRight;
                frm.ShowDialog();
            }
            else // ถ้ามีนัด 1 แพทย์
            {
                Console.WriteLine("กดออก VN แพทย์คนเดียว");
                SaveVn sv           = new SaveVn();
                int    appointRowId = appoint.ToArray()[0].rowId;
                string content      = await Task.Run(() => sv.save(smConfig.createVnUrl, idcard, appointRowId, ptRight));

                if (!String.IsNullOrEmpty(content))
                {
                    responseSaveVn app = JsonConvert.DeserializeObject <responseSaveVn>(content);
                    EpsonSlip      es  = new EpsonSlip();
                    es.printOutSlip(app);
                }
            }
            button3.Enabled = true;
            loadingForm2.Hide();
            this.Close();
        }
Exemplo n.º 2
0
        public async void sendVNandQueue(int rowId, string doctor)
        {
            Console.WriteLine($"Selected Doctor {rowId}");
            SaveVn sv      = new SaveVn();
            string content = await Task.Run(() => sv.save(smConfig.createVnUrl, idcard, rowId, hosPtRight));

            if (!String.IsNullOrEmpty(content))
            {
                responseSaveVn app = JsonConvert.DeserializeObject <responseSaveVn>(content);
                EpsonSlip      es  = new EpsonSlip();
                es.printOutSlip(app);
                this.Close();
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// ออก VN แทนทะเบียนพร้อมกับ ปริ้นสลิป VN + คิว
        /// </summary>
        /// <param name="exType"></param>
        public async void presetVn(string exType)
        {
            Console.WriteLine(exType + " was click");
            SaveVn sv      = new SaveVn();
            string content = await Task.Run(() => sv.save(smConfig.createVnUrl, idcard, appointId, hosPtRight, exType));

            if (!String.IsNullOrEmpty(content))
            {
                responseSaveVn app = JsonConvert.DeserializeObject <responseSaveVn>(content);
                EpsonSlip      es  = new EpsonSlip();
                es.printOutSlip(app);
                this.Close();
            }
        }
Exemplo n.º 4
0
        public void printOutSlip_Backup(responseSaveVn app)
        {
            try
            {
                SerialPrinter printer = new SerialPrinter(portName: "COM3", baudRate: 38400);

                EPSON e = new EPSON();

                string fontName = "Tahoma";

                Font fontRegular       = new Font(fontName, 26, FontStyle.Regular, GraphicsUnit.Pixel);
                Font fontBoldUnderline = new Font(fontName, 26, FontStyle.Bold | FontStyle.Underline, GraphicsUnit.Pixel);
                Font fontBold          = new Font(fontName, 26, FontStyle.Bold, GraphicsUnit.Pixel);
                Font fontJumbo         = new Font(fontName, 48, FontStyle.Bold | FontStyle.Underline, GraphicsUnit.Pixel);

                byte[] ImgTitle = DrawText($"ใช้บริการโดยตู้ Kiosk {app.dateSave}", fontRegular);
                byte[] ImgEx    = DrawText(app.ex, fontBoldUnderline);
                byte[] ImgVn    = DrawText("HN : " + app.hn + "\nVN : " + app.vn, fontJumbo);
                byte[] ImgName  = DrawText($"ชื่อ : {app.ptname}", fontRegular);

                byte[] ImgPtright = DrawText($"สิทธิ : {app.ptright}", fontBoldUnderline);

                string extraTxt = "";
                if (!String.IsNullOrEmpty(app.hospCode))
                {
                    extraTxt += $"\n{app.hospCode}";
                }

                if (!String.IsNullOrEmpty(app.doctor))
                {
                    extraTxt += $"\n{app.doctor}";
                }

                byte[] ImgHn = DrawText($"อายุ {app.age}\nบัตร ปชช. : {app.idcard}\n{app.mx}{extraTxt}", fontRegular);


                printer.Write(
                    ByteSplicer.Combine(
                        e.CenterAlign(),
                        e.PrintImage(File.ReadAllBytes("Images/LogoWithName2.png"), true, false, 500),
                        e.PrintImage(ImgTitle, true),
                        e.PrintImage(ImgEx, true),
                        e.PrintImage(ImgVn, true),
                        e.PrintImage(ImgName, true),
                        e.PrintImage(ImgHn, true),
                        e.PrintImage(ImgPtright, true),
                        e.PrintLine(" "),
                        e.SetBarcodeHeightInDots(350),
                        e.SetBarWidth(BarWidth.Thin),
                        e.PrintBarcode(BarcodeType.CODE128, app.hn),
                        e.PrintLine(" "),
                        e.FeedLines(6),
                        e.FullCut()
                        )
                    );


                if (app.queueStatus == "y")
                {
                    byte[] ImgTitleQueue = DrawText("ใช้บริการโดยตู้ Kiosk\nตรวจโรคทั่วไป\n", fontRegular);
                    byte[] ImgHnVn       = DrawText($"HN : {app.hn} VN : {app.vn} \n ชื่อ : {app.ptname}", fontBold);
                    byte[] ImgDetail     = DrawText($"ประเภท : {app.ptType}", fontRegular);
                    byte[] ImgQueue      = DrawText(app.queueNumber, fontJumbo);
                    byte[] ImgQueueWait  = DrawText($"จำนวนคิวที่รอ {app.queueWait} คิว", fontRegular);
                    printer.Write(
                        ByteSplicer.Combine(
                            e.CenterAlign(),
                            e.PrintImage(File.ReadAllBytes("Images/LogoWithNameOPD.png"), true, false, 500),
                            e.PrintImage(ImgTitleQueue, true),
                            e.PrintImage(ImgHnVn, true),
                            e.PrintImage(ImgDetail, true),
                            e.PrintImage(ImgQueue, true),
                            e.PrintImage(ImgQueueWait, true),
                            e.FeedLines(6),
                            e.FullCut()
                            )
                        );
                    printer.Dispose(); // close
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Exemplo n.º 5
0
        public void printOutSlip(responseSaveVn app)
        {
            try
            {
                string fontName           = "Tahoma";
                Font   fontRegular        = new Font(fontName, 16, FontStyle.Regular, GraphicsUnit.Pixel);
                Font   fontBold           = new Font(fontName, 16, FontStyle.Bold, GraphicsUnit.Pixel);
                Font   fontBoldUnderline  = new Font(fontName, 16, FontStyle.Bold | FontStyle.Underline, GraphicsUnit.Pixel);
                Font   fontSuperBold      = new Font(fontName, 28, FontStyle.Bold, GraphicsUnit.Pixel);
                Font   superBoldUnderline = new Font(fontName, 28, FontStyle.Bold | FontStyle.Underline, GraphicsUnit.Pixel);

                Font superBoldv2 = new Font(fontName, 24, FontStyle.Bold, GraphicsUnit.Pixel);

                byte[] PartialCut = { 0x0A, 0x0A, 0x0A, 0x1B, 0x69 };
                System.Globalization.CultureInfo _cultureTHInfo = new System.Globalization.CultureInfo("th-TH");
                string currDate = DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss", _cultureTHInfo);

                Printer printer = new Printer(smConfig.printerName);

                printer.AlignCenter();

                printer.Image(DrawTextImg($"คิวห้องตรวจ {app.queueNumber}", superBoldv2));
                printer.NewLines(3);

                printer.Image(new Bitmap(Bitmap.FromFile("Images/small-icon.bmp")));
                printer.Image(DrawTextImg(currDate, fontRegular));
                printer.Image(DrawTextImg(app.ex, fontRegular));
                printer.Image(DrawTextImg("HN : " + app.hn, superBoldUnderline));
                printer.Image(DrawTextImg("VN : " + app.vn, superBoldUnderline));
                printer.NewLine();
                printer.Image(DrawTextImg($"ชื่อ : {app.ptname}", fontBold));
                printer.NewLine();
                printer.Image(DrawTextImg($"สิทธิ : {app.ptright}", fontBoldUnderline));
                if (!String.IsNullOrEmpty(app.hospCode))
                {
                    printer.Image(DrawTextImg(app.hospCode, fontRegular));
                }

                printer.Image(DrawTextImg($"อายุ {app.age}", fontRegular));
                printer.Image(DrawTextImg($"บัตร ปชช. : {app.idcard}", fontRegular));
                printer.Image(DrawTextImg(app.mx, fontRegular));
                printer.NewLine();
                printer.Image(DrawTextImg($"คิวซักประวัติที่ {app.fakeQueue}", fontBold));
                printer.NewLine();

                if (!String.IsNullOrEmpty(app.doctor))
                {
                    printer.Image(DrawTextImg(app.doctor, fontRegular));
                }
                else
                {
                    printer.Image(DrawTextImg("แพทย์.....................", fontRegular));
                }

                /*
                 * var writer = new BarcodeWriter
                 * {
                 *  Format = BarcodeFormat.QR_CODE,
                 *  Options = new ZXing.Common.EncodingOptions
                 *  {
                 *      Height = 160,
                 *      Width = 306
                 *  }
                 * };
                 * var qrCodeImg = writer.Write(app.hn);
                 * printer.Image(qrCodeImg);
                 */

                var writer2 = new BarcodeWriter
                {
                    Format  = BarcodeFormat.CODE_39,
                    Options = new ZXing.Common.EncodingOptions
                    {
                        Height      = 60,
                        Width       = 306,
                        PureBarcode = true
                    }
                };
                var barcodeImg = writer2.Write(app.hn);
                printer.Image(barcodeImg);
                printer.Image(DrawTextImg("ยื่นรับยาที่ช่องหมายเลข6", fontBold));
                printer.Image(new Bitmap(Bitmap.FromFile("Images/extra.bmp")));

                //printer.Image(DrawTextImg($"หากที่อยู่ของท่านมีการเปลี่ยนแปลง", fontBold));
                //printer.Image(DrawTextImg($"กรุณาแจ้งแผนกทะเบียน", fontBold));
                //printer.Image(DrawTextImg($"เพื่อประโยชน์และสิทธิ์ของท่านเอง", fontBold));
                printer.NewLines(8);
                printer.Append(PartialCut);

                //////
                if (app.queueStatus == "y")
                {
                    //printer.Image(new Bitmap(Bitmap.FromFile("Images/small-icon2.bmp")));
                    //printer.Image(DrawTextImg(currDate, fontRegular));
                    //printer.NewLine();

                    /*
                     * printer.Image(DrawTextImg("บัตรคิวซักประวัติ", fontBold));
                     * printer.NewLine();
                     * printer.Image(DrawTextImg(app.queueRoom, fontRegular));
                     * printer.NewLine();
                     * printer.Image(DrawTextImg($"HN : {app.hn}", fontSuperBold));
                     * printer.NewLine();
                     * printer.Image(DrawTextImg($"ชื่อ : {app.ptname}", fontRegular));
                     * printer.Image(DrawTextImg($"ประเภท : {app.ptType}", fontRegular));
                     * printer.NewLine();
                     * printer.Image(DrawTextImg(app.queueNumber, fontSuperBold));
                     * printer.NewLine();
                     * printer.Image(DrawTextImg($"คิวพบแพทย์ผู้ป่วยนัด", fontRegular));
                     * printer.NewLines(8);
                     * printer.Append(PartialCut);
                     */

                    //printer.Image(new Bitmap(Bitmap.FromFile("Images/small-icon2.bmp")));
                    //printer.Image(DrawTextImg(currDate, fontRegular));
                    //printer.NewLine();
                    printer.Image(DrawTextImg("คิวพบแพทย์ผู้ป่วยนัด", fontBold));
                    printer.Image(DrawTextImg(currDate, fontRegular));
                    printer.Image(DrawTextImg(app.queueNumber, fontSuperBold));
                    printer.Image(DrawTextImg(app.queueRoom + " คิวที่ " + app.runNumber, fontRegular));
                    //printer.Image(DrawTextImg($"เลขคิวห้องตรวจ {app.runNumber}", fontSuperBold, 32));
                    printer.NewLine();
                    printer.Image(DrawTextImg($"คิวซักประวัติที่ {app.fakeQueue}", fontSuperBold, 32));
                    printer.NewLine();
                    if (!String.IsNullOrEmpty(app.doctor))
                    {
                        printer.Image(DrawTextImg(app.doctor, fontRegular));
                    }
                    else
                    {
                        printer.Image(DrawTextImg("แพทย์.....................", fontRegular));
                    }
                    printer.Image(DrawTextImg($"HN : {app.hn}", fontBold));
                    printer.Image(DrawTextImg($"ชื่อ : {app.ptname}", fontRegular));
                    printer.Image(DrawTextImg($"ประเภท : {app.ptType}", fontRegular));
                    printer.Image(DrawTextImg($"จำนวนคิวที่รอ {app.queueWait} คิว", fontRegular));
                    printer.Image(DrawTextImg($"ใบคิวสำหรับผู้ป่วย โปรดเก็บไว้กับตัว", fontBold));
                    printer.NewLines(8);
                    printer.Append(PartialCut);
                }
                //////
                printer.PrintDocument();
            }
            catch (Exception ex)
            {
                MessageBox.Show("ไม่สามารถพิมพ์ได้ " + ex.Message, "แจ้งเตือน");
                Console.WriteLine(ex.Message);
            }
        }