private ManutencaoBD OleoToManutencao(OleoBD o) { ManutencaoBD m = new ManutencaoBD(); m.Descricao = "TROCA DE ÓLEO"; m.KM = o.Km; m.Local = o.Local; m.Placa = o.Placa; m.Valor = o.Valor; return(m); }
private ManutencaoBD TelaToEntity() { ManutencaoBD c = new ManutencaoBD(); c.Placa = comboPlaca.Text; c.KM = txtKm.Text; c.Local = txtLocal.Text; c.Descricao = txtDescricao.Text; c.Valor = txtValor.Text.Replace("R$", "").Trim().Replace(",", "."); return(c); }
public bool Cadastra(OleoBD c, ManutencaoBD m) { if (!string.IsNullOrEmpty(c.Placa)) { if (c.Placa.Length > 6) { if (!string.IsNullOrEmpty(c.Km)) { if (!string.IsNullOrEmpty(c.Local)) { if (!string.IsNullOrEmpty(c.Valor)) { if (c.Valor.Length > 3) { OleoDAO DAO = new OleoDAO(); DataTable Result = new DataTable(); Result = DAO.Cadastra(c, Autenticacao.GetCodUsuario()); if (Result != null) { if (Result.Rows.Count > 0) { if (Result.Rows[0].ItemArray[0].ToString().Equals("1")) { ManutencaoBLL BLL = new ManutencaoBLL(); if (BLL.Cadastra(m)) { return(true); } else { return(false); } } else { return(false); } } } } } } } } } return(false); }
private void btnSalvar_Click(object sender, EventArgs e) { ManutencaoBD c = new ManutencaoBD(); ManutencaoBLL BLL = new ManutencaoBLL(); c = TelaToEntity(); if (BLL.Cadastra(c)) { MessageBox.Show("MANUTENÇÃO CADASTRADA COM SUCESSO"); LimpaTela(); } else { MessageBox.Show("Verifique os campos Obrigatórios"); MensagemErro(); } MensagemErro(); }
private void btnSalvar_Click(object sender, EventArgs e) { OleoBD c = new OleoBD(); OleoBLL BLL = new OleoBLL(); c = TelaToEntity(); ManutencaoBD m = OleoToManutencao(c); if (BLL.Cadastra(c, m)) { MessageBox.Show("Cadastro Realizado com Sucesso"); LimpaTela(); } else { MessageBox.Show("Verifique os campos Obrigatórios"); MensagemErro(); } MensagemErro(); }
public DataTable Cadastra(ManutencaoBD c, int usuario) { try { CriarConexao(); Abrir(); SqlDataAdapter Cmd; Cmd = new SqlDataAdapter("SP_CadastraManutencao", con); Cmd.SelectCommand.CommandType = System.Data.CommandType.StoredProcedure; Cmd.SelectCommand.Parameters.Add("@USUARIO", SqlDbType.VarChar).Value = usuario; Cmd.SelectCommand.Parameters.Add("@PLACA", SqlDbType.VarChar).Value = c.Placa; Cmd.SelectCommand.Parameters.Add("@KM", SqlDbType.VarChar).Value = c.KM; Cmd.SelectCommand.Parameters.Add("@DESCRICAO", SqlDbType.VarChar).Value = c.Descricao; Cmd.SelectCommand.Parameters.Add("@LOCAL", SqlDbType.VarChar).Value = c.Local; Cmd.SelectCommand.Parameters.Add("@VALOR", SqlDbType.VarChar).Value = c.Valor.Replace(",", ".").Trim(); DataTable data = new DataTable(); Cmd.Fill(data); Fechar(); return(data); } catch (Exception e) { Erros.SetErroBanco(e); Erros.SetHaErro(true); } finally { Fechar(); } return(null); }