예제 #1
0
        private void button4_Click(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection("Data Source=DELL-PC\\SQLEXPRESS;Initial Catalog=NGOIdatabase;Integrated Security=True");

            conn.Open();
            SqlCommand comd = conn.CreateCommand();

            comd.CommandType = CommandType.Text;
            comd.CommandText = "delete from Expenditures where Expenditures_id= '" + textBox3.Text + "'";
            comd.ExecuteNonQuery();
            //Salesdb sdb = new Salesdb();
            //dataGridView2.DataSource = sdb.selectall();
            conn.Close();
            this.Close();
            Expenditures exp = new Expenditures();

            exp.Show();
        }
예제 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection("Data Source=DELL-PC\\SQLEXPRESS;Initial Catalog=NGOIdatabase;Integrated Security=True");

            conn.Open();
            try
            {
                SqlCommand comd = conn.CreateCommand();
                comd.CommandType = CommandType.Text;
                DateTime d = Convert.ToDateTime(dateTimePicker1.Text);
                if (textBox3.Text == "")
                {
                    //MessageBox.Show("I will create new");
                    comd.CommandText = "INSERT INTO Expenditures (expenditure_type_id, Total_amount, Month_date , date_created) values ('" + comboBox2.Text + "','" + textBox1.Text + "','" + monthCalendar1.Text + "','" + d.Year + "-" + d.Month + "-" + d.Day + "')";
                }
                else
                {
                    //MessageBox.Show("I will update");
                    comd.CommandText = "UPDATE Expenditures SET expenditure_type_id='" + comboBox2.Text + "',Total_amount='" + textBox1.Text + "',Month_date='" + monthCalendar1.Text + "',date_created='" + d.Year + "-" + d.Month + "-" + d.Day + "' where expenditure_id=" + textBox3.Text;
                }
                //SqlCommand comd = conn.CreateCommand();
                // comd.CommandType = CommandType.Text;

                comd.ExecuteNonQuery();
                Expendituresdb edb = new Expendituresdb();
                dataGridView1.DataSource = edb.selectall();
                conn.Close();
            }
            catch (Exception e2)
            {
                MessageBox.Show(e2.Message);
            }
            reset_layout();
            this.Close();
            Expenditures ex = new Expenditures();

            ex.Show();
        }
예제 #3
0
        private void button4_Click(object sender, EventArgs e)
        {
            Form f = new Expenditures();

            f.Show();
        }