// Load the outgoings data from the device public static int LoadData() { DataSet ds = new DataSetv1(); //DataTable tb = ds.Tables["Outgoings"]; ; DataTable tb = new DataTable(); // We use XML to store the data int returnValue = 0; // create a file name to write to string filename = "OutgoingsDataXML.xml"; // Create the filestream to write with System.IO.FileStream stream = new System.IO.FileStream(filename, System.IO.FileMode.Open); // Write to the file with the WriteXML method tb.ReadXml(stream); // Copy the data to the OutGoings Dataset foreach (DataRow row in tb.Rows) { ds.Tables["Outgoings"].Rows.Add(row); } return(returnValue); }
private int SaveSingleRecord() { int returnValue = 0; // Check if were updtaing an exisiting record if (creatingNewEntry) { // New record // Insert a new record // Create an instance of the DataSet: DataSetv1 myDataSet = new DataSetv1(); // To add a row we first need a strongly typed row object. //The only difficult thing about creating a row is working out exactly what the method is that creates the row object. In general, while the row data type belongs to the DataSet, the creation method belongs to the table that the row belongs to // DataSetv1.OutGoingsRow row = myDataSet.OutGoings.NewOutGoingsRow(); DataSetv1.OutGoingsRow row = dataSetv1.OutGoings.NewOutGoingsRow(); // Now we can add the data row.Description = this.fldDescription.Text; row.Amount = Convert.ToDouble(this.fldAmount.Text); row.DayPaid = Convert.ToInt16(this.fldDayPaid.SelectedValue); row.ReOccuring = Convert.ToBoolean(this.fldReoccuring.Checked); row.DayOfWeekPaid = Convert.ToInt16(this.fldDayOfWeekPaid.SelectedIndex); row.Frequency = Convert.ToInt16(this.fldFrequency.Text); // save the row to the dataset // myDataSet.OutGoings.Rows.Add(row); dataSetv1.OutGoings.Rows.Add(row); myDataSet.AcceptChanges(); SaveDataToDataSet(); } else { // We are updating an exisitn record // Update exisiting row in dataset } return(returnValue); }