|
Use the pre tag when you paste code, so that indentation is preserved.
---
b { font-weight: normal; }
|
|
|
|
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
namespace Kundekartotek
{
public class CKundekartotek
{
public CKundekartotek()
{
arrKunder = new ArrayList();
KundePegepind = 0;
}
public void NyKunde(string Navn, string Adr, string Tlf)
{
try
{
CKunde MinKunde = new CKunde(Navn, Adr, Tlf);
arrKunder.Add(MinKunde);
}
catch (Exception)
{
throw;
}
}
public void OpdaterKunde(int ID, string Navn, string Adr, string Tlf)
{
try
{
CKunde MinKunde = FindKunde(ID);
MinKunde.Opdater(Navn, Adr, Tlf);
}
catch (Exception)
{
throw;
}
}
public void SletKunde(int ID)
{
try
{
CKunde MinKunde;
MinKunde = FindKunde(ID);
arrKunder.Remove(MinKunde);
}
catch (Exception)
{
throw;
}
}
private CKunde FindKunde(int ID)
{
bool bStopIteration = false;
CKunde MinKunde = null;
IEnumerator<CKunde> MinEnumerator = arrKunder.GetEnumerator();
while (MinEnumerator.MoveNext() && bStopIteration == false)
{
MinKunde = (CKunde)MinEnumerator.Current;
if (MinKunde.ID == ID)
bStopIteration = true;
}
if (bStopIteration == true)
{
return MinKunde;
}
else
{
throw new CKartoteksException("Kunde ej fundet");
}
}
private int KundePegepind;
//FoersteKunde: Sæt pegepind til første kunde og returner denne
public CKunde FoersteKunde()
{
KundePegepind = 0;
if (arrKunder.Count == 0)
{
return null;
}
else
{
return ((CKunde)arrKunder[KundePegepind]);
}
}
//NaesteKunde: Sæt pegepind til næste kunde og returner denne
public CKunde NaesteKunde()
{
++KundePegepind;
if (KundePegepind >= arrKunder.Count)
{
--KundePegepind;
return null;
}
return ((CKunde)arrKunder[KundePegepind]);
}
}
}
|
|
|
|
|
What error are you getting? Please paste only the code you're getting an error with (or the entire function containing the error). I cannot compile that code because CKunde is not defined.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Little House on the Flickr
Judah Himango
|
|
|
|
|
Hi, sorry about my poor english, here is the code:
private CKunde FindKunde(int ID)
{
bool bStopIteration = false;
CKunde MinKunde = null;
IEnumerator<CKunde> MinEnumerator = arrKunder.GetEnumerator();
while (MinEnumerator.MoveNext() && bStopIteration == false)
{
MinKunde = (CKunde)MinEnumerator.Current;
if (MinKunde.ID == ID)
bStopIteration = true;
}
if (bStopIteration == true)
{
return MinKunde;
}
else
{
throw new CKartoteksException("Kunde ej fundet");
}
}
....and here is the error-message:
Cannot implicitly convert type 'System.Collections.IEnumerator' to 'System.Collections.Generic.IEnumerator<Kundekartotek.CKunde>'. An explicit conversion exists (are you missing a cast?)
|
|
|
|
|
Hi again..., I have solved the problem, I removed the <ckunde> and now it works, sorry to have disturbed you.
Helge
|
|
|
|
|
Sorry man, i don't know any Finnish (or wathever the language is) .
(But even if it were english, i still wouldn't be able to help... )
"..Commit yourself to quality from day one..it's better to do nothing at all than to do something badly.."
-- Mark McCormick || Fold With Us! || Pensieve || VG.Net ||
|
|
|
|
|
Do I need to do anything special to get my ListView control to display its column headers?
I've added a couple of ColumnHeader objects (with valid text and widths) to the control's Columns property but they don't appear when the form is displayed. The ListView is currently empty, but that shouldn't cause a problem.
Thanks,
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
You need to set the ListView's View property to "Details".
|
|
|
|
|
Of course - good old report view! Thanks!
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
I am trying to write a Windows Service that monitors the system for user input (either through mouse or keyboard), and shuts the system down if it has been inactive for a certain period of time. It has to be a service, because a primary requirement is that it shuts down a PC sitting at a login window.
The service needs GUI for 1) Adjusting the service settings or monitoring the service in real-time, and 2) To provide a warning window if the machine is about to shut down (only when someone has logged in).
I created the project as a Windows Service, then wrote and debugged it using Main to get the application to run, as follows:
public class AutoShutdown_Class : System.ServiceProcess.ServiceBase<br />
{<br />
<br />
.<br />
.<br />
.<br />
<br />
public static void Main ()<br />
{<br />
System.ServiceProcess.ServiceBase.Run(new AutoShutdown_Class());<br />
<br />
<br />
Event_Watcher Events = new Event_Watcher();<br />
Application.Run(new Settings());<br />
}
The program has the following classes:
1.Auto Shutdown Service - service constructor, Main, OnStart, OnStop
2.Event Watcher - monitors the system to see if there is any user input, and keeps track of how long the system has been idle. Reads and writes settings from/to a file. Shuts the PC down if it has been idle for a certain period of time.
3.Settings - Windows Form that displays a status window, which is accessed by a user through a system tray icon. Changes the user makes to the settings are passed to the Event Watcher
4.Warning - Windows Form that displays a message when a system is about to be shutdown (only when a user is logged in).
It runs as intended during debugging when coded as above; however, when I try to move the last 2 lines of code from Main into OnStart (then compile and installutil), the service won't start as it says there is no work to be done.
It seems like I've followed the wrong approach and now need to figure out how to get back on track. From reading various message boards, it appears that I need to separate the above into an application and service. I've read some (extremely abstract) code about named pipes, but I really haven't been able to make sense of 1) What parts would go into the application and what would stay in the service, and 2) how the 2 would communicate.
Any and all suggestions are welcomed
|
|
|
|
|
I still haven't gotten anywhere on this, so any help would be greatly appreciated.
|
|
|
|
|
let me know if you do. I'm trying to turn a GUI app into a service and can't find any tutorials or anything.
My articles
BlackDice
|
|
|
|
|
I'm trying to read from a text file "Amine.txt", I'm gettin a compiling error <'System.IO.StreamReader' does not contain a definition for 'close'>
here is my code:
static void Main(string[] args)
{
StreamReader re = File.OpenText("Amine.txt");
string input = null;
while ((input = re.ReadLine()) != null)
{
Console.WriteLine(input);
}
re.close;
return 0;
aPerfectTool
|
|
|
|
|
re.Close();
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hi I have a class that I want to access by remoting in network clietns machines. That class has localizable message strings in resources files in its assembly. I need that remote class object use client uiculture for message strings. Is that possible like in local model? Does remoting pick all assemblies resources? How can achive that?
Thak you!
La realidad no es más que impulsos eléctricos del cerebro - Morpheus
|
|
|
|
|
Hello,
Ok so I just figured out how to create an assembly with VS 2005 and SQL 2005 Express.
So I wanted to see if I could create a little routing that connected to my sqlserver, hit a stored procedure and returned the results to the assemply. The results would be printed out when the assembly was executed.
Here is the code for the CS file
<br />
<br />
using System;<br />
using System.Collections.Generic;<br />
using System.Text;<br />
using System.Data.SqlTypes;<br />
using System.Data.SqlClient;<br />
using Microsoft.SqlServer.Server;<br />
<br />
<br />
public class CountForMe<br />
{<br />
private System.Data.SqlClient.SqlConnection ProductionConnection;<br />
private System.Data.SqlClient.SqlCommand spListTypeCodes;<br />
<br />
<br />
[Microsoft.SqlServer.Server.SqlProcedure]<br />
public static void HereWeBe()<br />
{<br />
<br />
CountForMe cfm = new CountForMe();<br />
cfm.GetData();<br />
cfm = null;<br />
}<br />
private void GetData()<br />
{<br />
ProductionConnection = new System.Data.SqlClient.SqlConnection();<br />
spListTypeCodes = new System.Data.SqlClient.SqlCommand();<br />
ProductionConnection.ConnectionString = "{TAKEN OUT FOR SECURITY}";<br />
spListTypeCodes.CommandText = "dbo.[spListTypeCodes]";<br />
spListTypeCodes.CommandType = System.Data.CommandType.StoredProcedure;<br />
spListTypeCodes.Connection = ProductionConnection;<br />
spListTypeCodes.Parameters.Add(new System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, false, ((System.Byte)(0)), ((System.Byte)(0)), "", System.Data.DataRowVersion.Current, null));<br />
ProductionConnection.Open();<br />
SqlDataReader myReader = spListTypeCodes.ExecuteReader();<br />
if (myReader.HasRows)<br />
{<br />
string message = "";<br />
message = "Type Code: " + myReader["TypeCode"].ToString() +<br />
" Type Description: " + myReader["TypeDescription"].ToString() +<br />
" Type Code deleted: " + myReader["TypeCodeDeleted"].ToString();<br />
SqlContext.Pipe.Send(message);<br />
}<br />
myReader.Close();<br />
myReader = null;<br />
ProductionConnection.Close();<br />
}<br />
<br />
}<br />
When I run the procedure here is what I get
<br />
Msg 6522, Level 16, State 1, Procedure spSecondAttempt, Line 0<br />
A .NET Framework error occurred during execution of user defined routine or aggregate 'spSecondAttempt': <br />
System.Security.SecurityException: Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.<br />
System.Security.SecurityException: <br />
at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet)<br />
at System.Security.PermissionSet.Demand()<br />
at System.Data.Common.DbConnectionOptions.DemandPermission()<br />
at System.Data.SqlClient.SqlConnection.PermissionDemand()<br />
at System.Data.SqlClient.SqlConnectionFactory.PermissionDemand(DbConnection outerConnection)<br />
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)<br />
at System.Data.SqlClient.SqlConnection.Open()<br />
at CountForMe.GetData()<br />
at CountForMe.HereWeBe()<br />
So I checked the 2.0 snap-in tool to make sure that my assembly is running with the correct permission set.
All looked good, in the Machine zone my assembly had full trust so I am guessing that means it has permission to do what ever it wants...
any help would be great. Do I maybe have to make the SQLAgent account a member of the Administrators group?
Thanks,
Will
I hate users. Not all of them, just the ones who talk.CP member: Al Einstien
|
|
|
|
|
Hello Will. Hello Everybody.
Are you running de app from other PC?
I think that sometime I had the same error when I tried to run an app from PC1 in PC2 via LAN.
I did not found the solution but I'd read so much time later that It's necessary set permission in the Framework for do it this.
I hope that someone can help us!.
Atte. Anthony Acuña
Phrase:
Somebody tell me why it's more real when I dream that I'm wake
|
|
|
|
|
thanks for the reply..
both are on the same machine. I will look around more on the MSDN2 site.
Thanks again for the help.
Will
I hate users. Not all of them, just the ones who talk.CP member: Al Einstien
|
|
|
|
|
is it possible to insert controlls inside a listbox?
can i insert a custom control too?
|
|
|
|
|
You can find what you want if you simply go to C# section and check for Grid Controls, inserting a control into a grid is the same as a listbox you simply have to change the control's class only,i could have given you an example but all my code is based on libraries code
I've been programming since year 1999, graduated from Univeristy Paris 2 France, fluent in C,C++,VC++,Web programming (XML,HTML,php etc..),.NET frameworks,C# and ASP.NET,SQL server, Mastering VC++ .NET and SQL server,data structure and database design
|
|
|
|
|
Hi,
I have solution with 10 class library and 1 web service. When I created set up project(.msi) in 2003 it works fine but after converting all the project to .net 2.0 (2005) even though conversion worked fine. I created new set up project which creats virtual directory and puts all the files there but I am getting all sort of erros with web.config. when i replace web.config with old file i am getting errors with global.asax.
Any idea?
Thanks
|
|
|
|
|
I have called a crystal report9 in c#.It displays some data and line chart(graph) well.Now i want to change this line chart to bar graph on mouse click or on mouse over in C#.what should I do.Any expert having idea about my problem?PLz tell me solution
|
|
|
|
|
I just want to know is there any way to get the contents of a requested web page & edit it ( all the images & other multimedia files be replaced by links which when clicked displays those replaced objects in their places) wduring runtime in a C#.NET windows application.
|
|
|
|
|
In short yes.
Without writing the whole code for you (only because i am short of time) you need to create an System.Net.HttpRequest object.
HttpWebRequest req = (HttpWebRequest)WebRequest.Create("thewebpageyouwanttoget");
set the method to post and content type and any values you need and then get a webresponse back by calling
WebResponse resp = req.GetResponse()
to get the HTML of the resulting webpage just pass it into a streamreader
StreamReader sr = new StreamReader(resp.GetResponseStream())<br />
string theWebPage = sr.ReadToEnd();
Now you have the full html of the webpage in a string.... just do your search and replaces there and then pass it to your form to display.
|
|
|
|
|
Can u please explain the technique with an example,also i want to know how to display the html content of the string as a web page without using the Microsoft Browser object.
|
|
|
|