protected void btnSalvar_Click(object sender, EventArgs e) { try { Formularioref novoForm = new Formularioref() { Nome = txtNome.Text, Setor = txtSetor.Text, Registro = txtRegistro.Text, Funcao = txtFuncao.Text, Justificativa = Justificativa.Value, OutrasSituacoes = OutraSitu.Value, DataOcorrido = calendarioData.Value, HorarioOcorrido = horario.Value }; Formulario.AdicionarFormulario(novoForm); txtFuncao.Text = ""; txtNome.Text = ""; txtRegistro.Text = ""; txtSetor.Text = ""; OutraSitu.Value = ""; calendarioData.Value = ""; horario.Value = ""; MessageBox.Show("Formulario Salvo"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public static void AdicionarFormulario(Formularioref f) { XElement x = new XElement("Forumulario"); x.Add(new XElement("Nome", f.Nome)); x.Add(new XElement("Funcao", f.Funcao)); x.Add(new XElement("Registro", f.Registro)); x.Add(new XElement("Setor", f.Setor)); x.Add(new XElement("Justificativa", f.Justificativa)); x.Add(new XElement("DataOcorrido", f.DataOcorrido)); x.Add(new XElement("HorarioOcorrido", f.HorarioOcorrido)); x.Add(new XElement("OutrasSituacoes", f.OutrasSituacoes)); XElement xml = XElement.Load(@"C:\Users\claudio.silva\source\repos\FormularioJust\FormularioJustif\Formulario.xml"); xml.Add(x); xml.Save(@"C:\Users\claudio.silva\source\repos\FormularioJust\FormularioJustif\Formulario.xml"); }