Example #1
0
        private void btLocalizar_Click(object sender, EventArgs e)
        {
            //Alterna imagens dos botões
            btLocalizar.ImageIndex = 3;

            frmConsultaUndMedida frmUmed = new frmConsultaUndMedida();

            frmUmed.ShowDialog();
            if (frmUmed.codigo != 0)
            {
                DALConexao      cx     = new DALConexao(DadosDaConexao.StringDeConexao);
                DLLUndMedida    dll    = new DLLUndMedida(cx);
                ModeloUndMedida modelo = dll.CarregaModeloUndMedida(frmUmed.codigo);
                txtUmedCod.Text  = modelo.UmedCod.ToString();
                txtUmedNome.Text = modelo.UmedNome;
                txtUmedData.Text = modelo.UmedData;
                label1.Visible   = true;
                this.alteraBotoes(3);
                closeCadUndMedida = 3;
            }
            else
            {
                this.LimpaTela();
                this.alteraBotoes(1);
                closeCadUndMedida      = 1;
                btLocalizar.ImageIndex = 2;
            }
            frmUmed.Dispose();
        }
Example #2
0
 private void txtUmedNome_Leave(object sender, EventArgs e)
 {
     if (this.operacao == "inserir")
     {
         int          r   = 0;
         DALConexao   cx  = new DALConexao(DadosDaConexao.StringDeConexao);
         DLLUndMedida dll = new DLLUndMedida(cx);
         r = dll.VerificaUndMedida(txtUmedNome.Text);
         if (r > 0)
         {
             DialogResult d = MessageBox.Show("Já existe um registro com este valor, deseja alterar o registro?", "Modificar?", MessageBoxButtons.YesNo);
             if (d.ToString() == "Yes")
             {
                 this.operacao = "alterar";
                 ModeloUndMedida modelo = dll.CarregaModeloUndMedida(r);
                 txtUmedCod.Text  = modelo.UmedCod.ToString();
                 txtUmedNome.Text = modelo.UmedNome;
                 txtUmedData.Text = modelo.UmedData;
                 label1.Visible   = true;
                 //this.alteraBotoes(3);
                 closeCadUndMedida = 3;
             }
         }
     }
 }