Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Control for Main Button Window

dmu4014dmu4014 Posts: 5Member
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();
}

Comments

  • tsagldtsagld Posts: 621Member
    : 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:
    [code]
    for( ; ; ) // he thinks this is not right!!!
    //he's wrong.
    {
    string c = entry.GetControl();
    if (c==null) break;
    ActionPerformed(c);
    }
    [/code]

    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:
    [code]
    foreach (Control control in entry.Controls)
    [/code]
    If that's not the case, then pls post the code for the Views.Form.GetControl() method.



    Greets,
    Eric Goldstein
    www.gvh-maatwerk.nl

  • dmu4014dmu4014 Posts: 5Member
    : : 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:
    : [code]
    : for( ; ; ) // he thinks this is not right!!!
    : //he's wrong.
    : {
    : string c = entry.GetControl();
    : if (c==null) break;
    : ActionPerformed(c);
    : }
    : [/code]
    :
    : 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:
    : [code]
    : foreach (Control control in entry.Controls)
    : [/code]
    : 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 = @"





  • tsagldtsagld Posts: 621Member
    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

  • dmu4014dmu4014 Posts: 5Member
    : 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 = @"


Sign In or Register to comment.