Пример #1
0
        private void CarregarDataGrid(String grupos_selecionados, String nome_item, Enumeradores.TipoComparador tpOP, long quantidade, bool abaixo_do_minimo)
        {
            try
            {
                DataGridViewImageColumn grdImg = new DataGridViewImageColumn();

                //this.grdGerenciamento.RowEnter -= new DataGridViewCellEventHandler(grdGerenciamento_RowEnter);
                grdGerenciamento.Columns.Clear();
                grdGerenciamento.DataSource            = _reportDAO.ItensParaGerenciamento(grupos_selecionados, nome_item, tpOP, quantidade, abaixo_do_minimo);
                grdGerenciamento.SelectionMode         = DataGridViewSelectionMode.FullRowSelect;
                grdGerenciamento.AllowUserToDeleteRows = false;

                grdGerenciamento.Columns["id"].Visible           = false;
                grdGerenciamento.Columns["estoquebaixo"].Visible = false;

                grdGerenciamento.Columns["descricao"].Width      = 300;
                grdGerenciamento.Columns["descricao"].HeaderText = "Nome do Item";

                grdGerenciamento.Columns["tamanho"].Width      = 80;
                grdGerenciamento.Columns["tamanho"].HeaderText = "Tamanho";

                grdGerenciamento.Columns["grupo_descricao"].Width      = 135;
                grdGerenciamento.Columns["grupo_descricao"].HeaderText = "Grupo";

                grdGerenciamento.Columns["quantidade"].Width      = 100;
                grdGerenciamento.Columns["quantidade"].HeaderText = "Estoque Atual";

                grdGerenciamento.Columns["estoqueminimo"].Width      = 100;
                grdGerenciamento.Columns["estoqueminimo"].HeaderText = "Estoque Mínimo";

                grdImg       = new DataGridViewImageColumn();
                grdImg.Image = img.Images[0];
                grdGerenciamento.Columns.Insert((int)ColunasDoGrid.Somar, grdImg);
                grdImg.HeaderText = "Somar";
                grdImg.Name       = "somar";
                grdGerenciamento.Columns["somar"].Width = 70;

                grdImg       = new DataGridViewImageColumn();
                grdImg.Image = img.Images[1];
                grdGerenciamento.Columns.Insert((int)ColunasDoGrid.Subtrair, grdImg);
                grdImg.HeaderText = "Subtrair";
                grdImg.Name       = "subtrair";
                grdGerenciamento.Columns["subtrair"].Width = 70;

                grdImg       = new DataGridViewImageColumn();
                grdImg.Image = img.Images[2];
                grdGerenciamento.Columns.Insert((int)ColunasDoGrid.Substituir, grdImg);
                grdImg.HeaderText = "Substituir";
                grdImg.Name       = "substituir";
                grdGerenciamento.Columns["substituir"].Width = 70;

                grdGerenciamento.Columns["precocusto"].Width      = 150;
                grdGerenciamento.Columns["precocusto"].HeaderText = "Preço de Custo";

                grdGerenciamento.Columns["precovenda"].Width      = 150;
                grdGerenciamento.Columns["precovenda"].HeaderText = "Preço de Venda";

                // this.grdGerenciamento.RowEnter += new
                //     DataGridViewCellEventHandler(grdGerenciamento_RowEnter);

                this.grdGerenciamento.Columns["quantidade"].DefaultCellStyle.Format    = "#0";
                this.grdGerenciamento.Columns["quantidade"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;

                this.grdGerenciamento.Columns["estoqueminimo"].DefaultCellStyle.Format    = "#0";
                this.grdGerenciamento.Columns["estoqueminimo"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;

                this.grdGerenciamento.Columns["tamanho"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;

                this.grdGerenciamento.Columns["precocusto"].DefaultCellStyle.Format    = "c";
                this.grdGerenciamento.Columns["precocusto"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;

                this.grdGerenciamento.Columns["precovenda"].DefaultCellStyle.Format    = "c";
                this.grdGerenciamento.Columns["precovenda"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Principal.ActiveForm.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                lblBarra.Text = "";
            }

            this.grdGerenciamento.ClearSelection();
        }