Hi Benj Nunez
Good Day
I try to do that but some error show up
and this is my code
the child form
////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Archive_System
{
public partial class Login : Form
{
public Login()
{
InitializeComponent();
}
private static new MainForm ParentForm = null;
public Login(MainForm APrent):this()
{
ParentForm = APrent;
}
private void OKbutton_Click(object sender, EventArgs e)
{
string un = userNametextBox.Text;
string ps = PasswardMaskedTextBox.Text;
if (un == "sahm" || ps == "java")
{
MessageBox.Show(this, "Login Work", "",
MessageBoxButtons.OK, MessageBoxIcon.Information);
ParentForm.menuStrip1.Enabled = !
ParentForm.menuStrip1.Enabled;
}
else
{
MessageBox.Show(this, "Login not work", "",
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void CancelButton_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
the main form
//////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Management;
namespace Archive_System
{
public partial class Main : Form
{
public Main()
{
try
{
InitializeComponent();
this.WindowState = FormWindowState.Maximized;
this.FormBorderStyle = FormBorderStyle.FixedSingle;
this.Closing += new CancelEventHandler(Form_Closing);
this.menuStrip1.Enabled = false;
//this.Enabled = false;
checkUser();
}
catch (Exception exp)
{
string ms = exp.Message;
MessageBox.Show(this, ms, "System Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
System.Data.SqlClient.SqlConnection con;
private void userToolStripMenuItem_Click(object sender,
EventArgs e)
{
try
{
createUser cu = new createUser();
cu.MdiParent = this;
cu.Show();
}
catch (Exception exp)
{
string ms = exp.Message;
MessageBox.Show(this, ms, "System Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void aboutToolStripMenuItem_Click(object sender,
EventArgs e)
{
About ab = new About();
ab.MdiParent = this;
ab.Show();
}
/*public void setPreviousForm(frmMain mainFrm)
{
prevForm = mainForm;
}*/
public void checkUser()
{
Login log = new Login();
//log.setPreviousForm(this);
log.ShowDialog(this);
}
private void Main_Load(object sender, EventArgs e)
{
con = new System.Data.SqlClient.SqlConnection();
con.ConnectionString = "Data Source=mr-x\
\SQLExpress2008;Initial Catalog=archive;Integrated Security=True";
con.Open();
}
public void Form_Closing(object sender, CancelEventArgs cArgs)
{
con.Close();
}
private void menuStrip1_ItemClicked(object sender,
ToolStripItemClickedEventArgs e)
{
}
}
}
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
and this is the error message
///////////////////////////////////////////
Error 1 The type or namespace name 'MainForm' could not be found (are
you missing a using directive or an assembly reference?) E:\Projects\C#
\Archive System\Archive System\Login.cs 18 28 Archive System
Error 2 The type or namespace name 'MainForm' could not be found (are
you missing a using directive or an assembly reference?) E:\Projects\C#
\Archive System\Archive System\Login.cs 20 22 Archive System
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
thank you for your help
Bes
Salim