Esempio n. 1
0
        /// <summary>
        /// The debug button click.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        private void DebugButtonClick(object sender, RoutedEventArgs e)
        {
            if (this.CurrentGoodsId == -1)
            {
                this.baskeеt.Add(this.piluleDataProvider.GetGood(this.OnBaskeеtChanged));
            }
            else
            {
                var goods = PiluleDal.GetGoodsDictionary(this.CurrentGoodsId);
                if (goods == null)
                {
                    return;
                }

                var basketData = new BaskeеtData(this.OnBaskeеtChanged)
                {
                    Id     = goods.Id,
                    Name   = goods.Name,
                    Amount = 1,
                    Price  = goods.Price
                };

                this.baskeеt.Add(basketData);
                this.DocVid.Content           = "Вид документа: продажа (открыт)";
                this.PaymentButton.IsEnabled  = true;
                this.PaymentButton.Background = new SolidColorBrush(Colors.DarkSeaGreen);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// The insert data button click.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        private async void InsertDataButtonClick(object sender, EventArgs e)
        {
            this.InsertDataButton.Enabled = false;
            this.ClearLog();
            var assemblyFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            if (string.IsNullOrEmpty(assemblyFolder))
            {
                this.OutLog("ExecutingAssembly not found");
                return;
            }

            var fileName = Path.Combine(assemblyFolder, "Docs", "ProductList.txt");
            var lines    = File.ReadAllLines(fileName);

            var goodsDictionaryList = new List <PiluleDal.GoodsDictionary>();
            var stockBalanceList    = new List <PiluleDal.StockBalance>();
            var rnd = new Random();

            foreach (var line in lines)
            {
                if (string.IsNullOrEmpty(line))
                {
                    continue;
                }

                var code        = $"{goodsDictionaryList.Count + 1:000000}";
                var price       = Convert.ToDecimal(rnd.Next(10000, 50000)) / 100;
                var splitResult = line.Split(new[] { ". " }, StringSplitOptions.None);
                PiluleDal.GoodsDictionary item = null;
                if (splitResult.Length == 1)
                {
                    item = new PiluleDal.GoodsDictionary {
                        Name = splitResult[0], Code = code, Comment = string.Empty, Price = price
                    };
                }

                if (splitResult.Length == 2)
                {
                    item = new PiluleDal.GoodsDictionary {
                        Name = splitResult[0], Code = code, Comment = splitResult[1], Price = price
                    };
                }

                if (item == null)
                {
                    continue;
                }

                goodsDictionaryList.Add(item);
                stockBalanceList.Add(new PiluleDal.StockBalance {
                    GoodsId = stockBalanceList.Count + 1, Amount = rnd.Next(0, 100)
                });
            }

            await PiluleDal.InsertGoodsDictionaryAsync(goodsDictionaryList, this.OutLog);

            await PiluleDal.InsertStockBalanceAsync(stockBalanceList, this.OutLog);
        }
Esempio n. 3
0
        /// <summary>
        /// The get multi mapping button click.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        private void GetMultiMappingButtonClick(object sender, EventArgs e)
        {
            var multiMapping = PiluleDal.MultiMapping();

            if (multiMapping == null)
            {
                return;
            }

            this.MainDataGridView.DataSource = multiMapping;
        }
Esempio n. 4
0
        /// <summary>
        /// The get stock balance button click.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        private void GetStockBalanceButtonClick(object sender, EventArgs e)
        {
            var stockBalance = PiluleDal.GetStockBalance();

            if (stockBalance == null)
            {
                return;
            }

            this.MainDataGridView.DataSource = stockBalance;
        }
Esempio n. 5
0
        /// <summary>
        /// The get goods dictionary button click.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        private void GetGoodsDictionaryButtonClick(object sender, EventArgs e)
        {
            var goodsDictionary = PiluleDal.GetGoodsDictionary();

            if (goodsDictionary == null)
            {
                return;
            }

            this.MainDataGridView.DataSource = goodsDictionary;
        }
Esempio n. 6
0
        /// <summary>
        /// The test storage proc button click.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        private void TestStorageProcButtonClick(object sender, EventArgs e)
        {
            int cnt;
            var goodsDictionary = PiluleDal.ExecuteStorageProc(13, out cnt);

            if (goodsDictionary == null)
            {
                return;
            }

            this.MainDataGridView.DataSource = goodsDictionary;
        }
Esempio n. 7
0
        /// <summary>
        /// The get debug value button click.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        private void GetDebugValueButtonClick(object sender, EventArgs e)
        {
            var debugValue = PiluleDal.GetDebugValue("GoodsDictionary");

            if (debugValue == null)
            {
                this.OutLog("NULL Value");
                return;
            }

            foreach (var items in debugValue)
            {
                foreach (var item in items)
                {
                    this.OutLog($"{item.Key}={item.Value} ");
                }
            }
        }
Esempio n. 8
0
 private void GoodsFilterTextChanged(object sender, TextChangedEventArgs e)
 {
     this.AddBaskedButton.IsEnabled  = false;
     this.AddBaskedButton.Background = new SolidColorBrush(Colors.Gainsboro);
     this.CurrentGoodsId             = -1;
     if (this.GoodsFilter.Text.Length > 2)
     {
         var template = this.GoodsFilter.Text;
         var item     = PiluleDal.GetFirstGoodsByTemplate(template);
         if (item == null)
         {
             return;
         }
         this.CurrentGoodsId             = item.Id;
         this.NameLabel.Content          = $"{item.Code} {item.Name} ({item.Comment})";
         this.AddBaskedButton.IsEnabled  = true;
         this.AddBaskedButton.Background = new SolidColorBrush(Colors.DarkSeaGreen);
     }
 }
Esempio n. 9
0
        /// <summary>
        /// The create db button click.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        private async void CreateDbButtonClick(object sender, EventArgs e)
        {
            this.CreateDbButton.Enabled = false;
            this.ClearLog();
            await PiluleDal.DropDataBaseAsync(this.OutLog);

            await PiluleDal.ExecuteScriptAsync("CreateDB", this.OutLog);

            await PiluleDal.ExecuteScriptAsync("CreateTable_Version", this.OutLog);

            await PiluleDal.ExecuteScriptAsync("CreateTable_GoodsDictionary", this.OutLog);

            await PiluleDal.ExecuteScriptAsync("CreateTable_StockBalance", this.OutLog);

            await PiluleDal.ExecuteScriptAsync("InsertVersion", this.OutLog);

            await PiluleDal.ExecuteScriptAsync("CreateTestStorageProc", this.OutLog);

            this.CreateDbButton.Enabled = true;
        }
Esempio n. 10
0
        /// <summary>
        /// The test button click.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        private void TestButtonClick(object sender, EventArgs e)
        {
            var x = PiluleDal.GetFirstGoodsByTemplate("Ай");

            this.OutLog(x.Name);
        }
Esempio n. 11
0
 /// <summary>
 /// The get version button click.
 /// </summary>
 /// <param name="sender">
 /// The sender.
 /// </param>
 /// <param name="e">
 /// The e.
 /// </param>
 private void GetVersionButtonClick(object sender, EventArgs e)
 {
     this.OutLog($"test ADO.NET   - {PiluleDal.CheckVersionAdoNet(VersionMarker)}");
     this.OutLog($"test DapperORM - {PiluleDal.CheckVersionDaperOrm(VersionMarker)}");
 }
Esempio n. 12
0
        private static void Main(string[] args)
        {
            // Console.WriteLine($"test ADO.NET   - {PiluleDal.CheckVersionAdoNet()}");
            // Console.WriteLine($"test DapperORM - {PiluleDal.CheckVersionDaperOrm()}");

            /*var debugValue = PiluleDal.GetDebugValue("GoodsDictionary");
             * if (debugValue != null)
             * {
             *  foreach (var items in debugValue) //foreach (ICollection<KeyValuePair<string, object>> items in debugValue)
             *  {
             *      foreach (var item in items)
             *      {
             *          Console.Write($"{item.Key}={item.Value} ");
             *      }
             *      Console.WriteLine();
             *  }
             * }*/

            // var result = PiluleDal.ExecuteNonSelectCommand();

            /*Console.WriteLine(PiluleDal.DropDataBase());
             * Console.WriteLine(PiluleDal.ExecuteScript("CreateDB"));
             * Console.WriteLine(PiluleDal.ExecuteScript("CreateTable_Version"));
             * Console.WriteLine(PiluleDal.ExecuteScript("CreateTable_GoodsDictionary"));
             * Console.WriteLine(PiluleDal.ExecuteScript("CreateTable_StockBalance"));
             * Console.WriteLine(PiluleDal.InsertDataExecute("DupelData"));
             *
             * Console.WriteLine(
             *  PiluleDal.InsertDataExecuteBulk(
             *      new List<PiluleDal.GoodsDictionary>
             *          {
             *              new PiluleDal.GoodsDictionary { Name = "xxx", Price = 25, Comment = "nop" }
             *          }));*/


            int cnt;
            var goodsDictionary = PiluleDal.ExecuteStorageProc(out cnt);

            goodsDictionary?.ToList().ForEach(Console.WriteLine);
            Console.WriteLine(cnt);

            /*goodsDictionary = PiluleDal.GetGoodsDictionary(3);
             * goodsDictionary?.ToList().ForEach(Console.WriteLine);*/

            //var goodsDictionary = PiluleDal.GetGoodsDictionary(new List<int> { 1, 3 });
            //goodsDictionary?.ToList().ForEach(Console.WriteLine);

            //var tuple = PiluleDal.MultiSelect();
            //tuple?.Item1?.ToList().ForEach(Console.WriteLine);
            //tuple?.Item2?.ToList().ForEach(Console.WriteLine);

            //var result = PiluleDal.MultiMapping();
            //result?.ToList().ForEach(Console.WriteLine);

            /*var mmf = MemoryMappedFile.CreateNew("MyFileInFile", 1);
             * using (var writer = mmf.CreateViewAccessor(0, 1))
             * {
             *  byte msg = 25;
             *  writer.Write(0, msg);
             * }
             *
             * var mmf1 = MemoryMappedFile.OpenExisting("MyFileInFile");
             * using (var reader = mmf1.CreateViewAccessor(0, 1, MemoryMappedFileAccess.Read))
             * {
             *  var msg = reader.ReadByte(0);
             *  Console.WriteLine(msg);
             * }*/

            Console.ReadKey();
        }