Click to See Complete Forum and Search --> : Modules in C#


vuyiswam
October 27th, 2008, 08:27 AM
Good Afternoon All

In VB.NET i used to have a Module. I need to Call the Main Form when the login is successfully. So this is what i deed in C# so Far in a Class, Can someone Help me on this in C#. Becaues C# does not have Modules.



using System;
using System.Collections.Generic;
using System.Text;

namespace SystemAdmin
{

class Startup
{
public void Main()
{

bool loggedIn;

frmLogin frmlogin = new frmLogin();

loggedIn = (frmlogin.ShowDialog() == DialogResult.OK);

if (loggedIn)
{

Application.Run(new frmmain());

}
}
}
}



And my Login Screen Login button is like this


String strusername = txtusername.Text;

String Password = txtpassword.Text;

int bl ;

bl = obj.Check_Login(strusername, strPassword);

if (bl == 1)
{
Me.DialogResult = Windows.Forms.DialogResult.OK;
}
else
{
MessageBox.Show("Invalid Login");
}


Thanks

HanneSThEGreaT
October 27th, 2008, 08:33 AM
Well Modules in VB have their downsides...
People prefer declaring all their public variables inside a module, but that doesn't make your program 100% object oriented - I guess it's just my opinion...

One option may be to make sealed classes with private constructors ( where all the members are static )

TheCPUWizard
October 27th, 2008, 08:43 AM
Your post looks like reasonable C#....

What is the PROBLEM?????

vuyiswam
October 27th, 2008, 08:53 AM
OK

My Problem is shown on ScreenShot

TheCPUWizard
October 27th, 2008, 09:00 AM
1) you do not have a class named "frmLogin" in the current namespace, nor do you have a "using" statement to import the namespace.

2) You do not have the proper namespace for Dialog Result.


A simple "right-click" and "Resolve..." will address the issues, if the proper assemblies are referenced in your project.

vuyiswam
October 28th, 2008, 04:47 AM
Thank you Very much, its Resolved