1. 程式人生 > >17日站立會議

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();
}
}

}
}