示例#1
0
        public void UpdateDgvComponents()
        {
            dgvComponents.AutoGenerateColumns = false;

            try
            {
                dgvComponents.DataSource = ComponentCtrl.GetAll();
            }
            catch (AggregateException ex)
            {
                MessageBox.Show("Aplicação servidora não responde: " + ex.Message);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Problema na solicitação: " + ex.Message);
            }
        }
示例#2
0
        public FormProductForm(FormProduct formProduct, int Id = 0)
        {
            InitializeComponent();

            this.formProduct = formProduct;

            this.tbId.Enabled = false;

            productComponents = null;

            try
            {
                if (Id > 0)
                {
                    DTO.Product product = ProductCtrl.GetById(Id);

                    this.tbId.Text     = Id.ToString();
                    tbName.Text        = product.Name;
                    tbDescription.Text = product.Description;
                    tbAmount.Text      = product.Amount.ToString();
                    tbPrice.Text       = product.Price.ToString("0.00");
                    this.tbId.ReadOnly = true;

                    productComponents = (from component in product.Components select component.Id).ToList();
                }

                componentsList = ComponentCtrl.GetAll();
                foreach (var component in componentsList)
                {
                    clbComponents.Items.Add(component.Name, productComponents != null && productComponents.Contains(component.Id));
                }

                this.tbName.Select();
            }
            catch (AggregateException ex)
            {
                MessageBox.Show("Aplicação servidora não responde: " + ex.Message);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Problema na solicitação: " + ex.Message);
            }
        }