-
May 24th, 2011, 10:45 AM
#1
C# Form to edit a database.
Hi!
Ive been working on a project which allows forms to edit information for a database. For one form I must have:
• An import button which should start an Open File dialog and using appropriate filtering allow the user to select the house details text file.
• A button which saves the record to the data source (database).
• A button which cancels the new record within the dataset.
• A close button to return to the main menu.
http://i276.photobucket.com/albums/k...Druid/menu.jpg
Ive made out the form as seen above. I really don't know how to save the record or cancel a new record. I think Ive got the import function working. Could anyone hear give me a hint towards what could be used to fix this?
The code im currently using is shown below:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Assignment2_V1
{
public partial class Import : Form
{
public Import()
{
InitializeComponent();
}
private void houseBindingNavigatorSaveItem_Click(object sender, EventArgs e)
{
this.Validate();
this.houseBindingSource.EndEdit();
this.tableAdapterManager.UpdateAll(this.estateAgentDataSet);
}
private void Import_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'estateAgentDataSet.house' table. You can move, or remove it, as needed.
this.houseTableAdapter.Fill(this.estateAgentDataSet.house);
}
private void btnClose_Click(object sender, EventArgs e)
{
this.Close();
}
private void garageToolStripButton_Click(object sender, EventArgs e)
{
try
{
this.houseTableAdapter.Garage(this.estateAgentDataSet.house);
}
catch (System.Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message);
}
}
private void btnImport_Click(object sender, EventArgs e)
{
openFileDialog1.ShowDialog();
}
}
}
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|