zoukankan      html  css  js  c++  java
  • Money-去哪了每日站立会议

    今天的任务是编写代码,自己负责每日清单部分,代码还不完善,还有部分代码没有调试完成,明天继续编写调试。

    private void 每日清单_Load(object sender, EventArgs e)
    {

    }

    private void dateTimePicker1_CloseUp(object sender, EventArgs e)
    {
    //-----------------清空listview------------------
    //挂起,防止闪烁
    listView1.BeginUpdate();
    //遍历Listview并删除项
    for (int i = listView1.Items.Count - 1; i >= 0; i--)
    {
    ListViewItem item = listView1.Items[i];
    listView1.Items.Remove(item);
    }
    //结束挂起
    listView1.EndUpdate();
    //--------------------清空完毕-------------------

    //-----------------刷新窗口信息------------------
    string filename=Application.StartupPath + "\" + "账目文件" + "\" + dateTimePicker1.Value.ToString("yyyy-MM") + "\" + dateTimePicker1.Value.ToString("yyyy-MM-dd") + ".txt";
    //检查当天账单文件是否存在
    //不存在
    if (File.Exists(filename) == false)
    {
    MessageBox.Show("当天没有账单!", "提示");
    }
    //存在,打开文件,以文件流读取每一行,写入listview
    else
    {
    listView1.BeginUpdate();//挂起
    StreamReader sr = new StreamReader(filename);
    string line;
    while ((line = sr.ReadLine()) != null)
    {
    string[] text = line.Split(' ');
    ListViewItem Lvi = new ListViewItem();
    Lvi.Text = text[0];
    Lvi.SubItems.Add(text[1]);
    Lvi.SubItems.Add(text[2]);
    this.listView1.Items.Add(Lvi);
    }
    sr.Close();
    listView1.EndUpdate();//结束挂起
    //刷新计数
    textBox1.Text = Convert.ToString(listView1.Items.Count);
    //刷新金额求和
    double MoneySum = 0;
    for (int i = 0; i <= listView1.Items.Count - 1; i++)
    {
    ListViewItem Item = listView1.Items[i];
    MoneySum += Convert.ToDouble(Item.SubItems[2].Text);
    }
    textBox2.Text = Convert.ToString(MoneySum);
    //刷新消费情况总和
    textBox3.Text = "0";
    textBox4.Text = "0";
    textBox5.Text = "0";
    textBox6.Text = "0";
    textBox7.Text = "0";
    textBox8.Text = "0";
    for (int i = 0; i <= listView1.Items.Count - 1; i++)
    {
    ListViewItem Item = listView1.Items[i];
    if (listView1.Items[i].SubItems[1].Text == "日常用品")
    textBox3.Text = (Convert.ToDouble(textBox3.Text) + Convert.ToDouble(listView1.Items[i].SubItems[2].Text)).ToString();
    if (listView1.Items[i].SubItems[1].Text == "学习用品")
    textBox4.Text = (Convert.ToDouble(textBox4.Text) + Convert.ToDouble(listView1.Items[i].SubItems[2].Text)).ToString();
    if (listView1.Items[i].SubItems[1].Text == "话费")
    textBox5.Text = (Convert.ToDouble(textBox5.Text) + Convert.ToDouble(listView1.Items[i].SubItems[2].Text)).ToString();
    if (listView1.Items[i].SubItems[1].Text == "饮食")
    textBox6.Text = (Convert.ToDouble(textBox6.Text) + Convert.ToDouble(listView1.Items[i].SubItems[2].Text)).ToString();
    if (listView1.Items[i].SubItems[1].Text == "衣服")
    textBox7.Text = (Convert.ToDouble(textBox7.Text) + Convert.ToDouble(listView1.Items[i].SubItems[2].Text)).ToString();
    if (listView1.Items[i].SubItems[1].Text == "其他")
    textBox8.Text = (Convert.ToDouble(textBox8.Text) + Convert.ToDouble(listView1.Items[i].SubItems[2].Text)).ToString();
    }
    }
    //--------------------刷新信息完毕---------------------

  • 相关阅读:
    guaguia
    webapp手机移动端开发技巧
    两个数组对象对比
    json 根据某个子,寻找父节点的算法
    递归写法
    数组归类
    视频点击按钮下载
    微信小程序 直接跳转到首页
    iframe 跨域传值
    判断对象是否为空
  • 原文地址:https://www.cnblogs.com/amnavov/p/10072967.html
Copyright © 2011-2022 走看看