-
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();
}
}
}
-
May 25th, 2011, 12:59 PM
#2
Re: C# Form to edit a database.
I noticed the sticky that says I need to include my VS version.
Im running Visual Studio 2008. I tihnk that means im using 3.5.net.
-
May 31st, 2011, 09:27 AM
#3
Re: C# Form to edit a database.
I can provide other information if required.
-
June 1st, 2011, 09:00 PM
#4
Re: C# Form to edit a database.
Originally Posted by 27CDruid
Hi!
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?
when you say save to a data source (database) do you mean an actual database or something like a text file that is acting as a database?
if you're talking about a text file you can use System.IO.Streamwriter to append text to an existing text file.
and what is the exact purpose of the cancel button? it looks to me like a button that would clear the text boxes when clicked on it, in that case you'd want call the method clear() on them either one by one or put them in a collection class like <list> and then loop through them
hope it helps.
btw try to use tags when posting code
-
June 2nd, 2011, 12:12 PM
#5
Re: C# Form to edit a database.
Specifically, use code tags around sections of code- it formats it so it's easy to read.
If you're working with a SQL Server backend, then I highly reccomend LINQ to SQL- there are a ton of tutorials on Google for the details. It's very easy to use- much easier than ADO.NET (in my opinion).
Code:
if (Issue.Resolved)
{
ThreadTools.Click();
MarkThreadResolved();
}
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
|