public Main_Form() { InitializeComponent(); // this is for intializing the main to this if (main == null) { main = this; } this.العملاءToolStripMenuItem.Enabled = false; this.المستخدمينToolStripMenuItem.Enabled = false; this.العملاءToolStripMenuItem.Enabled = false; this.البيعToolStripMenuItem.Enabled = false; this.الألبسةوأكسسواراتهاToolStripMenuItem.Enabled = false; this.استعادةنسخةسابقةToolStripMenuItem.Enabled = false; this.إنشاءنسخةاحتياطيةToolStripMenuItem.Enabled = false; this.الموردينToolStripMenuItem.Enabled = false; this.toolTip1.SetToolTip(this.pictureBox2, "خروج"); // toolTip1.Show("خروج", pictureBox2); }
private void login_btn_Click(object sender, EventArgs e) { log = new BL.Login_class(); DataTable dt = log.Login(id_text.Text, pwd_text.Text); if (dt.Rows.Count > 0) { if (dt.Rows[0][2].ToString() == "مدير") { Main_Form.getMain_Form().إنشاءنسخةاحتياطيةToolStripMenuItem.Enabled = true; Main_Form.getMain_Form().المستخدمينToolStripMenuItem.Enabled = true; Main_Form.getMain_Form().البيعToolStripMenuItem.Enabled = true; Main_Form.getMain_Form().العملاءToolStripMenuItem.Enabled = true; Main_Form.getMain_Form().الألبسةوأكسسواراتهاToolStripMenuItem.Enabled = true; Main_Form.getMain_Form().استعادةنسخةسابقةToolStripMenuItem.Enabled = true; Main_Form.getMain_Form().الموردينToolStripMenuItem.Enabled = true; Main_Form.getMain_Form().المستخدمينToolStripMenuItem.Visible = true; Main_Form.getMain_Form().الألبسةوأكسسواراتهاToolStripMenuItem.Visible = true; Main_Form.getMain_Form().الموردينToolStripMenuItem.Visible = true; Program.SalesMan = dt.Rows[0]["Full Name"].ToString(); this.Close(); } else if (dt.Rows[0][2].ToString() == "مستخدم عادي") { Main_Form.getMain_Form().إنشاءنسخةاحتياطيةToolStripMenuItem.Enabled = true; Main_Form.getMain_Form().المستخدمينToolStripMenuItem.Visible = false; Main_Form.getMain_Form().البيعToolStripMenuItem.Enabled = true; Main_Form.getMain_Form().العملاءToolStripMenuItem.Enabled = true; Main_Form.getMain_Form().الألبسةوأكسسواراتهاToolStripMenuItem.Visible = false; Main_Form.getMain_Form().الموردينToolStripMenuItem.Visible = false; Main_Form.getMain_Form().استعادةنسخةسابقةToolStripMenuItem.Enabled = true; Program.SalesMan = dt.Rows[0]["Full Name"].ToString(); this.Close(); } } else { MessageBox.Show("Login faild"); } }
// this is for lcosing the static variable public static void main_closed(Object sender, FormClosedEventArgs e) { // we are making it nnull because we may deal with it in another for other rthanthe login Form main = null; }