private void FormCardapio_Load(object sender, EventArgs e)
        {
            controle.CardapioDB tabela = new controle.CardapioDB();
            tabela.consultar(bs);

            lbIdCardapio.DataBindings.Add(new Binding("Text", bs, "idcardapio"));
            lbDescricao.DataBindings.Add(new Binding("Text", bs, "descricao"));
        }
        private void btnEdit_Click(object sender, EventArgs e)
        {
            FormFichaCardapio ficha = new FormFichaCardapio();

            ficha.Registro = (modelo.cardapio)bs.Current;
            ficha.ShowDialog();
            if (ficha.Registro != null)
            {
                controle.CardapioDB tabela = new controle.CardapioDB();
                tabela.consultar(bs);
                bs.ResetBindings(false);
            }
        }
示例#3
0
 private void editar()
 {
     try
     {
         controle.CardapioDB tabela = new controle.CardapioDB();
         Registro.descricao = txtDescricao.Text;
         tabela.editar(Registro);
         this.Dispose();
     }
     catch (Exception erro)
     {
         MessageBox.Show("Erro: " + erro.Message);
     }
 }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            FormFichaCardapio ficha = new FormFichaCardapio();

            ficha.Registro = null;
            ficha.ShowDialog();
            if (ficha.Registro != null)
            {
                controle.CardapioDB tabela = new controle.CardapioDB();
                tabela.consultar(bs);
                bs.MoveLast();
                bs.ResetBindings(false);
            }
        }
        private void btnDel_Click(object sender, EventArgs e)
        {
            DialogResult op;

            modelo.cardapio Registro = (modelo.cardapio)bs.Current;

            op = MessageBox.Show("Deseja EXCLUIR Cardapio numero :"
                                 + Registro.idcardapio, "Alerta",
                                 MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (op == DialogResult.Yes)
            {
                controle.CardapioDB tabela = new controle.CardapioDB();
                tabela.excluir(Registro.idcardapio);
                bs.RemoveCurrent();
                bs.ResetBindings(false);
            }
        }
示例#6
0
        private void novo()
        {
            try
            {
                controle.CardapioDB tabela = new controle.CardapioDB();
                Registro = new modelo.cardapio
                {
                    idcardapio = tabela.ProximoCodigo(),
                    descricao  = txtDescricao.Text
                };

                tabela.inserir(Registro);
                this.Dispose();
            }
            catch (Exception erro)
            {
                MessageBox.Show("Erro: " + erro.Message);
            }
        }