예제 #1
0
 //// 当前窗口高度
 //private int formHeight = 0;
 //// 当前窗口宽度
 //private int formWidth = 0;
 public MainForm()
 {
     InitializeComponent();
     // 禁止用户改变尺寸
     this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
     AddForm addForm = new AddForm();
     addForm.mForm = this;
 }
예제 #2
0
        /// <summary>
        /// 窗口加载时调用的事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MainForm_Load(object sender, EventArgs e)
        {
            AddForm addForm = new AddForm();

            addForm.mForm = this;
            // TODO: This line of code loads data into the 'familyDataSet.Consume' table. You can move, or remove it, as needed.
            // 我们这里不需要这样的刷新信息到表控件的代码 直接通过手写代码查询 下方代码的作用我们用绑定同样能够实现
            this.consumeTableAdapter.Fill(this.familyDataSet.Consume);
            //this.bindData(string.Empty);

            // 默认选中第一项
            cboDirection.SelectedIndex = 0;
            cboSort.SelectedIndex      = 0;
            cboType.SelectedIndex      = 0;
            cboCategory.SelectedIndex  = 0;
            // 隐藏下面大面板
            openOrClosePnlButtom(true);

            // 加载窗体的时候就开始计时  这样可以保证进入的时候当前时间是正确的
            DateTime dt = DateTime.Now;
            // 获得年月日部分
            string date = dt.ToLongDateString();
            // 获得时间部分
            string time = dt.ToLongTimeString();

            lblTime.Text = date + time;

            // 加载年月日下拉框的所有值
            // 年
            for (int i = 1900; i < 2060; i++)
            {
                cboYear.Items.Add(i.ToString());
            }
            // 月
            for (int i = 1; i < 13; i++)
            {
                cboMonth.Items.Add(i.ToString());
            }
            // 日
            for (int i = 1; i < 32; i++)
            {
                cboDay.Items.Add(i.ToString());
            }

            //// 下面的是判定日显示天数的方法  但并不正确
            //if (Convert.ToInt32(cboMonth.Text) == 1 || Convert.ToInt32(cboMonth.Text) == 3 || Convert.ToInt32(cboMonth.Text) == 5 || Convert.ToInt32(cboMonth.Text) == 7 || Convert.ToInt32(cboMonth.Text) == 8 || Convert.ToInt32(cboMonth.Text) == 10 || Convert.ToInt32(cboMonth.Text) == 12)
            //{
            //    for (int i = 1; i < 32; i++)
            //    {
            //        cboDay.Items.Add(i.ToString());
            //    }
            //}
            //else if (Convert.ToInt32((cboMonth.Text)) == 4 || Convert.ToInt32(cboMonth.Text) == 6 || Convert.ToInt32(cboMonth.Text) == 9 || Convert.ToInt32(cboMonth.Text) == 11)
            //{
            //    for (int i = 1; i < 31; i++)
            //    {
            //        cboDay.Items.Add(i.ToString());
            //    }
            //}
            //else
            //{
            //    if ((Convert.ToInt32(cboYear.Text) % 4 == 0 && Convert.ToInt32(cboYear.Text) % 100 != 0) || Convert.ToInt32(cboYear.Text) % 400 != 0)
            //    {
            //        for (int i = 1; i < 30; i++)
            //        {
            //            cboDay.Items.Add(i);
            //        }
            //    }
            //    else
            //    {
            //        for (int i = 1; i < 29; i++)
            //        {
            //            cboDay.Items.Add(i);
            //        }
            //    }
            //}

            // 取得总收入和总支出
            double shouRu, zhiChu;

            shouRu = this.getTotalMoney("收入");
            zhiChu = this.getTotalMoney("支出");
            // 把上面获得的值显示在 收入 支出 差额 textbox 上
            txtRu.Text  = shouRu.ToString();
            txtChu.Text = zhiChu.ToString();
            //这里打印差额的时候做一个计算  如果为正值就显示金黄色  负值显示红色  相等就显示黑色
            if (shouRu > zhiChu)
            {
                txtCha.ForeColor = Color.Yellow;
            }
            else if (shouRu == zhiChu)
            {
                txtCha.ForeColor = Color.Black;
            }
            else
            {
                txtCha.ForeColor = Color.Red;
            }
            txtCha.Text = (shouRu - zhiChu).ToString();
        }
예제 #3
0
 /// <summary>
 /// 这是我们伟大的同步数据表的方法
 /// </summary>
 public void fill()
 {
     AddForm addForm = new AddForm();
     addForm.mForm = this;
     this.consumeTableAdapter.Fill(this.familyDataSet.Consume);
 }
예제 #4
0
 /// <summary>
 ///  菜单栏所有按钮实现功能
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 // 增
 private void toolStripButton1_Click(object sender, EventArgs e)
 {
     AddForm addForm = new AddForm();
     //addForm.mainForm = this;
     addForm.Show();
 }
예제 #5
0
        /// <summary>
        /// 窗口加载时调用的事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MainForm_Load(object sender, EventArgs e)
        {
            AddForm addForm = new AddForm();
            addForm.mForm = this;
            // TODO: This line of code loads data into the 'familyDataSet.Consume' table. You can move, or remove it, as needed.
            // 我们这里不需要这样的刷新信息到表控件的代码 直接通过手写代码查询 下方代码的作用我们用绑定同样能够实现
            this.consumeTableAdapter.Fill(this.familyDataSet.Consume);
            //this.bindData(string.Empty);

            // 默认选中第一项
            cboDirection.SelectedIndex = 0;
            cboSort.SelectedIndex = 0;
            cboType.SelectedIndex = 0;
            cboCategory.SelectedIndex = 0;
            // 隐藏下面大面板
            openOrClosePnlButtom(true);

            // 加载窗体的时候就开始计时  这样可以保证进入的时候当前时间是正确的
            DateTime dt = DateTime.Now;
            // 获得年月日部分
            string date = dt.ToLongDateString();
            // 获得时间部分
            string time = dt.ToLongTimeString();
            lblTime.Text = date + time;

            // 加载年月日下拉框的所有值
            // 年
            for (int i = 1900; i < 2060; i++)
            {
                cboYear.Items.Add(i.ToString());
            }
            // 月
            for (int i = 1; i < 13; i++)
            {
                cboMonth.Items.Add(i.ToString());
            }
            // 日
            for (int i = 1; i < 32; i++)
            {
                cboDay.Items.Add(i.ToString());
            }

            //// 下面的是判定日显示天数的方法  但并不正确
            //if (Convert.ToInt32(cboMonth.Text) == 1 || Convert.ToInt32(cboMonth.Text) == 3 || Convert.ToInt32(cboMonth.Text) == 5 || Convert.ToInt32(cboMonth.Text) == 7 || Convert.ToInt32(cboMonth.Text) == 8 || Convert.ToInt32(cboMonth.Text) == 10 || Convert.ToInt32(cboMonth.Text) == 12)
            //{
            //    for (int i = 1; i < 32; i++)
            //    {
            //        cboDay.Items.Add(i.ToString());
            //    }
            //}
            //else if (Convert.ToInt32((cboMonth.Text)) == 4 || Convert.ToInt32(cboMonth.Text) == 6 || Convert.ToInt32(cboMonth.Text) == 9 || Convert.ToInt32(cboMonth.Text) == 11)
            //{
            //    for (int i = 1; i < 31; i++)
            //    {
            //        cboDay.Items.Add(i.ToString());
            //    }
            //}
            //else
            //{
            //    if ((Convert.ToInt32(cboYear.Text) % 4 == 0 && Convert.ToInt32(cboYear.Text) % 100 != 0) || Convert.ToInt32(cboYear.Text) % 400 != 0)
            //    {
            //        for (int i = 1; i < 30; i++)
            //        {
            //            cboDay.Items.Add(i);
            //        }
            //    }
            //    else
            //    {
            //        for (int i = 1; i < 29; i++)
            //        {
            //            cboDay.Items.Add(i);
            //        }
            //    }
            //}

            // 取得总收入和总支出
            double shouRu, zhiChu;
            shouRu = this.getTotalMoney("收入");
            zhiChu = this.getTotalMoney("支出");
            // 把上面获得的值显示在 收入 支出 差额 textbox 上
            txtRu.Text = shouRu.ToString();
            txtChu.Text = zhiChu.ToString();
            //这里打印差额的时候做一个计算  如果为正值就显示金黄色  负值显示红色  相等就显示黑色
            if (shouRu > zhiChu)
            {
                txtCha.ForeColor = Color.Yellow;
            }
            else if(shouRu == zhiChu)
            {
                txtCha.ForeColor = Color.Black;
            }
            else
            {
                txtCha.ForeColor = Color.Red;
            }
            txtCha.Text = (shouRu - zhiChu).ToString();
        }
예제 #6
0
 /// <summary>
 /// 点击 "新增收支" 按钮触发的事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnInsert_Click(object sender, EventArgs e)
 {
     AddForm addForm = new AddForm();
     addForm.mForm = this;
     addForm.Show();
 }