|
You have implemented the function ReserveOrCancelSeat to accept one parameter SeatManager.DisplayOptions choice . This means that when you call the function you should supply the needed parameter. Have a look at this tutorial: Functions - C# Tutorial[^].
In your implementation of the ReserveOrCancelSeat function the parameter SeatManager.DisplayOptions choice is not used. So removing the parameter would solve your problem, but you first might want to look into why you are not using it.
Good luck.
0100000101101110011001000111001011101001
|
|
|
|
|
ReserveOrCancelSeat(SeatManager.DisplayOptions choice); gives me 3 errors
1. ) expected
2. ; expected
3. Invalid expression term ')'
|
|
|
|
|
Did you change
private void btnOK_Click(object sender, EventArgs e)
{
ReserveOrCancelSeat();
}
into
private void btnOK_Click(object sender, EventArgs e)
{
ReserveOrCancelSeat(SeatManager.DisplayOptions choice);
} because that is not going to work.
Did you read the tutorial[^]. You really need to understand how functions work.
0100000101101110011001000111001011101001
|
|
|
|
|
Yes i changed it into ReserveOrCancelSeat(SeatManager.DisplayOptions choice);
So whats the solution i have been trying to figure it out for long time. im a beginner
|
|
|
|
|
Reverse the changes you made.
Then change your function implementation from
private void ReserveOrCancelSeat(SeatManager.DisplayOptions choice) into
private void ReserveOrCancelSeat()
If you want to improve your knowledge of functions read the tutorial[^].
0100000101101110011001000111001011101001
|
|
|
|
|
you have to provide us with the members of the SeatManager.DisplayOptions enum to help you choose one of them as a parameter to you function
as example if your SeatManager.DisplayOptionsenum is
<pre lang="C#">
enum SeatManager.DisplayOptionsenum
{
choice1
choice2
choice3
choice4
}
</pre>
you can call your function like this
<pre lang="C#">
private void btnOK_Click(object sender, EventArgs e)
{
ReserveOrCancelSeat( SeatManager.DisplayOptionsenum.choice1); // here comes the error message
}
</pre>
|
|
|
|
|
Thank you that helpt alot!
|
|
|
|
|
Well. I have done a small project.
But the problem is some of my required data is not available across whole project.
I mean, every time I go form to form I need to open the database and fill the same data from the same SqlDataAdapter.
Instead is it possible to keep the data somewhere globally for all the project forms?
With my project I have a class for the queries and tables and wherever I need data in the forms, there I use to call the Subs for filling the table like the below...
Class1.cs
=========
public void MyTableFill()
{
Con.ConnectionString = Con_1;
Con.Open();
SQLDAp = new SqlDataAdapter(MyQry, Con);
SQLDAp.Fill(MyTable);
Con.Close();
}
Form1.cs
========
Class1 MyDatas = new Class1();
Form1_Load()
{
MyDatas.MyTableFill();
}
Form2.cs
========
Class1 AccDatas=new Class1();
Form2_Load()
{
AccDatas.MyTableFill();
}
Thanks
|
|
|
|
|
|
I keep a static class that hold all the lists that support dimension data (typically stuff for comboboxes), every form uses this for static data. When the get accessor is called it checks for content and if there is none it gets the data from the database.
If the app changes the static data then the list is set to null. Next time it is requested the data is refreshed from the database. This does not work well for asynch processing (Silverlight);
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
The data access should not be in the UI layer at all. Have a separate class that encapsulates the data access and pass a reference to an instance of it to each form.
|
|
|
|
|
the best way is to create a global class and retrieve information from the database and store it in that class, and when any form needs that data it reads it from the global class
|
|
|
|
|
Use layered approach (tier). In your case three tier approach is suitable: DAL–Data Access Layer, BLL–Business Logic Layer and GUI –Graphical User Interface.
|
|
|
|
|
Dear Fellows,
I have only this question that can some one show me the sample of Inventory Database software in a form of images because I don't seen this software before so I got task its not a project its just a assignment for me so I don't know where to start how this inventory database software looks like how many labels, text boxes, what features are in main menu etc etc so can some one guide me???
Any help or assistance will be appreciated.
thanks
================================================
be happy always and also keep other happy as well...
================================================
|
|
|
|
|
How this software would look depends on what it would need to do.
So you first would need to write down its functional requirements.
If you want some samples of similar software use Google[^] and browse the links given.
0100000101101110011001000111001011101001
|
|
|
|
|
We have already explained to you here[^] that this question is too broad to be answered in these forums. There is no standard Supermarket Software that can be given to you; you need to design it based on the requirements of your Supermarket. If you really do not understand how to design a database then either you are on the wrong study course or in the wrong job.
|
|
|
|
|
Enable or disable controls inside the groupbox based on the checkbox state. If checkbox is unchecked and the groupbox and all controls inside are hidden. For a tri-state checkbox in immediate state, all controls inside are just disabled.
|
|
|
|
|
This is a follow-up question to: [^] posted in the C# Q/A Forum.
Why not post this question in C# Q/A forum, as well ?
"Beauty is in the eye of the beholder, and it may be necessary from time to time to give a stupid or misinformed beholder a black eye." Miss Piggy"
|
|
|
|
|
I have this sample data. Right now it is defined in a seperate C# file like this:
public class SampleData
{
public static ObservableCollection<Product> GetSampleData()
{
ObservableCollection<Product> teams = new ObservableCollection<Product>();
}
}
and I load the obsevableCollection inside GetSampleData().
It works and I am able to get the sample data anywhere in my program.
But how can I redesign this code so that I can create the sample data on the fly from outside the class?
|
|
|
|
|
0. 'as is' the code shown here will not work: your definition of 'GetSampleData' is supposed to return an ObservableCollection<product>, and it does not.
1. Why not make the Class 'static' as well ? As the code is now, the Class will have to be instantiated with 'new'
2. please explain more clearly exactly what you mean by "get the sample data on the fly from outside the class." You mean from a database ?
Would something like this work for you:
public static class SampleData
{
public static ObservableCollection<Product> teams = new ObservableCollection<Product>();
public static void GetSampleData()
{
// code here to access a database or whatever to fill the teams<Product> collection
}
}
In this type of access-model, once you have called 'GetSampleData,' and filled the 'teams' global static variable, you can access it from anywhere in your project by: SampleData.teams
Note: since you are using ObservableCollection, my guess is your intent is to make use of PropertyChanged and/or CollectionChanged facilties: I have not thought through the implications of making a static ObservableCollection.
There's a great new article here on CP about ObservableCollection I recommend you see: Enhanced ObservableCollection with ability to delay or disable notifications[^]
best, Bill
"Beauty is in the eye of the beholder, and it may be necessary from time to time to give a stupid or misinformed beholder a black eye." Miss Piggy"
|
|
|
|
|
Dear friends I have simple experience programming with C#,but new to deal with graph data structure. when I got some examples from MSDN which is the following
I face this error message Error
'WindowsApplication4.Graph<t> does not implement interface member 'System.Collections.IEnumerable.GetEnumerator()
'WindowsApplication4.Graph<l>GetEnumerator()' is either static, not public, or has the wrong return type.
and I had changed the return data type to all possible type and the error still the same please help me to overcome this problem.
#region Using directives
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
#endregion
namespace WindowsApplication4
{
public class Graph<T> : IEnumerable<T>
{
#region Private Member Variables
private NodeList<T> nodeSet;
#endregion
#region Constructors
public Graph() : this(null) { }
public Graph(NodeList<T> nodeSet)
{
if (nodeSet == null)
this.nodeSet = new NodeList<T>();
else
this.nodeSet = nodeSet;
}
#endregion
#region Methods
#region Add
#region AddNode
#region IEnumerable<T> Members
public IEnumerator<T> GetEnumerator()
{
foreach (GraphNode<T> gnode in nodeSet)
yield return gnode.Value;
}
#endregion
public void AddNode(GraphNode<T> node)
{
nodeSet.Add(node);
}
public void AddNode(T value)
{
nodeSet.Add(new GraphNode<T>(value));
}
#endregion
#region Add*Edge Methods
public void AddDirectedEdge(T from, T to)
{
AddDirectedEdge(from, to, 0);
}
public void AddDirectedEdge(GraphNode<T> from, GraphNode<T> to)
{
AddDirectedEdge(from, to, 0);
}
public void AddDirectedEdge(GraphNode<T> from, GraphNode<T> to, int cost)
{
from.Neighbors.Add(to);
from.Costs.Add(cost);
}
public void AddDirectedEdge(T from, T to, int cost)
{
((GraphNode<T>)nodeSet.FindByValue(from)).Neighbors.Add(nodeSet.FindByValue(to));
((GraphNode<T>)nodeSet.FindByValue(from)).Costs.Add(cost);
}
public void AddUndirectedEdge(T from, T to)
{
AddUndirectedEdge(from, to, 0);
}
public void AddUndirectedEdge(GraphNode<T> from, GraphNode<T> to)
{
AddUndirectedEdge(from, to, 0);
}
public void AddUndirectedEdge(GraphNode<T> from, GraphNode<T> to, int cost)
{
from.Neighbors.Add(to);
from.Costs.Add(cost);
to.Neighbors.Add(from);
to.Costs.Add(cost);
}
public void AddUndirectedEdge(T from, T to, int cost)
{
((GraphNode<T>)nodeSet.FindByValue(from)).Neighbors.Add(nodeSet.FindByValue(to));
((GraphNode<T>)nodeSet.FindByValue(from)).Costs.Add(cost);
((GraphNode<T>)nodeSet.FindByValue(to)).Neighbors.Add(nodeSet.FindByValue(from));
((GraphNode<T>)nodeSet.FindByValue(to)).Costs.Add(cost);
}
#endregion
#endregion
#region Clear
public void Clear()
{
nodeSet.Clear();
}
#endregion
#region Contains
public bool Contains(T value)
{
return nodeSet.FindByValue(value) != null;
}
#endregion
#region Remove
public bool Remove(T value)
{
GraphNode<T> nodeToRemove = (GraphNode<T>)nodeSet.FindByValue(value);
if (nodeToRemove == null)
return false;
nodeSet.Remove(nodeToRemove);
foreach (GraphNode<T> gnode in nodeSet)
{
int index = gnode.Neighbors.IndexOf(nodeToRemove);
if (index != -1)
{
gnode.Neighbors.RemoveAt(index);
gnode.Costs.RemoveAt(index);
}
}
return true;
}
#endregion
#endregion
#region Public Properties
public NodeList<T> Nodes
{
get
{
return nodeSet;
}
}
public int Count
{
get { return nodeSet.Count; }
}
#endregion
}
}
|
|
|
|
|
Didn't look at everything, but IEnumerable<T>.GetEnumerator() is supposed to return a class of something that implements IEnumerator<T>. Its not supposed to return your object. IEnumerator<T> implements methods to do that.
|
|
|
|
|
From a quick scan of your code, it looks like you know that both IEnumerable<t> and IEnumerable() interfaces must both be implemented, but you have your non-generic 'GetEnumerator() commented out: why ?
The other thing that 'jumps out' from the code is that while 'Graph implements IEnumerable, you don't seem to be taking advantage that an instance of 'Graph is inherently a List.
To really help with this, I think we'd need to know how and where you implement 'GraphNode and 'NodeList.
Have you googled on this error message, and looked on StackOverFlow, as well as CP, for similar questions ?
best, Bill
"Beauty is in the eye of the beholder, and it may be necessary from time to time to give a stupid or misinformed beholder a black eye." Miss Piggy"
|
|
|
|
|
The short answer to this is that IEnumerable<T> also mandates that you implement IEnumerable, which requires a method of signature
IEnumerator GetEnumerator()
Fortunately IEnumerator<T> similarly mandates IEnumerator, so you can fulfil this contract with an explicit interface implementation:
IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); }
(If you need to write an enumerator yourself, there's a similar issue with the Current property in IEnumerator<T> and IEnumerator, and a similar fix to return the same value but cast to object.)
However, as already pointed out, your graph is essentially wrapping a NodeList, and that already implements IEnumerable<T>. Instead of making an intermediate iterator, why not just forward the interface methods directly to the inner list?
IEnumerator<T> IEnumerable<T>.GetEnumerator() { return nodeList.GetEnumerator(); }
IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); }
(I've done both as explicit for symmetry and because you shouldn't be calling GetEnumerator directly; only one of them needs to be explicit.)
|
|
|
|
|
Dear Sir,
I had tried your kind suggestion ,but unfortunately faild as shown below.please could you help me by making the changes on the following code segment and returned it to me “I’m very sorry to bother you………”
Error 3 foreach statement cannot operate on variables of type 'WindowsApplication4.NodeList<t>' because 'WindowsApplication4.NodeList<t>' does not contain a public definition for 'GetEnumerator'
namespace WindowsApplication4
{
///
/// Represents a graph. A graph is an arbitrary collection of GraphNode
instances.
///
/// <typeparam name="T">The type of data stored in the graph's
nodes.
public class Graph<t> : IEnumerable<t>
{
#region Private Member Variables
private NodeList<t> nodeSet; // the set of nodes in the graph
#endregion
#region Constructors
public Graph() : this(null) { }
public Graph(NodeList<t> nodeSet)
{
if (nodeSet == null)
this.nodeSet = new NodeList<t>();
else
this.nodeSet = nodeSet;
}
#endregion
#region Methods
#region Add
#region AddNode
///
/// Adds a new GraphNode instance to the Graph
///
/// <param name="node" />The GraphNode instance to add.
///
#region IEnumerable<t> Members
///
/// Returns an enumerator that allows for iterating through the
contents of the graph.
public IEnumerator<t> GetEnumerator()
{
foreach (GraphNode<t> gnode in nodeSet)
yield return gnode.Value;
}
#endregion
////////////////////////////////////////////////////////////
IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); }
public void AddNode(GraphNode<t> node)
{
// adds a node to the graph
nodeSet.Add(node);
}
///
/// Adds a new value to the graph.
///
/// <param name="value" />The value to add to the graph
public void AddNode(T value)
{
nodeSet.Add(new GraphNode<t>(value));
}
#endregion
#region Add*Edge Methods
///
/// Adds a directed edge from a GraphNode with one value (from) to a GraphNode with another value (to).
///
/// <param name="from" />The value of the GraphNode from which the directed edge eminates.
/// <param name="to" />The value of the GraphNode to which the edge leads.
public void AddDirectedEdge(T from, T to)
{
AddDirectedEdge(from, to, 0);
}
and if I Changed it to public like this
public IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); }
Error 1 The modifier 'public' is not valid for this item
|
|
|
|