Ejemplo n.º 1
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            inventoryDataContext idc = new inventoryDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\09\OneDrive\C#\InventoryManagement\InventoryManagement\inventory_management.mdf;Integrated Security=True");

            int id = 0;

            if (!tbUser.Text.ToString().Equals(""))
            {
                id = Convert.ToInt32(tbUser.Text.ToString());
            }

            string pass = tbPass.Text.ToString();

            var row       = idc.logins.SingleOrDefault(r => r.user_id == id);
            var user_pass = row != null ? row.user_pass : String.Empty;
            var user_type = row != null ? row.user_type : String.Empty;

            if (id != 0 && !pass.Equals(""))
            {
                if (user_pass.ToString().Equals(pass))
                {
                    if (user_type.ToString().Equals("admin"))
                    {
                        InventoryManagement.adminLoginButtonClicked();
                    }
                    else
                    {
                        InventoryManagement.UserBtnClicked();
                    }
                }
                else
                {
                    MessageBox.Show("Password or username incorrect!");
                }
            }
            else
            {
                if (id == 0)
                {
                    MessageBox.Show("Username incorrect!!");
                }
                else
                {
                    MessageBox.Show("Username and Password field required!");
                }
            }
        }
Ejemplo n.º 2
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            inventoryDataContext idc = new inventoryDataContext(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\FASHAKINALEALEXANDER\Documents\FProjects\InventoryManagementSystem-master\InventoryManagement\InventoryManagement\inventory_management.mdf;Integrated Security=True");

            if (!tbUser.Text.Equals("") || !tbPass.Text.Equals(""))
            {
                if (tbUser.Text.Equals("admin") || tbPass.Text.Equals("1"))
                {
                    InventoryManagement.adminLoginButtonClicked();
                }
                else if (tbUser.Text.Equals("user") || tbPass.Text.Equals("2"))
                {
                    InventoryManagement.UserBtnClicked();
                }
                else
                {
                    MessageBox.Show("Password or username incorrect");
                }
            }
            else
            {
                MessageBox.Show("Please fill in the details");
            }

            /* //int id = 0;
             * if(!tbUser.Text.ToString().Equals(""))
             *
             *
             * {
             * if(!tbUser.Text.Equals(""))
             * id = Convert.ToInt32(tbUser.Text.ToString());
             * }
             *
             * string pass = tbPass.Text.ToString();
             *
             * var row = idc.logins.SingleOrDefault(r => r.user_id == id);
             * var user_pass = row != null ? row.user_pass : String.Empty;
             * var user_type = row != null ? row.user_type : String.Empty;
             *
             * if(id != 0 && !pass.Equals(""))
             * {
             *  if(user_pass.ToString().Equals(pass))
             *  {
             *      if(user_type.ToString().Equals("admin"))
             *      {
             *          InventoryManagement.adminLoginButtonClicked();
             *      }
             *      else
             *      {
             *          InventoryManagement.UserBtnClicked();
             *      }
             *  }
             *  else
             *  {
             *      MessageBox.Show("Password or username incorrect!");
             *  }
             * }
             * else
             * {
             *  if(id == 0)
             *  {
             *      MessageBox.Show("Username incorrect!!");
             *  }
             *  else
             *  {
             *      MessageBox.Show("Username and Password field required!");
             *  }
             * }
             */
        }