Ejemplo n.º 1
0
        private void frmCadastroProduto_Load(object sender, EventArgs e)
        {
            alterarBotoes(1);

            ////COMBO DA CATEGORIA
            DALConexao conexao = new DALConexao(DadosDaConexao.StringDeConexao);
            BLLCategoria daoCategoria = new BLLCategoria(conexao);
            cboCategoria.DataSource = daoCategoria.Localizar("");
            cboCategoria.DisplayMember = "cat_nome";
            cboCategoria.ValueMember = "cat_cod";
            //cboCategoria.AutoCompleteMode = AutoCompleteMode.Suggest;
            //cboCategoria.AutoCompleteSource = AutoCompleteSource.ListItems;
            try
            {
                BLLSubCategoria sub = new BLLSubCategoria(conexao);
                cboSubCategoria.DataSource = sub.LocalizaPorCategoria(1);
                //cbSubCategoria.DataSource = sub.LocalizaPorCategoria((int)cbCategoria.SelectedValue);
                cboSubCategoria.DisplayMember = "scat_nome";
                cboSubCategoria.ValueMember = "scat_cod";

            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            //COMBO UNIDADE DE MEDIDA
            BLLUnidMedida daoUniMedida = new BLLUnidMedida(conexao);
            cboUnidMedida.DataSource = daoUniMedida.Localizar("");
            cboUnidMedida.DisplayMember = "umed_nome";
            cboUnidMedida.ValueMember = "umed_cod";
        }
        private void btnPesquisar_Click(object sender, EventArgs e)
        {
            DALConexao    conexao    = new DALConexao(DadosDaConexao.StringDeConexao);
            BLLUnidMedida unidMedida = new BLLUnidMedida(conexao);

            GridUnidade.DataSource = unidMedida.Localizar(txtPesquisa.Text.ToUpper());
        }
        private void btnLocalizar_Click(object sender, EventArgs e)
        {
            frmConsultaUniMedida uniMedida = new frmConsultaUniMedida();

            uniMedida.ShowDialog();
            try
            {
                if (uniMedida.codigo != 0)
                {
                    DALConexao      conexao = new DALConexao(DadosDaConexao.StringDeConexao);
                    BLLUnidMedida   model   = new BLLUnidMedida(conexao);
                    ModeloUndMedida modelo  = model.carregarUnidades(uniMedida.codigo);
                    txtCodigo.Text    = Convert.ToString(modelo.Umed_cod);
                    txtUniMedida.Text = modelo.Umed_nome;
                    this.alterarBotoes(3);
                }
                else
                {
                    limparTela();
                    this.alterarBotoes(1);
                }
                uniMedida.Dispose();
            }
            catch (Exception ex)
            {
                MetroFramework.MetroMessageBox.Show(this, "Impossivel encontrar o registro. \n O resistro esta sendo utilizado em outro local " + ex.Message, "OK", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 private void btnSalvar_Click(object sender, EventArgs e)
 {
     try
     {
         ModeloUndMedida undMedida = new ModeloUndMedida();
         undMedida.Umed_nome = txtUniMedida.Text;
         DALConexao    dao    = new DALConexao(DadosDaConexao.StringDeConexao);
         BLLUnidMedida medida = new BLLUnidMedida(dao);
         if (this.operacao == "inserir")
         {
             medida.Inserir(undMedida);
             MetroFramework.MetroMessageBox.Show(this, "Cadastrado com sucesso", "OK", MessageBoxButtons.OK, MessageBoxIcon.Information);
             this.limparTela();
             this.alterarBotoes(1);
         }
         else
         {
             undMedida.Umed_cod = Convert.ToInt32(txtCodigo.Text);
             medida.Alterar(undMedida);
             MetroFramework.MetroMessageBox.Show(this, "Alterado com sucesso", "OK", MessageBoxButtons.OK, MessageBoxIcon.Information);
             this.limparTela();
             this.alterarBotoes(1);
         }
     }
     catch (Exception ex)
     {
         MetroFramework.MetroMessageBox.Show(this, "ops Ocorreu algum erro " + ex.Message, "OK", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
 private void btnExcluir_Click(object sender, EventArgs e)
 {
     try
     {
         DialogResult resultado = MetroFramework.MetroMessageBox.Show(this, "Realmente deseja excluir? ", "ATENÇÃO", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
         if (resultado.ToString() == "Yes")
         {
             ModeloUndMedida undMedida = new ModeloUndMedida();
             DALConexao      conexao   = new DALConexao(DadosDaConexao.StringDeConexao);
             BLLUnidMedida   medida    = new BLLUnidMedida(conexao);
             medida.Excluir(Convert.ToInt32(txtCodigo.Text));
             MetroFramework.MetroMessageBox.Show(this, "Excluido com sucesso", "OK", MessageBoxButtons.OK, MessageBoxIcon.Information);
             this.limparTela();
             this.alterarBotoes(1);
         }
     }
     catch (Exception ex)
     {
         MetroFramework.MetroMessageBox.Show(this, "ops Ocorreu algum erro " + ex.Message, "OK", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }