private void carregaListaAbastecimento(IEnumerable<XElement> pXmlLista) { Abastecimento abastecimento; foreach (XElement xmlAbastec in pXmlLista) { abastecimento = new Abastecimento(); abastecimento.ID = Int32.Parse(xmlAbastec.Element("id").Value); abastecimento.data_abastec = DateTime.Parse(xmlAbastec.Element("data_abastec").Value); abastecimento.hora_abastec = DateTime.Parse(xmlAbastec.Element("hora_abastec").Value); abastecimento.combustivel.ID = Int32.Parse(xmlAbastec.Element("id_tipo_combustivel").Value); abastecimento.km = Int32.Parse(xmlAbastec.Element("km").Value); abastecimento.litragem = Double.Parse(xmlAbastec.Element("litragem").Value); abastecimento.km_litro = Double.Parse(xmlAbastec.Element("km_litro").Value); abastecimento.valor_unit = Double.Parse(xmlAbastec.Element("valor_unit").Value); abastecimento.valor_total = Double.Parse(xmlAbastec.Element("valor_total").Value); abastecimento.posto.ID = Int32.Parse(xmlAbastec.Element("id_posto").Value); abastecimento.observacao = xmlAbastec.Element("observacao").Value; _lista.Add(abastecimento); } }
private void getSession() { abastecimento = (Session["abastecimento"] as Abastecimento); }
protected void Page_Load(object sender, EventArgs e) { /* * Op I - É incluir * Op A - É alterar */ if (!IsPostBack) { /***********************************************************/ abastecimento = new Abastecimento(); abastecimento.novo(); setSession(); /***********************************************************/ listaCombustivel(); ddCombustivel.Items.Add(new ListItem("Selecione", "0", true)); ddCombustivel.Items.FindByValue("0").Selected = true; /***********************************************************/ listaPosto(); ddPosto.Items.Add(new ListItem("Selecione", "0", true)); ddPosto.Items.FindByValue("0").Selected = true; /***********************************************************/ if (Request.QueryString["op"] == "A") { daoAbastecimento = new DAOAbastecimento(arquivo); abastecimento.ID = Int32.Parse(Request.QueryString["id"]); daoAbastecimento.buscarID(abastecimento); getDados(); abastecimento.editar(); setSession(); } } }
protected void btnExcluir_Click(object sender, EventArgs e) { abastecimento = (Session["abastecimento"] as Abastecimento); abastecimento.deletar(); try { abastecimento.aplicar(new DAOAbastecimento(arquivo)); Response.Redirect("default.aspx"); } catch (Exception Ex) { lblMsgErro.Visible = true; lblMsgErro.Text = Ex.Message; } }