예제 #1
0
        private void insertBtn_Click(object sender, EventArgs e)
        {
            if (this.textBox1.Text == "" || this.dateTimePicker1.Text == "")
            {
                MessageBox.Show("please insert Data");
            }
            else
            {
                AccountingRepository ar = new AccountingRepository();


                if (ar.GetCurrentAmmount() == 0)
                {
                    AccountingR i = new AccountingR();
                    i.Date           = this.dateTimePicker1.Value.ToShortDateString();
                    i.Money          = Convert.ToDouble(this.textBox1.Text);
                    i.CurrentAmmount = Convert.ToDouble(this.textBox1.Text);


                    if (ar.Insert(i))
                    {
                        List <AccountingR> allResult = ar.GetAllTransiction();
                        this.dataGrid1.DataSource = allResult;

                        this.textBox1.Text        = "";
                        this.dateTimePicker1.Text = "";
                    }
                    else
                    {
                        MessageBox.Show("Can Not Insert Transition", "Insert Error");
                    }
                }
                else
                {
                    AccountingR i = new AccountingR();
                    i.Date           = this.dateTimePicker1.Value.ToShortDateString();
                    i.Money          = Convert.ToDouble(this.textBox1.Text);
                    i.CurrentAmmount = ar.GetCurrentAmmount() + Convert.ToDouble(this.textBox1.Text);


                    if (ar.Insert(i))
                    {
                        List <AccountingR> allResult = ar.GetAllTransiction();
                        this.dataGrid1.DataSource = allResult;

                        this.textBox1.Text        = "";
                        this.dateTimePicker1.Text = "";
                    }
                    else
                    {
                        MessageBox.Show("Can Not Insert Transition", "Insert Error");
                    }
                }


                //
            }
        }