Example #1
0
        private void mainCategoryMasterButton_Click(object sender, EventArgs e)
        {
            MainCategoryMaster mainCategory = new MainCategoryMaster(this);

            this.Hide();
            mainCategory.Show();
        }
        private void returnButton_Click(object sender, EventArgs e)
        {
            MainCategoryMaster mainCategory = new MainCategoryMaster(master);

            this.Close();
            mainCategory.Show();
        }
        private void addButton_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("登録をしますか?", "確認", MessageBoxButtons.YesNo);

            if (result == DialogResult.Yes)
            {
                NpgsqlCommandBuilder builder;

                int    mainCode = int.Parse(mainCategoryCodeTextBox.Text); //大分類コード
                string mainName = mainCategoryNameTextBox.Text;            //大分類名

                string sql_str = "insert into main_category_m values(" + mainCode + ",'" + mainName + "');";

                conn.ConnectionString = @"Server = localhost; Port = 5432; User Id = postgres; Password = postgres; Database = master;"; //変更予定
                conn.Open();

                adapter = new NpgsqlDataAdapter(sql_str, conn);
                builder = new NpgsqlCommandBuilder(adapter);

                adapter.Fill(dt);
                adapter.Update(dt);


                conn.Close();

                MessageBox.Show("登録完了");

                MainCategoryMaster mainCategory = new MainCategoryMaster(master);
                this.Close();
                mainCategory.Show();
            }
            else
            {
            }
        }
Example #4
0
        private void updateButton_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("更新をしますか?", "確認", MessageBoxButtons.YesNo);

            if (result == DialogResult.Yes)
            {
                NpgsqlConnection     conn = new NpgsqlConnection();
                NpgsqlDataAdapter    adapter;
                NpgsqlCommandBuilder builder;
                DataTable            dt = new DataTable();

                string mainName = mainCategoryNameTextBox.Text;

                conn.ConnectionString = @"Server = 192.168.152.43; Port = 5432; User Id = postgres; Password = postgres; Database = master;"; //変更予定
                conn.Open();

                string sql_str = "update main_category_m set main_category_name = '" + mainName + "' where main_category_code = " + mainCode + ";";

                adapter = new NpgsqlDataAdapter(sql_str, conn);
                builder = new NpgsqlCommandBuilder(adapter);

                adapter.Fill(dt);
                adapter.Update(dt);
                MessageBox.Show("更新完了");

                conn.Close();

                MainCategoryMaster mainCategory = new MainCategoryMaster(master);
                this.Close();
                mainCategory.Show();
            }
            else
            {
            }
        }