private void AddRowToGridView(classInstructionRequest instruction, DataGridView grid, int index) { string[] row = new string[4]; row[0] = (grid.Rows.Count + 1).ToString(); row[1] = instruction.account[index]; row[2] = instruction.name[index]; row[3] = instruction.amount[index]; grid.Rows.Add(row); }
private void CheckAndFilterOverDraftsAccount(string filename) { classInstructionRequest instruction = new classInstructionRequest(); instruction.ReadInstructionFile(filename); File.Move(filename, filename.Substring(0, filename.LastIndexOf(".dat")) + "_bk_" + DateTime.Now.ToString("hhmmss_tt") + ".dat"); DataTable overDraftsAccountList = GetOverDraftsAccountdList(); AddLineToNewInstructionFile(instruction, overDraftsAccountList, filename); //ShowDataGridView(instruction, grdRequestValidAccount); }
private void AddLineToNewInstructionFile(classInstructionRequest instruction, DataTable list, string filename) { grdRequestValidAccount.Rows.Clear(); grdRequestInvalidAccount.Rows.Clear(); string failName = CreateFailInstructionFileName(filename); FileStream fs = new FileStream(filename, FileMode.Create); StreamWriter w = new StreamWriter(fs, Encoding.ASCII); FileStream fs1 = new FileStream(failName, FileMode.Create); StreamWriter w1 = new StreamWriter(fs1, Encoding.ASCII); FileStream fs2 = new FileStream(failName.Replace('Q', 'P'), FileMode.Create); StreamWriter w2 = new StreamWriter(fs2, Encoding.ASCII); w.Write("00" + instruction.fileProcessDate); w.Write('\n'); w1.Write("00" + instruction.fileProcessDate); w1.Write('\n'); int count = 0; int count1 = 0; for (int i = 0; i < instruction.numberOfRecord; i++) { if (CheckOverDraftsAccount(instruction.account[i], long.Parse(instruction.amount[i]), list) == true) { w.Write(instruction.recordContent[i]); w.Write('\n'); count++; AddRowToGridView(instruction, grdRequestValidAccount, i); } else { w1.Write(instruction.recordContent[i]); w1.Write('\n'); w2.WriteLine(CreateResponseRecord(instruction.recordContent[i])); count1++; AddRowToGridView(instruction, grdRequestInvalidAccount, i); } } w.Write("99" + instruction.fileProcessDate + count.ToString().PadLeft(12, '0')); w.Write('\n'); w1.Write("99" + instruction.fileProcessDate + count1.ToString().PadLeft(12, '0')); w1.Write('\n'); w.Flush(); w.Close(); fs.Close(); w1.Flush(); w1.Close(); fs1.Close(); w2.Flush(); w2.Close(); fs2.Close(); }