示例#1
0
        public void Save(EmployeeBO bo)
        {
            string text = bo.Name + ";" + bo.Age + ";" + bo.Salary;
               FileStream fout = new FileStream("data.txt", FileMode.Append);
               StreamWriter sw = new StreamWriter(fout);

               sw.WriteLine(text);

               sw.Close();
               fout.Close();
        }
示例#2
0
 public void Save(EmployeeBO bo)
 {
     //salary calculate
        if (bo.Age < 20)
        {
        bo.Salary = 40000;
        }
        else {
        bo.Salary = 80000;
        }
        EmployeeDAL dal = new EmployeeDAL();
        dal.Save(bo);
 }
示例#3
0
        public void Input()
        {
            Console.Write("Enter Name = ");
            string name = Console.ReadLine();
            Console.Write("Enter Age = ");
            string age = Console.ReadLine();

            EmployeeBO bo = new EmployeeBO();
            bo.Name = name;
            bo.Age = int.Parse( age);

            EmployeeBLL employeeBll = new EmployeeBLL();

            employeeBll.Save(bo);
            Console.WriteLine("Data saved");
        }
示例#4
0
        public List<EmployeeBO> ReadData()
        {
            List<EmployeeBO> list = new List<EmployeeBO>();
               //read from file
               FileStream fin = new FileStream("data.txt",FileMode.Open);
               StreamReader sr = new StreamReader(fin);
               string line;

               while((line = sr.ReadLine())!=null)
               {
               string[] data = line.Split(';');

               EmployeeBO bo = new EmployeeBO();
               bo.Name = data[0];
               bo.Age = int.Parse(data[1]);
               bo.Salary = double.Parse(data[2]);

               list.Add(bo);
               }

               return list;
        }