Skip to content
This repository has been archived by the owner on Feb 9, 2023. It is now read-only.

Commit

Permalink
Created the login validation - works in theory, but seems to crash th…
Browse files Browse the repository at this point in the history
…e program. Could someone run it and tell me what happens?
  • Loading branch information
AlexanderLea committed Mar 27, 2012
1 parent aa58a3b commit 19bdb71
Show file tree
Hide file tree
Showing 11 changed files with 88 additions and 51 deletions.
Binary file modified SOFT130 Coursework.suo
Binary file not shown.
29 changes: 12 additions & 17 deletions WindowsFormsApplication1/LoginForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

86 changes: 52 additions & 34 deletions WindowsFormsApplication1/LoginForm.cs
Expand Up @@ -22,23 +22,28 @@ public frmLogin()
private void frmLogin_Load(object sender, EventArgs e) private void frmLogin_Load(object sender, EventArgs e)
{ {
//READ FILE //READ FILE
//local variables //local variables
int i; string[] productData;
string[] branchData;
string[] categoryData;




//set up StreamReader //set up StreamReader
StreamReader reader = new StreamReader("argus-BIG.txt"); StreamReader reader = new StreamReader("argus-BIG.txt");
while (reader.ReadLine() != null)
{
//create array to hold data values
string[] branchData = new string[11];


//make reader start at beginning of file //make reader start at beginning of file
reader.DiscardBufferedData(); reader.DiscardBufferedData();
reader.BaseStream.Seek(0, SeekOrigin.Begin); reader.BaseStream.Seek(0, SeekOrigin.Begin);
reader.BaseStream.Position = 0; reader.BaseStream.Position = 0;


while (!reader.EndOfStream)
{
//create array to hold data values
branchData = new string[11];

//get 11 lines of branch data file //get 11 lines of branch data file
for (i = 0; i < 11; i++) for (int i = 0; i < 11; i++)
{ {
branchData[i] = reader.ReadLine(); branchData[i] = reader.ReadLine();
} }
Expand All @@ -63,18 +68,19 @@ private void frmLogin_Load(object sender, EventArgs e)
//tempBranch.setNoCategories(Convert.ToInt32(branchData[10])); //tempBranch.setNoCategories(Convert.ToInt32(branchData[10]));


//add branch to main arrayList //add branch to main arrayList

tempBranch.addBranchToMainArgus(tempBranch); tempBranch.addBranchToMainArgus(tempBranch);




for (i = 0; i < Convert.ToInt32(tempBranch.getNoCategories()); i++) for (int i = 0; i < Convert.ToInt32(tempBranch.getNoCategories()); i++)
{ {
//create array to hold data values //create array to hold data values
string[] categoryData = new string[3]; categoryData = new string[3];


//get 3 lines of category data file //get 3 lines of category data file
for (i = 0; i < 3; i++) for (int j = 0; j < 3; j++)
{ {
categoryData[i] = reader.ReadLine(); categoryData[j] = reader.ReadLine();
} }


//new instance of Category Class //new instance of Category Class
Expand All @@ -89,15 +95,15 @@ private void frmLogin_Load(object sender, EventArgs e)
//add category to Categories in branch arrayList //add category to Categories in branch arrayList
tempBranch.addCategoryToBranch(tempCategory); tempBranch.addCategoryToBranch(tempCategory);


for (i = 0; i < Convert.ToInt32(tempCategory.getNoProduct()); i++) for (int j = 0; j < Convert.ToInt32(tempCategory.getNoProduct()); j++)
{ {
//create array to hold data values //create array to hold data values
string[] productData = new string[6]; productData = new string[6];


//get 6 lines of category data file //get 6 lines of category data file
for (i = 0; i < 6; i++) for (int k = 0; k < 6; k++)
{ {
productData[i] = reader.ReadLine(); productData[k] = reader.ReadLine();
} }


//new instance of Product Class //new instance of Product Class
Expand All @@ -119,35 +125,47 @@ private void frmLogin_Load(object sender, EventArgs e)
} }
} }


public bool branchIDcheck() public bool branchIDcheck(string inBranchID)
{ {
string branchID;
int equal = 0;
bool validID = false; bool validID = false;


branchID = txtBranchID.Text;

//Branch branch = new Branch(); //Branch branch = new Branch();
MainBranch main = new MainBranch(); MainBranch main = new MainBranch();


while (equal != 0) if (inBranchID != "")
foreach (Branch b in main.mainArgus) {
String.Compare(branchID, b.getBranchID()); do

{
foreach (Branch b in main.mainArgus)
{
if (inBranchID == b.getBranchID())
validID = true;
}
} while (validID == false);
}


MessageBox.Show("valid" + Convert.ToString(validID));


return validID; return validID;
} }


private void btnLogin_Click(object sender, EventArgs e) private void btnLogin_Click(object sender, EventArgs e)
{ {
bool valid; bool valid = false;
MainBranch MainBranch = new MainBranch(); MainBranch MainBranch = new MainBranch();

valid = branchIDcheck();


MainBranch.Show(); //get input from text field and pass it to login validation
this.Hide(); valid = branchIDcheck(txtBranchID.Text);

if (valid == true)
{
MainBranch.Show();
this.Hide();
}
else
{
MessageBox.Show("Invalid branch ID - please try again");
}
} }


private void txtBranchID_MaskInputRejected(object sender, MaskInputRejectedEventArgs e) private void txtBranchID_MaskInputRejected(object sender, MaskInputRejectedEventArgs e)
Expand Down
Binary file modified WindowsFormsApplication1/bin/Debug/Argus.exe
Binary file not shown.
Binary file modified WindowsFormsApplication1/bin/Debug/Argus.pdb
Binary file not shown.
Binary file modified WindowsFormsApplication1/obj/x86/Debug/Argus.exe
Binary file not shown.
Binary file modified WindowsFormsApplication1/obj/x86/Debug/Argus.pdb
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Expand Up @@ -130,3 +130,27 @@ C:\Users\Alexander\Dropbox\University\SOFT130\Argus---acronym\Argus---acronym\Wi
C:\Users\Alexander\Dropbox\University\SOFT130\Argus---acronym\Argus---acronym\WindowsFormsApplication1\obj\x86\Debug\GenerateResource.write.1.tlog C:\Users\Alexander\Dropbox\University\SOFT130\Argus---acronym\Argus---acronym\WindowsFormsApplication1\obj\x86\Debug\GenerateResource.write.1.tlog
C:\Users\Alexander\Dropbox\University\SOFT130\Argus---acronym\Argus---acronym\WindowsFormsApplication1\obj\x86\Debug\Argus.exe C:\Users\Alexander\Dropbox\University\SOFT130\Argus---acronym\Argus---acronym\WindowsFormsApplication1\obj\x86\Debug\Argus.exe
C:\Users\Alexander\Dropbox\University\SOFT130\Argus---acronym\Argus---acronym\WindowsFormsApplication1\obj\x86\Debug\Argus.pdb C:\Users\Alexander\Dropbox\University\SOFT130\Argus---acronym\Argus---acronym\WindowsFormsApplication1\obj\x86\Debug\Argus.pdb
C:\Documents and Settings\ajlea\Desktop\1\AlexanderLea-Argus---acronym-aa58a3b\WindowsFormsApplication1\obj\x86\Debug\Argus.exe
C:\Documents and Settings\ajlea\Desktop\1\AlexanderLea-Argus---acronym-aa58a3b\WindowsFormsApplication1\obj\x86\Debug\Argus.pdb
C:\Documents and Settings\ajlea\Desktop\1\AlexanderLea-Argus---acronym-aa58a3b\WindowsFormsApplication1\bin\Debug\Argus.exe
C:\Documents and Settings\ajlea\Desktop\1\AlexanderLea-Argus---acronym-aa58a3b\WindowsFormsApplication1\bin\Debug\Argus.pdb
C:\Documents and Settings\ajlea\Desktop\1\AlexanderLea-Argus---acronym-aa58a3b\WindowsFormsApplication1\obj\x86\Debug\ResolveAssemblyReference.cache
C:\Documents and Settings\ajlea\Desktop\1\AlexanderLea-Argus---acronym-aa58a3b\WindowsFormsApplication1\obj\x86\Debug\WindowsFormsApplication1.frmLogin.resources
C:\Documents and Settings\ajlea\Desktop\1\AlexanderLea-Argus---acronym-aa58a3b\WindowsFormsApplication1\obj\x86\Debug\WindowsFormsApplication1.frmBranchDetails.resources
C:\Documents and Settings\ajlea\Desktop\1\AlexanderLea-Argus---acronym-aa58a3b\WindowsFormsApplication1\obj\x86\Debug\WindowsFormsApplication1.MainBranch.resources
C:\Documents and Settings\ajlea\Desktop\1\AlexanderLea-Argus---acronym-aa58a3b\WindowsFormsApplication1\obj\x86\Debug\WindowsFormsApplication1.ProductDetails.resources
C:\Documents and Settings\ajlea\Desktop\1\AlexanderLea-Argus---acronym-aa58a3b\WindowsFormsApplication1\obj\x86\Debug\Argus.Properties.Resources.resources
C:\Documents and Settings\ajlea\Desktop\1\AlexanderLea-Argus---acronym-aa58a3b\WindowsFormsApplication1\obj\x86\Debug\GenerateResource.read.1.tlog
C:\Documents and Settings\ajlea\Desktop\1\AlexanderLea-Argus---acronym-aa58a3b\WindowsFormsApplication1\obj\x86\Debug\GenerateResource.write.1.tlog
C:\Users\Alexander\Desktop\frmLogin dunt work_fileReadOkay\frmLogin dunt work_fileReadOkay\AlexanderLea-Argus---acronym-aa58a3b\WindowsFormsApplication1\obj\x86\Debug\Argus.exe
C:\Users\Alexander\Desktop\frmLogin dunt work_fileReadOkay\frmLogin dunt work_fileReadOkay\AlexanderLea-Argus---acronym-aa58a3b\WindowsFormsApplication1\obj\x86\Debug\Argus.pdb
C:\Users\Alexander\Desktop\frmLogin dunt work_fileReadOkay\frmLogin dunt work_fileReadOkay\AlexanderLea-Argus---acronym-aa58a3b\WindowsFormsApplication1\bin\Debug\Argus.exe
C:\Users\Alexander\Desktop\frmLogin dunt work_fileReadOkay\frmLogin dunt work_fileReadOkay\AlexanderLea-Argus---acronym-aa58a3b\WindowsFormsApplication1\bin\Debug\Argus.pdb
C:\Users\Alexander\Desktop\frmLogin dunt work_fileReadOkay\frmLogin dunt work_fileReadOkay\AlexanderLea-Argus---acronym-aa58a3b\WindowsFormsApplication1\obj\x86\Debug\ResolveAssemblyReference.cache
C:\Users\Alexander\Desktop\frmLogin dunt work_fileReadOkay\frmLogin dunt work_fileReadOkay\AlexanderLea-Argus---acronym-aa58a3b\WindowsFormsApplication1\obj\x86\Debug\WindowsFormsApplication1.frmLogin.resources
C:\Users\Alexander\Desktop\frmLogin dunt work_fileReadOkay\frmLogin dunt work_fileReadOkay\AlexanderLea-Argus---acronym-aa58a3b\WindowsFormsApplication1\obj\x86\Debug\WindowsFormsApplication1.frmBranchDetails.resources
C:\Users\Alexander\Desktop\frmLogin dunt work_fileReadOkay\frmLogin dunt work_fileReadOkay\AlexanderLea-Argus---acronym-aa58a3b\WindowsFormsApplication1\obj\x86\Debug\WindowsFormsApplication1.MainBranch.resources
C:\Users\Alexander\Desktop\frmLogin dunt work_fileReadOkay\frmLogin dunt work_fileReadOkay\AlexanderLea-Argus---acronym-aa58a3b\WindowsFormsApplication1\obj\x86\Debug\WindowsFormsApplication1.ProductDetails.resources
C:\Users\Alexander\Desktop\frmLogin dunt work_fileReadOkay\frmLogin dunt work_fileReadOkay\AlexanderLea-Argus---acronym-aa58a3b\WindowsFormsApplication1\obj\x86\Debug\Argus.Properties.Resources.resources
C:\Users\Alexander\Desktop\frmLogin dunt work_fileReadOkay\frmLogin dunt work_fileReadOkay\AlexanderLea-Argus---acronym-aa58a3b\WindowsFormsApplication1\obj\x86\Debug\GenerateResource.read.1.tlog
C:\Users\Alexander\Desktop\frmLogin dunt work_fileReadOkay\frmLogin dunt work_fileReadOkay\AlexanderLea-Argus---acronym-aa58a3b\WindowsFormsApplication1\obj\x86\Debug\GenerateResource.write.1.tlog

0 comments on commit 19bdb71

Please sign in to comment.