File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
using ClientLib;
using ClientLib.CommonService;
using DevExpress.XtraGrid;
using DevExpress.XtraGrid.Views.Grid;
using DevExpress.XtraGrid.Views.Grid.ViewInfo;
using Popbill;
using Popbill.Taxinvoice;
using PublicLib;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace HANMI_J_SALE
{
public partial class TaxBillByPopbill : PublicLib.CommonMDI
{
private TaxinvoiceService m_Popbill;
private DataTable m_Order, m_Detail;
public TaxBillByPopbill()
{
InitializeComponent();
gridControl_TaxBill_NotMake.LookAndFeel.Style = DevExpress.LookAndFeel.LookAndFeelStyle.Flat;
gridControl_TaxBill_NotMake.LookAndFeel.UseDefaultLookAndFeel = false;
gridView_TaxBill_NotMake.Appearance.HeaderPanel.BackColor = Color.FromArgb(170, 204, 255);
gridControl_TaxBill_Maked.LookAndFeel.Style = DevExpress.LookAndFeel.LookAndFeelStyle.Flat;
gridControl_TaxBill_Maked.LookAndFeel.UseDefaultLookAndFeel = false;
gridView_TaxBill_Maked.Appearance.HeaderPanel.BackColor = Color.FromArgb(170, 204, 255);
gridControl_Etc.LookAndFeel.Style = DevExpress.LookAndFeel.LookAndFeelStyle.Flat;
gridControl_Etc.LookAndFeel.UseDefaultLookAndFeel = false;
gridView_Etc.Appearance.HeaderPanel.BackColor = Color.FromArgb(170, 204, 255);
gridControl_Cust.LookAndFeel.Style = DevExpress.LookAndFeel.LookAndFeelStyle.Flat;
gridControl_Cust.LookAndFeel.UseDefaultLookAndFeel = false;
gridView_Cust.Appearance.HeaderPanel.BackColor = Color.FromArgb(170, 204, 255);
gridControl_NotSendList.LookAndFeel.Style = DevExpress.LookAndFeel.LookAndFeelStyle.Flat;
gridControl_NotSendList.LookAndFeel.UseDefaultLookAndFeel = false;
gridView_NotSendList.Appearance.HeaderPanel.BackColor = Color.FromArgb(170, 204, 255);
gridControl_Sended.LookAndFeel.Style = DevExpress.LookAndFeel.LookAndFeelStyle.Flat;
gridControl_Sended.LookAndFeel.UseDefaultLookAndFeel = false;
gridView_Sended.Appearance.HeaderPanel.BackColor = Color.FromArgb(170, 204, 255);
gridControl_PopBill.LookAndFeel.Style = DevExpress.LookAndFeel.LookAndFeelStyle.Flat;
gridControl_PopBill.LookAndFeel.UseDefaultLookAndFeel = false;
gridView_PopBill.Appearance.HeaderPanel.BackColor = Color.FromArgb(170, 204, 255);
m_Order = null;
panelControl_Search.Height = 70;
progressBarControl_Send.Visible = false;
progressBarControl_Sended.Visible = false;
//if (ConstClass._DEBUG_MODE)
//{
// dateEdit_SDATE.DateTime = Convert.ToDateTime("2018-12-01");
// dateEdit_FDATE.DateTime = Convert.ToDateTime("2018-12-31");
//}
//else
//{
// dateEdit_SDATE.DateTime = Convert.ToDateTime(DateTime.Now.AddMonths(-1).ToString("yyyy-MM") + "-01");
// dateEdit_FDATE.DateTime = DateTime.Now;
//}
DateTime today = DateTime.Now.Date;
if (today.Day <= 10)
{
today = today.AddMonths(-1);
}
DateTime firstDay = today.AddDays(1 - today.Day);
DateTime lastDay = firstDay.AddMonths(1).AddDays(-1);
dateEdit_SDATE.DateTime = firstDay;
dateEdit_FDATE.DateTime = lastDay;
if (today.Day <= 10)
{
dateEdit_Date.DateTime = firstDay.AddMonths(1).AddDays(-1);
}
else
{
dateEdit_Date.DateTime = DateTime.Now;
}
xtraTabControl_TaxBill.SelectedTabPage = xtraTabPage_Batch;
panelControl_Cust.Visible = true;
xtraTabControl_Tab.SelectedTabPage = xtraTabPage_Tab1;
xtraTabControl_Tab.SelectedPageChanged += (sender, e) =>
{
panelControl_Search.Height = xtraTabControl_Tab.SelectedTabPageIndex == 0 ? 70 : 37;
panelControl_Date.Visible = xtraTabControl_Tab.SelectedTabPageIndex != 1;
panelControl_Cust.Left = xtraTabControl_Tab.SelectedTabPageIndex == 1 ? 25 : 396;
};
DataView c16 = new DataView(ConstClass._DATA);
c16.RowFilter = "CATE_CD = 'C' and GRP_CD = 'C16'";
UtilClass.SetLookup(lookUpEdit_SIGN_GUBUN, c16, "NO_CD", "NO_CD_NM", true, true);
DataView c18 = new DataView(ConstClass._DATA);
c18.RowFilter = "CATE_CD = 'C' and GRP_CD = 'C18'";
UtilClass.SetLookup(lookUpEdit_TAX_REQ_TYPE, c18, "NO_CD", "NO_CD_NM", true);
DataView c19 = new DataView(ConstClass._DATA);
c19.RowFilter = "CATE_CD = 'C' and GRP_CD = 'C19'";
UtilClass.SetLookup(lookUpEdit_TAX_TYPE, c19, "NO_CD", "NO_CD_NM", true);
gridControl_TaxBill_NotMake.Visible = true;
gridControl_TaxBill_NotMake.Dock = DockStyle.Fill;
gridControl_TaxBill_Maked.Visible = false;
gridControl_TaxBill_Maked.Dock = DockStyle.None;
panelControl_TAX_DT.Visible =
panelControl_REQ_TYPE.Visible =
panelControl_TAX_TYPE.Visible = true;
simpleButton_Popbill.Click += (sender, e) =>
{
Process.Start("https://www.popbill.com/");
};
checkEdit_NotMake.CheckedChanged += (sender, e) =>
{
if (checkEdit_NotMake.Checked)
{
simpleButton_Make.Text = "선택된 모든 자료를 발행";
gridControl_TaxBill_Maked.Visible = false;
gridControl_TaxBill_Maked.Dock = DockStyle.None;
gridControl_TaxBill_NotMake.Visible = true;
gridControl_TaxBill_NotMake.Dock = DockStyle.Fill;
panelControl_TAX_DT.Visible =
panelControl_REQ_TYPE.Visible =
panelControl_TAX_TYPE.Visible = true;
}
else
{
simpleButton_Make.Text = "선택된 모든 자료를 발행취소";
gridControl_TaxBill_Maked.Visible = true;
gridControl_TaxBill_Maked.Dock = DockStyle.Fill;
gridControl_TaxBill_NotMake.Visible = false;
gridControl_TaxBill_NotMake.Dock = DockStyle.None;
panelControl_TAX_DT.Visible =
panelControl_REQ_TYPE.Visible =
panelControl_TAX_TYPE.Visible = false;
}
if (xtraTabControl_TaxBill.SelectedTabPageIndex == 1)
{
gridControl_Etc.DataSource = null;
}
};
buttonEdit_CUST_NM.EditValueChanged += (sender, e) =>
{
labelControl_CUST_CD.Text = "";
};
buttonEdit_CUST_NM.ButtonClick += (sender, e) =>
{
selectCustProc();
};
buttonEdit_CUST_NM.KeyPress += (sender, e) =>
{
if (e.KeyChar == '\r')
{
selectCustProc();
}
};
simpleButton_CompSave.Click += (sender, e) =>
{
try
{
this.Cursor = Cursors.WaitCursor;
SerializedSqlParam[] aParam = new SerializedSqlParam[]
{
ClientClass.CreateSqlParameter("COMP_CD", SqlDbType.NVarChar, ConstClass._COMP_CD),
ClientClass.CreateSqlParameter("TB_COMP_CD", SqlDbType.NVarChar, "POPBILL"),
ClientClass.CreateSqlParameter("COMP_NM", SqlDbType.NVarChar, textEdit_COMP_NM.Text),
ClientClass.CreateSqlParameter("BIZ_NO", SqlDbType.NVarChar, textEdit_BIZ_NO.Text),
ClientClass.CreateSqlParameter("OWNER_NM", SqlDbType.NVarChar, textEdit_OWNER_NM.Text),
ClientClass.CreateSqlParameter("COND_NM", SqlDbType.NVarChar, textEdit_COND_NM.Text),
ClientClass.CreateSqlParameter("EVNT_NM", SqlDbType.NVarChar, textEdit_EVNT_NM.Text),
ClientClass.CreateSqlParameter("TB_USR_NM", SqlDbType.NVarChar, textEdit_TB_USR_NM.Text),
ClientClass.CreateSqlParameter("TEL_NO", SqlDbType.NVarChar, textEdit_TEL_NO.Text),
ClientClass.CreateSqlParameter("FAX_NO", SqlDbType.NVarChar, textEdit_FAX_NO.Text),
ClientClass.CreateSqlParameter("EMAIL", SqlDbType.NVarChar, textEdit_EMAIL.Text),
ClientClass.CreateSqlParameter("ADDR1", SqlDbType.NVarChar, textEdit_ADDR1.Text),
ClientClass.CreateSqlParameter("TB_USR_ID", SqlDbType.NVarChar, textEdit_TB_USR_ID.Text),
ClientClass.CreateSqlParameter("TB_USR_PWD", SqlDbType.NVarChar, textEdit_TB_USR_PWD.Text),
ClientClass.CreateSqlParameter("TB_BANK_NM", SqlDbType.NVarChar, textEdit_TB_BANK_NM.Text),
ClientClass.CreateSqlParameter("TB_ACCT_NO", SqlDbType.NVarChar, textEdit_TB_ACCT_NO.Text),
ClientClass.CreateSqlParameter("TB_ACCT_NM", SqlDbType.NVarChar, textEdit_TB_ACCT_NM.Text),
ClientClass.CreateSqlParameter("REG_ID", SqlDbType.NVarChar, ConstClass._USR_ID)
};
ResultData resultData = ClientClass.SetData("SaveTaxBillByPopbill_Comp", aParam);
if (resultData.isError)
{
throw new Exception(resultData.ResultValue);
}
this.Cursor = Cursors.Arrow;
MessageBox.Show("저장 완료");
}
catch (Exception ex)
{
this.Cursor = Cursors.Arrow;
MessageBox.Show(ex.Message);
}
};
simpleButton_CustSave.Click += (sender, e) =>
{
try
{
DataRow row = gridView_Cust.GetFocusedDataRow();
if (row == null)
{
return;
}
this.Cursor = Cursors.WaitCursor;
string cust_cd = UtilClass.toStr(row["CUST_CD"]);
SerializedSqlParam[] aParam = new SerializedSqlParam[]
{
ClientClass.CreateSqlParameter("COMP_CD", SqlDbType.NVarChar, ConstClass._COMP_CD),
ClientClass.CreateSqlParameter("CUST_CD", SqlDbType.NVarChar, cust_cd),
ClientClass.CreateSqlParameter("CUST_NM", SqlDbType.NVarChar, textEdit_CUST_NM.Text),
ClientClass.CreateSqlParameter("BIZ_NO", SqlDbType.NVarChar, textEdit_CUST_BIZ_NO.Text),
ClientClass.CreateSqlParameter("OWNER_NM", SqlDbType.NVarChar, textEdit_CUST_OWNER_NM.Text),
ClientClass.CreateSqlParameter("COND_NM", SqlDbType.NVarChar, textEdit_CUST_COND_NM.Text),
ClientClass.CreateSqlParameter("EVNT_NM", SqlDbType.NVarChar, textEdit_CUST_EVNT_NM.Text),
ClientClass.CreateSqlParameter("FAX_NO", SqlDbType.NVarChar, textEdit_CUST_FAX_NO.Text),
ClientClass.CreateSqlParameter("ADDR1", SqlDbType.NVarChar, textEdit_CUST_ADDR1.Text),
ClientClass.CreateSqlParameter("MGR_NM", SqlDbType.NVarChar, textEdit_CUST_MGR_NM.Text),
ClientClass.CreateSqlParameter("MGR_TEL_NO", SqlDbType.NVarChar, textEdit_CUST_MGR_TEL_NO.Text),
ClientClass.CreateSqlParameter("MGR_EMAIL", SqlDbType.NVarChar, textEdit_CUST_MGR_EMAIL.Text),
ClientClass.CreateSqlParameter("REG_ID", SqlDbType.NVarChar, ConstClass._USR_ID)
};
ResultData resultData = ClientClass.SetData("SaveTaxBillByPopbill_Cust", aParam);
if (resultData.isError)
{
throw new Exception(resultData.ResultValue);
}
this.Cursor = Cursors.Arrow;
MessageBox.Show("저장 완료");
searchCust();
Application.DoEvents();
for (int i = 0; i < gridView_Cust.RowCount; i++)
{
if (UtilClass.isEqual(cust_cd, gridView_Cust.GetDataRow(i)["CUST_CD"]))
{
gridView_Cust.FocusedRowHandle = i;
break;
}
}
}
catch (Exception ex)
{
this.Cursor = Cursors.Arrow;
MessageBox.Show(ex.Message);
}
};
gridView_Cust.FocusedRowChanged += (sender, e) =>
{
textEdit_CUST_NM.Text = "";
textEdit_CUST_BIZ_NO.Text = "";
textEdit_CUST_OWNER_NM.Text = "";
textEdit_CUST_COND_NM.Text = "";
textEdit_CUST_EVNT_NM.Text = "";
textEdit_CUST_FAX_NO.Text = "";
textEdit_CUST_ADDR1.Text = "";
textEdit_CUST_MGR_NM.Text = "";
textEdit_CUST_MGR_TEL_NO.Text = "";
textEdit_CUST_MGR_EMAIL.Text = "";
DataRow row = gridView_Cust.GetFocusedDataRow();
if (row == null)
{
return;
}
textEdit_CUST_NM.Text = UtilClass.toStr(row["CUST_NM"]);
textEdit_CUST_BIZ_NO.Text = UtilClass.toStr(row["BIZ_NO"]);
textEdit_CUST_OWNER_NM.Text = UtilClass.toStr(row["OWNER_NM"]);
textEdit_CUST_COND_NM.Text = UtilClass.toStr(row["COND_NM"]);
textEdit_CUST_EVNT_NM.Text = UtilClass.toStr(row["EVNT_NM"]);
textEdit_CUST_FAX_NO.Text = UtilClass.toStr(row["FAX_NO"]);
textEdit_CUST_ADDR1.Text = UtilClass.toStr(row["ADDR1"]);
textEdit_CUST_MGR_NM.Text = UtilClass.toStr(row["MGR_NM"]);
textEdit_CUST_MGR_TEL_NO.Text = UtilClass.toStr(row["MGR_TEL_NO"]);
textEdit_CUST_MGR_EMAIL.Text = UtilClass.toStr(row["MGR_EMAIL"]);
};
simpleButton_Make.Click += (sender, e) =>
{
if (checkEdit_NotMake.Checked)
{
if (xtraTabControl_TaxBill.SelectedTabPageIndex == 0)
{
makeProcBatch();
}
else
{
makeProcEtc();
}
}
else
{
if (xtraTabControl_TaxBill.SelectedTabPageIndex == 0)
{
unMakeProcBatch();
}
else
{
unMakeProcEtc();
}
}
};
simpleButton_SelectAll.Click += (sender, e) =>
{
DataTable aData = null;
GridView view = null;
if (xtraTabControl_Tab.SelectedTabPageIndex == 0)
{
if (xtraTabControl_TaxBill.SelectedTabPageIndex == 0)
{
if (checkEdit_NotMake.Checked)
{
if (gridControl_TaxBill_NotMake.DataSource == null)
{
return;
}
aData = gridControl_TaxBill_NotMake.DataSource as DataTable;
view = gridView_TaxBill_NotMake;
}
else
{
if (gridControl_TaxBill_Maked.DataSource == null)
{
return;
}
aData = gridControl_TaxBill_Maked.DataSource as DataTable;
view = gridView_TaxBill_Maked;
}
}
else
{
if (gridControl_Etc.DataSource == null)
{
return;
}
aData = gridControl_Etc.DataSource as DataTable;
view = gridView_Etc;
}
}
else if (xtraTabControl_Tab.SelectedTabPageIndex == 1)
{
if (gridControl_Cust.DataSource == null)
{
return;
}
aData = gridControl_Cust.DataSource as DataTable;
view = gridView_Cust;
}
else if (xtraTabControl_Tab.SelectedTabPageIndex == 2)
{
if (xtraTabControl_Send.SelectedTabPageIndex == 0)
{
if (gridControl_NotSendList.DataSource == null)
{
return;
}
aData = gridControl_NotSendList.DataSource as DataTable;
view = gridView_NotSendList;
}
}
if (aData == null || view == null)
{
return;
}
try
{
view.BeginDataUpdate();
foreach (DataRow row in aData.Rows)
{
row["SEL_FIELD"] = "Y";
}
}
finally
{
view.EndDataUpdate();
}
};
simpleButton_SelectNone.Click += (sender, e) =>
{
DataTable aData = null;
GridView view = null;
if (xtraTabControl_Tab.SelectedTabPageIndex == 0)
{
if (xtraTabControl_TaxBill.SelectedTabPageIndex == 0)
{
if (checkEdit_NotMake.Checked)
{
if (gridControl_TaxBill_NotMake.DataSource == null)
{
return;
}
aData = gridControl_TaxBill_NotMake.DataSource as DataTable;
view = gridView_TaxBill_NotMake;
}
else
{
if (gridControl_TaxBill_Maked.DataSource == null)
{
return;
}
aData = gridControl_TaxBill_Maked.DataSource as DataTable;
view = gridView_TaxBill_Maked;
}
}
else
{
if (gridControl_Etc.DataSource == null)
{
return;
}
aData = gridControl_Etc.DataSource as DataTable;
view = gridView_Etc;
}
}
else if (xtraTabControl_Tab.SelectedTabPageIndex == 1)
{
if (gridControl_Cust.DataSource == null)
{
return;
}
aData = gridControl_Cust.DataSource as DataTable;
view = gridView_Cust;
}
else if (xtraTabControl_Tab.SelectedTabPageIndex == 2)
{
if (xtraTabControl_Send.SelectedTabPageIndex == 0)
{
if (gridControl_NotSendList.DataSource == null)
{
return;
}
aData = gridControl_NotSendList.DataSource as DataTable;
view = gridView_NotSendList;
}
}
if (aData == null || view == null)
{
return;
}
try
{
view.BeginDataUpdate();
foreach (DataRow row in aData.Rows)
{
row["SEL_FIELD"] = "N";
}
}
finally
{
view.EndDataUpdate();
}
};
simpleButton_SendSelectAll.Click += (sender, e) =>
{
try
{
if (gridControl_NotSendList.DataSource == null)
{
return;
}
DataTable aData = gridControl_NotSendList.DataSource as DataTable;
gridView_NotSendList.BeginDataUpdate();
foreach (DataRow row in aData.Rows)
{
row["SEL_FIELD"] = "Y";
}
}
finally
{
gridView_NotSendList.EndDataUpdate();
}
};
simpleButton_SendSelectNone.Click += (sender, e) =>
{
try
{
if (gridControl_NotSendList.DataSource == null)
{
return;
}
DataTable aData = gridControl_NotSendList.DataSource as DataTable;
gridView_NotSendList.BeginDataUpdate();
foreach (DataRow row in aData.Rows)
{
row["SEL_FIELD"] = "N";
}
}
finally
{
gridView_NotSendList.EndDataUpdate();
}
};
simpleButton_Send.Click += (sender, e) =>
{
try
{
if (gridControl_NotSendList.DataSource == null)
{
return;
}
DataTable aData = gridControl_NotSendList.DataSource as DataTable;
DataRow[] rows = aData.Select("SEL_FIELD = 'Y'");
if (rows == null || rows.Length < 1)
{
throw new Exception("전송할 자료를 선택하십시오.");
}
DataView s08 = new DataView(ConstClass._DATA);
s08.RowFilter = "CATE_CD = 'S' and GRP_CD = 'S01' and NO_CD = '08'";
if (s08.Count < 1)
{
throw new Exception("팝빌 로그인 아이디가 존재하지 않습니다.");
}
string popbill_id = UtilClass.toStr(s08[0]["NO_CD_NM"]);
if (UtilClass.isNull(popbill_id))
{
throw new Exception("팝빌 로그인 아이디를 등록하십시오.");
}
if (MessageBox.Show("선택한 자료들을 팝빌로 전송하시겠습니까?", "전송", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
{
return;
}
this.Cursor = Cursors.WaitCursor;
DataTable sendData = new DataTable();
sendData.Columns.Add("BILL_NO", typeof(string));
DataRow sendRow;
string bill_no, msg, hp;
int cnt;
Taxinvoice tax;
TaxinvoiceDetail detail;
Response response;
DataView view = new DataView(m_Detail);
progressBarControl_Send.Properties.DisplayFormat.FormatString = "{0:#,##0} / " + rows.Length.ToString("#,##0");
progressBarControl_Send.Position = 0;
progressBarControl_Send.Properties.Minimum = 0;
progressBarControl_Send.Properties.Maximum = rows.Length;
progressBarControl_Send.Visible = true;
Application.DoEvents();
DataRow row;
int yCnt = 0, nCnt = 0;
for (int i = 0; i < rows.Length; i++)
{
row = rows[i];
progressBarControl_Send.Position++;
Application.DoEvents();
bill_no = UtilClass.toStr(row["BILL_NO"]);
// 계산서 정보
tax = new Taxinvoice();
tax.writeDate = UtilClass.toStr(row["TAX_DT"]).Replace(".", "");
tax.chargeDirection = "정과금";
tax.issueType = "정발행";
tax.purposeType = UtilClass.toStr(row["TAX_REQ_TYPE_NM"]);
tax.issueTiming = "직접발행";
tax.taxType = UtilClass.toInt(row["VAT_MY"]) != 0 ? "과세" : "영세";
tax.supplyCostTotal = UtilClass.toInt(row["CURR_MY"]).ToString();
tax.taxTotal = UtilClass.toInt(row["VAT_MY"]).ToString();
tax.totalAmount = (UtilClass.toInt(row["CURR_MY"]) + UtilClass.toInt(row["VAT_MY"])).ToString();
// 공급자 정보
tax.invoicerCorpNum = textEdit_BIZ_NO.Text.Trim().Replace("-", "");
//tax.invoicerCorpNum = "4178151496";
tax.invoicerCorpName = textEdit_COMP_NM.Text.Trim();
tax.invoicerMgtKey = bill_no;
tax.invoicerCEOName = textEdit_OWNER_NM.Text.Trim();
tax.invoicerAddr = textEdit_ADDR1.Text.Trim();
tax.invoicerBizClass = textEdit_COND_NM.Text.Trim();
tax.invoicerBizType = textEdit_EVNT_NM.Text.Trim();
tax.invoicerContactName = textEdit_TB_USR_NM.Text.Trim().Equals("") ? textEdit_OWNER_NM.Text.Trim() : textEdit_TB_USR_NM.Text.Trim();
tax.invoicerEmail = textEdit_EMAIL.Text.Trim();
// 공급받는자 정보
tax.invoiceeType = "사업자";
tax.invoiceeCorpNum = UtilClass.toStr(row["BIZ_NO"]).Replace("-", "");
tax.invoiceeCorpName = UtilClass.toStr(row["CUST_NM"]);
tax.invoiceeCEOName = UtilClass.toStr(row["OWNER_NM"]);
tax.invoiceeAddr = UtilClass.toStr(row["ADDR1"]);
tax.invoiceeBizClass = UtilClass.toStr(row["COND_NM"]);
tax.invoiceeBizType = UtilClass.toStr(row["EVNT_NM"]);
tax.invoiceeContactName1 = UtilClass.isNull(row["MGR_NM"]) ? UtilClass.toStr(row["OWNER_NM"]) : UtilClass.toStr(row["MGR_NM"]);
tax.invoiceeEmail1 = UtilClass.isNull(row["MGR_EMAIL"]) ? UtilClass.toStr(row["EMAIL"]) : UtilClass.toStr(row["MGR_EMAIL"]);
// 상세항목
tax.detailList = new List<TaxinvoiceDetail>();
view.RowFilter = "BILL_NO = '" + bill_no + "'";
cnt = view.Count > 0 ? view.Count - 1 : 1;
//for (int j = 0; j < view.Count; j++)
//{
detail = new TaxinvoiceDetail();
detail.serialNum = 1;
detail.purchaseDT = UtilClass.toStr(row["TAX_DT"]).Replace(".", ""); //UtilClass.toStr(view[j]["ORDER_DATE"]);
if (cnt == 0)
{
detail.itemName = UtilClass.toStr(view[0]["ITEM_NM"]);
}
else
{
detail.itemName = UtilClass.toStr(view[0]["ITEM_NM"]) + " 외 " + cnt.ToString() + "건";
}
detail.spec = ""; // UtilClass.toStr(view[j]["ORDER_NORM"]);
detail.qty = ""; // UtilClass.toInt(view[0]["ORDER_QTY"]).ToString();
detail.unitCost = "";
detail.supplyCost = tax.supplyCostTotal;
detail.tax = tax.taxTotal;
detail.remark = "";
tax.detailList.Add(detail);
//}
try
{
response = m_Popbill.RegistIssue(textEdit_BIZ_NO.Text.Trim().Replace("-", ""), tax, false, "", false, "", "");
if (response.code != 1)
{
throw new Exception(response.code.ToString() + " " + response.message);
}
yCnt++;
//DataView s01 = new DataView(ConstClass._DATA);
//s01.RowFilter = "CATE_CD = 'S' and GRP_CD = 'S01' and NO_CD = '10'";
//bool directSendYN = false;
//if (s01.Count > 0)
//{
// directSendYN = UtilClass.isEqual(s01[0]["NO_CD_NM"], "Y");
//}
//if (directSendYN)
//{
// MgtKeyType KeyType = (MgtKeyType)Enum.Parse(typeof(MgtKeyType), "SELL");
// response = m_Popbill.SendToNTS(textEdit_BIZ_NO.Text.Trim(), KeyType, "", popbill_id);
// if (response.code != 1)
// {
// throw new Exception(response.code.ToString() + " " + response.message);
// }
//}
//else
//{
// response = m_Popbill.RegistIssue(textEdit_BIZ_NO.Text.Trim(), tax, false, "", false, "", "");
// if (response.code != 1)
// {
// throw new Exception(response.code.ToString() + " " + response.message);
// }
//}
}
catch (Exception ee)
{
nCnt++;
MessageBox.Show("다음과 같은 사유로 " + UtilClass.toStr(row["BILL_NO"]) + " 의 전송을 실패하였습니다.\n\n" + ee.Message);
continue;
}
sendRow = sendData.NewRow();
sendRow["BILL_NO"] = UtilClass.toStr(row["BILL_NO"]);
sendData.Rows.Add(sendRow);
msg = ConstClass._COMP_NM + "에서 주문하신 상품 " + cnt + " 건에 대한 세금계산서를 발행하였습니다." +
"\r\n발행일자 : " + UtilClass.toStr(row["TAX_DT"]) +
"\r\n발행번호 : " + bill_no +
"\r\n공급가액 : " + UtilClass.toInt(row["CURR_MY"]).ToString("#,##0") +
"\r\n세액 : " + UtilClass.toInt(row["VAT_MY"]).ToString("#,##0") +
"\r\n합계 : " + (UtilClass.toInt(row["CURR_MY"]) + UtilClass.toInt(row["VAT_MY"])).ToString("#,##0");
hp = UtilClass.toStr(row["MGR_TEL_NO"]);
if (UtilClass.isNull(hp) || !hp.StartsWith("01"))
{
hp = UtilClass.toStr(row["OWNER_TEL_NO"]);
if (UtilClass.isNull(hp) || !hp.StartsWith("01"))
{
hp = "";
}
}
//if (ConstClass._DEBUG_MODE)
//{
// if (i % 3 == 0)
// {
// hp = "010-5571-3734";
// }
// else if (i % 3 == 1)
// {
// hp = "010-2568-9089";
// }
// else
// {
// hp = "010-7179-2554";
// }
//}
if (!UtilClass.isNull(hp))
{
//ClientClass.sendSMS(hp, msg);
}
}
sendData.TableName = "ADATA";
ResultData data1 = new ResultData();
data1.TableData = sendData;
ResultData[] dataList = new ResultData[] { data1 };
SerializedSqlParam[] aParam = new SerializedSqlParam[]
{
ClientClass.CreateSqlParameter("COMP_CD", SqlDbType.NVarChar, ConstClass._COMP_CD),
ClientClass.CreateSqlParameter("SEND_YN", SqlDbType.NVarChar, "Y"),
ClientClass.CreateSqlParameter("REG_ID", SqlDbType.NVarChar, ConstClass._USR_ID)
};
ResultData resultData = ClientClass.SetTableData("SaveTaxBillByPopbill_Send", dataList, aParam);
if (resultData.isError)
{
throw new Exception("팝빌 전송은 완료하였지만, 다음과 같은 사유로 시스템 적용에 실패하였습니다.\n개발사에 문의를 부탁드립니다.\n\n" + resultData.ResultValue);
}
aData.AcceptChanges();
double remainPoint = m_Popbill.GetBalance(textEdit_BIZ_NO.Text.Trim().Replace("-", ""));
labelControl_Point.Text = remainPoint.ToString("#,##0") + " P";
this.Cursor = Cursors.Arrow;
MessageBox.Show("전송 완료.\n\n성공 : " + yCnt.ToString("#,##0") + " 건\n실패 : " + nCnt.ToString("#,##0") + " 건");
progressBarControl_Send.Visible = false;
xtraTabControl_Send.SelectedTabPageIndex = 1;
searchSendAll();
}
catch (Exception ex)
{
this.Cursor = Cursors.Arrow;
MessageBox.Show(ex.Message);
progressBarControl_Send.Visible = false;
}
};
simpleButton_SendedSelectAll.Click += (sender, e) =>
{
try
{
if (gridControl_Sended.DataSource == null)
{
return;
}
DataTable aData = gridControl_Sended.DataSource as DataTable;
gridView_Sended.BeginDataUpdate();
foreach (DataRow row in aData.Rows)
{
row["SEL_FIELD"] = "Y";
}
}
finally
{
gridView_Sended.EndDataUpdate();
}
};
simpleButton_SendedSelectNone.Click += (sender, e) =>
{
try
{
if (gridControl_Sended.DataSource == null)
{
return;
}
DataTable aData = gridControl_Sended.DataSource as DataTable;
gridView_Sended.BeginDataUpdate();
foreach (DataRow row in aData.Rows)
{
row["SEL_FIELD"] = "N";
}
}
finally
{
gridView_Sended.EndDataUpdate();
}
};
simpleButton_CancelSend.Click += (sender, e) =>
{
try
{
if (gridControl_Sended.DataSource == null)
{
return;
}
DataTable aData = gridControl_Sended.DataSource as DataTable;
DataRow[] rows = aData.Select("SEL_FIELD = 'Y'");
if (rows == null || rows.Length < 1)
{
throw new Exception("전송취소할 자료를 선택하십시오.");
}
DataView s08 = new DataView(ConstClass._DATA);
s08.RowFilter = "CATE_CD = 'S' and GRP_CD = 'S01' and NO_CD = '08'";
if (s08.Count < 1)
{
throw new Exception("팝빌 로그인 아이디가 존재하지 않습니다.");
}
string popbill_id = UtilClass.toStr(s08[0]["NO_CD_NM"]);
if (UtilClass.isNull(popbill_id))
{
throw new Exception("팝빌 로그인 아이디를 등록하십시오.");
}
if (MessageBox.Show("선택한 자료들을 팝빌로 전송하시겠습니까?", "전송", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
{
return;
}
this.Cursor = Cursors.WaitCursor;
DataTable sendData = new DataTable();
sendData.Columns.Add("BILL_NO", typeof(string));
DataRow sendRow;
string bill_no;
int yCnt = 0, nCnt = 0;
Response response;
DataView view = new DataView(m_Detail);
progressBarControl_Sended.Properties.DisplayFormat.FormatString = "{0:#,##0} / " + rows.Length.ToString("#,##0");
progressBarControl_Sended.Position = 0;
progressBarControl_Sended.Properties.Minimum = 0;
progressBarControl_Sended.Properties.Maximum = rows.Length;
progressBarControl_Sended.Visible = true;
Application.DoEvents();
DataRow row;
MgtKeyType keyType = (MgtKeyType)Enum.Parse(typeof(MgtKeyType), "SELL");
for (int i = 0; i < rows.Length; i++)
{
row = rows[i];
progressBarControl_Sended.Position++;
Application.DoEvents();
bill_no = UtilClass.toStr(row["BILL_NO"]);
try
{
response = m_Popbill.CancelIssue(textEdit_BIZ_NO.Text.Trim().Replace("-", ""), keyType, bill_no, "", popbill_id);
if (response.code != 1)
{
throw new Exception(response.code.ToString() + " " + response.message);
}
yCnt++;
}
catch (Exception ee)
{
nCnt++;
MessageBox.Show("다음과 같은 사유로 " + bill_no + " 의 전송취소를 실패하였습니다.\n\n" + ee.Message);
continue;
}
sendRow = sendData.NewRow();
sendRow["BILL_NO"] = bill_no;
sendData.Rows.Add(sendRow);
}
sendData.TableName = "ADATA";
ResultData data1 = new ResultData();
data1.TableData = sendData;
ResultData[] dataList = new ResultData[] { data1 };
SerializedSqlParam[] aParam = new SerializedSqlParam[]
{
ClientClass.CreateSqlParameter("COMP_CD", SqlDbType.NVarChar, ConstClass._COMP_CD),
ClientClass.CreateSqlParameter("SEND_YN", SqlDbType.NVarChar, "N"),
ClientClass.CreateSqlParameter("REG_ID", SqlDbType.NVarChar, ConstClass._USR_ID)
};
ResultData resultData = ClientClass.SetTableData("SaveTaxBillByPopbill_Send", dataList, aParam);
if (resultData.isError)
{
throw new Exception("팝빌 전송은 완료하였지만, 다음과 같은 사유로 시스템 적용에 실패하였습니다.\n개발사에 문의를 부탁드립니다.\n\n" + resultData.ResultValue);
}
aData.AcceptChanges();
double remainPoint = m_Popbill.GetBalance(textEdit_BIZ_NO.Text.Trim().Replace("-", ""));
labelControl_Point.Text = remainPoint.ToString("#,##0") + " P";
this.Cursor = Cursors.Arrow;
MessageBox.Show("전송취소 완료.\n\n성공 : " + yCnt.ToString("#,##0") + " 건\n실패 : " + nCnt.ToString("#,##0") + " 건");
progressBarControl_Sended.Visible = false;
xtraTabControl_Send.SelectedTabPageIndex = 0;
searchNotSendList();
}
catch (Exception ex)
{
this.Cursor = Cursors.Arrow;
MessageBox.Show(ex.Message);
progressBarControl_Sended.Visible = false;
}
};
this.Shown += (sender, e) =>
{
try
{
DataView s06 = new DataView(ConstClass._DATA);
s06.RowFilter = "CATE_CD = 'S' and GRP_CD = 'S01' and NO_CD = '06'";
DataView s07 = new DataView(ConstClass._DATA);
s07.RowFilter = "CATE_CD = 'S' and GRP_CD = 'S01' and NO_CD = '07'";
DataView s11 = new DataView(ConstClass._DATA);
s11.RowFilter = "CATE_CD = 'S' and GRP_CD = 'S01' and NO_CD = '11'";
if (s06.Count < 1 || s07.Count < 1)
{
throw new Exception("세금계산서 전송을 위한 환경정보가 없습니다.");
}
string linkID = UtilClass.toStr(s06[0]["NO_CD_NM"]);
string key = UtilClass.toStr(s07[0]["NO_CD_NM"]);
m_Popbill = new TaxinvoiceService(linkID, key);
m_Popbill.IsTest = s11.Count > 0 && UtilClass.isEqual(s11[0]["NO_CD_NM"], "Y");
SerializedSqlParam[] aParam = new SerializedSqlParam[]
{
ClientClass.CreateSqlParameter("COMP_CD", SqlDbType.NVarChar, ConstClass._COMP_CD)
};
ResultData resultData = ClientClass.GetData("GetTaxBillByPopbill_Init", aParam);
if (resultData.isError)
{
throw new Exception(resultData.ResultValue);
}
if (resultData.TableData.Rows.Count > 0)
{
textEdit_COMP_NM.Text = UtilClass.toStr(resultData.TableData.Rows[0]["COMP_NM"]);
textEdit_BIZ_NO.Text = UtilClass.toStr(resultData.TableData.Rows[0]["BIZ_NO"]);
textEdit_OWNER_NM.Text = UtilClass.toStr(resultData.TableData.Rows[0]["OWNER_NM"]);
textEdit_COND_NM.Text = UtilClass.toStr(resultData.TableData.Rows[0]["COND_NM"]);
textEdit_EVNT_NM.Text = UtilClass.toStr(resultData.TableData.Rows[0]["EVNT_NM"]);
textEdit_TB_USR_NM.Text = UtilClass.toStr(resultData.TableData.Rows[0]["TB_USR_NM"]);
textEdit_TEL_NO.Text = UtilClass.toStr(resultData.TableData.Rows[0]["TEL_NO"]);
textEdit_FAX_NO.Text = UtilClass.toStr(resultData.TableData.Rows[0]["FAX_NO"]);
textEdit_EMAIL.Text = UtilClass.toStr(resultData.TableData.Rows[0]["EMAIL"]);
textEdit_ADDR1.Text = UtilClass.toStr(resultData.TableData.Rows[0]["ADDR1"]);
textEdit_TB_USR_ID.Text = UtilClass.toStr(resultData.TableData.Rows[0]["TB_USR_ID"]);
textEdit_TB_USR_PWD.Text = UtilClass.toStr(resultData.TableData.Rows[0]["TB_USR_PWD"]);
textEdit_TB_BANK_NM.Text = UtilClass.toStr(resultData.TableData.Rows[0]["TB_BANK_NM"]);
textEdit_TB_ACCT_NO.Text = UtilClass.toStr(resultData.TableData.Rows[0]["TB_ACCT_NO"]);
textEdit_TB_ACCT_NM.Text = UtilClass.toStr(resultData.TableData.Rows[0]["TB_ACCT_NM"]);
}
double remainPoint = m_Popbill.GetBalance(textEdit_BIZ_NO.Text.Trim().Replace("-", ""));
labelControl_Point.Text = remainPoint.ToString("#,##0") + " P";
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
this.Close();
}
};
}
private void selectCustProc()
{
SelectCustomerForm form = new SelectCustomerForm(buttonEdit_CUST_NM.Text, DateTime.Now);
buttonEdit_CUST_NM.Text = "";
labelControl_CUST_CD.Text = "";
if (form.ShowDialog() != DialogResult.Yes)
{
return;
}
buttonEdit_CUST_NM.Text = form.m_CUST_NM;
labelControl_CUST_CD.Text = form.m_CUST_CD;
if (xtraTabControl_Tab.SelectedTabPageIndex == 0)
{
lookUpEdit_SIGN_GUBUN.Focus();
}
else
{
searchProc();
}
}
public override void searchProc()
{
switch (xtraTabControl_Tab.SelectedTabPageIndex)
{
case 0:
searchTaxBill();
break;
case 1:
searchCust();
break;
case 2:
searchSend();
break;
}
}
private void searchTaxBill()
{
if (xtraTabControl_TaxBill.SelectedTabPageIndex == 0)
{
searchTaxBillBatch();
}
else
{
searchTaxBillEtc();
}
}
private void searchTaxBillBatch()
{
try
{
this.Cursor = Cursors.WaitCursor;
if (checkEdit_NotMake.Checked)
{
gridControl_TaxBill_NotMake.DataSource = null;
}
else
{
gridControl_TaxBill_Maked.DataSource = null;
}
SerializedSqlParam[] aParam = new SerializedSqlParam[]
{
ClientClass.CreateSqlParameter("COMP_CD", SqlDbType.NVarChar, ConstClass._COMP_CD),
ClientClass.CreateSqlParameter("SDATE", SqlDbType.NVarChar, dateEdit_SDATE.DateTime.ToString("yyyy.MM.dd")),
ClientClass.CreateSqlParameter("FDATE", SqlDbType.NVarChar, dateEdit_FDATE.DateTime.ToString("yyyy.MM.dd")),
ClientClass.CreateSqlParameter("CUST_CD", SqlDbType.NVarChar, labelControl_CUST_CD.Text),
ClientClass.CreateSqlParameter("SIGN_GUBUN", SqlDbType.NVarChar, lookUpEdit_SIGN_GUBUN.EditValue),
ClientClass.CreateSqlParameter("INCLUDE_CARD", SqlDbType.NVarChar, checkEdit_Card.Checked ? "Y" : "N"),
ClientClass.CreateSqlParameter("MAKE_YN", SqlDbType.NVarChar, checkEdit_Maked.Checked ? "Y" : "N")
};
ResultData resultData = ClientClass.GetData("GetTaxBillByPopbill_TaxData", aParam);
if (resultData.isError)
{
throw new Exception(resultData.ResultValue);
}
if (checkEdit_NotMake.Checked)
{
gridControl_TaxBill_NotMake.DataSource = resultData.DataList.Tables[0];
m_Order = resultData.DataList.Tables[1];
gridControl_TaxBill_NotMake.Focus();
}
else
{
gridControl_TaxBill_Maked.DataSource = resultData.TableData;
gridControl_TaxBill_Maked.Focus();
}
this.Cursor = Cursors.Arrow;
}
catch (Exception ex)
{
this.Cursor = Cursors.Arrow;
MessageBox.Show(ex.Message);
}
}
private void searchTaxBillEtc()
{
try
{
this.Cursor = Cursors.WaitCursor;
if (UtilClass.isNull(labelControl_CUST_CD.Text))
{
buttonEdit_CUST_NM.Focus();
throw new Exception("거래처를 선택하십시오.");
}
if (checkEdit_NotMake.Checked)
{
gridControl_TaxBill_NotMake.DataSource = null;
}
else
{
gridControl_TaxBill_Maked.DataSource = null;
}
SerializedSqlParam[] aParam = new SerializedSqlParam[]
{
ClientClass.CreateSqlParameter("COMP_CD", SqlDbType.NVarChar, ConstClass._COMP_CD),
ClientClass.CreateSqlParameter("SDATE", SqlDbType.NVarChar, dateEdit_SDATE.DateTime.ToString("yyyy.MM.dd")),
ClientClass.CreateSqlParameter("FDATE", SqlDbType.NVarChar, dateEdit_FDATE.DateTime.ToString("yyyy.MM.dd")),
ClientClass.CreateSqlParameter("CUST_CD", SqlDbType.NVarChar, labelControl_CUST_CD.Text),
ClientClass.CreateSqlParameter("SIGN_GUBUN", SqlDbType.NVarChar, lookUpEdit_SIGN_GUBUN.EditValue),
ClientClass.CreateSqlParameter("INCLUDE_CARD", SqlDbType.NVarChar, checkEdit_Card.Checked ? "Y" : "N"),
ClientClass.CreateSqlParameter("MAKE_YN", SqlDbType.NVarChar, checkEdit_Maked.Checked ? "Y" : "N")
};
ResultData resultData = ClientClass.GetData("GetTaxBillByPopbill_EtcTaxData", aParam);
if (resultData.isError)
{
throw new Exception(resultData.ResultValue);
}
gridControl_Etc.DataSource = resultData.TableData;
gridControl_Etc.Focus();
this.Cursor = Cursors.Arrow;
}
catch (Exception ex)
{
this.Cursor = Cursors.Arrow;
MessageBox.Show(ex.Message);
}
}
private void searchCust()
{
try
{
this.Cursor = Cursors.WaitCursor;
gridControl_Cust.DataSource = null;
SerializedSqlParam[] aParam = new SerializedSqlParam[]
{
ClientClass.CreateSqlParameter("COMP_CD", SqlDbType.NVarChar, ConstClass._COMP_CD),
ClientClass.CreateSqlParameter("CUST_CD", SqlDbType.NVarChar, labelControl_CUST_CD.Text),
ClientClass.CreateSqlParameter("NOT_EMAIL", SqlDbType.NVarChar, checkEdit_Maked.Checked ? "Y" : "N")
};
ResultData resultData = ClientClass.GetData("GetTaxBillByPopbill_Cust", aParam);
if (resultData.isError)
{
throw new Exception(resultData.ResultValue);
}
gridControl_Cust.DataSource = resultData.TableData;
this.Cursor = Cursors.Arrow;
gridControl_Cust.Focus();
}
catch (Exception ex)
{
this.Cursor = Cursors.Arrow;
MessageBox.Show(ex.Message);
}
}
private void searchSend()
{
if (xtraTabControl_Send.SelectedTabPageIndex == 0)
{
searchNotSendList();
}
else if (xtraTabControl_Send.SelectedTabPageIndex == 1)
{
searchSendList();
}
else
{
searchPopBill();
}
}
private void searchNotSendList()
{
try
{
this.Cursor = Cursors.WaitCursor;
gridControl_NotSendList.DataSource = null;
SerializedSqlParam[] aParam = new SerializedSqlParam[]
{
ClientClass.CreateSqlParameter("COMP_CD", SqlDbType.NVarChar, ConstClass._COMP_CD),
ClientClass.CreateSqlParameter("SDATE", SqlDbType.NVarChar, dateEdit_SDATE.DateTime.ToString("yyyy.MM.dd")),
ClientClass.CreateSqlParameter("FDATE", SqlDbType.NVarChar, dateEdit_FDATE.DateTime.ToString("yyyy.MM.dd")),
ClientClass.CreateSqlParameter("CUST_CD", SqlDbType.NVarChar, labelControl_CUST_CD.Text)
};
ResultData resultData = ClientClass.GetData("GetTaxBillByPopbill_NotSendList", aParam);
if (resultData.isError)
{
throw new Exception(resultData.ResultValue);
}
gridControl_NotSendList.DataSource = resultData.DataList.Tables[0];
m_Detail = resultData.DataList.Tables[1];
this.Cursor = Cursors.Arrow;
gridControl_NotSendList.Focus();
}
catch (Exception ex)
{
this.Cursor = Cursors.Arrow;
MessageBox.Show(ex.Message);
}
}
private void searchSendList()
{
try
{
this.Cursor = Cursors.WaitCursor;
gridControl_Sended.DataSource = null;
SerializedSqlParam[] aParam = new SerializedSqlParam[]
{
ClientClass.CreateSqlParameter("COMP_CD", SqlDbType.NVarChar, ConstClass._COMP_CD),
ClientClass.CreateSqlParameter("SDATE", SqlDbType.NVarChar, dateEdit_SDATE.DateTime.ToString("yyyy.MM.dd")),
ClientClass.CreateSqlParameter("FDATE", SqlDbType.NVarChar, dateEdit_FDATE.DateTime.ToString("yyyy.MM.dd")),
ClientClass.CreateSqlParameter("CUST_CD", SqlDbType.NVarChar, labelControl_CUST_CD.Text)
};
ResultData resultData = ClientClass.GetData("GetTaxBillByPopbill_SendList", aParam);
if (resultData.isError)
{
throw new Exception(resultData.ResultValue);
}
gridControl_Sended.DataSource = resultData.TableData;
this.Cursor = Cursors.Arrow;
gridControl_Sended.Focus();
}
catch (Exception ex)
{
this.Cursor = Cursors.Arrow;
MessageBox.Show(ex.Message);
}
}
private void searchSendAll()
{
try
{
this.Cursor = Cursors.WaitCursor;
gridControl_NotSendList.DataSource = null;
gridControl_Sended.DataSource = null;
SerializedSqlParam[] aParam = new SerializedSqlParam[]
{
ClientClass.CreateSqlParameter("COMP_CD", SqlDbType.NVarChar, ConstClass._COMP_CD),
ClientClass.CreateSqlParameter("SDATE", SqlDbType.NVarChar, dateEdit_SDATE.DateTime.ToString("yyyy.MM.dd")),
ClientClass.CreateSqlParameter("FDATE", SqlDbType.NVarChar, dateEdit_FDATE.DateTime.ToString("yyyy.MM.dd")),
ClientClass.CreateSqlParameter("CUST_CD", SqlDbType.NVarChar, labelControl_CUST_CD.Text)
};
ResultData resultData = ClientClass.GetData("GetTaxBillByPopbill_Send", aParam);
if (resultData.isError)
{
throw new Exception(resultData.ResultValue);
}
gridControl_NotSendList.DataSource = resultData.DataList.Tables[0];
m_Detail = resultData.DataList.Tables[1];
gridControl_Sended.DataSource = resultData.DataList.Tables[2];
this.Cursor = Cursors.Arrow;
gridControl_Sended.Focus();
}
catch (Exception ex)
{
this.Cursor = Cursors.Arrow;
MessageBox.Show(ex.Message);
}
}
private void searchPopBill()
{
try
{
this.Cursor = Cursors.WaitCursor;
gridControl_PopBill.DataSource = null;
DataView s08 = new DataView(ConstClass._DATA);
s08.RowFilter = "CATE_CD = 'S' and GRP_CD = 'S01' and NO_CD = '08'";
if (s08.Count < 1)
{
throw new Exception("팝빌 로그인 아이디가 존재하지 않습니다.");
}
string popbill_id = UtilClass.toStr(s08[0]["NO_CD_NM"]);
if (UtilClass.isNull(popbill_id))
{
throw new Exception("팝빌 로그인 아이디를 등록하십시오.");
}
// 문서상태값 조회옵션
string[] stat = new string[5];
stat[0] = "100";
stat[1] = "3**";
stat[2] = "4**";
stat[3] = "5**";
stat[4] = "6**";
// 문서유형 배열, N-일반세금계산서, M-수정세금계산서
string[] docType = new string[2];
docType[0] = "N";
docType[1] = "M";
// 과세형태 배열, T-과세, N-면세, Z-영세
string[] taxType = new string[3];
taxType[0] = "T";
taxType[1] = "N";
taxType[2] = "Z";
// 발행유형 배열, N-정발행 / R-역발행 / T-위수탁
string[] issueType = new string[3];
issueType[0] = "N";
issueType[1] = "R";
issueType[2] = "T";
// 지연발행 여부, 미기재시 전체, true-지연발행분 조회, false-정상발행분 조회
bool? lateOnly = null;
TISearchResult searchResult = m_Popbill.Search(
textEdit_BIZ_NO.Text.Trim().Replace("-", ""),
MgtKeyType.SELL,
"W", // R: 등록일자, I: 발행일자, W: 작성일자
dateEdit_SDATE.DateTime.ToString("yyyyMMdd"),
dateEdit_FDATE.DateTime.ToString("yyyyMMdd"),
stat,
docType,
taxType,
issueType,
lateOnly,
"", // 종사업장 유무, 공백-전체조회, 0-종사업장 없는 문서 조회, 1-종사업장번호 조건에 따라 조회
"S", // 종사업장번호 유형, S-공급자, B-공급받는자, T-수탁자
"", // 종사업장번호, 콤마(",")로 구분하여 구성 ex) "0001,1234"
"", // 거래처 조회, 거래처 사업자등록번호 또는 상호명 기재, 미기재시 전체조회
"A", // 정렬방향, A-오름차순, D-내림차순
1, // 페이지번호
1000, // 페이지당 검색결과 갯수
"", // 일반/연동문서 구분, 공백-전체조회, 0-일반문서 조회, 1-연동문서조회
popbill_id
);
DataTable aData = new DataTable();
aData.Columns.Add("WRITE_DATE", typeof(string));
aData.Columns.Add("REG_DT", typeof(string));
aData.Columns.Add("TAX_TYPE", typeof(string));
aData.Columns.Add("TAX_REQ_TYPE", typeof(string));
aData.Columns.Add("CUST_NM", typeof(string));
aData.Columns.Add("BIZ_NO", typeof(string));
aData.Columns.Add("CURR_MY", typeof(int));
aData.Columns.Add("VAT_MY", typeof(decimal));
aData.Columns.Add("TOT_MY", typeof(decimal));
DataRow row;
foreach (TaxinvoiceInfo info in searchResult.list)
{
row = aData.NewRow();
row["WRITE_DATE"] = info.writeDate.Substring(0, 4) + "-" + info.writeDate.Substring(4, 2) + "-" +
info.writeDate.Substring(6, 2);
row["REG_DT"] = info.regDT.Substring(0, 4) + "-" + info.regDT.Substring(4, 2) + "-" +
info.regDT.Substring(6, 2) + " " + info.regDT.Substring(8, 2) + ":" + info.regDT.Substring(10, 2) + ":" +
info.regDT.Substring(12, 2);
row["TAX_TYPE"] = info.taxType;
row["TAX_REQ_TYPE"] = info.purposeType;
row["CUST_NM"] = info.invoiceeCorpName;
row["BIZ_NO"] = info.invoiceeCorpNum.Substring(0, 3) + "-" + info.invoiceeCorpNum.Substring(3, 2) + "-" +
info.invoiceeCorpNum.Substring(5, 5);
row["CURR_MY"] = UtilClass.toDecimal(info.supplyCostTotal);
row["VAT_MY"] = UtilClass.toDecimal(info.taxTotal);
row["TOT_MY"] = UtilClass.toDecimal(info.supplyCostTotal) + UtilClass.toDecimal(info.taxTotal);
aData.Rows.Add(row);
}
gridControl_PopBill.DataSource = aData;
this.Cursor = Cursors.Arrow;
}
catch (Exception ex)
{
this.Cursor = Cursors.Arrow;
MessageBox.Show(ex.Message);
}
}
public override void excelProc()
{
if (xtraTabControl_Tab.SelectedTabPageIndex == 0)
{
if (xtraTabControl_TaxBill.SelectedTabPageIndex == 0)
{
if (checkEdit_NotMake.Checked)
{
this.ExportExcelGrid(gridControl_TaxBill_NotMake);
}
else
{
this.ExportExcelGrid(gridControl_TaxBill_Maked);
}
}
else
{
this.ExportExcelGrid(gridControl_Etc);
}
}
else if (xtraTabControl_Tab.SelectedTabPageIndex == 1)
{
this.ExportExcelGrid(gridControl_Cust);
}
else if (xtraTabControl_Tab.SelectedTabPageIndex == 2)
{
if (xtraTabControl_Send.SelectedTabPageIndex == 0)
{
this.ExportExcelGrid(gridControl_NotSendList);
}
else if (xtraTabControl_Send.SelectedTabPageIndex == 1)
{
this.ExportExcelGrid(gridControl_Sended);
}
else
{
this.ExportExcelGrid(gridControl_PopBill);
}
}
}
private void makeProcBatch()
{
try
{
if (gridControl_TaxBill_NotMake.DataSource == null)
{
return;
}
if (MessageBox.Show("세금계산서 자료를 발행하시겠습니까?", "발행", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
{
return;
}
this.Cursor = Cursors.WaitCursor;
gridView_TaxBill_NotMake.PostEditor();
gridView_TaxBill_NotMake.UpdateCurrentRow();
Application.DoEvents();
DataTable srcData = gridControl_TaxBill_NotMake.DataSource as DataTable;
DataRow[] rows = srcData.Select("SEL_FIELD = 'Y'");
if (rows == null || rows.Length < 1)
{
throw new Exception("발행할 자료를 선택하십시오.");
}
DataRow row;
DataTable aData = new DataTable();
aData.Columns.Add("COMP_CD", typeof(string));
aData.Columns.Add("CUST_CD", typeof(string));
DataTable bData = new DataTable();
bData.Columns.Add("COMP_CD", typeof(string));
bData.Columns.Add("ORDER_NO", typeof(string));
bData.Columns.Add("CUST_CD", typeof(string));
DataRow[] rowList;
foreach (DataRow aRow in rows)
{
if (UtilClass.isNull(aRow["BIZ_NO"]))
{
throw new Exception(UtilClass.toStr(aRow["CUST_NM"]) + " : 사업자 번호가 누락되어 있습니다.");
}
else if (UtilClass.isNull(aRow["COND_NM"]))
{
throw new Exception(UtilClass.toStr(aRow["COND_NM"]) + " : 사업자등록증의 업태가 누락되어 있습니다.");
}
else if (UtilClass.isNull(aRow["EVNT_NM"]))
{
throw new Exception(UtilClass.toStr(aRow["EVNT_NM"]) + " : 사업자등록증의 종목이 누락되어 있습니다.");
}
row = aData.NewRow();
row["COMP_CD"] = ConstClass._COMP_CD;
row["CUST_CD"] = aRow["CUST_CD"];
aData.Rows.Add(row);
rowList = m_Order.Select("COMP_CD = '" + ConstClass._COMP_CD + "' and CUST_CD = '" + UtilClass.toStr(aRow["CUST_CD"]) + "'");
if (rowList == null)
{
continue;
}
foreach (DataRow bRow in rowList)
{
row = bData.NewRow();
row["COMP_CD"] = ConstClass._COMP_CD;
row["ORDER_NO"] = bRow["ORDER_NO"];
row["CUST_CD"] = bRow["CUST_CD"];
bData.Rows.Add(row);
}
}
aData.TableName = "ADATA";
bData.TableName = "BDATA";
ResultData data1 = new ResultData();
data1.TableData = aData;
ResultData data2 = new ResultData();
data2.TableData = bData;
ResultData[] dataList = new ResultData[] { data1, data2 };
SerializedSqlParam[] aParam = new SerializedSqlParam[]
{
ClientClass.CreateSqlParameter("TAX_DT", SqlDbType.NVarChar, dateEdit_Date.DateTime.ToString("yyyy.MM.dd")),
ClientClass.CreateSqlParameter("TAX_REQ_TYPE", SqlDbType.NVarChar, lookUpEdit_TAX_REQ_TYPE.EditValue),
ClientClass.CreateSqlParameter("TAX_TYPE", SqlDbType.NVarChar, lookUpEdit_TAX_TYPE.EditValue),
ClientClass.CreateSqlParameter("REG_ID", SqlDbType.NVarChar, ConstClass._USR_ID)
};
ResultData resultData = ClientClass.SetTableData("CreateTaxBillNumberBatch", dataList, aParam);
if (resultData.isError)
{
throw new Exception(resultData.ResultValue);
}
this.Cursor = Cursors.Arrow;
MessageBox.Show("발행완료.");
checkEdit_Maked.Checked = true;
searchTaxBill();
}
catch (Exception ex)
{
this.Cursor = Cursors.Arrow;
MessageBox.Show(ex.Message);
}
}
private void makeProcEtc()
{
try
{
if (gridControl_Etc.DataSource == null)
{
return;
}
if (MessageBox.Show("업체별 세금계산서 자료를 발행하시겠습니까?", "발행", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
{
return;
}
this.Cursor = Cursors.WaitCursor;
gridView_Etc.PostEditor();
gridView_Etc.UpdateCurrentRow();
Application.DoEvents();
DataTable srcData = gridControl_Etc.DataSource as DataTable;
DataRow[] rows = srcData.Select("SEL_FIELD = 'Y'");
if (rows == null || rows.Length < 1)
{
throw new Exception("발행할 자료를 선택하십시오.");
}
DataRow row;
DataTable aData = new DataTable();
aData.Columns.Add("ORDER_NO", typeof(string));
aData.Columns.Add("LN_SEQ", typeof(int));
foreach (DataRow aRow in rows)
{
row = aData.NewRow();
row["ORDER_NO"] = aRow["ORDER_NO"];
row["LN_SEQ"] = aRow["LN_SEQ"];
aData.Rows.Add(row);
}
aData.TableName = "ADATA";
ResultData data1 = new ResultData();
data1.TableData = aData;
ResultData[] dataList = new ResultData[] { data1 };
SerializedSqlParam[] aParam = new SerializedSqlParam[]
{
ClientClass.CreateSqlParameter("COMP_CD", SqlDbType.NVarChar, ConstClass._COMP_CD),
ClientClass.CreateSqlParameter("TAX_DT", SqlDbType.NVarChar, dateEdit_Date.DateTime.ToString("yyyy.MM.dd")),
ClientClass.CreateSqlParameter("TAX_REQ_TYPE", SqlDbType.NVarChar, lookUpEdit_TAX_REQ_TYPE.EditValue),
ClientClass.CreateSqlParameter("TAX_TYPE", SqlDbType.NVarChar, lookUpEdit_TAX_TYPE.EditValue),
ClientClass.CreateSqlParameter("REG_ID", SqlDbType.NVarChar, ConstClass._USR_ID)
};
ResultData resultData = ClientClass.SetTableData("CreateTaxBillNumberEtc", dataList, aParam);
if (resultData.isError)
{
throw new Exception(resultData.ResultValue);
}
this.Cursor = Cursors.Arrow;
MessageBox.Show("발행완료.");
checkEdit_Maked.Checked = true;
searchTaxBill();
}
catch (Exception ex)
{
this.Cursor = Cursors.Arrow;
MessageBox.Show(ex.Message);
}
}
private void unMakeProcBatch()
{
try
{
if (gridControl_TaxBill_Maked.DataSource == null)
{
return;
}
if (MessageBox.Show("발행된 세금계산서 자료를 취소하시겠습니까?", "발행취소", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
{
return;
}
this.Cursor = Cursors.WaitCursor;
gridView_TaxBill_Maked.PostEditor();
gridView_TaxBill_Maked.UpdateCurrentRow();
Application.DoEvents();
DataTable srcData = gridControl_TaxBill_Maked.DataSource as DataTable;
DataRow[] rows = srcData.Select("SEL_FIELD = 'Y'");
if (rows == null || rows.Length < 1)
{
throw new Exception("취소할 자료를 선택하십시오.");
}
DataRow row;
DataTable aData = new DataTable();
aData.Columns.Add("CUST_CD", typeof(string));
aData.Columns.Add("BILL_NO", typeof(string));
foreach (DataRow aRow in rows)
{
row = aData.NewRow();
row["CUST_CD"] = aRow["CUST_CD"];
row["BILL_NO"] = aRow["BILL_NO"];
aData.Rows.Add(row);
}
aData.TableName = "ADATA";
ResultData data1 = new ResultData();
data1.TableData = aData;
ResultData[] dataList = new ResultData[] { data1 };
SerializedSqlParam[] aParam = new SerializedSqlParam[]
{
ClientClass.CreateSqlParameter("COMP_CD", SqlDbType.NVarChar, ConstClass._COMP_CD),
ClientClass.CreateSqlParameter("REG_ID", SqlDbType.NVarChar, ConstClass._USR_ID)
};
ResultData resultData = ClientClass.SetTableData("CancelCreateTaxBillNumberBatch", dataList, aParam);
if (resultData.isError)
{
throw new Exception(resultData.ResultValue);
}
this.Cursor = Cursors.Arrow;
MessageBox.Show("발행취소 완료.");
searchTaxBill();
}
catch (Exception ex)
{
this.Cursor = Cursors.Arrow;
MessageBox.Show(ex.Message);
}
}
private void unMakeProcEtc()
{
try
{
if (gridControl_Etc.DataSource == null)
{
return;
}
if (MessageBox.Show("발행된 업체별/건발행 세금계산서 자료를 취소하시겠습니까?", "발행취소", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
{
return;
}
this.Cursor = Cursors.WaitCursor;
gridView_Etc.PostEditor();
gridView_Etc.UpdateCurrentRow();
Application.DoEvents();
DataTable srcData = gridControl_Etc.DataSource as DataTable;
DataRow[] rows = srcData.Select("SEL_FIELD = 'Y'");
if (rows == null || rows.Length < 1)
{
throw new Exception("취소할 자료를 선택하십시오.");
}
DataRow row;
DataTable aData = new DataTable();
aData.Columns.Add("ORDER_NO", typeof(string));
aData.Columns.Add("LN_SEQ", typeof(int));
aData.Columns.Add("BILL_NO", typeof(string));
foreach (DataRow aRow in rows)
{
row = aData.NewRow();
row["ORDER_NO"] = aRow["ORDER_NO"];
row["LN_SEQ"] = aRow["LN_SEQ"];
row["BILL_NO"] = aRow["BILL_NO"];
aData.Rows.Add(row);
}
aData.TableName = "ADATA";
ResultData data1 = new ResultData();
data1.TableData = aData;
ResultData[] dataList = new ResultData[] { data1 };
SerializedSqlParam[] aParam = new SerializedSqlParam[]
{
ClientClass.CreateSqlParameter("COMP_CD", SqlDbType.NVarChar, ConstClass._COMP_CD),
ClientClass.CreateSqlParameter("REG_ID", SqlDbType.NVarChar, ConstClass._USR_ID)
};
ResultData resultData = ClientClass.SetTableData("CancelCreateTaxBillNumberEtc", dataList, aParam);
if (resultData.isError)
{
throw new Exception(resultData.ResultValue);
}
this.Cursor = Cursors.Arrow;
MessageBox.Show("발행취소 완료.");
searchTaxBill();
}
catch (Exception ex)
{
this.Cursor = Cursors.Arrow;
MessageBox.Show(ex.Message);
}
}
}
}