Beispiel #1
0
 /// <summary>
 /// Нажатие на кнопку добавить.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void addButton_Click(object sender, EventArgs e)
 {
     try
     {
         var selectedNode = storageTree.SelectedNode;
         if (selectedNode != null)
         {
             var pcv = new ProductCardView();
             pcv.ShowDialog();
             Product pr = pcv.Result;
             if (pr == null)
             {
                 return;
             }
             var array = pr.GetArray();
             var row   = new ProductRow();
             row.Product = pr;
             row.CreateCells(dataGrid);
             for (int j = 0; j < array.Length; ++j)
             {
                 row.Cells[j].Value = array[j];
             }
             dataGrid.Rows.Add(row);
             Storage.Products.Add(pr);
             ((StorageNode)selectedNode).Cathegory.Products.Add(pr);
             SuperSmartCsvManager.WriteToCsv((StorageNode)selectedNode);
         }
     }
     catch
     {
     }
 }
Beispiel #2
0
        /// <summary>
        /// Дабл клик по тривью.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void storageTree_DoubleClick(object sender, EventArgs e)
        {
            var selectedNode = storageTree.SelectedNode;

            if (selectedNode != null)
            {
                dataGrid.Rows.Clear();
                var products = ((StorageNode)selectedNode).Cathegory.Products;

                for (int i = 0; i < products.Count(); ++i)
                {
                    var row   = new ProductRow();
                    var array = products[i].GetArray();
                    row.CreateCells(dataGrid);
                    for (int j = 0; j < array.Length; ++j)
                    {
                        row.Cells[j].Value = array[j];
                    }
                    row.Product = products[i];
                    dataGrid.Rows.Add(row);
                }
            }
        }