/// <summary> /// 매출 SAT010T, SAT011T저장 공통함수 /// </summary> /// <param name="header"></param> /// <param name="details"></param> /// <param name="trans"></param> public static void SaveTrans(BasketHeader header, BasketBase[] details, TranDbHelper db, SQLiteTransaction trans) { string queryStringSAT010T = Extensions.LoadSqlCommand("TransManager", "SaveTrans"); string queryStringSAT011T = Extensions.LoadSqlCommand("TransManager", "SaveTransState"); // buffer sequence int sqTrxn = 0; #region SAT010T - Header // save to SAT010T // add header db.ExecuteNonQuery(queryStringSAT010T, new string[] { "@DD_SALE", "@CD_STORE", "@NO_POS", "@NO_TRXN", "@SQ_TRXN", "@VC_CONT", "@ID_USER", "@SQ_SHIFT" }, new object[] { ConfigData.Current.AppConfig.PosInfo.SaleDate, ConfigData.Current.AppConfig.PosInfo.StoreNo, ConfigData.Current.AppConfig.PosInfo.PosNo, ConfigData.Current.AppConfig.PosInfo.TrxnNo, sqTrxn.ToString().ToString(3, TypeProperties.Number), header.ToString(), ConfigData.Current.AppConfig.PosInfo.CasNo, ConfigData.Current.AppConfig.PosInfo.ShiftCount }, trans); sqTrxn++; #endregion #region 상세내역, BasketBase list if (details != null) { for (int i = 0; i < details.Length; i++) { db.ExecuteNonQuery(queryStringSAT010T, new string[] { "@DD_SALE", "@CD_STORE", "@NO_POS", "@NO_TRXN", "@SQ_TRXN", "@VC_CONT", "@ID_USER", "@SQ_SHIFT" }, new object[] { ConfigData.Current.AppConfig.PosInfo.SaleDate, ConfigData.Current.AppConfig.PosInfo.StoreNo, ConfigData.Current.AppConfig.PosInfo.PosNo, ConfigData.Current.AppConfig.PosInfo.TrxnNo, sqTrxn.ToString().ToString(3, TypeProperties.Number), details[i].ToString(), ConfigData.Current.AppConfig.PosInfo.CasNo, ConfigData.Current.AppConfig.PosInfo.ShiftCount }, trans); sqTrxn++; } } #endregion #region Basket end db.ExecuteNonQuery(queryStringSAT010T, new string[] { "@DD_SALE", "@CD_STORE", "@NO_POS", "@NO_TRXN", "@SQ_TRXN", "@VC_CONT", "@ID_USER", "@SQ_SHIFT" }, new object[] { ConfigData.Current.AppConfig.PosInfo.SaleDate, ConfigData.Current.AppConfig.PosInfo.StoreNo, ConfigData.Current.AppConfig.PosInfo.PosNo, ConfigData.Current.AppConfig.PosInfo.TrxnNo, sqTrxn.ToString().ToString(3, TypeProperties.Number), new BasketEnd().ToString(), ConfigData.Current.AppConfig.PosInfo.CasNo, ConfigData.Current.AppConfig.PosInfo.ShiftCount }, trans); #endregion #region SAT011T db.ExecuteNonQuery(queryStringSAT011T, new string[] { "@DD_SALE", "@CD_STORE", "@NO_POS", "@NO_TRXN", "@FG_TRXN", "@FG_CANC", "@ID_USER", "@DD_TIME" }, new object[] { ConfigData.Current.AppConfig.PosInfo.SaleDate, ConfigData.Current.AppConfig.PosInfo.StoreNo, ConfigData.Current.AppConfig.PosInfo.PosNo, ConfigData.Current.AppConfig.PosInfo.TrxnNo, header.TrxnType, header.CancType, ConfigData.Current.AppConfig.PosInfo.CasNo, DateTimeUtils.GetYearMonthDayTimeString(DateTime.Now), }, trans); #endregion }
/// <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(); } } }