Example #1
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="parentForm"> A reference to the parent form</param>
        /// <param name="salesManagementDataModel">A reference to the sales management data model</param>
        /// <param name="selectedTabIndex">Index of the tab to initialize the form with</param>
        public frmSalesManagement(
            frmProductsOverview parentForm, SalesManagement salesManagement, int selectedTabIndex)
        {
            using (var context = new ArrboraDatabase())
            {
                var data = context.SalesManagements.ToList();
                var selectedSalesManagement = data.Where(p => p.SalesManagementID == salesManagement.SalesManagementID).First();
            }
            using (var context1 = new ArrboraDatabase())
            {
                var s = context1.Payments.ToList();
                var y = context1.SellingPrices.ToList();
            }
            _dbContext = new ArrboraDatabase();
            InitializeComponent();
            _salesManagement = _dbContext.SalesManagements.Where(
                p => p.SalesManagementID == salesManagement.SalesManagementID).First();
            _paymentUnits = _dbContext.PaymentUnits.Where(
                p => p.PaymentID == salesManagement.PaymentID).ToList();

            _parentForm = parentForm;

            //UpdateDataModels();
            UpdateSalesManagementForm(DataState.WriteToUI);

            saleManagementTabControl.SelectedIndex = selectedTabIndex;
        }
Example #2
0
 private void addProductOverviewToolStripMenuItem_Click(object sender, EventArgs e)
 {
     using (var context = new ArrboraDatabase())
     {
         var data = context.ProductOverviews.ToList();
         LoadDataGridView(data);
     }
 }
Example #3
0
        private void cmbBrand_SelectedValueChanged(object sender, EventArgs e)
        {
            var selectedBrand = (string)cmbBrand.SelectedValue;

            using (var context = new ArrboraDatabase())
            {
                var data = context.ProductOverviews.ToList();
                UpdateModelCombo(data, (string)cmbBrand.SelectedValue);
            }
        }
Example #4
0
 /// <summary>
 /// Load data into the Grid view
 /// </summary>
 /// <param name="data"></param>
 public void UpdateDataGridView()
 {
     using (var context = new ArrboraDatabase())
     {
         var data = context.ProductOverviews.ToList();
         UpdateBrandCombo(data);
         UpdateModelCombo(data, "");
         // Data grid view column setting
         dataGridViewProductOverview.DataSource = data;
         dataGridViewProductOverview.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
     }
 }
Example #5
0
 private void btnReset_Click(object sender, EventArgs e)
 {
     dtmDateFrom.Checked = false;
     dtmDateTo.Checked   = false;
     cmbPriceFrom.ResetText();
     cmbPriceTo.ResetText();
     using (var context = new ArrboraDatabase())
     {
         var data = context.ProductOverviews.ToList();
         UpdateDataGridView();
         UpdateBrandCombo(data);
         UpdateModelCombo(data, "");
     }
 }
Example #6
0
 private List <ProductOverview> SearchProductOverview(string brand, string model,
                                                      DateTime minDate, DateTime maxDate, long priceFrom, long priceTo)
 {
     using (var context = new ArrboraDatabase())
     {
         var data = context.ProductOverviews.ToList();
         return((from product in data
                 where ((brand == "" || product.Brand == brand) &&
                        (model == "" || product.Model == model) &&
                        product.DateOfPurchase > minDate &&
                        product.DateOfPurchase < maxDate &&
                        (priceFrom == 0 || product.TotalPurchase > priceFrom) &&
                        (priceTo == 0 || product.TotalPurchase < priceTo))
                 select product).ToList());
     }
 }
Example #7
0
        /// <summary>
        /// Constructor
        /// </summary>
        public frmProductsOverview()
        {
            InitializeComponent();
            _dbInstance = new ArrboraDatabase();
            //InsertData();

            InitializeDataGridViewStyle();
            InitializeColumsToTabsMapping();

            _dataGridControlSizeReduced = true;


            UpdateDataGridView();
            LoadPriceCombo();

            Show();
        }
Example #8
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();
            }
        }