/// <summary> /// TR만들고 보냄 /// Journal저장 /// </summary> /// <param name="signOn"></param> /// <param name="casNo"></param> /// <param name="casName"></param> /// <param name="printJournal">저널저장여부</param> BasketHeader MakeTrans(bool signOn, string casNo, string casName) { BasketHeader header = new BasketHeader() { CasNo = casNo, CasName = casName, TrxnType = signOn ? NetCommConstants.TRXN_TYPE_SIGNON : NetCommConstants.TRXN_TYPE_SIGNOFF, CancType = "0" }; TranDbHelper db = null; SQLiteTransaction trans = null; try { db = TranDbHelper.InitInstance(); trans = db.BeginTransaction(); TransManager.SaveTrans(header, null, db, trans); trans.Commit(); TransManager.OnTransComplete(); } catch (Exception ex) { if (trans != null) { trans.Rollback(); } LogUtils.Instance.LogException(ex); } finally { trans.Dispose(); db.Dispose(); } return(header); }
/// <summary> /// Db접속예제 /// </summary> public void SQLiteAccess() { /// /// method 1 /// Transaction 처리 안함 /// using (var db = TranDbHelper.InitInstance()) { string queryString = Extensions.LoadSqlCommand("FileName", "CommandName"); db.ExecuteNonQuery(queryString, new string[] { "@CD_STORE" }, new object[] { ConfigData.Current.AppConfig.PosInfo.StoreNo }); } /// /// method 2 /// Transacition 사용 /// TranDbHelper tranDb = null; SQLiteTransaction trans = null; try { tranDb = TranDbHelper.InitInstance(); trans = tranDb.BeginTransaction(); BasketHeader header = new BasketHeader(); #region Basket header // header.TxBufVer... #endregion #region Basket details // 준비금 BasketPay prepareAmt = new BasketPay(); prepareAmt.BalAmt = "112121"; #endregion // SAT010T, SAT011T저장 TransManager.SaveTrans(header, new BasketBase[] { prepareAmt }, tranDb, trans); #region Summary table 처리, SAT300T... // get query string from file string queryString = Extensions.LoadSqlCommand("FileName", "CommandName"); tranDb.ExecuteNonQuery(queryString, new string[] { "@CD_STORE" }, new object[] { ConfigData.Current.AppConfig.PosInfo.StoreNo }, trans); // transaction 개체준다 #endregion trans.Commit(); // TR 완료시 TransManager.OnTransComplete(); } catch (Exception ex) { trans.Rollback(); LogUtils.Instance.LogException(ex); } finally { if (tranDb != null) { tranDb.Dispose(); } } }