|
Hi
i've created a sample application with these characteristics :
1. I have 2 tables (Customers & Orders) in sql server database, Customers is master table and Orders is child table.
2. I have 3 forms in my app,
a. MainForm which display all customers
b. FrmCustomer which use to add new customer or edit current customer, it also display all orders of current customer.
c. FrmOrder which use to add new order or edit current order.
i want give ability to end-user to add new customer and his orders at the same time and click Ok, then my objectContext save all changes to back-end database. for example when i add new customer, FrmCustomer display me to enter new customer info, also i add some orders to his orders list, when i click OK in FrmCustomer, it should save customer and all orders Hierarchically, but it only save customer to database and not orders! can anybody help me to solve this problem ?
here is my code in MainForm to add new customer :
Customer newCust = (Customer)this.bindingSource1.AddNew();
FrmCustomer frm = new FrmCustomer(newCust,this.db);
if (frm.ShowDialog() == DialogResult.OK)
{
this.bindingSource1.Add(newCust);
db.SaveChanges(true);
}
else
{
this.bindingSource1.CancelEdit();
}
and here is my code in FrmCustomer to add new order :
Order newOrd = (Order)this.bindingSource1.AddNew();
FrmOrder frm = new FrmOrder(newOrd, this._objContext);
if (frm.ShowDialog() == DialogResult.OK)
{
this.bindingSource1.EndEdit();
}
else
{
this.bindingSource1.CancelEdit();
}
Note : db object is my global objectContext to pass to my form's constructor.
thanks in advance.
|
|
|
|
|
Check if the orders are saved to the database with no customer number.
You need to pass the new customer number to the orders object after the customer is created.
I do all this manually, call the submit method on the object (customer) in the savebutton method, get the ID returned via the object. I would also wrap the entire thing in a transaction in case it breaks, not sure you can do that using the bindingsource methods.
|
|
|
|
|
how to block pc on network from another pc
anyone can guide me
|
|
|
|
|
With C# code ? What do you want to do exactly ? Write an app that rejects all network traffic from a specific IP ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
What do you mean block? You haven't really told us much there - block access to the internet? Block people wearing purple socks accessing it?
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Pete O'Hanlon wrote: Block people wearing purple socks accessing it?
If he said yes, then how will you check this condition?
|
|
|
|
|
nagendrathecoder wrote: If he said yes, then how will you check this condition?
Using the new MS FMI API. FMI means Footwear Management Instrumentation.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
|
Hi
I'm using Linq to sql with following Connection string
"Data Source=sqlAddress;Initial Catalog=DB;Integrated Security=False;User ID=userName;Password=myPass"
Program working fine and I can protect code, string in exe using nonreverse protection but how can i protect that connection string from snifers over TCP
Thanks
|
|
|
|
|
Without knowing how or why your sending the entire connection string over the network, there's little anyone can tell you of any use.
|
|
|
|
|
|
can i make encapsulation from class to another class ??
|
|
|
|
|
If you mean 'can I encapsulate one class in another' then yes. Encapsulation is the idea of hiding the implimentation. A good example would be when a collection is being used, externally no one should see how which collection type is used, at most individual elements and an iterator are exposed.
Think this way:
A has a B - A has encapsulated the functionality of B - it has a reference to it and can use it.
A is a C - A extends C through inheritence.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
thx mster good idea
|
|
|
|
|
thanks Mr .
good Answer
Thaer
|
|
|
|
|
Nagy Vilmos wrote: Think this way:
A has a B - A has encapsulated the functionality of B - it has a reference to it and can use it.
A is a C - A extends C through inheritence.
The clearest description I have seen for a long time; many thanks.
|
|
|
|
|
I use 'has a/is a' as a rule of thumb when looking at the relationship between two classes. The problem comes when A is a B and C or has a D or C...
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
Does dotnet provide video converter APIs???
Can anyone help me out??
yogesh
|
|
|
|
|
No. You have to use a third party library to do it, or write your own (good luck with that!)
Google results for ".net video encoding[^]".
|
|
|
|
|
Could you suggest me any third party way? i have searched on google but did not get useful yet.
yogesh
|
|
|
|
|
|
Thanks for read this topic.
I'm so Confused in how to recognize these simple geometry.
Like lines,rectangular etc.
So thanks.
Thank your help~
|
|
|
|
|
kideve wrote: I'm so Confused in how to recognize these simple geometry.
Me too! What do you mean by recognize? Are you trying to create a program, and if so what is its purpose?
|
|
|
|
|
Oh,maybe that's my Syntax Error.
That's means Shape Matching.
Yes,I'm trying to create a program to do this,for lost Children.
modified on Sunday, October 4, 2009 9:39 AM
|
|
|
|
|
kideve wrote: That's means Shape Matching.
Yes,I'm trying to create a program to do this,for lost Children.
I'm sorry but I am still having trouble understanding your problem. Are you trying to recognize shapes from some input device, photographs or similar? How does this relate to lost children?
|
|
|
|