下面是可能給你一些想法基本的控制檯應用程序....
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Xml.Linq;
namespace ConsoleApplication1
{
class Program
{
//private static XElement AccountData = new XElement("Root");
private static DataSet dataSet = new DataSet();
static void Main(string[] args)
{
DataSet dataSet = new DataSet();
string[] readText = File.ReadAllLines(@"<Path to your account data file>\AccountData.txt");
string strAccountNumber = string.Empty;
string strPin = string.Empty;
string strName = string.Empty;
dataSet.ReadXml(new StringReader(new XElement("Root",
from str in readText
let fields = str.Split('*')
select new XElement("AccountData",
new XAttribute("AccountNo", fields[0]),
new XAttribute("Name", fields[1]),
new XAttribute("Pin", fields[2]),
new XAttribute("ChkBalance", fields[3]),
new XAttribute("SavBalance", fields[4])
)
).ToString()));
do
{
Console.WriteLine("Please enter your Account Number (press 'Q' to exit)");
strAccountNumber = Console.ReadLine().ToLower();
if (dataSet.Tables[0].Select(string.Format("AccountNo = '{0}'", strAccountNumber)).Count() == 1)
{
Console.WriteLine("Please enter your Pin");
strPin = Console.ReadLine().ToLower();
Console.WriteLine("Please enter your Name");
strName = Console.ReadLine();
if (dataSet.Tables[0].Select(string.Format("Pin = '{0}' AND Name = '{1}'", strPin, strName)).Count() == 1)
{
DataRow[] result = dataSet.Tables[0].Select(string.Format("Pin = '{0}' AND Name = '{1}'", strPin, strName));
foreach (DataRow row in result)
{
Console.WriteLine(string.Format("Account Info for :: {0}", strName));
Console.WriteLine("{0}, {1}, {2}, {3}, {4}", row[0], row[1], row[2], row[3], row[4]);
}
}
else
{
Console.WriteLine("Incorrect Details");
}
}
} while (strAccountNumber != "q");
}
}
}
不要忘了替換路徑.....
string[] readText = File.ReadAllLines ....
與路徑到您的數據.....
你是什麼意思「比較」? –
如果名稱和密碼已關聯,或者是使用帳號 – user3558676
註冊的名稱,則必須將該信息存儲在數據庫中,並使用查詢確定名稱和密碼是否與帳戶號碼相關聯。你也可以使用XML文件。 –