Example #1
0
        public void Insert(Shouhin shouhin)
        {
            string sql = "INSERT INTO shouhin(sname,tanka) VALUES(@sname,@tanka)";
            var    cmd = new MySqlCommand(sql, con.Connection);

            cmd.Parameters.AddWithValue("@sname", shouhin.Sname);
            cmd.Parameters.AddWithValue("@tanka", shouhin.Tanka);

            cmd.ExecuteNonQuery();
        }
Example #2
0
        public void Update(Shouhin shouhin)
        {
            var sql = "UPDATE shouhin SET sname=@sname,tanka=@tanka WHERE sid=@sid";
            var cmd = new MySqlCommand(sql, con.Connection);

            cmd.Parameters.AddWithValue("@sname", shouhin.Sname);
            cmd.Parameters.AddWithValue("@tanka", shouhin.Tanka);
            cmd.Parameters.AddWithValue("@sid", shouhin.Sid);

            cmd.ExecuteNonQuery();
        }
Example #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            String sname = textBoxSname.Text;
            int    tanka = int.Parse(textBoxTanka.Text);

            if (shouhin == null)
            {
                shouhin = new Shouhin(0, sname, tanka);
            }
            else
            {
                shouhin.Sname = sname;
                shouhin.Tanka = tanka;
            }
        }
Example #4
0
        private void buttonDel_Click(object sender, EventArgs e)
        {
            Shouhin shouhin = GetCurrentShouhin();

            if (MessageBox.Show(shouhin.Sname + "を削除しますか?", "削除",
                                MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                var con = new HanbaiConnection();
                var dao = new ShouhinDAO(con);

                con.Open();
                dao.Delete(shouhin.Sid);
                dao.Fill(dtShouhin);
                con.Close();
            }
        }
Example #5
0
        public Shouhin FindById(int sid)
        {
            var sql = "SELECT * FROM shouhin WHERE mid=@sid";
            var cmd = new MySqlCommand(sql, con.Connection);

            cmd.Parameters.AddWithValue("@sid", sid);

            var reader = cmd.ExecuteReader();

            Shouhin s = null;

            if (reader.Read())
            {
                var sname = reader.GetString("sname");
                var tanka = reader.GetInt32("tanka");

                s = new Shouhin(sid, sname, tanka);
            }
            reader.Close();

            return(s);
        }