Exemple #1
0
 /// <summary>
 /// 라벨 프린트
 /// </summary>
 /// <param name="command">ZPL 라벨 프린트 커맨드</param>
 public static void PrintByCommand(string command)
 {
     try
     {
         if (!LabelPrint.PrinterConnectionOpen())
         {
             return;
         }
         if (Printer == null)
         {
             Printer = ZebraPrinterFactory.GetInstance(PrinterConnection);
         }
         Printer.SendCommand(command);
     }
     catch (ConnectionException ex)
     {
         MessageBox.Show("프린트 실패" + Environment.NewLine + ex.ToString(), "실패", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemple #2
0
        public static void PrintLabel(string EventNM, string PGM_ID, string PGM_NM, PrintData data)
        {
            try
            {
                if (!LabelPrint.PrinterConnectionOpen())
                {
                    return;
                }

                if (Printer == null)
                {
                    Printer = ZebraPrinterFactory.GetInstance(PrinterConnection);
                }

                string BOTTOM_LEFT  = "";
                string BOTTOM_RIGHT = "";
                if (DBUtils.sqlConnection.State == ConnectionState.Open)
                {
                    using (SqlCommand SqlCommand = new SqlCommand())
                    {
                        SqlCommand.Connection  = DBUtils.sqlConnection;
                        SqlCommand.CommandText = "P_8190_R_CFG";
                        SqlCommand.CommandType = CommandType.StoredProcedure;
                        SqlCommand.Parameters.Add("@rCOMP", SqlDbType.NVarChar).Value    = "100";
                        SqlCommand.Parameters.Add("@rCFG_KEY", SqlDbType.NVarChar).Value = "";
                        SqlCommand.Parameters.Add("@rCFG_NM", SqlDbType.NVarChar).Value  = "";
                        SqlCommand.Parameters.Add("@rCFG_VAL", SqlDbType.NVarChar).Value = "";
                        SqlCommand.Parameters.Add("@rCFG_TP", SqlDbType.NVarChar).Value  = "LBLNO";
                        SqlCommand.Parameters.Add("@rETC", SqlDbType.NVarChar).Value     = "";

                        SqlCommand.Parameters.Add("@rPGM_ID", SqlDbType.NVarChar).Value   = PGM_ID;
                        SqlCommand.Parameters.Add("@rPGM_NM", SqlDbType.NVarChar).Value   = PGM_NM;
                        SqlCommand.Parameters.Add("@rEVENT_NM", SqlDbType.NVarChar).Value = EventNM;
                        SqlCommand.Parameters.Add("@rMSG", SqlDbType.NVarChar).Value      = "";
                        SqlCommand.Parameters.Add("@rCRT_USR", SqlDbType.NVarChar).Value  = "System";
                        SqlCommand.Parameters.Add("@rCRT_PC", SqlDbType.NVarChar).Value   = DBUtils.ClientPcName;
                        SqlCommand.Parameters.Add("@rCRT_IP", SqlDbType.NVarChar).Value   = DBUtils.ClientIPAddress;
                        SqlCommand.Parameters.Add("@rCRT_MENU", SqlDbType.NVarChar).Value = "PC";
                        SqlCommand.Parameters.Add("@rOK", SqlDbType.NVarChar).Value       = "";

                        SqlDataAdapter dataAdapter = new SqlDataAdapter(SqlCommand);
                        DataSet        dataSet     = new DataSet();
                        dataAdapter.Fill(dataSet);
                        if (dataSet.Tables[0].Rows.Count == 2)
                        {
                            BOTTOM_LEFT  = dataSet.Tables[0].Rows[0]["CFG_VAL"].ToString();
                            BOTTOM_RIGHT = dataSet.Tables[0].Rows[1]["CFG_VAL"].ToString();
                        }
                    }
                }
                else
                {
                    MessageBox.Show("DB연결이 끊어졌습니다.", "알림", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                }

                int    DefaultX = 30;
                int    DefaultY = 20;
                string command  = "^XA" +
                                  "^SEE:UHANGUL.DAT^FS" +
                                  "^CW1,E:KFONT3.TTF" +
                                  "^CI28^FS" +
                                  "^FWB" +                                                                      // 문자 방향
                                  "^BY2" +                                                                      // 바코드 크기
                                  "^FO" + DefaultX.ToString() + "," + DefaultY.ToString() + "^GB532,740,3^FS" + // BOX 그리기
                                  "^CF1,50" +                                                                   // 폰트설정
                                  "^FT" + (DefaultX + 50).ToString() + "," + (DefaultY + 730).ToString() + "^FD" + data.LBL_NO + "^FS" + "^BC,60,N,N,N" + "^FO" + (DefaultX + 10).ToString() + "," + (DefaultY + 40).ToString() + "^FD" + data.LBL_NO + "^FS" +
                                  "^CF1,50,40";                                                                 // 폰트설정
                if (data.ITEM_NM.Length > 20)
                {
                    command = command + "^FT" + (DefaultX + 150).ToString() + "," + (DefaultY + 730).ToString() + "^FD품목: " + data.ITEM_NM.Substring(0, 21) + "^FS" +
                              "^FT" + (DefaultX + 200).ToString() + "," + (DefaultY + 730).ToString() + "^FD" + data.ITEM_NM.Substring(21, data.ITEM_NM.Length - 21) + "^FS";
                }
                else
                {
                    command = command + "^FT" + (DefaultX + 150).ToString() + "," + (DefaultY + 730).ToString() + "^FD품목: " + data.ITEM_NM + "^FS";
                }
                command = command + "^A1,40,30^FT" + (DefaultX + 300).ToString() + "," + (DefaultY + 730).ToString() + "^FD품목번호: " + data.ITEM_NO + "^FS" +
                          "^A1,40,30^FT" + (DefaultX + 340).ToString() + "," + (DefaultY + 730).ToString() + "^FD재고번호: " + data.LOT_NO + "^FS" + "^BC,50,N,N,N" + "^FO" + (DefaultX + 300).ToString() + "," + (DefaultY + 40).ToString() + "^FD" + data.LOT_NO + "^FS";

                command = command + "^A1,35,30^FT" + (DefaultX + 380).ToString() + "," + (DefaultY + 730).ToString() + "^FD입고: " + data.ORDER_QTY + " " + data.UNIT + "^FS" +
                          "^CF1,30,25" +               // 폰트설정
                          "^FT" + (DefaultX + 430).ToString() + "," + (DefaultY + 730).ToString() + "^FD구매처: " + data.VENDOR_NM + "^FS" +
                          "^FT" + (DefaultX + 460).ToString() + "," + (DefaultY + 730).ToString() + "^FD하역일자: " + data.UNLOAD_DATE + "^FS" +
                          "^FT" + (DefaultX + 490).ToString() + "," + (DefaultY + 730).ToString() + "^FD사용기한: " + data.USE_DEADLN + "^FS" +
                          "^FT" + (DefaultX + 520).ToString() + "," + (DefaultY + 730).ToString() + "^FD보관조건: " + data.KEEP_CONDITION + "^FS" +
                          "^FT" + (DefaultX + 560).ToString() + "," + (DefaultY + 740).ToString() + "^FD" + BOTTOM_LEFT + "^FS" +
                          "^FO" + (DefaultX + 540).ToString() + "," + (DefaultY + 330).ToString() + "^FD" + data.LABEL_SEQ + "/" + data.LABEL_QTY + "^FS" +
                          "^FO" + (DefaultX + 540).ToString() + "," + (DefaultY + 10).ToString() + "^FD" + BOTTOM_RIGHT + "^FS";
                command = command + "^XZ";
                Printer.SendCommand(command);
            }
            catch (ConnectionException ex)
            {
                MessageBox.Show("프린트 실패" + Environment.NewLine + ex.ToString(), "실패", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (SqlException ex)
            {
                MessageBox.Show("프린트 실패" + Environment.NewLine + ex.ToString(), "실패", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ex)
            {
                MessageBox.Show("프린트 실패" + Environment.NewLine + ex.ToString(), "실패", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }