|
Hello I have a issue to discuss that recently I have a made a C# program for Rental Car Management, although its very easy cause all it contained was SQL statements manipulating the data form database. The issues starts when I gather all the elements or functions and display them to be accessed by one Main window where I can access all the different elements of the programs. I am showing you the code for this part, My teacher says its bit complicated and he would have done it simpler and differently.
I will appreciate any help comments to improve this.
namespace CMS1 // The Main NameSpace which is used for referencing rest of the program.
{
class CMS
{
// Structure of the Form mad with Views FileSystem.
Views.Form entry;
string formSpec = @"
<vertical>
<horizontal>
<vertical>
<horizontal>
<vertical>
<horizontal>
<horizontal>
<space width="130">
";
// a Method wich calls all other Programs from one single main.
public void ActionPerformed( string c )
{
switch (c)
{
case "ManageCustomer":
ManageCustomer m1= new ManageCustomer();
m1.Go();
break;
case "ManageContract":
ManageContract m2 = new ManageContract();
m2.Go();
break;
case "ManageEmployee":
ManageEmployee m3 = new ManageEmployee();
m3.Go();
break;
case "ManagePayment":
ManagePayment m4 = new ManagePayment();
m4.Go();
break;
case "ManageCar":
ManageCar m5 = new ManageCar();
m5.Go();
break;
case"ManageCarCatagories":
ManageCarCatagories m6 = new ManageCarCatagories();
m6.Go();
break;
case "Exit":
entry.CloseGUI();
break;
default:
return;
}
}
//every thing OK up til here, no problems, but all the problems start after this.
public void Go()
{
entry = new Views.Form(formSpec);
for( ; ; ) // he thinks this is not right!!!
{
string c = entry.GetControl();
if (c==null) break;
ActionPerformed(c);
}
entry.CloseGUI();
}
static void Main(string[] args)
{
CMS cms=new CMS();
cms.Go();
}
kind regards
JG
|
|
|
|
|
You could always do something like this:
string c;<br />
while (c = entry.GetControl() != null)<br />
{<br />
ActionPerformed(c);<br />
entry.CloseGUI();<br />
}
But I don't see why this should be inside a for loop or any loop at all...
|
|
|
|
|
The point I am trying to make or what is the main issue in this is that, there is a Main window with six option buttons, lets say I want to open manage cars. I want the Main window with the six options to stay open and waiting for me until I am finished manageing cars and after that closed or shut the manageing cars window.
Then I can choose lets say the manage Customer option to open that window and so on, the conflicted 'infinit for loop ' {; ;} right now allows me to do that.
But the teacher thinks thats not too smart, I of course am looking or asking assistence if someone has a better idea or someother solution which my teacher has and he dont want to share it with me uptil now.
kind regards
ruler
-- modified at 2:11 Friday 10th March, 2006
|
|
|
|
|
How to transfer textfile using C# webservice
Pushpa Sengathiron
|
|
|
|
|
You could probably use something from this article:
http://www.codeproject.com/useritems/FILE_DOWNLOAD.asp
But really you could just create a method that returns a string.
Or what do you mean exactly?
|
|
|
|
|
thanks we have decided to use webclient method which is by default available in c#.
Pushpa Sengathiron
|
|
|
|
|
Hi All,
I'm having trouble putting my question into words, so if it sounds funny, i'm sorry. But here goes...
I've created a View in SQL that contains all the info i need from the different tables i have. The view contains Example:
TransactionDate, StaffID, StaffName, BrandID, BrandName, TotalCash, TotalQty
2006/03/01, 1, Jan, 2, Loreal, 250, 10
2006/03/01, 1, Jan, 3, Kerastase, 200, 8
2006/03/01, 2, Koos, 1, Revlon, 200, 11
2006/03/01, 2, Koos, 2, Loreal, 290, 12
2006/03/02, 1, Jan, 1, Revlon, 500, 25
2006/03/02, 1, Jan, 3, Kerastase, 345, 15
2006/03/03, 1, Jan, 3, Kerastase, 100, 6
2006/03/04, 2, Koos, 1, Revlon, 120, 3
With this examle jou see that i've calculated the totals on the TransactionDate for each Staffmember for each Brand.
I want to know if it is possible to write a procedure in SQL and send from C# a DateValue and BrandID to SQL to let the procedure know that it should only do the calculation between a specified Date and on every Brand. I need One total for each brand between the specified date: example 2006/03/01 - 2006/03/03.
I can do the calculation in C# but i need to speed up the processing time by using the database to do the calculation and not the application we wrote. Would Using a procedure in SQL actually speed up the Process or Would our application still run more or less the same time because it has to send a value to the database and wait for the calculation to complete and get the Value back from the Database?
I need to know rather urgantly Please. Thank you in advance.
|
|
|
|
|
Hi
You can do it by passing two parameters(both dates start and end date) to the procedure and in procedure use group by brand clause . I think yours problem will be solved.
|
|
|
|
|
Thanks, but would this method actually speed up things?
|
|
|
|
|
Generally, yes.
There already is functionality to do grouping in the database, but if you do the work in C# you would have to build it more or less from scratch. Less code is less risk for bugs, and also testing a query is easier than testing a lot of C# code.
If you run into performance problems you might want to try to do the grouping on the original data instead of the view, and add indices on the fields you are grouping on and comparing.
---
b { font-weight: normal; }
|
|
|
|
|
Hello,
I used a number of Textboxes in Web Application using C#, now i want to access all these but i don't want to write name of each textbox i just want to use an ARRAY to assign values (Or Access these textboxes), I saw this somewhere in Visual Basic 6.0 but i don't know how can i do that in Visual Studio 2003 please tell me some solution for this to avoid write the names of all these ???????????????
Waiting to hear something soon from anyone
Regards,
AbuBakar
|
|
|
|
|
First: Please don't write your postings two, three or four times!
Your form has got the Controls property. You can access all controls using it. Check if the control is a textbox then you can work with it.
for (int i = 0; i < this.Controls.Count; i++) {
if (String.Compare(this.Controls[i].GetType().ToString(), "System.Windows.Forms.TextBox") == 0) {
((System.Windows.Forms.TextBox)this.Controls[i]).Text = "Bla";
} // if
} // for i
Greetings,
Ingo
------------------------------
PROST Roleplaying Game
|
|
|
|
|
First: My Internet speed was very slow that's y i sent problem more than one time.
Hello,
Thanks a lot for every brother, dear i want to do this in Web Application <asp:textbox> not in Windows Application so please send me some code how can i add textboxes in controls and use later on..
Regards,
AbuBakar
|
|
|
|
|
I don't think the control array is in .NET any more (and good riddance!!).
If you use WinApp, you can dynamically create the controls and assign the names to the controls (textBox001, textBox002 etc). Then you can put the controls in a collection such as hashtable for easy access. Though I am not sure how is it to be done in web app.
I would suggest you use dynamic array sparringly, only if you need to, but because of lazy to type out the names. The last vb program that I need to do some enhancement, I was cursing and swearing when I trying to debug the forms. Can you imagine that the whole application consist only of control array of buttons, textboxes, checkboxes?!!
|
|
|
|
|
Hi
You can get TextBoxArray controller using “Microsoft.VisualBasic.Compatibility.VB6” Namespace.
I did not try. Please try with this.
Good luck
Chandana
|
|
|
|
|
Hello,
I used a number of Textboxes in Web Application using C#, now i want to access all these but i don't want to write name of each textbox i just want to use an ARRAY to assign values (Or Access these textboxes), I saw this somewhere in Visual Basic 6.0 but i don't know how can i do that in Visual Studio 2003 please tell me some solution for this to avoid write the names of all these ???????????????
Waiting to hear something soon from anyone
Regards,
AbuBakar
|
|
|
|
|
Hello,
I used a number of Textboxes in Web Application using C#, now i want to access all these but i don't want to write name of each textbox i just want to use an ARRAY to assign values (Or Access these textboxes), I saw somewhere in Visual Basic 6.0 but i don't know how can i do that in Visual Studio 2003 please tell me some solution for this to avoid write the names of all these ???????????????
Waiting to hear something soon from anyone
Regards,
AbuBakar
|
|
|
|
|
I would like to catch the sql error that returns from the stored procedure.
The SP is written in 2005 with try/catch statement.
What should be placed in the catch statement of the SP and how can the .net code i.e vb.net or C# get this error to show to the user?
Thanks
|
|
|
|
|
try
{
//ur code
}
catch(SqlException ee)
{
Response.Write("alert('" + ee.Message+ "')");
}
|
|
|
|
|
It depends on the client application (ASP.NET, Console, or WinForm).
In all cases, I would build a string that explains the exception, including any property particular to the SqlException class.
When the string is ready, there are many ways to display it to the user:
ASP.NET: You may use a label.
WinForm: MessageBox
Console: Console.Error.WriteLine
Some piece of advice:
- When displaying error information, give the user the tools to fix the problem, by telling as much as possible to the user. In the case of the SqlException class, there are the Procedure, LineNumber, Number, etc. properties. There is nothing more frustrating than the "An error occured" message.
- In the Console version, notice the use of the Error StreamWriter property of the class. I do this, because the Console.WriteLine call outputs to the regular output stream.
--------
"I say no to drugs, but they don't listen."
- Marilyn Manson
|
|
|
|
|
Hello!
Remember, in setup of account record Outlook there is an opportunity to open postbox of other user.
How to retrieve contacts list other Outlook user postbox?
I shall be grateful for any information on the given question.
Thanks,
Alexander
|
|
|
|
|
How can i draw a line or rectange in a ASP.net Web form by getting the points from the user or by using mouse down event.
Rohit
|
|
|
|
|
The mouse events are obviously client side, so you would do it using Javascript or something. As it is client side, there is nothing specific .NET related to this. And no, I can't point you to any information about how it is done - I have seen someone doing similar things, but I avoid Javascript whenever posibile so I have no intention finding out how it is done.
Alternatively embed a WinForm control on the page. This is probably easier to program but it will only work if the client has the .NET Framework installed.
|
|
|
|
|
thanks a lot for ur reply. Can u just tell me any of the sites where i can get a smple javascript code for that
Rohit
|
|
|
|
|
As I said, I do not touch Javascript so I have no idea where to find samples. Life is too short for weakly types scripting languages.
|
|
|
|
|