C#

Moderators: None (Apply to moderate this forum)
Number of threads: 2720
Number of posts: 5746

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Control for Main Button Window Posted by dmu4014 on 23 Feb 2006 at 11:56 PM
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.

static void Main(string[ ] args)
{
CMS cms=new CMS();
cms.Go();
}

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();
}

Report
Re: Control for Main Button Window Posted by tsagld on 24 Feb 2006 at 5:04 AM
: 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.
:
: static void Main(string[ ] args)
: {
: CMS cms=new CMS();
: cms.Go();
: }
:
: 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();
: }
:
:

You didn't post all your code, so I can't see what kind of class Views.Form is, but the following fragment seems tricky:
for( ; ; ) // he thinks this is not right!!!
           //he's wrong.
{
  string c = entry.GetControl();
  if (c==null) break;
  ActionPerformed(c);
}


You enter an endless loop and it seems that you try to loop through all controls within 'entry'.
But doesn't 'entry.GetControl()' returns the same control each iteration? That would mean you will never leave the loop. I expect you would need something like this:
foreach (Control control in entry.Controls)

If that's not the case, then pls post the code for the Views.Form.GetControl() method.



Greets,
Eric Goldstein
www.gvh-maatwerk.nl

Report
Re: Control for Main Button Window Posted by dmu4014 on 26 Feb 2006 at 2:30 AM
: : 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.
: :
: : static void Main(string[ ] args)
: : {
: : CMS cms=new CMS();
: : cms.Go();
: : }
: :
: : 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();
: : }
: :
: :
:
: You didn't post all your code, so I can't see what kind of class Views.Form is, but the following fragment seems tricky:
:
: for( ; ; ) // he thinks this is not right!!!
:            //he's wrong.
: {
:   string c = entry.GetControl();
:   if (c==null) break;
:   ActionPerformed(c);
: }
: 

:
: You enter an endless loop and it seems that you try to loop through all controls within 'entry'.
: But doesn't 'entry.GetControl()' returns the same control each iteration? That would mean you will never leave the loop. I expect you would need something like this:
:
: foreach (Control control in entry.Controls)
: 

: If that's not the case, then pls post the code for the Views.Form.GetControl() method.
:
:
:
: Greets,
: Eric Goldstein
: www.gvh-maatwerk.nl
:
:
hello
thanks ever so much your attention,

I tried your method , but I get this error that the 'entry'is not found, I am posting you the "form" so you can have the whole picture.
using System;
using Views;
using System.IO;
using System.Drawing;
using System.Data.OleDb;
using System.Collections;
using System.Windows.Forms;
namespace CMS1
{
public class ManageCar
{
static string source = "Provider=Microsoft.Jet.OLEDB.4.0;" + @"Data Source=DanCarRental.mdb";
OleDbConnection db; // connects to the DB.
OleDbCommand command;
OleDbDataReader reader;
string sql;
Views.Form form;
string formSpec = @"<Form Text=ManageCar BackColor = silver>
<vertical>
<horizontal>
</horizontal>
<vertical>
<horizontal>
<Label Name=VehicleID Width=100/>
<TextBox Name=VehicleID/>
</horizontal>
<horizontal>
<Label Name= LicensePlateNum Width=100/>
<TextBox Name=LicensePlateNum/>
</horizontal>
<horizontal>
<Label Name= Type Width=100/>
<TextBox Name=Type/>
</horizontal>
<horizontal>
<Label Name= Color Width=100/>
<TextBox Name=Color/>
</horizontal>
<horizontal>
<Label Name=Status Width=100/>
<TextBox Name=Status/>
</horizontal>
<horizontal>
<Label Name= MilesDriven Width=100/>
<TextBox Name=MilesDriven/>
</horizontal>
<horizontal>
<Label Name= ACPresent Width=100/>
<TextBox Name=ACPresent/>
</horizontal>
<horizontal>
<Label Name=CDPresent Width=100/>
<TextBox Name=CDPresent/>
</horizontal>
<horizontal>
<Label Name= ModelNum Width=100/>
<TextBox Name=ModelNum/>
</horizontal>
<horizontal>
<Label Name= CarYear Width=100/>
<TextBox Name=CarYear/>
</horizontal>
<horizontal>
<Button Name='Create'/>
<Button Name='Read'/>
<Button Name='Update'/>
</horizontal>
<horizontal>
<Button Name='Delete'/>
<Button Name='Clear'/>
<Button Name='Exit'/>
</horizontal>
</vertical>
</vertical>
</form>";
you the main idea is not to loose the Main window, while one(lets say user) chooses to manage a customer, and as he/she pushes the button to activate the window, the Main window should stay there, and lets say when the user is finished with manageing customer, he/she closes the window and still the Main is there, so user can again choose another function.

kind regards
dmu4014
Report
Re: Control for Main Button Window Posted by tsagld on 27 Feb 2006 at 6:00 AM
Again, I'ld like to see the code for the Views.Form.GetControl() method.
It looks like you are using that method in a wrong way. But I cannot tell if I don't see the code.


Greets,
Eric Goldstein
www.gvh-maatwerk.nl

Report
Re: Control for Main Button Window Posted by dmu4014 on 28 Feb 2006 at 8:14 AM
: Again, I'ld like to see the code for the Views.Form.GetControl() method.
: It looks like you are using that method in a wrong way. But I cannot tell if I don't see the code.
:
:
: Greets,
: Eric Goldstein
: www.gvh-maatwerk.nl
:
:
Hello again

I do applogise for the mistake I am now pasteing you the Main form.

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 = @"<Form Text=Main BackColor = silver>
<vertical>
<horizontal>
<Button Name='ManageEmployee'Width=170 Height=40 Font = Bold10 />
<Button Name='ManageContract'Width=170 Height=40 Font = Bold10 />
</horizontal>
<vertical>
<horizontal>
<Button Name='ManageCustomer'Width=170 Height=40 Font = Bold10 />
<Button Name='ManagePayment'Width=170 Height=40 Font = Bold10 />
</horizontal>
</vertical>
<vertical>
<horizontal>
<Button Name='ManageCar'Width=170 Height=40 Font = Bold10 />
<Button Name='ManageCarCatagories'Width=170 Height=40 Font = Bold10 />
</horizontal>
</vertical>
<horizontal>
<Space Width= 130 /><Button Name='Exit'/>
</horizontal>
</vertical>
</form>";
// 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;
}
}
//This method calls the forms forward to be displayed.
public void Go()
{
entry = new Views.Form(formSpec);
for( ; ; )
{
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




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.