Exemplo n.º 1
0
        private void btnConfirmarFornecedor_Click(object sender, EventArgs e)
        {
            if (cmbNome.SelectedIndex != -1)
            {
                btnConfirmarFornecedor.Visible = false;
                cmbNome.Enabled = false;

                lblCnpj.Visible                  = true;
                txtCnpj.Visible                  = true;
                lblEndereco.Visible              = true;
                txtEndereco.Visible              = true;
                lblTelefone.Visible              = true;
                txtTelefone.Visible              = true;
                gpbIncluirMaterial.Visible       = true;
                lblLegendaAdicionar.Visible      = true;
                lblLegendaIncluso.Visible        = true;
                lstboxMateriaisAdicionar.Visible = true;
                lstboxMateriaisInclusos.Visible  = true;
                panelStatus.Visible              = true;
                gpbMateriais.Visible             = true;
                btnLixeira.Visible               = true;
                btnAlterar.Visible               = true;
                btnCancelar.Location             = new Point(504, 430);

                int codigoFornecedor = int.Parse(cmbNome.SelectedValue.ToString());

                DataRow[] row;

                row = oDtFornecedor.Select("id_for = " + codigoFornecedor);

                int rowIndex = oDtFornecedor.Rows.IndexOf(row[0]);

                txtCnpj.Text     = oDtFornecedor.Rows[rowIndex]["cnpj_for"].ToString();
                txtEndereco.Text = oDtFornecedor.Rows[rowIndex]["endereco_for"].ToString();
                txtTelefone.Text = oDtFornecedor.Rows[rowIndex]["telefone_for"].ToString();

                if (oDtFornecedor.Rows[rowIndex]["status_for"].ToString() == "True")
                {
                    rdbAtivo.Checked = true;
                }
                else
                {
                    rdbInativo.Checked = true;
                }

                try
                {
                    lstboxMateriaisInclusos.Items.Clear();


                    DataTable oDtMateriaisFornecedor = new DataTable();
                    oDtMateriaisFornecedor = camadaNegocios.DataTableMateriaisFornecedor(codigoFornecedor);

                    string codigoMaterial;
                    string nomeMaterial;


                    for (int i = 0; i < oDtMateriaisFornecedor.Rows.Count; i++)
                    {
                        codigoMaterial = oDtMateriaisFornecedor.Rows[i]["Codigo"].ToString();
                        nomeMaterial   = oDtMateriaisFornecedor.Rows[i]["Nome"].ToString();

                        //Formatando os dados para lstbox
                        while (codigoMaterial.Length < 6)
                        {
                            codigoMaterial = '0' + codigoMaterial;
                        }


                        lstboxMateriaisInclusos.Items.Add(codigoMaterial + " - " + nomeMaterial);
                    }
                }

                catch
                {
                    //nada ocorre
                }
            }

            else
            {
                MessageBox.Show("Selecione um forncedor");
            }
        }