i run a ATM project and here is my problem
i got a winforms login with 2 textboxes (username & nip)
i got a textfile defining different username and their nip:
Korben Dallas,D001
Jerry Cann,C001
Eric Clapton,C002

so here is my code

private void button2_Click(object sender, EventArgs e)
        {
            string line;

            bool trouve = false;

            string nip = textBox1.Text + "," + textBox2.Text;

            StreamReader sr = new StreamReader(@"C:\Users\cdi\Desktop\Clients.txt");

            while ((line = sr.ReadLine()) != null)
            {
                if (!trouve)
                {

                    int x = string.Compare(line, nip);
                    if (x == 0)
                    {
                        // MessageBox.Show("ok");
                        Transaction tr = new Transaction();
                        tr.Show();
                        this.Hide();
                        trouve = true;
                        break;
                    }                    
                      trouve = false;                    
                }
            }
            if (!trouve)
                MessageBox.Show("error");
        }
    }

this code is working well
but my problem is ,once my winforms transaction is open i would like to affilliate the nip from my customers textfile to the nip of my account textfile(which is :
C,D001,10001,457.98
C,C001,10021,1028.49
C,C002,10031,4.10

heere is my code so far (for this i use a console application)

static void Main(string[] args)
        {
            string strline;
            string[] strarray;
            char[] chararray=new char[]{','};

            FileStream fs = new FileStream(@"I:\projet\ComptesCopy.txt", FileMode.Open);
            StreamReader sr = new StreamReader(fs);
            strline = sr.ReadLine();
            while (strline!= null)
            {
                strarray = strline.Split(chararray);
                for (int x = 0; x <= strarray.GetUpperBound(0); x++)
                {
                    Console.WriteLine(strarray[x].Trim());
                }
                strline=sr.ReadLine();
                }
            sr.Close();
            Console.ReadLine();
            }

i can read all my content but i cant figure out how to proceed to match the nip from Uer textfile to nip from Account textfile
thanx by advance

1) You can store the user data in a database and read it from each application.
2) You can use Sockets to send messages between the apps.
3) You can use WCF (and the like) to send messages between the apps.

Treat each file as a set of entities (Customers and Accounts).

using System;
using System.Collections.Generic;
using System.IO;
using System.Windows.Forms;

namespace WindowsFormsApplication3
{
  public partial class Form2 : Form
  {
    public Form2()
    {
      InitializeComponent();
    }

    class Customer
    {
      public string Name { get; set; }
      public string AcctNbr { get; set; }
      public Account Account { get; set; }
      public static Customer FromLine(string line)
      {
        string[] flds = line.Split(new string[] { "," }, StringSplitOptions.None);
        return new Customer()
        {
          Name = flds[0],
          AcctNbr = flds[1],
        };
      }
    }
    class Account
    {
      public string AcctType { get; set; }
      public string AcctNbr { get; set; }
      public int SomeInt { get; set; }
      public decimal Balance { get; set; }
      public static Account FromLine(string line)
      {
        string[] flds = line.Split(new string[] { "," }, StringSplitOptions.None);
        return new Account()
        {
          AcctType=flds[0],
          AcctNbr=flds[1],
          SomeInt=int.Parse(flds[2]),
          Balance=decimal.Parse(flds[3]),
        };
      }
    }
    static Customer[] LoadCustomers()
    {
      List<Customer> result = new List<Customer>();
      using (StreamReader sr = new StreamReader("Customer.txt"))
      {
        string line;
        while (!string.IsNullOrEmpty((line = sr.ReadLine() ?? string.Empty).Trim()))
        {
          result.Add(Customer.FromLine(line));
        }
      }
      return result.ToArray();
    }
    static Account[] LoadAccounts()
    {
      List<Account> result = new List<Account>();
      using (StreamReader sr = new StreamReader("Account.txt"))
      {
        string line;
        while (!string.IsNullOrEmpty((line = sr.ReadLine() ?? string.Empty).Trim()))
        {
          result.Add(Account.FromLine(line));
        }
      }
      return result.ToArray();
    }
    static Account LookupAccount(Account[] accts, string number)
    {
      for (int i1 = 0; i1 < accts.Length; i1++)
      {
        if (string.Equals(accts[i1].AcctNbr, number, StringComparison.OrdinalIgnoreCase))
          return accts[i1];
      }
      return null;
    }

    void button1_Click(object sender, EventArgs e)
    {
      Customer[] customers = LoadCustomers();
      Account[] accounts = LoadAccounts();
      for (int i1 = 0; i1 < customers.Length; i1++)
      {
        customers[i1].Account = LookupAccount(accounts, customers[i1].AcctNbr);
      }

      for (int i1 = 0; i1 < customers.Length; i1++)
      {
        Console.WriteLine(string.Format("{0}'s account balance is: {1}",
          customers[i1].Name,
          customers[i1].Account == null ? "null" : customers[i1].Account.Balance.ToString()));
      }
    }
  }
}
Korben Dallas's account balance is: 457.98
Jerry Cann's account balance is: 1028.49
Eric Clapton's account balance is: 4.10

Also I think your sample file has bad data. I'm pretty sure Eric Clapton's account has more than $4.10 :)

commented: As helpfull as ever. +14

thank you sooooooooooooo much
wow

sure Eric Clapton's account has more than $4.10

Considering he played(Among others) with "The Yardbirds", "The Blues breakers" and "The Cream" that is a true statement :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.