コード例 #1
0
 public InventoryEditController(InventoryEdit screen, ProductModel product, InventoryScreen inventoryScreen)
 {
     _dbc = DatabaseController.Instance;
     this._product = product;
     this._screen = screen;
     this._inventoryScreen = inventoryScreen;
     FillWithProductInfo();
 }
コード例 #2
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            // when an cell is clicked                                                      ///there is not supposed to be any logic in a view
            var senderGrid = (DataGridView)sender;

            // if the clicked cell is an column, and the row is not the header
            if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn && e.RowIndex >= 0)
            {
                // if thecolumnindex is 11 opens the edit screen
                if (e.ColumnIndex == 10)
                {
                    int             selectedrowindex = dataGridView1.SelectedCells[0].RowIndex;
                    DataGridViewRow selectedRow      = dataGridView1.Rows[selectedrowindex];

                    string currentProductId = Convert.ToString(selectedRow.Cells["nr"].Value);
                    int    currentProduct   = Int32.Parse(currentProductId);

                    ////test
                    //MessageBox.Show(currentProductId);


                    // linq select product with the current ID
                    var selectedproduct1 = ProductModel.List
                                           .Where(t => t.ProductId == currentProduct)
                                           .Select(t => t)
                                           .ToList();


                    // run edit screen here
                    // make an editscreen with current product as argument
                    InventoryEdit edit = new InventoryEdit(selectedproduct1[0], this);
                    edit.ShowDialog();
                    this.Refresh();
                }
            }
        }
コード例 #3
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {                                   
            // when an cell is clicked                                                      ///there is not supposed to be any logic in a view
            var senderGrid = (DataGridView)sender;

            // if the clicked cell is an column, and the row is not the header
            if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn && e.RowIndex >= 0) {

                // if thecolumnindex is 11 opens the edit screen
                if (e.ColumnIndex == 10)
                {

                    int selectedrowindex = dataGridView1.SelectedCells[0].RowIndex;
                    DataGridViewRow selectedRow = dataGridView1.Rows[selectedrowindex];

                    string currentProductId = Convert.ToString(selectedRow.Cells["nr"].Value);
                    int currentProduct = Int32.Parse(currentProductId);
                   
                    ////test
                    //MessageBox.Show(currentProductId);

 
                    // linq select product with the current ID
                    var selectedproduct1 = ProductModel.List
                            .Where(t => t.ProductId == currentProduct)
                            .Select(t => t)
                            .ToList();


                    // run edit screen here
                    // make an editscreen with current product as argument
                    InventoryEdit edit = new InventoryEdit(selectedproduct1[0], this);
                    edit.ShowDialog();
                    this.Refresh();
                }
            }
                  
        }