|
Hi All,
Can anybody let me know how to convert numeric values into words
ex.. 723890-- Seven Lakh Twenty Three Thousand Eight Hundred Ninety Only
But plz give me the answer of my this problem into indian currency meand hundreds,thousands,lakhs,crores.............................and etc
Thnx in advance
|
|
|
|
|
|
Hello,
I am having an EventReader.cs class which is polling for the events from the server. It is done thru Thread. The class EventReader.cs is as follows:
EventReader.cs
==================================Start of “EventReader.cs”==============
<br />
using System;<br />
<br />
using System.Collections.Generic;<br />
<br />
using System.Text;<br />
<br />
using DemoClient.PerspectiveMgtAPI;<br />
<br />
using System.Threading;<br />
<br />
using System.Diagnostics;<br />
<br />
using System.Collections;<br />
<br />
using System.ComponentModel;<br />
<br />
<br />
<br />
namespace DemoClient.proxy<br />
<br />
{<br />
<br />
public class EventReader : BackgroundWorker<br />
<br />
{<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
private readonly PerspectiveMgtProxy mPerspectiveMgt;<br />
<br />
private readonly Queue<EventInfo> mEventQueue;<br />
<br />
<br />
<br />
private bool mStatus;<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
public void runPoller ()<br />
<br />
{<br />
<br />
while (mStatus)<br />
<br />
{<br />
<br />
Console.WriteLine("Reading events in the Poller....****************************");<br />
<br />
<br />
<br />
EventInfo[] events = mPerspectiveMgt.getService().getEvents(mPerspectiveMgt.getSessionId());<br />
<br />
Console.WriteLine("Getting events: " + events.Length);<br />
<br />
foreach (EventInfo eventInfo in events)<br />
<br />
{<br />
<br />
fireEvent(eventInfo);<br />
<br />
}<br />
<br />
<br />
<br />
}<br />
<br />
}<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
public EventReader (PerspectiveMgtProxy aPerspectiveMgt)<br />
<br />
{<br />
<br />
mPerspectiveMgt = aPerspectiveMgt;<br />
<br />
<br />
<br />
mEventQueue = new Queue<EventInfo>(); <br />
<br />
<br />
<br />
Thread pollerThread = new Thread(new ThreadStart(runPoller));<br />
<br />
pollerThread.IsBackground = true;<br />
<br />
pollerThread.Start(); <br />
<br />
}<br />
<br />
<br />
<br />
<br />
<br />
public void start ()<br />
<br />
{<br />
<br />
mStatus = true; <br />
<br />
}<br />
<br />
<br />
<br />
<br />
<br />
public void stop ()<br />
<br />
{<br />
<br />
mStatus = false; <br />
<br />
}<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
private void fireEvent (EventInfo anEventInfo)<br />
<br />
{<br />
<br />
Console.WriteLine("(*) fireEvent: " + anEventInfo.eventName);<br />
<br />
Console.WriteLine("(*) Event: " + EventName.DispletAdded.ToString()); <br />
<br />
<br />
<br />
if (anEventInfo.eventName == EventName.DispletAdded.ToString())<br />
<br />
{<br />
<br />
fireDispletAdded(anEventInfo);<br />
<br />
}<br />
<br />
<br />
<br />
String objectType = anEventInfo.sourceType;<br />
<br />
int objectId = anEventInfo.sourceId;<br />
<br />
<br />
<br />
EventName eventType = findEventType(anEventInfo.eventName);<br />
<br />
if (eventType == null)<br />
<br />
{<br />
<br />
Console.WriteLine("TODO: specified event not available");<br />
<br />
return;<br />
<br />
}<br />
<br />
<br />
<br />
<br />
<br />
private EventName findEventType (String anEventName)<br />
<br />
{<br />
<br />
try<br />
<br />
{<br />
<br />
return (EventName)Enum.Parse(typeof(EventName), anEventName);<br />
<br />
}<br />
<br />
catch (Exception e)<br />
<br />
{<br />
<br />
Console.WriteLine("No event is found with the given name: " + anEventName);<br />
<br />
}<br />
<br />
<br />
<br />
return 0;<br />
<br />
}<br />
<br />
<br />
<br />
<br />
<br />
private void pushEventToQueue (EventInfo anEventInfo)<br />
<br />
{<br />
<br />
lock (this)<br />
<br />
{<br />
<br />
<br />
mEventQueue.Enqueue(anEventInfo);<br />
<br />
<br />
<br />
Monitor.Pulse(this);<br />
<br />
}<br />
<br />
}<br />
<br />
<br />
<br />
<br />
<br />
private EventInfo popEventFromQueue ()<br />
<br />
{<br />
<br />
lock (this)<br />
<br />
{<br />
<br />
while (mEventQueue.Count == 0)<br />
<br />
{<br />
<br />
Monitor.Wait(this);<br />
<br />
} <br />
<br />
<br />
<br />
return mEventQueue.Dequeue();<br />
<br />
} <br />
<br />
}<br />
<br />
<br />
<br />
<br />
<br />
private void fireDispletAdded (EventInfo anEvent)<br />
<br />
{<br />
<br />
Console.WriteLine("fireDispletAdded (Event=" + anEvent + ")");<br />
<br />
<br />
<br />
String[] values = anEvent.values;<br />
<br />
<br />
<br />
<br />
int perspectiveId = anEvent.sourceId;<br />
<br />
int displetId = Convert.ToInt32(values[0]);<br />
<br />
<br />
<br />
ObjectId pId = new ObjectId();<br />
<br />
pId.id = perspectiveId;<br />
<br />
<br />
<br />
Perspective perspective = PerspectiveMgtProxy.getInstance().findPerspective(pId);<br />
<br />
<br />
<br />
ObjectId dId = new ObjectId();<br />
<br />
dId.id = displetId;<br />
<br />
<br />
<br />
Displet displet = PerspectiveMgtProxy.getInstance().getDisplets(new ObjectId[] {dId})[0];<br />
<br />
<br />
<br />
<br />
IEnumerator myEnumerator = EventListenerList.getInstance().getPerspectiveListeners().GetEnumerator();<br />
<br />
while(myEnumerator.MoveNext())<br />
<br />
{<br />
<br />
PerspectiveListener listener = ((PerspectiveListener)myEnumerator.Current);<br />
<br />
<br />
<br />
PerspectiveEvent perspectiveEvent = new PerspectiveEvent(perspective, displet);<br />
<br />
listener.displetAdded(perspectiveEvent);<br />
<br />
<br />
<br />
Console.WriteLine("fireDispletAdded invoked.");<br />
<br />
}<br />
<br />
}<br />
<br />
}<br />
<br />
}
===============================End of “EventReader.cs”==========================
I am getting the geometry for the sources as well the Name & Path of the source from the server. I am drawing the labels to show the sources at the runtime. I have created a Window Form “PerspectiveWindow.cs” which is containing those labels showing the sources. Now when a new source is being added at the server side I am using “DispletAdded” Event to update my PerspectiveWindow and draw the respective displet containing the source. I am doing this in a internal class in “PerspectiveWindow.cs” itself. I am able to get the events but I am not able to draw the new displet on the Window since an exception is raised at the time of adding the control to the Form as a Label with the respective geometry and name.
mWindow.Controls.Add(label1); -- This line raises the exception InvalidOperationException : “Cross-thread operation not valid: Control "PerspectiveWindow" accessed from a thread other than the thread it was created on.”
The code snippet for PerspectiveWindow.cs is as follows:
PerspectiveWindow.cs
======================Start of File “PerspectiveWindow.cs”=========================
<br />
using System;<br />
<br />
using System.Collections.Generic;<br />
<br />
using System.ComponentModel;<br />
<br />
using System.Data;<br />
<br />
using System.Drawing;<br />
<br />
using System.Text;<br />
<br />
using System.Windows.Forms;<br />
<br />
using DemoClient.proxy;<br />
<br />
using DemoClient.PerspectiveMgtAPI;<br />
<br />
<br />
<br />
namespace DemoClient<br />
<br />
{<br />
<br />
public partial class PerspectiveWindow : Form<br />
<br />
{<br />
<br />
<br />
<br />
private Perspective mPerspective;<br />
<br />
private PerspectiveListener mPerspectiveHandler;<br />
<br />
<br />
<br />
<br />
<br />
public PerspectiveWindow ()<br />
<br />
{<br />
<br />
InitializeComponent();<br />
<br />
}<br />
<br />
<br />
<br />
public void init (Perspective aPerspective)<br />
<br />
{<br />
<br />
mPerspective = aPerspective;<br />
<br />
}<br />
<br />
<br />
<br />
<br />
<br />
public void PerspectiveWindow_Load (object sender, EventArgs e)<br />
<br />
{<br />
<br />
Console.WriteLine("OnLoad....");<br />
<br />
<br />
<br />
if (mPerspective == null)<br />
<br />
return;<br />
<br />
<br />
<br />
Console.WriteLine("Perspective: " + mPerspective.ToString());<br />
<br />
<br />
<br />
SuspendLayout();<br />
<br />
<br />
<br />
this.Text = mPerspective.getName();<br />
<br />
this.Size = mPerspective.getDimension(); <br />
<br />
<br />
<br />
ResumeLayout(false);<br />
<br />
PerformLayout();<br />
<br />
<br />
<br />
Console.WriteLine("Perspective widget added to the Perpective window");<br />
<br />
<br />
<br />
mPerspectiveHandler = new PerspectiveEventHandler(this); <br />
<br />
mPerspective.addPerspectiveListener(mPerspectiveHandler);<br />
<br />
}<br />
<br />
<br />
<br />
<br />
<br />
<br />
internal class PerspectiveEventHandler : PerspectiveListener<br />
<br />
{<br />
<br />
private PerspectiveWindow mWindow;<br />
<br />
<br />
<br />
public PerspectiveEventHandler (PerspectiveWindow aWindow)<br />
<br />
{<br />
<br />
mWindow = aWindow;<br />
<br />
}<br />
<br />
<br />
<br />
public void displetAdded (PerspectiveEvent anEvent)<br />
<br />
{<br />
<br />
Console.WriteLine("(+) Displet added: ", anEvent);<br />
<br />
drawDisplet();<br />
<br />
Console.WriteLine("(+) Displet added returned.");<br />
<br />
}<br />
<br />
<br />
<br />
<br />
<br />
public void displetRemoved (PerspectiveEvent anEvent)<br />
<br />
{<br />
<br />
Console.WriteLine("(-) Displet removed: ", anEvent);<br />
<br />
}<br />
<br />
<br />
<br />
<br />
<br />
public void displetsZOrderChanged (PerspectiveEvent anEvent)<br />
<br />
{<br />
<br />
Console.WriteLine("(-) displetsZOrderChanged: ", anEvent);<br />
<br />
}<br />
<br />
<br />
<br />
<br />
<br />
private void drawDisplet ()<br />
<br />
{<br />
<br />
DispletInfo info = new DispletInfo();<br />
<br />
<br />
<br />
String sourceName = info.name;<br />
<br />
<br />
<br />
<br />
Label label1 = new Label();<br />
<br />
label1.BackColor = System.Drawing.SystemColors.ControlLightLight;<br />
<br />
label1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;<br />
<br />
label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F,<br />
<br />
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));<br />
<br />
label1.Location = new System.Drawing.Point(info.x, info.y);<br />
<br />
label1.Size = new System.Drawing.Size(info.width, info.height);<br />
<br />
label1.TabIndex = 1;<br />
<br />
label1.Text = sourceName;
<br />
<br />
<br />
mWindow.Controls.Add(label1);
<br />
}<br />
<br />
}<br />
<br />
}<br />
<br />
}
Please let me know if there are any other doubts.
Any help will be appreciated.
Thanks & Regards,
Kapil Singhal
|
|
|
|
|
|
This is probably also an interesting read for you: What's up with BeginInvoke?[^]
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
You should only ask the solution of your problem instead of copy pasting your code.
it's too long and i think nobody have enough time to go through it..
take it positively.
anyways what i guessed from your message's "subject" not from text, is that u want to access control from different thread than from in which it is contained or created.
so the solution is that (if u r working in c# 2.0)
write this line in constructor of the class where the control is
Control.CheckForIllegalCrossThreadCalls = false;
|
|
|
|
|
hi everybody,
i have created a browser now i came across a problem.when i put my mouse pointer in title bar
of browser window and drags /moves it browser also moves with it too, which i want to disable.how could
i acheive it please send some clue.if possible please send some code.
|
|
|
|
|
Your question doesn't really make sense to me. When you say that you have "created a browser", what do you mean exactly? What is "browser" in this context, and why should it not move when you move the window?
---
single minded; short sighted; long gone;
|
|
|
|
|
Hi all
"The located assembly's manifest definition with name 'Interop.SQLDMO' does not match the assembly reference."
That is the error I'm getting when I try to use a C# library with my application.
The thing is I am using SQLDMO in my app that calls the library and it is just fine - when I get to calling the DLL though I always get that error.
Could you please help me out from this. It is very urgent for me to resolve this problem.
Thanks in advance
Saurabh Gupta
Software Engineer
|
|
|
|
|
hi,
is it possible to add a member variable/function to a class at runtime..
This is possible in Python..
regards,
nas
|
|
|
|
|
nasambur wrote: is it possible to add a member variable/function to a class at runtime..
C# is a statically typed language, which means that the compiler needs to know about all members of a class during compilation, so that it can lay them out properly in memory.
You can add static methods to a class using LCG[^], a new feature in .NET 2.0
|
|
|
|
|
No, that is not possible in .NET.
What are you trying to accomplish? For questions like this there usually is an object oriented solution that works just as well, or simetimes even better.
---
single minded; short sighted; long gone;
|
|
|
|
|
Can't we achieve this using CodeDOM?
|
|
|
|
|
No. You can use CodeDom to create source code, which you can compile if you want, but that can only be used to create a new assembly, you can't change an existing class at runtime.
---
single minded; short sighted; long gone;
|
|
|
|
|
Have a look at http://www.codeproject.com/cs/library/typebuilderlib.asp You might find it interesting
|
|
|
|
|
hi,
i am developing a windows application in that i want to extract all the email ids present in the body of a particular text file
any idea
jaz
|
|
|
|
|
1- Crate a regular expression for email.
2- Read each sentence of the text one by one.
3 -Match it with the regular expression, if matched successfully store it somewhere [Like array list].
4- When you will complete reading the text file, you will be having all the email ids with you.
Regards,
Prakash Kalakoti
|
|
|
|
|
Hi Prakash,
Thanks for your help
Now it is working properly
Thanks once again
jaz
|
|
|
|
|
Hi,
How to display icons/images on ListView SubItems using C#.Net 2?
Thanking you in advance
jaz
|
|
|
|
|
Try an ImageList .
Trinity: Neo... nobody has ever done this before.
Neo: That's why it's going to work.
|
|
|
|
|
no..i was asking about how to display icons on the subitems of a listview?
using imagelist, i know to display icons for listview items...but pls help how to display icons on subitems?
thanks
|
|
|
|
|
|
|
For the Best result. You can use the Telerik Component. Which will be So good to solve ur problem
Regards,
A Jabeer Ali
|
|
|
|
|
I am just a beginner in C# and need to create a basic C# form to enter student information:
first and last name
email
graduation year
month of graduation
I have to use some type of menu for the graduation year and month (dropdown, radio button list or checkbox list).
I have used C# code generator to create the following code:
using System;
namespace SIU.Student.Graduation
{
public class EntryForm
{
// private members
string strFirstName;
string strLastName;
string strEMail;
string strGraduationYear;
string strGraduationMonth;
// empty constructor
public EntryForm ()
{
}
// full constructor
public EntryForm (string FirstName, string LastName, string EMail, string GraduationYear, string GraduationMonth)
{
this.strFirstName = FirstName;
this.strLastName = LastName;
this.strEMail = EMail;
this.strGraduationYear = GraduationYear;
this.strGraduationMonth = GraduationMonth;
}
// public accessors
public string FirstName
{
get { return strFirstName;}
set { strFirstName = value; }
}
public string LastName
{
get { return strLastName;}
set { strLastName = value; }
}
public string EMail
{
get { return strEMail;}
set { strEMail = value; }
}
public string GraduationYear
{
get { return strGraduationYear;}
set { strGraduationYear = value; }
}
public string GraduationMonth
{
get { return strGraduationMonth;}
set { strGraduationMonth = value; }
}
}
}
using System;
using System.Data;
using System.Data.Client;
namespace SIU.Student.Graduation.Data
{
public class SqlDataProvider
{
public SqlDataProvider(){}
public void AddEntryForm(EntryForm EntryForm)
{
// Initialize SPROC
SqlConnection conn = new SqlConnection(Globals.ConnectionString);
SqlCommand cmd = new SqlCommand("KSU.Student.Graduation_EntryForm_Add", conn);
cmd.CommandType = CommandType.StoredProcedure;
// Add Parameters
cmd.Parameters.Add("@firstName", EntryForm.FirstName);
cmd.Parameters.Add("@lastName", EntryForm.LastName);
cmd.Parameters.Add("@eMail", EntryForm.EMail);
cmd.Parameters.Add("@graduationYear", EntryForm.GraduationYear);
cmd.Parameters.Add("@graduationMonth", EntryForm.GraduationMonth);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
}
public void UpdateEntryForm(EntryForm EntryForm)
{
// Initialize SPROC
SqlConnection conn = new SqlConnection(Globals.ConnectionString);
SqlCommand cmd = new SqlCommand("KSU.Student.Graduation_EntryForm_Update", conn);
cmd.CommandType = CommandType.StoredProcedure;
// Update Parameters
cmd.Parameters.Add("@firstName", EntryForm.FirstName);
cmd.Parameters.Add("@lastName", EntryForm.LastName);
cmd.Parameters.Add("@eMail", EntryForm.EMail);
cmd.Parameters.Add("@graduationYear", EntryForm.GraduationYear);
cmd.Parameters.Add("@graduationMonth", EntryForm.GraduationMonth);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
}
public void DeleteEntryForm(EntryForm EntryFormID)
{
// Initialize SPROC
SqlConnection conn = new SqlConnection(Globals.ConnectionString);
SqlCommand cmd = new SqlCommand("KSU.Student.Graduation_EntryForm_Delete", conn);
cmd.CommandType = CommandType.StoredProcedure;
// Delete Parameters
cmd.Parameters.Add("@EntryFormID", EntryFormID);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
}
public EntryForm GetEntryFormByID(EntryForm EntryFormID)
{
// Initialize SPROC
SqlConnection conn = new SqlConnection(Globals.ConnectionString);
SqlCommand cmd = new SqlCommand("KSU.Student.Graduation_EntryForm_GetByID", conn);
cmd.CommandType = CommandType.StoredProcedure;
SqlDataReader reader = null;
EntryForm entryForm = null;
// GetByID Parameters
cmd.Parameters.Add("@EntryFormID", EntryFormID);
// Execute
conn.Open();
reader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
if(reader.Read())
{
entryForm = SqlDataHelpers.PopulateEntryFormFromSqlDataReader(reader);
}
conn.Close();
return entryForm;
}
public static EntryForm PopulateEntryFormFromSqlDataReader(SqlDataReader dr)
{
EntryForm entryForm = new EntryForm();
entryForm.FirstName = Convert.ToString(dr["firstName"]);
entryForm.LastName = Convert.ToString(dr["lastName"]);
entryForm.EMail = Convert.ToString(dr["eMail"]);
entryForm.GraduationYear = Convert.ToString(dr["graduationYear"]);
entryForm.GraduationMonth = Convert.ToString(dr["graduationMonth"]);
return entryForm;
}
}
}
I need to figure out way to code the drop-down menu for GraduationYear and GraduationMonth fields.
Can somebody provide a ready code snippet to insert it in the above code pls?
Do I miss any other important coding for this entry form?
Thanks so much!
heroz100
|
|
|
|