20日站立會議
今日修改昨天的程式碼,進行完善
panel1.Visible = false;
panel2.Visible = false;
listBox1.Items.Clear();
string str = dateTimePicker1.Text;
string sFile = null;
if (Directory.Exists(Test.path + @"\文字資料\" + str.Substring(0, 8)))
{
string sp = Test.path + @"\文字資料\" + str.Substring(0, 8) + @"\" + str.Substring(8) + @".txt";
if (File.Exists(sp))
{
using (FileStream fs = new FileStream(sp, FileMode.OpenOrCreate, FileAccess.Read))
{
byte[] buffer = new byte[1024 * 1024 * 5];
int x = fs.Read(buffer, 0, buffer.Length);
sFile = Encoding.Default.GetString(buffer, 0, x);
}
if (sFile == null)
{
textBox1.Text = "0";//日常用品
textBox2.Text = "0";//學習用品
textBox3.Text = "0";//電話卡
textBox4.Text = "0";//飲食
textBox5.Text = "0";//衣服
textBox6.Text = "0";//其他
}
else
{
double sum = 0;
int count = 0;
string[] sNew = sFile.Split(Environment.NewLine.ToCharArray());
foreach (string s in sNew)
{
if (s == "")
{
continue;
}
count++;
listBox1.Items.Add(s);
string[] text = s.Split('\t');
//重新整理消費情況總和
if (text[1] == "日常用品")
{
textBox1.Text = (Convert.ToDouble(textBox1.Text) + Convert.ToDouble(text[2])).ToString();
sum += Convert.ToDouble(text[2]);
}
else if (text[1] == "學習用品")
{
textBox2.Text = (Convert.ToDouble(textBox2.Text) + Convert.ToDouble(text[2])).ToString();
sum += Convert.ToDouble(text[2]);
}
else if (text[1] == "話費")
{
textBox3.Text = (Convert.ToDouble(textBox3.Text) + Convert.ToDouble(text[2])).ToString();
sum += Convert.ToDouble(text[2]);
}
else if (text[1] == "飲食")
{
textBox4.Text = (Convert.ToDouble(textBox4.Text) + Convert.ToDouble(text[2])).ToString();
sum += Convert.ToDouble(text[2]);
}
else if (text[1] == "衣服")
{
textBox5.Text = (Convert.ToDouble(textBox5.Text) + Convert.ToDouble(text[2])).ToString();
sum += Convert.ToDouble(text[2]);
}
else if (text[1] == "其他")
{
textBox6.Text = (Convert.ToDouble(textBox6.Text) + Convert.ToDouble(text[2])).ToString();
sum += Convert.ToDouble(text[2]);
}
}
textBox7.Text = count.ToString();
textBox8.Text = sum.ToString();
}
}
else