コード例 #1
0
        private void buscarServico(int id)
        {
            Camadas.BLL.Servico          bllServ   = new Camadas.BLL.Servico();
            List <Camadas.Model.Servico> listaServ = new List <Camadas.Model.Servico>();

            listaServ = bllServ.SelectById(id);
            if (listaServ != null)
            {
                servico = listaServ[0];
            }
        }
コード例 #2
0
        private void btnGravar_Click(object sender, EventArgs e)
        {
            Camadas.BLL.Servico bllServ = new Camadas.BLL.Servico();

            Camadas.Model.Servico servico = new Camadas.Model.Servico();
            servico.id        = Convert.ToInt32(lblId.Text);
            servico.descricao = txtDescricao.Text;
            servico.valorServ = Convert.ToSingle(txtValor.Text);

            string msg;
            string titulo;
            int    id = Convert.ToInt32(lblId.Text);

            if (id == -1)
            {
                msg    = "Deseja inserir os dados do Servico?";
                titulo = "Inserir";
            }
            else
            {
                msg    = "Deseja alterar os dados do Servico?";
                titulo = "Editar";
            }

            DialogResult resposta;

            resposta = MessageBox.Show(msg, titulo, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
            if (resposta == DialogResult.Yes)
            {
                if (id == -1)
                {
                    bllServ.Insert(servico);
                }
                else
                {
                    bllServ.Update(servico);
                }
            }

            dgvServico.DataSource = "";
            dgvServico.DataSource = bllServ.Select();

            limpaCampos();
            habilitaCampos(false);
        }