public override bool alterar(CorboUtils.Dominio.ClasseBase obj) { _erro = false; try { var xmlAbastec = _xmlDoc.Descendants("abastecimento").Where(x => x.Attribute("id").Value == ((Abastecimento)obj).ID.ToString()).FirstOrDefault(); if (xmlAbastec != null) { xmlAbastec.Element("data_abaste").Value=((Abastecimento)obj).data_abastec.ToString("dd/MM/yyyy"); xmlAbastec.Element("hora_abastec").Value=((Abastecimento)obj).hora_abastec.ToString("hh:mm"); xmlAbastec.Element("id_tipo_combustivel").Value=((Abastecimento)obj).combustivel.ID.ToString(); xmlAbastec.Element("km").Value=((Abastecimento)obj).km.ToString(); xmlAbastec.Element("litragem").Value=((Abastecimento)obj).litragem.ToString(); xmlAbastec.Element("km_litro").Value=((Abastecimento)obj).km_litro.ToString(); xmlAbastec.Element("valor_unit").Value=((Abastecimento)obj).valor_unit.ToString(); xmlAbastec.Element("valor_total").Value=((Abastecimento)obj).valor_total.ToString(); xmlAbastec.Element("id_posto").Value = ((Abastecimento)obj).posto.ID.ToString(); xmlAbastec.Element("id_veiculo").Value=((Abastecimento)obj).veiculo.ID.ToString(); xmlAbastec.Element("sincronizado").Value="N"; salvarXML(); } } catch (Exception e) { _erro = true; throw new Exception("Erro ao alterar o abastecimento. " + e.Message); } return !_erro; }
public override bool alterar(CorboUtils.Dominio.ClasseBase obj) { _erro = false; try { var veiculo = _xmlDoc.Descendants("veiculo").Where(x => x.Attribute("id").Value == ((Veiculo)obj).ID.ToString()).FirstOrDefault(); if (veiculo != null) { veiculo.Element("placa").Value = ((Veiculo)obj).placa; veiculo.Element("marca").Value = ((Veiculo)obj).marca; veiculo.Element("modelo").Value = ((Veiculo)obj).modelo; veiculo.Element("cor").Value = ((Veiculo)obj).cor; salvarXML(); } } catch (Exception e) { _erro = true; throw new Exception("Erro ao alterar o veículo. " + e.Message); } return !_erro; }
public override bool inserir(CorboUtils.Dominio.ClasseBase obj) { _erro = false; try { XElement novo = new XElement("abastecimento", new XAttribute("id", DataLib.getID().ToString()), new XElement("data_abastec", ((Abastecimento)obj).data_abastec.ToString("dd/MM/yyyy")), new XElement("hora_abastec", ((Abastecimento)obj).hora_abastec.ToString("hh:mm")), new XElement("id_tipo_combustivel", ((Abastecimento)obj).combustivel.ID.ToString()), new XElement("km", ((Abastecimento)obj).km.ToString()), new XElement("litragem", ((Abastecimento)obj).litragem.ToString()), new XElement("km_litro", ((Abastecimento)obj).km_litro.ToString()), new XElement("valor_unit", ((Abastecimento)obj).valor_unit.ToString()), new XElement("valor_total", ((Abastecimento)obj).valor_total.ToString()), new XElement("id_posto", ((Abastecimento)obj).posto.ID.ToString()), new XElement("id_veiculo", ((Abastecimento)obj).veiculo.ID.ToString()), new XElement("sincronizado", "N")); _xmlDoc.Element("abastecimentos").Add(novo); salvarXML(); } catch (Exception e) { _erro = true; throw new Exception("Erro ao inserir o abastecimento. " + e.Message); } return !_erro; }
public override bool buscarID(CorboUtils.Dominio.ClasseBase obj) { Boolean encontrado = false; var posto = _xmlDoc.Descendants("posto").Where(x => x.Attribute("id").Value == obj.ID.ToString()).FirstOrDefault(); if (posto != null) { encontrado = true; ((Posto)obj).nome = posto.Element("nome").Value; ((Posto)obj).bairro = posto.Element("bairro").Value; ((Posto)obj).cidade = posto.Element("cidade").Value; ((Posto)obj).uf = posto.Element("uf").Value; } return encontrado; }
public override bool buscarID(CorboUtils.Dominio.ClasseBase obj) { Boolean encontrado = false; var veiculo = _xmlDoc.Descendants("veiculo").Where(x => x.Attribute("id").Value == obj.ID.ToString()).FirstOrDefault(); if (veiculo != null) { encontrado = true; ((Veiculo)obj).placa=veiculo.Element("placa").Value; ((Veiculo)obj).marca = veiculo.Element("marca").Value; ((Veiculo)obj).modelo = veiculo.Element("modelo").Value; ((Veiculo)obj).cor = veiculo.Element("cor").Value; } return encontrado; }
public override bool excluir(CorboUtils.Dominio.ClasseBase obj) { _erro = false; try { var posto = _xmlDoc.Descendants("posto").Where(x => x.Attribute("id").Value == ((Veiculo)obj).ID.ToString()).FirstOrDefault(); if (posto != null) { posto.Remove(); salvarXML(); } } catch (Exception e) { _erro = true; throw new Exception("Erro ao excluir o posto. " + e.Message); } return !_erro; }
public override bool alterar(CorboUtils.Dominio.ClasseBase obj) { _erro = false; try { var posto = _xmlDoc.Descendants("posto").Where(x => x.Attribute("id").Value == ((Veiculo)obj).ID.ToString()).FirstOrDefault(); if (posto != null) { posto.Element("nome").Value = ((Posto)obj).nome; posto.Element("bairro").Value = ((Posto)obj).bairro; posto.Element("cidade").Value = ((Posto)obj).cidade; posto.Element("uf").Value = ((Posto)obj).uf; salvarXML(); } } catch (Exception e) { _erro = true; throw new Exception("Erro ao alterar o posto. " + e.Message); } return !_erro; }
public override bool inserir(CorboUtils.Dominio.ClasseBase obj) { throw new NotImplementedException(); }
public override bool buscarID(CorboUtils.Dominio.ClasseBase obj) { _erro = false; try { var xmlAbastec = _xmlDoc.Descendants("veiculo").Where(x => x.Attribute("id").Value == obj.ID.ToString()).FirstOrDefault(); ((Abastecimento)obj).ID = Int32.Parse(xmlAbastec.Element("id").Value); ((Abastecimento)obj).data_abastec = DateTime.Parse(xmlAbastec.Element("data_abastec").Value); ((Abastecimento)obj).hora_abastec = DateTime.Parse(xmlAbastec.Element("hora_abastec").Value); ((Abastecimento)obj).combustivel.ID = Int32.Parse(xmlAbastec.Element("id_tipo_combustivel").Value); ((Abastecimento)obj).km = Int32.Parse(xmlAbastec.Element("km").Value); ((Abastecimento)obj).litragem = Double.Parse(xmlAbastec.Element("litragem").Value); ((Abastecimento)obj).km_litro = Double.Parse(xmlAbastec.Element("km_litro").Value); ((Abastecimento)obj).valor_unit = Double.Parse(xmlAbastec.Element("valor_unit").Value); ((Abastecimento)obj).valor_total = Double.Parse(xmlAbastec.Element("valor_total").Value); ((Abastecimento)obj).posto.ID = Int32.Parse(xmlAbastec.Element("id_posto").Value); ((Abastecimento)obj).observacao = xmlAbastec.Element("observacao").Value; } catch (Exception e) { _erro = true; throw new Exception("Erro ao consultar o lançamento de abastecimento. " + e.Message); } finally { _erro = false; } return !_erro; }
public override bool inserir(CorboUtils.Dominio.ClasseBase obj) { _erro = false; try { XElement novo = new XElement("posto", new XAttribute("id", DataLib.getID().ToString()), new XElement("nome", ((Posto)obj).nome), new XElement("bairro", ((Posto)obj).bairro), new XElement("cidade", ((Posto)obj).cidade), new XElement("uf", ((Posto)obj).uf)); _xmlDoc.Element("postos").Add(novo); salvarXML(); } catch (Exception e) { _erro = true; throw new Exception("Erro ao inserir o posto. " + e.Message); } return !_erro; }
public override bool inserir(CorboUtils.Dominio.ClasseBase obj) { _erro = false; try { XElement novo = new XElement("veiculo", new XAttribute("id", DataLib.getID().ToString()), new XElement("placa", ((Veiculo)obj).placa), new XElement("marca", ((Veiculo)obj).marca), new XElement("modelo", ((Veiculo)obj).modelo), new XElement("cor", ((Veiculo)obj).cor)); _xmlDoc.Element("veiculos").Add(novo); salvarXML(); } catch (Exception e) { _erro = true; throw new Exception("Erro ao inserir o veículo. " + e.Message); } return !_erro; }