Ejemplo n.º 1
0
        private void productOverviewContextMenuStrip_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            // if (_selectedRowID == -1) return;
            if (dataGridViewProductOverview.CurrentCell == null)
            {
                return;
            }
            _selectedRowID      = (int)dataGridViewProductOverview.CurrentCell.OwningRow.Cells["SalesManagementID"].Value;
            _selectedColumnName = dataGridViewProductOverview.CurrentCell.OwningColumn.HeaderText;
            var salesManagementDataRow   = _salesManagementService.GetSalesManagementById(_selectedRowID);
            var salesManagementDataModel = _salesManagementService.ConvertToDataModel(salesManagementDataRow);

            switch (e.ClickedItem.Name)
            {
            case "addProductOverviewToolStripMenuItem":
                var salesManagementID = _salesManagementService.AddEmptySalesManagement();
                UpdateDataGridView();
                break;

            case "editProductOverviewToolStripMenuItem":
                var activeTab          = _columnNameToTabIndex[_selectedColumnName];
                var frmSalesManagement = new frmSalesManagement(this, salesManagementDataModel, activeTab);
                frmSalesManagement.Show();
                break;

            case "deleteProductOverviewToolStripMenuItem":
                _salesManagementService.DeleteSalesManagementByID(_selectedRowID);
                UpdateDataGridView();
                break;
            }
        }
Ejemplo n.º 2
0
        private void productOverviewContextMenuStrip_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            if (dataGridViewProductOverview.CurrentCell == null)
            {
                return;
            }
            var             salesManagementID  = (long)dataGridViewProductOverview.CurrentCell.OwningRow.Cells["SalesManagementID"].Value;
            var             selectedColumnName = dataGridViewProductOverview.CurrentCell.OwningColumn.HeaderText;
            SalesManagement selectedSalesManagement;
            //using (var context = new ArrboraDatabase())
            //{
            //    var data = context.SalesManagements.ToList();
            //    //LoadDataGridView(data);
            //    selectedSalesManagement = data.Where(p => p.SalesManagementID == salesManagementID).First();
            //}

            var data = _dbInstance.SalesManagements.ToList();

            selectedSalesManagement = data.Where(p => p.SalesManagementID == salesManagementID).First();
            frmSalesManagement frmSalesManagement;

            switch (e.ClickedItem.Name)
            {
            case "addProductOverviewToolStripMenuItem":
                var newSalesManagement = new SalesManagement()
                {
                    Product         = new Product(),
                    Payment         = new Payment(),
                    ProductDelivery = new ProductDelivery(),
                    PurchasePrice   = new PurchasePrice(),
                    SellingPrice    = new SellingPrice()
                };
                newSalesManagement.Payment.PaymentUnits.Add(new PaymentUnit());
                frmSalesManagement = new frmSalesManagement(this, newSalesManagement, 0);
                frmSalesManagement.Show();
                UpdateDataGridView();
                break;

            case "editProductOverviewToolStripMenuItem":
                var activeTab = _columnNameToTabIndex[selectedColumnName];
                frmSalesManagement = new frmSalesManagement(this, selectedSalesManagement, activeTab);
                frmSalesManagement.Show();
                break;

            case "deleteProductOverviewToolStripMenuItem":
                // _salesManagementService.DeleteSalesManagementByID(_selectedRowID);
                UpdateDataGridView();
                break;
            }
        }
Ejemplo n.º 3
0
        private void dataGridViewProductOverview_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex == -1 || e.ColumnIndex == -1)
            {
                return;
            }
            var selectedColumn = _dataGridTable.Columns[e.ColumnIndex].ColumnName;
            var activeTab      = _columnNameToTabIndex[selectedColumn];

            _selectedRowID
                = (int)dataGridViewProductOverview.Rows[e.RowIndex].Cells["SalesManagementID"].Value;
            var selectedSalesManagement = _salesManagementService.GetSalesManagementById(_selectedRowID);

            var salesManagementDataModel = _salesManagementService.ConvertToDataModel(selectedSalesManagement);
            var frmSalesManagement       = new frmSalesManagement(this, salesManagementDataModel, activeTab);

            frmSalesManagement.Show();
        }
Ejemplo n.º 4
0
        private void dataGridViewProductOverview_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex == -1 || e.ColumnIndex == -1)
            {
                return;
            }
            var selectedColumn = dataGridViewProductOverview.Columns[e.ColumnIndex].DataPropertyName;
            var activeTab      = _columnNameToTabIndex[selectedColumn];

            var salesManagementID
                = (int)dataGridViewProductOverview.Rows[e.RowIndex].Cells["SalesManagementID"].Value;

            using (var context = new ArrboraDatabase())
            {
                var data = context.SalesManagements.ToList();
                //LoadDataGridView(data);
                var selectedSalesManagement = data.Where(p => p.SalesManagementID == salesManagementID).First();

                //var salesManagementDataModel = _salesManagementService.ConvertToDataModel(selectedSalesManagement);
                var frmSalesManagement = new frmSalesManagement(this, selectedSalesManagement, activeTab);
                frmSalesManagement.Show();
            }
        }