|
You have to return the newly created ID's from the first insert and update your data before sending the second insert.
A better solution may be to parcel the whole data set up as xml, pass it into a stored procedure, then you can process the whole lot in one shot.
If you have knowledge, let others light their candles at it.
Margaret Fuller (1810 - 1850)
www.JacksonSoft.co.uk
|
|
|
|
|
The application shouldn't know or care about the details; all that should be handled in the Data Access Layer.
|
|
|
|
|
Hi every Body.
please tell me why do you we use cookie and session in web site?
thank you.
|
|
|
|
|
Cookies are used to persist data on the client so that it can be reused by your web page when it is next loaded. Session variable are similar, but on the server end. However as these are linked to a particular session ID they will go away after a bit when the client leaves your web site as they are stored in memory. However, cookies are saved to disk, and may be deleted by the end user.
Many sites do not use either, and don't need to.
It all depends what you want to do, and how you want your web app to work.
If you have knowledge, let others light their candles at it.
Margaret Fuller (1810 - 1850)
www.JacksonSoft.co.uk
|
|
|
|
|
|
hi,
i have to restore a java window that is minimized in systray (process is: javaw.exe) and not shown in the taskbar.
i get the processid by process.getprocess but the mainwindowhandle is 0 if the window is minimized.
does anyone knows how i can get the main window handle? the window title is known.
thank you.
|
|
|
|
|
I think the window is closed at this moment.
Can't you send a message to the process?
|
|
|
|
|
now i can get the handle by form caption (GetWindowByCaption) but it looks frozen (no repaint, the textboxes are complety missing). but it seems i am able to set the needed values.
thanks for ur help!
|
|
|
|
|
|
I have a new windows application project using C# and I make setup project.
In the windows application project I have MDIParent as Main Form and i write this code to change the language from English to Arabic:
System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("ar-EG");
System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("ar-EG");
this.Controls.Clear();
this.InitializeComponent();
this method is fine when i run the application.
but when i install the setup project this method not change any thing.
i need help about this problem.
thanks
wael salem
|
|
|
|
|
I'm having trouble implementing a depth chart for my football simulator program. The way my program is structured, I have a Player class, a Team class, and a League class--the core classes. The depthchart would group players by their position and, by each position, sort by OVR (integer) in descending order (but only if their injury status is "false"--governed by a CanPlay method in my Player class; otherwise, they are not eligible for the depthchart). Position is a PlayerPosition type and PlayerPosition is enumerated as such:
[code]
public enum PlayerPosition { QB, HB, WR, TE, LT, LG, C, RG, RT, DE, DT, OLB, MLB, CB, FS, SS }
[/code]
This is in my Team class:
[code]
public List<Player> depthChart { get; set; }
public List<Player>[] DepthChart
{
get
{
var result = new List<Player>[Enum.GetValues(typeof(PlayerPosition)).Length];
foreach (PlayerPosition pos in Enum.GetValues(typeof(PlayerPosition)))
{
result[(int)pos] = this.Players.Where(pl => pl.position == pos && pl.CanPlay).OrderByDescending(pl => pl.OVR).ToList();
}
return result;
}
[/code]
These are in my Main() method: two attempts to obtain information from the depth chart.
Method 1:
[code]
Team t = league.Teams[0];
var depthChart = t.DepthChart;
Console.WriteLine(depthChart);
[/code]
Method 2:
[code]
foreach (PlayerPosition pos in Enum.GetValues(typeof(PlayerPosition)))
{
Console.Write(pos.ToString() + ':');
depthChart[(int)pos].ForEach(p => Console.Write(' ' + p.lastName));
Console.WriteLine();
}
[/code]
For method 1, I get on the console readout: System.Collections.Generic.List`1[FranchiseSim.Player][]
For method 2, I get on the console readout only the proper position strings (like QB, RB, etc.) and the colon ( but nothing from the depth chart.
|
|
|
|
|
First, a direct answer to your questions:
Method 1
var depthChart = t.DepthChart;
Console.WriteLine(depthChart);
depthChart will be a List<Player> so the .ToString() method will just return the typename of the depthChart . To get the player roster you need to iterate over the list and get output each player individually. You should put a method in your Team class (NOT in the main method- bad encapsulation).
Method 2
foreach (PlayerPosition pos in Enum.GetValues(typeof(PlayerPosition)))
{
Console.Write(pos.ToString() + ':');
depthChart[(int)pos].ForEach(p => Console.Write(' ' + p.lastName));
Console.WriteLine();
}
Is more complicated. The position of a type of player in the depth chart doesn't correspond to the position in the depthChart list, unless you ONLY add them in the order they appear in the enum. To do so would be very bad design. If (and only if) you have one player per position, you could consider a Dictionary<PlayerPosition, Player> Though even this is messy.
Now for the hard part, I think the overall design of the above is wrong. Some people will disagree with me, others will (hopefully) agree you can wrapper all the following up in <IMO> tags if you like . There is debate about the use of enums . I fall into the camp that they are [mostly] evil. The prescence of enums normally indicates a lack of polymorphism that should be expressed. In your case I think you should have something like the following:
public Interface IPlayer
{
string Surname {get; set;}
string PositionName { get; }
}
public abstract class Player : IPlayer
{
public string Surname {get; set;}
public string PositionName { get; protected set; }
}
public class QuaterBack : Player
{
public QuaterBack()
{
PositionName = "Quater Back";
}
}
public class WideReciever : Player
{
public QuaterBack()
{
PositionName = "Wide Reciever";
}
}
public interface ITeam
{
List<IPlayer> Players {get; }
}
public class Team : ITeam
{
public List<IPlayer> Players {get; private set}
public string TeamRoster()
{
string roster = "";
Players.ForEach( p=> roster += p.PositionName + ": " + p.Surname + " ");
return roster;
}
public Team()
{
Players = new List<IPlayer>();
}
}
The big question should now be why bother? Functionality is now encapsulated in the correct place, Player handles whatever the player does,Team will handle team-level stuff. Also, you can add extra properties to Player , for example a Positional Shortcode e.g. ("QB"), in the original implementation you would have to keep a dictionary for such information (and any other information relating to the position. Additionally The above can be made to demonstrate polymorhpism: As an example, let's say only Quaterbacks are allowed to kick off (I don't know enough about American football for a real example), you can add a KickOff method to a Quaterback without implementing it for any of the other player types. Not only that, but long enums often lead to messy switch statements (or long lists of if s), giving off a rank code-smell as they go.
The code I've given isn't perfect (I haven't thought about it very deeply), but hopefully will provide a starting point. For example, I think there really should be a IPlayerType interface subclassed by PlayerType type inherted per position (e.g. QuaterBack ), and the Player should expose a property of IPlayerType , rather than BE a QuaterBack or LineBack or whatever. This will allow the player to change position easily and encapsultes the position properly, against the player.
Take a look at for some started WRT enums:
http://devpinoy.org/blogs/cruizer/archive/2007/09/12/enums-are-evil.aspx[^]
and http://www.colourcoding.net/Blog/archive/2009/07/25/enums-are-evil-the-state-pattern.aspx[^]
One of the problems in describing the reason why you shouldn't use enums is that they work when starting out writing a class (so any explanation of why not to use them seems longer/harder than the original), but as the class develops the shortfalls start to appear.
Hope this helps!
CCC solved so far: 2 (including a Hard One!)
37!?!! - Randall, Clerks
|
|
|
|
|
Thank you for your response. I've considered your ideas and it occurred to me that maybe all of this isn't necessary afterall; perhaps, for each team, I could simply list each position with each player at that position in descending order by OVR with simple loops.
This is in my Main() method
foreach (Team t in league.Teams)
{
Console.WriteLine("");
Console.WriteLine(t.Name + " " + t.Nickname);
foreach (PlayerPosition pos in Enum.GetValues(typeof(PlayerPosition)))
{
Console.WriteLine(pos);
league.AllPlayers.Where(pl => pl.position == pos).OrderByDescending(pl => pl.OVR).ToList().ForEach(pl => pl.Print());
}
}
The only problem with this code is that for each team displayed, it's putting ALL of the players in the league, regardless of what team they're on, in each team's roster that is displayed.
I believe has to do with the AllPlayers designation. This is located in my League class:
public List<Player> AllPlayers
{
get
{
var list = from t in Teams
from p in t.Players
select p;
return list.ToList();
}
}
How would you suggest I fix this?
|
|
|
|
|
This idea is not good from a from an oo point of view. It is important to encapsulate your classes properly.
You have a need for a team class, it should be responsible for maintaining it's own list of players. Likewise each player must maintain it's own information (e.g. Name, Position etc).
I suggest you try my example. To get the list of players in a particular position, you would just have to loop around each team, then loop each roster looking for players of the type required.
I also suggest you find a good OO book and learn the basic principles. If you are using an OO language like C#, learning OO principles will make coding easier for you, and the code you will produce will be neater and easier to maintain and understand. It is difficult to make the mental shift from procedure to object oriented programming, but doing so will make your life easier when using c# and is well worth the effort.
CCC solved so far: 2 (including a Hard One!)
37!?!! - Randall, Clerks
|
|
|
|
|
I have a winform with two texboxes, one below the other.
When i resize horizontal there is no problem, but when i want to resize vertical only can resize one and i need to resize both proportionally.
Already tryed many anchor property configurations without luck...
Any idea?
Thanks in advance.
|
|
|
|
|
Hi,
I was thinking about Anchor property as well. How about using a SplitContainer in a horizontal oritation, with two textBoxes Dock property set as Fill?
Br!"
Sun
|
|
|
|
|
You suggestion not soove my needs... each texbox is on different groupbox...
|
|
|
|
|
I solved it with main form Resize event... and playing with groupbox Top and Height properties.
Thanks anyways....
|
|
|
|
|
Hi,I am doing a project related to image erosion .. can someone help me to write codings for th erosion process alone in c# (windows application).
|
|
|
|
|
hi,this is suhdir final year in computer science and engineering.i am doing a project for my final year.project is a chatting software.project details:
software is similar to gtalk and diffrence is here conference call is possible.i have done the chatting part but one thing i am in delema how to make call??plz give me some idea how to make call.time is short in my hand.plz help me.
|
|
|
|
|
Are you talking about this :
http://dotnet.org.za/ruari/archive/2004/11/10/6254.aspx
In fact, I havent tried it. I did a chat application but not actually making conference calls.
Might be some1 else can help.
|
|
|
|
|
Hi,
Does anyone have idea on how to create a few radio buttons using data from XML file?
I would like to have the buttons to be created once I load the form. But I do not have any idea as I started learn about XML today.
Thank you in advance.
Zar Ni
|
|
|
|
|
Well.. just parse the XML document (plenty of tutorials online) and find the elements representing the radio buttons. And in your Form_Load event you create the buttons and add them to the Form. Good luck!
|
|
|
|
|
Can't work out what I'm doing wrong. When I programmatically add a button to the first cell of a table layout panel by calling 'tlp.Controls.Add(newButton, 0, 0) ' it works the first three times, shifting existing controls along a cell as expected. However after the third time the same code inserts the button into the second cell a few times, then after more calls, the third etc. Examlpe code below.
Is there a limit on how many times you can call Controls.Add(ctrl, column, row) for a given cell?
private int nextIndex = 1;
private void bAddButton_Click(object sender, EventArgs e)
{
Button newButton = new Button();
newButton.Text = nextIndex.ToString();
tableLayoutPanel1.Controls.Add(newButton, 0, 0);
nextIndex++;
}
|
|
|
|
|
Message Closed
modified 23-Nov-14 7:05am.
|
|
|
|
|