Example #1
0
      private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
      {
          frmAdminHome l = frmAdminHome.getInstance();

          l.Show();
          this.Hide();
      }
        private void cmdLogin_Click(object sender, EventArgs e)
        {
            Boolean isAdmin = false;

            foreach (Employee a in EmployeeDL.adminName)
            {
                if (a.AdminName == txtUserName.Text && a.AdminPassword == txtPassword.Text)
                {
                    txtUserName.Text = "";
                    txtPassword.Text = "";
                    isAdmin          = true;
                    //MyUtil.loginUser = a;
                }

                this.Hide();
            }

            if (isAdmin)
            {
                frmAdminHome admin = new frmAdminHome();
                admin.Show();
                MessageBox.Show("Admin Login Successfully");
                goto found;
            }

            /* else
             * {
             *  MessageBox.Show("invalid user");
             * }
             */
            Boolean isFound = false;

            foreach (Employee i in EmployeeDL.employeeName)
            {
                if (i.EmployeeName == txtUserName.Text && i.EmployeePassword == txtPassword.Text)
                {
                    isFound          = true;
                    txtUserName.Text = "";
                    txtPassword.Text = "";
                    MyUtil.loginUser = i;
                }
            }

            if (isFound)
            {
                this.Hide();
                EmployeeHome contact = new EmployeeHome();
                contact.Show();
                MessageBox.Show("Logged in as an Employee");
            }
            else
            {
                MessageBox.Show("Employee not Registered!");
            }

found:
            int y = 5;
        }
 public static frmAdminHome getInstance()
 {
     if (l == null)
     {
         l = new frmAdminHome();
         l.Show();
         return(l);
     }
     else
     {
         return(l);
     }
 }