public CheckOutPanel() { InitializeComponent(); this.Paint += new PaintEventHandler(RePaint); emp = new CheckOutItem(); items = new CheckOutItemCollection(); }
//Having a method for reading the file public void ReadFile() { //declaring the stream reader StreamReader reader; //Declaring the record string record; //Creating a temporary checkoutitem CheckOutItem tmpCheck; //using a try catch block try { //the reader is a new streamreader reader = new StreamReader("Inventory.dat"); //record is equal to what the reader reads //While it is not the end of the stream while (!reader.EndOfStream) { record = reader.ReadLine(); //the temporary checkoutitem is new tmpCheck = new CheckOutItem(); //the tmpcheck parses the record tmpCheck.EmpParse(record); //the items that are used are equal to the tmpcheck items.Add(tmpCheck); //items[used++] = tmpCheck; //and the record reads the reader again //record = reader.ReadLine(); } //then the reader closes reader.Close(); } //using the catch statement catch { } }
private void btnSubmit_Click(object sender, EventArgs e) { //if the submit button is clicked //if the accept check box is checked Match match; if (chkAccept.Checked) { //having a pettern match for the S Number match = Regex.Match(txtSNum.ToString(), @"S(\d{8,8})", RegexOptions.IgnoreCase); if (!match.Success) { isEmpty = true; MessageBox.Show("Please enter your S# with 8 digits."); //sets the focus txtSNum.Focus(); //selects all txtSNum.SelectAll(); return; } else if (txtSNum.Text.Length > 9) { isEmpty = true; MessageBox.Show("Please enter your S# with 8 digits."); //sets the focus txtSNum.Focus(); //selects all txtSNum.SelectAll(); return; } if (txtSNum.Text == "") { isEmpty = true; //if the txtSNum textbox doesn't have anything MessageBox.Show("Please enter your S#."); //sets the focus txtSNum.Focus(); //selects all txtSNum.SelectAll(); return; } //but if there is no employee first name if (txtEmpFirst.Text == "") { //then a flag will set off isEmpty = true; //and opens up a message box to tell the user //to enter their first name in the textbox. MessageBox.Show("Please enter your first name."); //sets the focus txtEmpFirst.Focus(); //selects all txtEmpFirst.SelectAll(); //returns return; } //but if there is no employee last name if (txtEmpLast.Text == "") { //then a flag will set off. isEmpty = true; //and opens up a message box to tell the user //to enter their last name in the textbox MessageBox.Show("Please enter your last name."); //sets the focus txtEmpLast.Focus(); //selects all txtEmpLast.SelectAll(); return; } //but if there is no email in the textbox if (txtEmpEmail.Text == "") { //then a flag will set off isEmpty = true; //and opens up a message box to tell the user //to enter their email in the textbox MessageBox.Show("Please enter your email."); //sets the focus txtEmpEmail.Focus(); //selects all txtEmpEmail.SelectAll(); return; } //but if there is no text in the textbox if (panCheck.txtItemInfo.Text == "") { //then a flag will set off isEmpty = true; //and opens up a message box to tell the user //to enter their item information in the textbox MessageBox.Show("Please enter your item information."); //sets the focus panCheck.txtItemInfo.Focus(); //selects all panCheck.txtItemInfo.SelectAll(); return; } //but if there is no tag number if (panCheck.txtTagNum.Text == "") { isEmpty = true; //and opens up a message box to tell the user //to enter their tag number in the textbox MessageBox.Show("Please enter your tag number."); //sets the focus panCheck.txtTagNum.Focus(); //selects all panCheck.txtTagNum.SelectAll(); return; } //but if there is no date if (panCheck.txtDateCheckOut.Text == "") { //then a flag will set off isEmpty = true; //and opens up a message box to tell the user //to enter their date of check out in the textbox MessageBox.Show("Please enter the date of check out."); //sets the focus panCheck.txtDateCheckOut.Focus(); //selects all panCheck.txtDateCheckOut.SelectAll(); return; } //if all is well if (isEmpty == false) { //initializing a new checkoutitem emp = new CheckOutItem(); //adding the text from the textboxes into the items in checkoutitem emp.EmpSNum = txtSNum.Text; emp.EmpFirst = txtEmpFirst.Text; emp.EmpLast = txtEmpLast.Text; emp.EmpEmail = txtEmpEmail.Text; emp.EmpItem = panCheck.txtItemInfo.Text; emp.EmpTagNum = panCheck.txtTagNum.Text; emp.EmpDate = panCheck.txtDateCheckOut.Text; chkAccept.Checked = false; //adding all the items items.Add(emp); //sorting all the items by the S Number items.sort(); txtSNum.Clear(); txtEmpFirst.Clear(); txtEmpLast.Clear(); panCheck.txtItemInfo.Clear(); panCheck.txtTagNum.Clear(); panCheck.txtDateCheckOut.Clear(); radSoft.Enabled = true; radEquip.Enabled = true; txtEmpEmail.Clear(); radNo.Checked = false; radYes.Checked = true; txtEmpEmail.ReadOnly = true; email = "@rrcc.edu"; txtSNum.Focus(); radEquip.Checked = false; radSoft.Checked = false; radInvent.Checked = false; } this.Size = new Size(369, 314); //after that isEmpty is set to false again isEmpty = false; //clears everything } //if they didn't check the accept checkbox else if (chkAccept.Checked == false) { //then a message box will show and make sure that the check box is checked MessageBox.Show("Please check Accept Terms of \n User Agreement"); //sets the focus chkAccept.Focus(); } }
//writng a add function public void Add(CheckOutItem item) { items.Add(item); //needed this because that was most of the problem ++used; }
public frmEquipmentInventory(frmCheckItemOut formItem, CheckOutItemCollection check) { InitializeComponent(); mainForm = formItem; //declaring i as 0 int i = 0; //making the checkoutitem item equal the item in the collection at i CheckOutItem item = check.objectat(i); if (check.count() == 0) { return; } //using a for loop for the nodes for the treeview //creating new root node TreeNode root = new TreeNode(); //creating new child node TreeNode child = new TreeNode(); //creating new grandchild node TreeNode gChild = new TreeNode(); //adding the text from the textboxes to the root, child, gChild root.Text = item.EmpSNumFirstLast(); child.Text = item.EmpItemTag(); gChild.Text = item.EmpDate; //adding the root to the treeview treeEmp.Nodes.Add(root); //adding the child to the root root.Nodes.Add(child); //adding the grandchild to the child child.Nodes.Add(gChild); for (i = 1; i < check.count(); i++) { //making it so that the checkoutitem is equal to the list of items item = check.objectat(i); if (root.Text != item.EmpSNumFirstLast() && check.count() > 0) {//if the root text doesn't equal the s num text root = new TreeNode(); child = new TreeNode(); //creating new grandchild node gChild = new TreeNode(); root.Text = item.EmpSNumFirstLast(); child.Text = item.EmpItemTag(); gChild.Text = item.EmpDate; //adding the root to the treeview treeEmp.Nodes.Add(root); //adding the child to the root root.Nodes.Add(child); //adding the grandchild to the child child.Nodes.Add(gChild); // allCheck.WriteFile(root.Text); // allCheck.WriteFile(child.Text); //allCheck.WriteFile(gChild.Text); } else if (child.Text != item.EmpItemTag() && check.count() > 0) //if the child text doesn't equal the item des and tag num { child = new TreeNode(); gChild = new TreeNode(); child.Text = item.EmpItemTag(); gChild.Text = item.EmpDate; //adding the child to the root root.Nodes.Add(child); //adding the grandchild to the child child.Nodes.Add(gChild); } else if (gChild.Text != item.EmpDate && check.count() > 0) // if the text doesn't equal the text in the date text { //creating new grandchild node gChild = new TreeNode(); //equaling the text of the gChild to the text in the item gChild.Text = item.EmpDate; //adding the grandchild to the child child.Nodes.Add(gChild); } } }