string str; string invoice_num_10; string invoice_num_9; double invoice_amount_9=0; double invoice_tax_9=0; int i; if(openFileDialog1.ShowDialog() == DialogResult.Cancel) return; System.IO.StreamReader f_name = new System.IO.StreamReader(openFileDialog1.FileName,System.Text.Encoding.Default); while((str = f_name.ReadLine()) != null) //读取每一行的信息 { if(str.StartsWith("//")) { str = f_name.ReadLine(); //int nRowCount = Convert.ToInt32(str[3]); str = str.Replace("~~", "~"); string[] mychar = str.Split(‘~‘); int nRowCount = Convert.ToInt16(mychar[5]); invoice_num_9 = mychar[3]+mychar[4]; invoice_num_10 = mychar[8]; invoice_amount_9= Convert.ToDouble(mychar[9]); invoice_tax_9= Convert.ToDouble(mychar[11]); // MessageBox.Show(invoice_num_9); for(i=1;i<=efGrid1.EFRows -1;i++) //循环Grid每一行,找到与读取invoice_num_10相同的行,并赋值 { if(efGrid1.GetDataDisplay(i,"invoice_num_10").ToString().Trim() == invoice_num_10.Trim()) { efGrid1[i,"check_option"] = true; efGrid1[i,"invoice_num_9"] = invoice_num_9; efGrid1[i,"invoice_amount_9"] =invoice_amount_9; efGrid1[i,"tax_amount_9"] =invoice_tax_9; } } for(int iRow=0; iRow<nRowCount; iRow++) { str = f_name.ReadLine(); } } } f_name.Close();
时间: 2024-10-25 04:18:19