/// <summary> /// 포트오픈 /// </summary> public void OpenPort() { try { spPort = new SerialPort() { PortName = "COM7", BaudRate = (int)9600, DataBits = (int)8, Parity = Parity.None, StopBits = StopBits.One, //Handshake = Handshake.RequestToSend, Handshake = Handshake.None, //Encoding = Encoding.UTF8, //한글처리 필요시 Encoding = Encoding.GetEncoding("ks_c_5601-1987"), NewLine = "\n", ReadTimeout = 500, WriteTimeout = 500 }; spPort.Open(); } catch (Exception ex) { spPort.Dispose(); spPort = null; ClsLog.WriteLog(ClsLog.LOG_EXCEPTION, System.Reflection.MethodBase.GetCurrentMethod().Name, ex.Message); } }
/// <summary> /// 로우 검사 /// </summary> /// <param name="rowInput"></param> /// <returns></returns> private bool checkRow(DataGridViewRow rowInput) { bool bRet = false; try { if (rowInput == null) { return(false); } else if (Regex.IsMatch(rowInput.Cells["colUnitPrice"].Value.ToString(), @"\D")) { return(false); } else if (Regex.IsMatch(rowInput.Cells["colQty"].Value.ToString(), @"\D")) { return(false); } else if (Regex.IsMatch(rowInput.Cells["colDisCount"].Value.ToString(), @"\D")) { return(false); } bRet = true; } catch (Exception ex) { ClsLog.WriteLog(ClsLog.LOG_EXCEPTION, System.Reflection.MethodBase.GetCurrentMethod().Name, ex.Message); } return(bRet); }
/// <summary> /// 아이디체크 /// </summary> /// <returns></returns> private bool CheckId() { bool bRet = false; string sId = txtId.Text; string sName = null; try { if (CheckInput("I", sId) != true) { return(false); } sName = clsLogin.SearchName(sId); if (sName != null) { txtName.Text = sName; txtPwd.Focus(); bRet = true; } else { MessageBox.Show("잘못된 캐셔번호 입니다."); txtName.Text = ""; txtId.Focus(); } } catch (Exception ex) { ClsLog.WriteLog(ClsLog.LOG_EXCEPTION, System.Reflection.MethodBase.GetCurrentMethod().Name, ex.Message); } return(bRet); }
/// <summary> /// 거래번호조회 /// </summary> /// <returns></returns> public string SelectTranNo() { string sRet = null; string sQuery = "SELECT MAX(TRAN_NO) FROM SALHDR"; SqlDataReader sqlRead = null; try { sqlRead = clsDb.GetData(sQuery); if (sqlRead.Read() == true) { sRet = sqlRead[0].ToString(); } } catch (Exception ex) { ClsLog.WriteLog(ClsLog.LOG_EXCEPTION, System.Reflection.MethodBase.GetCurrentMethod().Name, ex.Message); } finally { if (sqlRead.IsClosed != true) { sqlRead.Close(); } } return(sRet); }
/// <summary> /// 숫자키 클릭 이벤트 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnNum_Click(object sender, EventArgs e) { string sKey = null; try { sKey = ((Button)sender).Text; if (ctrFocus == txtId) { if ((txtId.Text.Length + sKey.Length) <= 6) { txtId.Text += sKey; } txtId.Focus(); txtId.Select(txtId.TextLength, 0); } else if (ctrFocus == txtPwd) { if ((txtPwd.Text.Length + sKey.Length) <= 2) { txtPwd.Text += sKey; } txtPwd.Focus(); txtPwd.Select(txtPwd.TextLength, 0); }//end if~ else if } catch (Exception ex) { ClsLog.WriteLog(ClsLog.LOG_EXCEPTION, System.Reflection.MethodBase.GetCurrentMethod().Name, ex.Message); } }
/// <summary> /// 거래보류 카운트 /// </summary> /// <returns></returns> public int SelectHoldCount() { int iRet = 0; SqlDataReader sqlRead = null; string sQuery = null; try { sQuery = "SELECT count(*) " + "FROM SALHDR " + "WHERE tran_type = '02'"; sqlRead = clsDb.GetData(sQuery); if (sqlRead.Read() == true) { iRet = (int)sqlRead[0]; } } catch (Exception ex) { ClsLog.WriteLog(ClsLog.LOG_EXCEPTION, System.Reflection.MethodBase.GetCurrentMethod().Name, ex.Message); } finally { if (sqlRead.IsClosed != true) { sqlRead.Close(); } } return(iRet); }
/// <summary> /// 보류리스트 /// </summary> public bool SearchHoldList() { bool bRet = false; int iIndex = 0; List <Dictionary <string, string> > liHold = null; try { liHold = clsTran.SearchHold(); if (liHold.Count > 0) { foreach (Dictionary <string, string> dicHold in liHold) { iIndex = grdHoldList.Rows.Add(); grdHoldList.Rows[iIndex].Cells["colNo"].Value = iIndex; grdHoldList.Rows[iIndex].Cells["colSaleDate"].Value = dicHold["sal_date"]; grdHoldList.Rows[iIndex].Cells["colPrice"].Value = dicHold["sal_price"]; grdHoldList.Rows[iIndex].Cells["colStoreNo"].Value = dicHold["STORE_NO"]; grdHoldList.Rows[iIndex].Cells["colPosNo"].Value = dicHold["POS_NO"]; grdHoldList.Rows[iIndex].Cells["colTranNo"].Value = dicHold["TRAN_NO"]; } bRet = true; } } catch (Exception ex) { ClsLog.WriteLog(ClsLog.LOG_EXCEPTION, System.Reflection.MethodBase.GetCurrentMethod().Name, ex.Message); } return(bRet); }
/// <summary> /// 이름검색 /// </summary> /// <param name="sId"></param> /// <returns></returns> public string SearchName(string sId) { string sName = null; string sQuery = "SELECT EMP_NAME FROM EMPMST " + "WHERE EMP_ID =" + "'" + sId + "'"; SqlDataReader sqlRead = null; try { sqlRead = clsDb.GetData(sQuery); if (sqlRead.Read() == true) { sName = sqlRead[0].ToString(); } } catch (Exception ex) { ClsLog.WriteLog(ClsLog.LOG_EXCEPTION, System.Reflection.MethodBase.GetCurrentMethod().Name, ex.Message); } finally { if (sqlRead.IsClosed != true) { sqlRead.Close(); } } return(sName); }
/// <summary> /// 로그인체크 /// </summary> /// <param name="sId"></param> /// <param name="sPwd"></param> /// <returns></returns> public bool CheckLogin(string sId, string sPwd) { bool bRet = false; int iCount = -1; string sQuery = "SELECT count(*) FROM EMPMST " + "WHERE EMP_ID =" + "'" + sId + "'" + "AND EMP_PASS ="******"'" + sPwd + "'"; SqlDataReader sqlRead = null; try { sqlRead = clsDb.GetData(sQuery); if (sqlRead.Read() == true) { iCount = (int)sqlRead[0]; if (iCount > 0) { bRet = true; } } } catch (Exception ex) { ClsLog.WriteLog(ClsLog.LOG_EXCEPTION, System.Reflection.MethodBase.GetCurrentMethod().Name, ex.Message); } finally { if (sqlRead.IsClosed != true) { sqlRead.Close(); } } return(bRet); }
/// <summary> /// 판매등록 /// </summary> private bool RegisterSale() { bool bRet = false; FrmLogin frmLogin = null; try { frmLogin = new FrmLogin(); frmLogin.ShowDialog(); if (ClsMain.sLoginState == "true") { FrmSale frmSale = new FrmSale(); frmSale.txtCashierNo.Text = ClsMain.sCashierNo; frmSale.txtCashierName.Text = ClsMain.sName; frmSale.ShowDialog(); } bRet = true; } catch (Exception ex) { ClsLog.WriteLog(ClsLog.LOG_EXCEPTION, System.Reflection.MethodBase.GetCurrentMethod().Name, ex.Message); } return(bRet); }
/// <summary> /// 수량 변경 /// </summary> /// <returns></returns> private bool ChangeQty() { bool bRet = false; string sValue = null; int iQty = 0; try { sValue = txtInput.Text; if (sValue == "") { sValue = (int.Parse(grdSaleList.CurrentRow.Cells["colQty"].Value.ToString()) + 1).ToString(); } if (CheckInput("count", sValue) != true) { return(false); } iQty = int.Parse(sValue); grdSaleList.CurrentRow.Cells["colQty"].Value = iQty; txtInput.Clear(); bRet = true; } catch (Exception ex) { ClsLog.WriteLog(ClsLog.LOG_EXCEPTION, System.Reflection.MethodBase.GetCurrentMethod().Name, ex.Message); } return(bRet); }
/// <summary> /// 가격변경 /// </summary> /// <param name="sPrice"></param> /// <returns></returns> private bool ChangePrice() { bool bRet = false; string sValue = null; int iPrice = 0; try { sValue = txtInput.Text; if (CheckInput("price", sValue) != true) { return(false); } iPrice = int.Parse(sValue); grdSaleList.CurrentRow.Cells["colUnitPrice"].Value = iPrice; txtInput.Clear(); bRet = true; } catch (Exception ex) { ClsLog.WriteLog(ClsLog.LOG_EXCEPTION, System.Reflection.MethodBase.GetCurrentMethod().Name, ex.Message); } return(bRet); }
/// <summary> /// 로우추가 /// </summary> /// <param name="rowData"></param> /// <returns></returns> public bool AddRow(List <Dictionary <string, string> > liRowData) { bool bRet = false; int iIndex = 0; try { if (liRowData.Count > 0) { foreach (Dictionary <string, string> rowData in liRowData) { iIndex = grdSaleList.Rows.Add(); grdSaleList.Rows[iIndex].Cells["colSeq"].Value = iIndex; grdSaleList.Rows[iIndex].Cells["colCode"].Value = rowData["colCode"]; grdSaleList.Rows[iIndex].Cells["colTitle"].Value = rowData["colTitle"]; grdSaleList.Rows[iIndex].Cells["colUnitPrice"].Value = rowData["colUnitPrice"]; grdSaleList.Rows[iIndex].Cells["colQty"].Value = rowData["colQty"]; grdSaleList.Rows[iIndex].Cells["colDisCount"].Value = rowData["colDisCount"]; grdSaleList.Rows[iIndex].Cells["colTaxYn"].Value = rowData["colTaxYn"]; grdSaleList.Rows[iIndex].Cells["colPrice"].Value = rowData["colPrice"]; grdSaleList.Rows[iIndex].Cells["colRemarks"].Value = rowData["colRemarks"]; } ChangeButton("tran"); bRet = true; } } catch (Exception ex) { ClsLog.WriteLog(ClsLog.LOG_EXCEPTION, System.Reflection.MethodBase.GetCurrentMethod().Name, ex.Message); } return(bRet); }
/// <summary> /// 행 삭제 /// </summary> /// <returns></returns> private bool DeleteRow() { bool bRet = false; DataGridViewRow grdRow = null; int iCurrentRow = 0; try { if (grdSaleList.CurrentRow == null) { return(false); } iCurrentRow = grdSaleList.CurrentRow.Index; grdRow = grdSaleList.Rows[iCurrentRow]; grdSaleList.Rows.RemoveAt(iCurrentRow); if (grdSaleList.Rows.Count <= 0) { ChangeButton("sale"); } bRet = true; } catch (Exception ex) { ClsLog.WriteLog(ClsLog.LOG_EXCEPTION, System.Reflection.MethodBase.GetCurrentMethod().Name, ex.Message); } return(bRet); }
/// <summary> // 행업데이트 /// </summary> private bool UpdateRow() { bool bRet = false; int iUnitPrice = 0; int iPrice = 0; int iQty = 0; int iDisCount = 0; int iRowIndex = 0; try { if (checkRow(grdSaleList.CurrentRow) != true) { return(false); } iRowIndex = grdSaleList.CurrentRow.Index; iUnitPrice = int.Parse(grdSaleList.Rows[iRowIndex].Cells["colUnitPrice"].Value.ToString()); iQty = int.Parse(grdSaleList.Rows[iRowIndex].Cells["colQty"].Value.ToString()); iDisCount = int.Parse(grdSaleList.Rows[iRowIndex].Cells["colDisCount"].Value.ToString()); //iPrice = (iUnitPrice * iQty) - ((iUnitPrice * iQty) * iDisCount / 100 ); iPrice = (iUnitPrice * iQty) - (iDisCount * iQty); grdSaleList.Rows[iRowIndex].Cells["colPrice"].Value = iPrice; bRet = true; } catch (Exception ex) { ClsLog.WriteLog(ClsLog.LOG_EXCEPTION, System.Reflection.MethodBase.GetCurrentMethod().Name, ex.Message); } return(bRet); }
/// <summary> /// 합계업데이트 /// </summary> /// <returns></returns> private bool UpdateTotal() { bool bRet = false; int iSubTotal = 0; int iDisCount = 0; int iTotal = 0; try { foreach (DataGridViewRow grdRow in grdSaleList.Rows) { iSubTotal += int.Parse(grdRow.Cells["colUnitPrice"].Value.ToString()) * int.Parse(grdRow.Cells["colQty"].Value.ToString()); iTotal += int.Parse(grdRow.Cells["colPrice"].Value.ToString()); } iDisCount = iSubTotal - iTotal; txtSubTotal.Text = String.Format("{0:#,###}", iSubTotal); txtDisCount.Text = String.Format("{0:#,###}", iDisCount); txtTotal.Text = String.Format("{0:#,###}", iTotal); } catch (Exception ex) { ClsLog.WriteLog(ClsLog.LOG_EXCEPTION, System.Reflection.MethodBase.GetCurrentMethod().Name, ex.Message); } return(bRet); }
/// <summary> /// 할인변경 /// </summary> /// <param name="Discount"></param> /// <returns></returns> private bool ChangeDisCount() { bool bRet = false; int iDisCount = 0; string sValue = null; string sType = "persent"; int iUnitPrice = 0; int iTemp = 0; try { sValue = txtInput.Text; if (CheckInput("disCount", sValue) != true) { return(false); } if (sValue == "99") { sType = "value"; } switch (sType) { case "persent": iDisCount = int.Parse(sValue); iUnitPrice = int.Parse(grdSaleList.CurrentRow.Cells["colUnitPrice"].Value.ToString()); iTemp = (iUnitPrice * iDisCount / 100); grdSaleList.CurrentRow.Cells["colDisCount"].Value = iTemp; grdSaleList.CurrentRow.Cells["colRemarks"].Value = iDisCount + "% 할인"; txtInput.Clear(); bRet = true; break; case "value": FrmDisCount frmDisCount = new FrmDisCount(this); frmDisCount.Show(); bRet = true; break; default: break; } } catch (Exception ex) { ClsLog.WriteLog(ClsLog.LOG_EXCEPTION, System.Reflection.MethodBase.GetCurrentMethod().Name, ex.Message); } return(bRet); }
/// <summary> /// ESC 버튼 클릭 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnEsc_Click(object sender, EventArgs e) { try { } catch (Exception ex) { ClsLog.WriteLog(ClsLog.LOG_EXCEPTION, System.Reflection.MethodBase.GetCurrentMethod().Name, ex.Message); } }
/// <summary> /// 폼시작 이벤트 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void FrmLogin_Load(object sender, EventArgs e) { try { ClsDB.OpenDataBase(); } catch (Exception ex) { ClsLog.WriteLog(ClsLog.LOG_EXCEPTION, System.Reflection.MethodBase.GetCurrentMethod().Name, ex.Message); } }
/// <summary> /// 폼종료 이벤트 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void FrmSale_FormClosed(object sender, FormClosedEventArgs e) { try { ClsDB.CloseDataBase(); } catch (Exception ex) { ClsLog.WriteLog(ClsLog.LOG_EXCEPTION, System.Reflection.MethodBase.GetCurrentMethod().Name, ex.Message); } }
/// <summary> /// 등록버튼 클릭 이벤트 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnRegister_Click(object sender, EventArgs e) { try { this.Close(); }//end try catch (Exception ex) { ClsLog.WriteLog(ClsLog.LOG_EXCEPTION, System.Reflection.MethodBase.GetCurrentMethod().Name, ex.Message); }//end catch }
private void btnMain_Click(object sender, EventArgs e) { int iIndex = 0; try { iIndex = ((Button)sender).TabIndex; switch (iIndex) { case 1: //영업시작 StartSale(); break; case 2: //판매등록 RegisterSale(); break; case 3: //마감입금 break; case 4: //정산출력 break; case 5: //관리설정 break; case 6: //영업관리 break; case 7: //영업종료 CloseSale(); break; case 8: //종 료 ClosePos(); break; default: break; } } catch (Exception ex) { ClsLog.WriteLog(ClsLog.LOG_EXCEPTION, System.Reflection.MethodBase.GetCurrentMethod().Name, ex.Message); } }
/// <summary> /// 포커스 저장 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void txtFocus_Enter(object sender, EventArgs e) { try { ctrFocus = (Control)sender; } catch (Exception ex) { ClsLog.WriteLog(1, System.Reflection.MethodBase.GetCurrentMethod().Name, ex.Message); } }
/// <summary> /// 포트종료 /// </summary> public void ClosePort() { try { spPort.Close(); } catch (Exception ex) { ClsLog.WriteLog(ClsLog.LOG_EXCEPTION, System.Reflection.MethodBase.GetCurrentMethod().Name, ex.Message); } }
/// <summary> /// 데이터베이스 열기 /// </summary> public static void OpenDataBase() { try { sqlConn = new SqlConnection(sSource); sqlConn.Open(); } catch (Exception ex) { ClsLog.WriteLog(ClsLog.LOG_EXCEPTION, System.Reflection.MethodBase.GetCurrentMethod().Name, ex.Message); } }
/// <summary> /// 상품복원 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void RestoreGoods() { FrmRestore frmRestor = new FrmRestore(this); try { frmRestor.Show(); } catch (Exception ex) { ClsLog.WriteLog(ClsLog.LOG_EXCEPTION, System.Reflection.MethodBase.GetCurrentMethod().Name, ex.Message); } }
/// <summary> /// 고객정보 엔터 이벤트 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void txtInfo_KeyDown(object sender, KeyEventArgs e) { try { if (e.KeyCode == Keys.Return) { } } catch (Exception ex) { ClsLog.WriteLog(ClsLog.LOG_EXCEPTION, System.Reflection.MethodBase.GetCurrentMethod().Name, ex.Message); } }
/// <summary> /// 보류리스트 검색 /// </summary> /// <param name="sTranNo"></param> /// <returns></returns> public List <Dictionary <string, string> > SearchHold() { SqlDataReader sqlRead = null; List <Dictionary <string, string> > liRet = null; Dictionary <string, string> dicGoods = null; string sQuery = null; try { liRet = new List <Dictionary <string, string> >(); sQuery = "SELECT hdr.sal_date, " + "hdr.tot_amt AS sal_HoldPrice, " + "hdr.POS_NO, " + "hdr.STORE_NO, " + "hdr.TRAN_NO " + "FROM salhdr hdr " + "INNER JOIN saldtl dtl " + "ON(hdr.sal_date = dtl.sal_date " + "AND hdr.store_no = dtl.store_no " + "AND hdr.pos_no = dtl.pos_no " + "AND hdr.tran_no = dtl.tran_no) " + "WHERE hdr.tran_type = '02' " + "GROUP BY hdr.TRAN_TYPE, hdr.SAL_DATE, hdr.TOT_AMT, hdr.POS_NO, hdr.STORE_NO, hdr.TRAN_NO"; sqlRead = clsDb.GetData(sQuery); while (sqlRead.Read() == true) { dicGoods = new Dictionary <string, string>(); dicGoods["sal_date"] = sqlRead["sal_date"].ToString(); dicGoods["sal_price"] = sqlRead["sal_HoldPrice"].ToString(); dicGoods["STORE_NO"] = sqlRead["STORE_NO"].ToString(); dicGoods["POS_NO"] = sqlRead["POS_NO"].ToString(); dicGoods["TRAN_NO"] = sqlRead["TRAN_NO"].ToString(); liRet.Add(dicGoods); } } catch (Exception ex) { ClsLog.WriteLog(ClsLog.LOG_EXCEPTION, System.Reflection.MethodBase.GetCurrentMethod().Name, ex.Message); } finally { if (sqlRead.IsClosed != true) { sqlRead.Close(); } } return(liRet); }
/// <summary> /// 종료버튼 클릭 이벤트 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnClose_Click(object sender, EventArgs e) { try { if (MessageBox.Show("종료하시겠습니까?", "", MessageBoxButtons.YesNo) == DialogResult.Yes) { Application.Exit(); } } catch (Exception ex) { ClsLog.WriteLog(ClsLog.LOG_EXCEPTION, System.Reflection.MethodBase.GetCurrentMethod().Name, ex.Message); } }
/// <summary> /// 날짜 타이머 /// </summary> private void DateTimer() { try { Timer timer = new System.Windows.Forms.Timer(); timer.Interval = 1000; // 1초 timer.Tick += new EventHandler(GetCurrentDate); timer.Start(); } catch (Exception ex) { ClsLog.WriteLog(ClsLog.LOG_EXCEPTION, System.Reflection.MethodBase.GetCurrentMethod().Name, ex.Message); } }