17日站立会议

今日站立会议,大家修改了各自的代码

public partial class Form当日消费情况 : Form
{
public Form当日消费情况()
{
InitializeComponent();
}
bool flag = false;
private void Form当日消费情况_Load(object sender, EventArgs e)
{
label1.Text = "消费情况如下";
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
{
string[] sNew = sFile.Split(Environment.NewLine.ToCharArray());

foreach (string s in sNew)
{
if (s == "")
{
continue;
}
string[] text = s.Split('\t');
//刷新消费情况总和

if (text[1] == "日常用品")
textBox1.Text = (Convert.ToDouble(textBox1.Text) + Convert.ToDouble(text[2])).ToString();
if (text[1] == "学习用品")
textBox2.Text = (Convert.ToDouble(textBox2.Text) + Convert.ToDouble(text[2])).ToString();
if (text[1] == "话费")
textBox3.Text = (Convert.ToDouble(textBox3.Text) + Convert.ToDouble(text[2])).ToString();
if (text[1] == "饮食")
textBox4.Text = (Convert.ToDouble(textBox4.Text) + Convert.ToDouble(text[2])).ToString();
if (text[1] == "衣服")
textBox5.Text = (Convert.ToDouble(textBox5.Text) + Convert.ToDouble(text[2])).ToString();
if (text[1] == "其他")
textBox6.Text = (Convert.ToDouble(textBox6.Text) + Convert.ToDouble(text[2])).ToString();
}
}
}
else
{
textBox1.Text = "0";//日常用品
textBox2.Text = "0";//学习用品
textBox3.Text = "0";//电话卡
textBox4.Text = "0";//饮食
textBox5.Text = "0";//衣服
textBox6.Text = "0";//其他
}
}
else
{
textBox1.Text = "0";//日常用品
textBox2.Text = "0";//学习用品
textBox3.Text = "0";//电话卡
textBox4.Text = "0";//饮食
textBox5.Text = "0";//衣服
textBox6.Text = "0";//其他
}
}

private void button1_Click(object sender, EventArgs e)
{
Form功能选择 f = new Form功能选择();
f.Show();
flag = true;
this.Close();
}

private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
{
label1.Text = "消费情况如下";
string str = dateTimePicker1.Text;
string sFile = null;
string dp = Test.path + @"\文本数据\" + str.Substring(0, 8);
if (Directory.Exists(dp))
{
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
{
string[] sNew = sFile.Split(Environment.NewLine.ToCharArray());

foreach (string s in sNew)
{
if (s == "")
{
continue;
}
string[] text = s.Split('\t');
//刷新消费情况总和

if (text[1] == "日常用品")
textBox1.Text = (Convert.ToDouble(textBox1.Text) + Convert.ToDouble(text[2])).ToString();
if (text[1] == "学习用品")
textBox2.Text = (Convert.ToDouble(textBox2.Text) + Convert.ToDouble(text[2])).ToString();
if (text[1] == "话费")
textBox3.Text = (Convert.ToDouble(textBox3.Text) + Convert.ToDouble(text[2])).ToString();
if (text[1] == "饮食")
textBox4.Text = (Convert.ToDouble(textBox4.Text) + Convert.ToDouble(text[2])).ToString();
if (text[1] == "衣服")
textBox5.Text = (Convert.ToDouble(textBox5.Text) + Convert.ToDouble(text[2])).ToString();
if (text[1] == "其他")
textBox6.Text = (Convert.ToDouble(textBox6.Text) + Convert.ToDouble(text[2])).ToString();
}
}
}
else
{
textBox1.Text = "0";//日常用品
textBox2.Text = "0";//学习用品
textBox3.Text = "0";//电话卡
textBox4.Text = "0";//饮食
textBox5.Text = "0";//衣服
textBox6.Text = "0";//其他
}
}
else
{
textBox1.Text = "0";//日常用品
textBox2.Text = "0";//学习用品
textBox3.Text = "0";//电话卡
textBox4.Text = "0";//饮食
textBox5.Text = "0";//衣服
textBox6.Text = "0";//其他
}
}

private void Form当日消费情况_FormClosed(object sender, FormClosedEventArgs e)
{
if (flag)
{
return;
}
else
{
Test._f.Close();
}
}

}
}

猜你喜欢

转载自www.cnblogs.com/chenchen21/p/9975942.html