Esempio n. 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                string desc = txtSitua.Text;
                desc = desc.Trim();
                int qtd = desc.Count();

                if (qtd > 200)
                {
                    throw new Exception("O campo 'Situação' não pode passar de 200 caracteres");
                }

                FuncionarioDTO funcionario = cboFuncio.SelectedItem as FuncionarioDTO;
                AutoDTO        auto        = cboAuto.SelectedItem as AutoDTO;
                PecasDTO       pecas       = cboPeca.SelectedItem as PecasDTO;

                OrcamentoDTO dto = new OrcamentoDTO();
                dto.FuncionarioId = funcionario.Id;
                dto.AutoId        = auto.Id;
                dto.PecaId        = pecas.Id;
                dto.Situacao      = txtSitua.Text;
                dto.Valor         = nudValor.Value;

                OrcamentoBusiness buss = new OrcamentoBusiness();
                buss.Salvar(dto);

                MessageBox.Show("Orcamento efetuado com sucesso.", "SIGMA", MessageBoxButtons.OK);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "SIGMA", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 2
0
        public List <PecasDTO> ConsultarPecas(string id)
        {
            string script = $"SELECT * FROM pecas WHERE orcamento_id_orcamento = {id}";

            List <MySqlParameter> parms = new List <MySqlParameter>();

            Database        db     = new Database();
            MySqlDataReader reader = db.ExecuteSelectScript(script, parms);

            List <PecasDTO> Pecas = new List <PecasDTO>();

            while (reader.Read())
            {
                PecasDTO dados = new PecasDTO();
                dados.descricao  = reader.GetString("descricao");
                dados.nome       = reader.GetString("nome");
                dados.quantidade = reader.GetInt32("quantidade");
                dados.valor      = reader.GetDouble("valor");

                Pecas.Add(dados);
            }

            reader.Close();
            return(Pecas);
        }
Esempio n. 3
0
 public void LoadScreen(PecasDTO dto)
 {
     this.dto       = dto;
     txtNome.Text   = dto.Nome;
     txtDesc.Text   = dto.Descricao;
     nudPreco.Value = dto.Valor;
 }
Esempio n. 4
0
        void CarregarCboPeca()
        {
            PecasDTO        dto   = new PecasDTO();
            PecasBusiness   buss  = new PecasBusiness();
            List <PecasDTO> lista = buss.Listar();

            cboPeca.ValueMember   = nameof(dto.Id);
            cboPeca.DisplayMember = nameof(dto.Nome);
            cboPeca.DataSource    = lista;
        }
Esempio n. 5
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            PecasDTO dto = new PecasDTO();

            dto.descricao              = txtDesc.Text;
            dto.nome                   = txtNome.Text;
            dto.quantidade             = Convert.ToInt32(nudQuantidade.Value);
            dto.valor                  = Convert.ToDouble(txtValor.Text) * dto.quantidade;
            dto.orcamento_id_orcamento = Convert.ToInt32(lblOrc.Text);

            produtosCarrinho.Add(dto);
        }
Esempio n. 6
0
        private void dgvPecas_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 4)
            {
                PecasDTO        dto  = dgvPecas.Rows[e.RowIndex].DataBoundItem as PecasDTO;
                frmAlterarPecas tela = new frmAlterarPecas();
                tela.LoadScreen(dto);
                tela.Show();
            }

            if (e.ColumnIndex == 5)
            {
                PecasDTO dto = dgvPecas.Rows[e.RowIndex].DataBoundItem as PecasDTO;

                DialogResult resposta = MessageBox.Show("Quer mesmo apagar este registro?", "NerdT", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if (resposta == DialogResult.Yes)
                {
                    PecasBusiness business = new PecasBusiness();
                    business.Remover(dto.Id);
                    MessageBox.Show("Registro removido com sucesso!", "NerdT", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
                }
            }
        }