Пример #1
0
 public override bool AddReceipt(Receipt parReceipt)
 {
     using (var DB = new SQLite(ReceiptFile))
     {
         return(DB.ExecuteNonQuery <Receipt>(SqlAddReceipt, parReceipt) > 0);
     }
 }
Пример #2
0
 public override bool InsertAddWeight(AddWeight parAddWeight)
 {
     using (var DB = new SQLite(ConfigFile))
     {
         return(DB.ExecuteNonQuery <AddWeight>(SqlInsertAddWeight, parAddWeight) > 0);
     }
 }
Пример #3
0
 public override bool DeleteReceiptWares(ReceiptWares parIdReceiptWares)
 {
     using (var DB = new SQLite(ReceiptFile))
     {
         return(DB.ExecuteNonQuery <IdReceiptWares>(SqlDeleteReceiptWares, parIdReceiptWares) > 0 /*&& RecalcHeadReceipt(parParameters)*/);
     }
 }
Пример #4
0
 public override bool FixWeight(ReceiptWares parIdReceipt)
 {
     using (var DB = new SQLite(ReceiptFile))
     {
         return(DB.ExecuteNonQuery <ReceiptWares>(SqlSetFixWeight, parIdReceipt) > 0);
     }
 }
Пример #5
0
 public override bool SetRefundedQuantity(ReceiptWares parReceiptWares)
 {
     using (var DB = new SQLite(ReceiptFile))
     {
         return(DB.ExecuteNonQuery <ReceiptWares>(SqlSetRefundedQuantity, parReceiptWares) > 0);
     }
 }
Пример #6
0
 public override bool DeleteReceiptEvent(IdReceipt parIdReceipt)
 {
     using (var DB = new SQLite(ReceiptFile))
     {
         return(DB.ExecuteNonQuery <IdReceipt>(SqlDeleteReceiptEvent, parIdReceipt) > 0);
     }
 }
Пример #7
0
 public override bool RecalcHeadReceipt(IdReceipt parReceipt)
 {
     using (var DB = new SQLite(ReceiptFile))
     {
         return(DB.ExecuteNonQuery <IdReceipt>(this.SqlRecalcHeadReceipt, parReceipt) > 0);
     }
 }
Пример #8
0
 public override bool InsertWeight(Object parWeight)
 {
     using (var DB = new SQLite(ConfigFile))
     {
         return(DB.ExecuteNonQuery <Object>(SqlInsertWeight, parWeight) > 0);
     }
 }
Пример #9
0
 public override bool InsertLogRRO(LogRRO pLog)
 {
     using (var DB = new SQLite(ReceiptFile))
     {
         return(DB.ExecuteNonQuery <LogRRO>(SqlInsertLogRRO, pLog) > 0);
     }
 }
Пример #10
0
 public override bool ReplaceWaresReceipt(ReceiptWares parReceiptWares)
 {
     using (var DB = new SQLite(ReceiptFile))
     {
         return(DB.ExecuteNonQuery <ReceiptWares>(SqlReplaceWaresReceipt, parReceiptWares) > 0);
     }
 }
Пример #11
0
 /// <summary>
 /// Повертає фактичну кількість після вставки(добавляє до текучої кількості - -1 якщо помилка;
 /// </summary>
 /// <param name="parParameters"></param>
 /// <returns></returns>
 public override bool AddWares(ReceiptWares parReceiptWares)
 {
     using (var DB = new SQLite(ReceiptFile))
     {
         return(DB.ExecuteNonQuery <ReceiptWares>(SqlInsertWaresReceipt, parReceiptWares) > 0 /*&& RecalcHeadReceipt((IdReceipt)parReceiptWares)*/);
     }
 }
Пример #12
0
 public override bool DeleteWaresReceiptPromotion(IdReceipt parIdReceipt)
 {
     using (var DB = new SQLite(ReceiptFile))
     {
         DB.ExecuteNonQuery <IdReceipt>(SqlDeleteWaresReceiptPromotion, parIdReceipt);
     }
     return(true);
 }
Пример #13
0
 public override bool InsertBarCode2Cat(WaresReceiptPromotion parWRP)
 {
     using (var DB = new SQLite(ReceiptFile))
     {
         DB.ExecuteNonQuery <WaresReceiptPromotion>(SqlInsertBarCode2Cat, parWRP);
     }
     return(true);
 }
Пример #14
0
 public override bool SetStateReceipt(Receipt parReceipt)
 {
     using (var DB = new SQLite(ReceiptFile))
     {
         DB.ExecuteNonQuery <Receipt>(SqlSetStateReceipt, parReceipt);
     }
     return(true);
 }
Пример #15
0
 public override bool UpdateQR(ReceiptWares pRW)
 {
     using (var DB = new SQLite(ReceiptFile))
     {
         return(DB.ExecuteNonQuery <ReceiptWares>(SqlUpdateQR, pRW) > 0);
     }
     //return true;
 }
Пример #16
0
 public override bool MoveReceipt(ParamMoveReceipt parMoveReceipt)
 {
     using (var DB = new SQLite(ReceiptFile))
     {
         DB.ExecuteNonQuery <ParamMoveReceipt>(SqlMoveReceipt, parMoveReceipt);
     }
     return(true);
 }
Пример #17
0
 public bool CreateMIDIndex()
 {
     using (var DB = new SQLite(MidFile))
     {
         DB.ExecuteNonQuery(SqlCreateMIDIndex);
     }
     return(true);
 }
Пример #18
0
 public override bool UpdateQuantityWares(ReceiptWares parReceiptWares)
 {
     using (var DB = new SQLite(ReceiptFile))
     {
         lock (GetObjectForLockByIdWorkplace(parReceiptWares.IdWorkplace))
         {
             return(DB.ExecuteNonQuery(SqlUpdateQuantityWares, parReceiptWares) > 0 /*&& RecalcHeadReceipt(parParameters)*/);
         }
     }
 }
Пример #19
0
 public override bool CloseReceipt(Receipt parReceipt)
 {
     using (var DB = new SQLite(ReceiptFile))
     {
         lock (GetObjectForLockByIdWorkplace(parReceipt.IdWorkplace))
         {
             return(DB.ExecuteNonQuery <Receipt>(SqlCloseReceipt, parReceipt) > 0);
         }
     }
 }
Пример #20
0
 public override bool UpdateClient(IdReceipt parIdReceipt, int parCodeClient)
 {
     using (var DB = new SQLite(ReceiptFile))
     {
         lock (GetObjectForLockByIdWorkplace(parIdReceipt.IdWorkplace))
         {
             return(DB.ExecuteNonQuery <IdReceipt>(SqlUpdateClient, parIdReceipt) > 0);
         }
     }
 }
Пример #21
0
        ///////////////////////////////////////////////////////////////////
        /// Переробляю через відкриття закриття конекта.
        ///////////////////////////////////////////////////////////////////
        ///

        ///////////////// Config

        public override bool SetConfig <T>(string parName, T parValue, SQL pDB = null)
        {
            using (var DB = new SQLite(ConfigFile))
            {
                if (pDB == null)
                {
                    DB.ExecuteNonQuery <object>(this.SqlReplaceConfig, new { NameVar = parName, DataVar = parValue, @TypeVar = parValue.GetType().ToString() });
                }
                else
                {
                    pDB.ExecuteNonQuery <object>(this.SqlReplaceConfig, new { NameVar = parName, DataVar = parValue, @TypeVar = parValue.GetType().ToString() });
                }
            }
            return(true);
        }
Пример #22
0
 public override bool ReplacePayment(IEnumerable <Payment> parData)
 {
     using (var DB = new SQLite(ReceiptFile))
     {
         if (parData != null && parData.Count() > 0)
         {
             if (parData.Count() == 1)//Костиль через проблеми з мультипоточністю BD
             {
                 DB.ExecuteNonQuery <Payment>(SqlReplacePayment, parData.First());
             }
             else
             {
                 DB.BulkExecuteNonQuery <Payment>(SqlReplacePayment, parData);
             }
         }
     }
     return(true);
 }
Пример #23
0
        protected (int, bool) Parse(string[] pLines, int pCurVersion, SQLite pDB)
        {
            int  NewVer = pCurVersion, Ver;
            bool isReload = false;

            foreach (var el in pLines)
            {
                var i = el.IndexOf("VER=>");
                if (i >= 0)
                {
                    string   str = el.Substring(i + 5);
                    string[] All = str.Split(';');
                    if (int.TryParse(All[0], out Ver))
                    {
                        if (Ver > pCurVersion)
                        {
                            try
                            {
                                pDB.ExecuteNonQuery(el);
                                if (All.Length > 1 && All[1].Equals("Reload".ToUpper()))
                                {
                                    isReload = true;
                                }
                            }
                            catch (Exception e)
                            {
                                if (e.Message.IndexOf("duplicate column name:") == -1)
                                {
                                    throw new Exception(e.Message, e);
                                }
                            }
                        }

                        if (NewVer <= Ver)
                        {
                            NewVer = Ver;
                        }
                    }
                }
            }

            return(NewVer, isReload);
        }
Пример #24
0
        public WDB_SQLite(DateTime parD = default(DateTime), string parConnect = "", bool pIsUseOldDB = false)  : base(Path.Combine(Global.PathIni, "SQLite.sql"))
        {
            Connect    = parConnect;
            varVersion = "SQLite.0.0.1";
            DT         = parD != default(DateTime) ? parD.Date : DateTime.Today.Date;
            InitSQL();


            if (IsFirstStart)
            {
                UpdateDB(ref pIsUseOldDB);
            }


            if (!File.Exists(ConfigFile))
            {
                db = new SQLite(ConfigFile);
                db.ExecuteNonQuery(SqlCreateConfigTable);
                db.Close();
            }
            //db = new SQLite(ConfigFile);//,"",this.varCallWriteLogSQL);


            if (!File.Exists(ReceiptFile))
            {
                var receiptFilePath = Path.GetDirectoryName(ReceiptFile);
                if (!Directory.Exists(receiptFilePath))
                {
                    Directory.CreateDirectory(receiptFilePath);
                }
                //Створюємо щоденну табличку з чеками.
                var db = new SQLite(ReceiptFile);
                db.ExecuteNonQuery(SqlCreateReceiptTable);
                db.Close();
                db = null;
            }


            if (!File.Exists(MidFile))
            {
                if (pIsUseOldDB)
                {
                    db = new SQLite(ConfigFile);
                    var varLastMidFile = GetConfig <string>("Last_MID");
                    db = null;
                    if (!string.IsNullOrEmpty(varLastMidFile) && File.Exists(varLastMidFile))
                    {
                        LastMidFile = varLastMidFile;
                    }
                }
                if (!pIsUseOldDB || string.IsNullOrEmpty(LastMidFile))
                {
                    var db = new SQLite(MidFile);
                    db.ExecuteNonQuery(SqlCreateMIDTable);
                    db.Close();
                    db = null;
                }
            }

            /*
             * if (pTypeDb == eTypeDb.AllMid || pTypeDb == eTypeDb.AllRC)
             * {
             *  if (pTypeDb == eTypeDb.AllMid)
             *  {
             *      db = new SQLite(MidFile);
             *      db.ExecuteNonQuery("ATTACH '" + ReceiptFile + "' AS rc");
             *  }
             *  else
             *  {
             *      db = new SQLite(ReceiptFile);
             *      db.ExecuteNonQuery("ATTACH '" + MidFile + "' AS mid");
             *      //db.ExecuteNonQuery("ATTACH '" + ConfigFile + "' AS con");
             *  }
             *  db.ExecuteNonQuery("ATTACH '" + ConfigFile + "' AS con");
             * }
             *
             * if(pTypeDb == eTypeDb.Mid)
             *  db = new SQLite(MidFile);
             *
             * if(pTypeDb == eTypeDb.RC)
             *  db = new SQLite(ReceiptFile);
             *
             * if (pTypeDb == eTypeDb.Config)
             *  db = new SQLite(ConfigFile);
             */

            db = new SQLite(ReceiptFile);
            db.ExecuteNonQuery("ATTACH '" + MidFile + "' AS mid");
            db.ExecuteNonQuery("ATTACH '" + ConfigFile + "' AS con");

            db.ExecuteNonQuery("PRAGMA synchronous = EXTRA;");
            db.ExecuteNonQuery("PRAGMA journal_mode = DELETE;");
            db.ExecuteNonQuery("PRAGMA wal_autocheckpoint = 5;");
        }