Exemple #1
0
 //-------------------------------------------------------------------------------------------------------------------
 private void btLocalizar_Click(object sender, EventArgs e)
 {
     try
     {
         frmConsultaCompra fc = new frmConsultaCompra();
         fc.ShowDialog();
         if (fc.codigo != -1)
         {
             this.operacao = "alteracao";
             BLLCompra    bll    = new BLLCompra();
             ModeloCompra modelo = bll.carregaModelo(fc.codigo);
             txtComCod.Text                = modelo.com_cod.ToString();
             txtNFiscal.Text               = modelo.com_nfiscal.ToString();
             txtForCod.Text                = modelo.for_cod.ToString();
             dtVenda.Value                 = modelo.com_data;
             txtTotal.Text                 = modelo.com_pagto_total.ToString();
             nupParcelas.Value             = modelo.com_nparcela;
             cbTipoPagamento.SelectedValue = modelo.tpa_cod;
             if (modelo.com_status == 2)
             {
                 MessageBox.Show("Esta compra foi cancelada", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
             this.txtCliCod_Leave(sender, e);
             //carrega os itens
             dgvItens.Rows.Clear();
             BLLItensCompra it    = new BLLItensCompra();
             DataTable      itens = it.ListagemComFiltro(modelo.com_cod);
             for (int i = 0; i < itens.Rows.Count; i++)
             {
                 try
                 {
                     //gambi
                     ModeloProduto p    = new ModeloProduto();
                     BLLProduto    bllp = new BLLProduto();
                     p = bllp.carregaModelo(Convert.ToInt32(itens.Rows[i]["pro_cod"]));
                     double   total = Convert.ToDouble(itens.Rows[i]["itc_valor"]) * Convert.ToDouble(itens.Rows[i]["itc_qtde"]);
                     String[] k     = new String[] { itens.Rows[i]["pro_cod"].ToString(), p.pro_nome, itens.Rows[i]["itc_qtde"].ToString(), itens.Rows[i]["itc_valor"].ToString(), total.ToString() };
                     this.dgvItens.Rows.Add(k);
                 }
                 catch (Exception error)
                 {
                     MessageBox.Show(error.Message);
                 }
             }
             this.alteraBotoes(3);
         }
         else
         {
             this.alteraBotoes(1);
         }
         fc.Dispose();
     }catch (Exception error)
     {
         MessageBox.Show(error.Message);
     }
 }