Exemplo n.º 1
0
        /// <summary>
        /// TODO  use PartID and DTO to hydrate the control
        /// </summary>
        /// <param name="part"></param>
        /// <param name="ctx"></param>
        public PartView(Part part, BadgerDataModel ctx)
        {
            InitializeComponent();
            _context = ctx;
            ISuppliersService var = new SuppliersService(_context);

            inventoryService = new InventoryService(_context);
            partsService     = new PartsService(_context);
            this.dataGridView1.AutoGenerateColumns   = false;
            this.dgvTransactions.AutoGenerateColumns = false;
            if (part.PartID > 0)
            {
                _part = partsService.Find(part.PartID);
            }
            else
            {
                _part           = partsService.New();
                _part.AddedBy   = Globals.CurrentUserName;
                _part.DateAdded = DateTime.Today;
            }
            cboSuppliers.DisplayMember = "SupplierName";
            cboSuppliers.ValueMember   = "SupplierID";
            cboSuppliers.SelectedItem  = _part.SupplierId;
            cboSuppliers.DataSource    = var.GetAll();

            cboUnits.DisplayMember = "UOM";
            cboUnits.ValueMember   = "UID";
            cboUnits.SelectedItem  = _part.UID;
            cboUnits.DataSource    = partsService.Units();

            cboManus.DisplayMember = "Manufacturer";
            cboManus.ValueMember   = "ManuID";
            cboManus.SelectedItem  = _part.ManuId;
            cboManus.DataSource    = partsService.Manufacturers();


            bsPart.DataSource = _part;

            // This triggers the Save Button On changed--
            bsPart.CurrentItemChanged += BsPart_CurrentItemChanged;

            this.btnSave.Enabled         = _isDirty;
            this.txtSupplierDesc.Enabled = false;
            _documents = _context.Document.Where(r => r.PartID == _part.PartID).ToList();
            // _documents = _part.Document.ToList();
            bsDocuments.DataSource        = _documents;
            this.dataGridView1.DataSource = bsDocuments;

            LoadTransaction();

            this.rbRecieved.Checked = true;
        }
Exemplo n.º 2
0
        private void InitializeGrid()
        {
            // Currency Decimal Style
            DataGridViewCellStyle dstyleCurrency = new DataGridViewCellStyle();

            dstyleCurrency.Format    = "C";
            dstyleCurrency.NullValue = "";
            dstyleCurrency.Alignment = DataGridViewContentAlignment.MiddleRight;
            // Currency Decimal Style
            DataGridViewCellStyle dstyleDecimal = new DataGridViewCellStyle();

            dstyleDecimal.Format    = "N2";
            dstyleDecimal.NullValue = "0.00";
            dstyleDecimal.Alignment = DataGridViewContentAlignment.MiddleRight;
            // Wrapping Text Style
            DataGridViewCellStyle dstyleWrapText = new DataGridViewCellStyle();

            dstyleWrapText.NullValue = "";
            dstyleWrapText.Alignment = DataGridViewContentAlignment.TopLeft;
            dstyleWrapText.WrapMode  = DataGridViewTriState.True;


            // ID Column --
            DataGridViewTextBoxColumn colID = new DataGridViewTextBoxColumn();

            colID.HeaderText       = "LineID";
            colID.DataPropertyName = "LineID";
            colID.Width            = 75;

            // PartID Column --
            DataGridViewLinkColumn colPartID = new DataGridViewLinkColumn();

            colPartID.HeaderText       = "PartID";
            colPartID.DataPropertyName = "PartID";
            colPartID.Width            = 50;

            // Description Column --
            DataGridViewTextBoxColumn colDescription = new DataGridViewTextBoxColumn();

            colDescription.HeaderText       = "Description";
            colDescription.DataPropertyName = "Description";
            colDescription.Width            = 450;
            colDescription.AutoSizeMode     = DataGridViewAutoSizeColumnMode.Fill;


            // Unit of Measure --
            DataGridViewComboBoxColumn colUnit = new DataGridViewComboBoxColumn();

            colUnit.Width            = 60;
            colUnit.DisplayMember    = "UOM";
            colUnit.ValueMember      = "UID";
            colUnit.DataPropertyName = "Uom";
            // UnitCost ----------
            DataGridViewTextBoxColumn colCost = new DataGridViewTextBoxColumn();

            colCost.Width            = 60;
            colCost.HeaderText       = "Cost";
            colCost.DataPropertyName = "UnitCost";
            colCost.DefaultCellStyle = dstyleCurrency;

            // Qnty ----------
            DataGridViewTextBoxColumn colQnty = new DataGridViewTextBoxColumn();

            colQnty.Width            = 60;
            colQnty.HeaderText       = "Qnty";
            colQnty.DataPropertyName = "Qnty";

            colQnty.DefaultCellStyle = dstyleDecimal;
            // Extended ----------
            DataGridViewTextBoxColumn colExtended = new DataGridViewTextBoxColumn();

            colExtended.Width            = 60;
            colExtended.HeaderText       = "Extended";
            colExtended.DataPropertyName = "Extended";
            colExtended.DefaultCellStyle = dstyleCurrency;

            colUnit.DataSource = _partService.Units();
            view.Columns.AddRange(colID, colPartID, colDescription, colUnit, colCost, colQnty, colExtended);
            view.Dock = DockStyle.None;
            this.Controls.Add(view);

            BindGrid();

            bsLineItems.DataSource = lineItems;
        }