Exemplo n.º 1
0
        private void metroGrid1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 12 && e.RowIndex >= 0)
            {
                if (!Constants.OPEN_DATE.Equals(m_strLastSearchDate))
                {
                    MetroMessageBox.Show(this, Constants.getMessage("ERROR_PRINT_DATE"), "Search", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }


                string strSlipNo = GRD_SLIP[2, e.RowIndex].Value.ToString();
                string printCnt  = (GRD_SLIP[12, e.RowIndex].Value == null || string.Empty.Equals(GRD_SLIP[12, e.RowIndex].Value.ToString().Trim()))
                    ? "0" : GRD_SLIP[12, e.RowIndex].Value.ToString();
                Transaction       tran     = new Transaction();
                PrintSlipLangForm langForm = new PrintSlipLangForm(m_Logger);
                langForm.ShowDialog(this);
                string strSlipLang = string.Empty;
                if (langForm.m_SelectLang != null && !string.Empty.Equals(langForm.m_SelectLang.Trim()))
                {
                    strSlipLang = langForm.m_SelectLang;
                }
                else
                {
                    MetroMessageBox.Show(this, "Select Lang.", "Search", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (langForm.DialogResult != DialogResult.OK)
                {
                    return;
                }
                JObject jsonDocs = tran.GetPrintDocs(strSlipNo);
                if (jsonDocs != null)//출력
                {
                    string docid, retailer, goods, tourist, adsinfo, preview = string.Empty;
                    docid    = jsonDocs["DOCID"].ToString();
                    retailer = jsonDocs["RETAILER"].ToString();
                    goods    = jsonDocs["GOODS"].ToString();
                    tourist  = jsonDocs["TOURIST"].ToString();
                    adsinfo  = jsonDocs["ADSINFO"].ToString();
                    preview  = jsonDocs["PREVIEW"].ToString();

                    docid = strSlipLang + docid.Substring(2);
                    try
                    {
                        GTF_ReceiptPrinter printer = new GTF_ReceiptPrinter(m_Logger);
                        printer.setPrinter(Constants.PRINTER_TYPE);
#if DEBUG
                        printer.PrintSlip_ja(docid.Replace("[REPUBLISH]", "1"), retailer, goods, tourist, adsinfo);
#else
                        printer.PrintSlip_ja(docid.Replace("[REPUBLISH]", "1"), retailer, goods, tourist, adsinfo, "Y".Equals(preview));
#endif
                    }
                    catch (Exception ex)
                    {
                        m_Logger.Error(ex.StackTrace);
                    }

                    JObject tempObj  = new JObject();
                    JObject tempObj2 = new JObject();
                    tempObj.Add("SLIP_NO", strSlipNo);
                    tempObj2.Add(Constants.PRINT_CNT, (Int32.Parse(printCnt) + 1).ToString());

                    if (GRD_SLIP[13, e.RowIndex].Value == null || !"02".Equals(GRD_SLIP[13, e.RowIndex].Value.ToString()))
                    {
                        MessageForm msgForm = new MessageForm(Constants.getMessage("SLIP_CONFIRM"), null, MessageBoxButtons.YesNo);
                        msgForm.ShowDialog(this);
                        if (msgForm.DialogResult == DialogResult.Yes)
                        {
                            string refunddt = System.DateTime.Now.ToString("yy'/'MM'/'dd HH:mm:ss");
                            tempObj2.Add("SLIP_STATUS_CODE", "02");
                            tempObj2.Add("REFUNDDT", refunddt);
                            refunddt = "";
                        }
                    }

                    tran.UpdateSlip(tempObj, tempObj2);
                    tempObj.RemoveAll();
                    tempObj2.RemoveAll();
                    tempObj  = null;
                    tempObj2 = null;
                    BTN_SEARCH_Click(null, null);
                }
                else
                {
                    MetroMessageBox.Show(this, "Print Error", "Search", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }
        }