コード例 #1
0
        public static void Update(MySql.Data.MySqlClient.MySqlCommand cmd, StockCard sc)
        {
            cmd.CommandText = sc.GetUpdateSQL();
            cmd.ExecuteNonQuery();
            foreach (StockCardEntry sce in sc.STOCK_CARD_ENTRIES)
            {
                if (sce.ID == 0)
                {
                    cmd.CommandText = sce.GetInsertSQL();
                    cmd.ExecuteNonQuery();
                    cmd.CommandText = StockCardEntry.SelectMaxIDSQL();
                    sce.ID          = Convert.ToInt32(cmd.ExecuteScalar());
                }
                else
                {
                    cmd.CommandText = sce.GetUpdateSQL();
                    cmd.ExecuteNonQuery();
                }
            }
            cmd.CommandText = StockCardEntry.FindByStockCard(sc.ID);
            MySql.Data.MySqlClient.MySqlDataReader r = cmd.ExecuteReader();
            IList sces = StockCardEntry.TransformReaderList(r);

            r.Close();
            foreach (StockCardEntry sce in sces)
            {
                sce.UPDATED = sc.STOCK_CARD_ENTRIES.Contains(sce);
            }
            foreach (StockCardEntry sce in sces)
            {
                if (!sce.UPDATED)
                {
                    cmd.CommandText = StockCardEntry.DeleteSQL(sce.ID);
                    cmd.ExecuteNonQuery();
                }
            }
        }
コード例 #2
0
 public static void Delete(MySql.Data.MySqlClient.MySqlCommand cmd, StockCardEntry sc)
 {
     cmd.CommandText = StockCardEntry.DeleteSQL(sc.ID);
     cmd.ExecuteNonQuery();
 }