public void RemoveHyphenFromTrans(/* IN & OUT */ TransRec[] transArray) { TransRec[] tempArray1 = new TransRec[transArray.Length]; for (int d = 0; d < transArray.Length; d++) { tempArray1[d] = transArray[d]; string forSplit3 = tempArray1[d].strPartNumber; string[] remHyphen3 = forSplit3.Split('-'); string firstHalfPartNum3 = remHyphen3[0]; string secHalfPartNum3 = remHyphen3[1]; string localPartNum3 = firstHalfPartNum3 + secHalfPartNum3; tempArray1[d].strPartNumber = localPartNum3; transArray[d].strPartNumber = tempArray1[d].strPartNumber; transArray[d].chrTransType = tempArray1[d].chrTransType; transArray[d].intTransQty = tempArray1[d].intTransQty; } transArray = tempArray1; }
// * * * * * * * * * * * * * * START OF PROCESSINGING TRANSACTIONS * * * * * * * * * * * * * * * * private void ProcTransBtn_Click(object sender, EventArgs e) { transRecStruct = new TransRec(); StreamReader din1; string filename = "Transactions.in"; din1 = new StreamReader(filename); if (!File.Exists(filename)) { MessageBox.Show("The input file Transactions.in does not exist. The program will terminate."); this.Close(); } else { MessageBox.Show("The Transactions are being read into the program."); } // This chunk determines how long to make the array if storying these values into their own away string readToCount = ""; int lineCount = 0; readToCount = din1.ReadLine(); while (readToCount != null) { lineCount++; readToCount = din1.ReadLine(); } // array will store the Transactions.In file transactionsIn = new TransRec[lineCount]; // Read in first line of Transactions.In StreamReader din3; din3 = new StreamReader(filename); string transLineRead = ""; transLineRead = din3.ReadLine(); string[] firstLnRdArray = transLineRead.Split((char[])null, StringSplitOptions.RemoveEmptyEntries); transRecStruct.strPartNumber = firstLnRdArray[0]; // this char conversion is currently showing the ascii int val in the struct.. transRecStruct.chrTransType = Convert.ToChar(firstLnRdArray[1]); transRecStruct.intTransQty = Convert.ToInt32(firstLnRdArray[2]); transactionsIn[0].strPartNumber = transRecStruct.strPartNumber; transactionsIn[0].chrTransType = transRecStruct.chrTransType; transactionsIn[0].intTransQty = transRecStruct.intTransQty; //MessageBox.Show("The first line of the file is" + transRecStruct.strPartNumber + transRecStruct.chrTransType + transRecStruct.intTransQty); // Split string with hyphen and store into struct string forTransSplit = transRecStruct.strPartNumber; string[] remHyphen1 = forTransSplit.Split('-'); string firstHalfTransPartNum = remHyphen1[0]; string secHalfTransPartNum = remHyphen1[1]; string localTransPartNum = firstHalfTransPartNum + secHalfTransPartNum; transRecStruct.strPartNumber = localTransPartNum; if (accessClass.FindElement(/* IN */ resizedArray, /* IN */ Convert.ToInt32(localTransPartNum)) == true) { accessClass.GetCurrentPosition(); if (transRecStruct.chrTransType == 's' || transRecStruct.chrTransType == 'S' && (resizedArray[accessClass.GetCurrentPosition()].intQtyOnHand - transRecStruct.intTransQty > -1)) { resizedArray[accessClass.GetCurrentPosition()].intQtyOnHand = resizedArray[accessClass.GetCurrentPosition()].intQtyOnHand - transRecStruct.intTransQty; } else if (transRecStruct.chrTransType == 'p' || transRecStruct.chrTransType == 'P') { resizedArray[accessClass.GetCurrentPosition()].intQtyOnOrder = resizedArray[accessClass.GetCurrentPosition()].intQtyOnOrder + transRecStruct.intTransQty; } else if (transRecStruct.chrTransType == 'r' || transRecStruct.chrTransType == 'R' && (resizedArray[accessClass.GetCurrentPosition()].intQtyOnHand - transRecStruct.intTransQty > -1)) { resizedArray[accessClass.GetCurrentPosition()].intQtyOnHand = resizedArray[accessClass.GetCurrentPosition()].intQtyOnHand + transRecStruct.intTransQty; resizedArray[accessClass.GetCurrentPosition()].intQtyOnOrder = resizedArray[accessClass.GetCurrentPosition()].intQtyOnOrder - transRecStruct.intTransQty; } resizedArray = accessClass.GetIncomingArray(); } else // if the part num is not in the master list, show error and ignore it. { MessageBox.Show(localTransPartNum + " does not exist in the list."); } // * * * * * * * * * END OF PROCESSING FIRST LINE OF TRANSACTIONS.IN * * * * * * * * int m = 1; string importLineRead1 = ""; importLineRead1 = din3.ReadLine(); while (importLineRead1 != null) { string[] importtLnRdArray1 = importLineRead1.Split((char[])null, StringSplitOptions.RemoveEmptyEntries); transRecStruct.strPartNumber = importtLnRdArray1[0]; // this char conversion is currently showing the ascii int val in the struct.. transRecStruct.chrTransType = Convert.ToChar(importtLnRdArray1[1]); transRecStruct.intTransQty = Convert.ToInt32(importtLnRdArray1[2]); transactionsIn[m].strPartNumber = transRecStruct.strPartNumber; transactionsIn[m].chrTransType = transRecStruct.chrTransType; transactionsIn[m].intTransQty = transRecStruct.intTransQty; // Split string with hyphen and store into struct string forTransSplit1 = transRecStruct.strPartNumber; string[] remHyphen2 = forTransSplit1.Split('-'); string firstHalfTransPartNum1 = remHyphen2[0]; string secHalfTransPartNum1 = remHyphen2[1]; string localTransPartNum1 = firstHalfTransPartNum1 + secHalfTransPartNum1; transRecStruct.strPartNumber = localTransPartNum1; if (accessClass.FindElement(/* IN */ resizedArray, /* IN */ Convert.ToInt32(localTransPartNum1)) == true) { accessClass.GetCurrentPosition(); if (transRecStruct.chrTransType == 's' || transRecStruct.chrTransType == 'S') { resizedArray[accessClass.GetCurrentPosition()].intQtyOnHand = resizedArray[accessClass.GetCurrentPosition()].intQtyOnHand - transRecStruct.intTransQty; } else if (transRecStruct.chrTransType == 'p' || transRecStruct.chrTransType == 'P') { resizedArray[accessClass.GetCurrentPosition()].intQtyOnOrder = resizedArray[accessClass.GetCurrentPosition()].intQtyOnOrder + transRecStruct.intTransQty; } else if (transRecStruct.chrTransType == 'r' || transRecStruct.chrTransType == 'R') { resizedArray[accessClass.GetCurrentPosition()].intQtyOnHand = resizedArray[accessClass.GetCurrentPosition()].intQtyOnHand + transRecStruct.intTransQty; resizedArray[accessClass.GetCurrentPosition()].intQtyOnOrder = resizedArray[accessClass.GetCurrentPosition()].intQtyOnOrder - transRecStruct.intTransQty; } } else // if the part num is not in the master list, show error and ignore it. { MessageBox.Show(localTransPartNum + " does not exist in the list."); } m++; importLineRead1 = din3.ReadLine(); } resizedArray = accessClass.GetIncomingArray(); din1.Close(); din3.Close(); procTransBtn.Enabled = false; outputBtn.Enabled = true; }