Ejemplo n.º 1
0
        public FrmProdutoCadastrar(AcaoNaTela acaoNaTela, Produto produto)
        {
            InitializeComponent();
            acaoNaTelaSelecionada = acaoNaTela;

            if (acaoNaTela == AcaoNaTela.Inserir)
            {
                this.Text = "Cadastrar Produto";

                produtoCollections = produtoNegocios.TipoConsultar("");

                produtoCollections.Sort((x, y) => x.Tipo.CompareTo(y.Tipo));
                comboBoxTipo.DataSource = produtoCollections;
            }
            else if (acaoNaTela == AcaoNaTela.Alterar)
            {
                this.Text = "Alterar Produto";
                this.textBoxIdProduto.Text = produto.IdProduto.ToString();
                this.textBoxCodigo.Text    = produto.Codigo;
                int valorTipo = produto.IdTipo;
                produtoCollections           = produtoNegocios.TipoConsultar("");
                this.comboBoxTipo.DataSource = produtoCollections;
                int i = comboBoxTipo.FindString(produto.Tipo);
                comboBoxTipo.SelectedIndex     = i;
                this.richTextBoxDescricao.Text = produto.Descricao;
                this.textBoxValor.Text         = produto.Valor.ToString();
                this.textBoxSabor.Text         = produto.Sabor;
            }
            else if (acaoNaTela == AcaoNaTela.Consultar)
            {
                this.Text = "Alterar Produto";
                this.textBoxCodigo.ReadOnly        = true;
                this.textBoxCodigo.TabStop         = false;
                this.comboBoxTipo.Enabled          = false;
                this.comboBoxTipo.TabStop          = false;
                this.richTextBoxDescricao.ReadOnly = true;
                this.richTextBoxDescricao.TabStop  = false;
                this.textBoxValor.ReadOnly         = true;
                this.textBoxValor.TabStop          = false;
                this.textBoxSabor.ReadOnly         = true;
                this.textBoxSabor.TabStop          = false;
                this.labelTotal300Char.Visible     = false;
                this.btnNovotipo.Visible           = false;

                produtoCollections           = produtoNegocios.TipoConsultar("");
                this.comboBoxTipo.DataSource = produtoCollections;
                int i = comboBoxTipo.FindString(produto.Tipo);
                comboBoxTipo.SelectedIndex     = i;
                this.textBoxCodigo.Text        = produto.Codigo;
                this.richTextBoxDescricao.Text = produto.Descricao;
                this.textBoxValor.Text         = produto.Valor.ToString();
                this.textBoxSabor.Text         = produto.Sabor;

                this.buttonProdutoSalvar.Visible = false;
                this.buttonProdutoCancelar.Text  = "Fechar";
                this.buttonProdutoCancelar.Focus();
            }
        }
Ejemplo n.º 2
0
        public void atualizarGrid()
        {
            ProdutoNegocios  produtoNegocios   = new ProdutoNegocios();
            ProdutoColletion produtoCollection = new ProdutoColletion();

            produtoCollection = produtoNegocios.TipoConsultar("");

            dgwTipo.DataSource          = null;
            dgwTipo.AutoGenerateColumns = false;
            produtoCollection.Sort((x, y) => x.Tipo.CompareTo(y.Tipo));
            dgwTipo.DataSource = produtoCollection;
            //dgwTipo.Sort(colTipo,ListSortDirection.Ascending);
            dgwTipo.Update();
            dgwTipo.Refresh();
        }