19日站立会议
今天进行了每日消费的编程
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