示例#1
0
 public static void Save(MySql.Data.MySqlClient.MySqlCommand cmd, StockCard sc)
 {
     cmd.CommandText = sc.GetInsertSQL();
     cmd.ExecuteNonQuery();
     cmd.CommandText = StockCard.SelectMaxIDSQL();
     sc.ID           = Convert.ToInt32(cmd.ExecuteScalar());
     foreach (StockCardEntry sce in sc.STOCK_CARD_ENTRIES)
     {
         cmd.CommandText = sce.GetInsertSQL();
         cmd.ExecuteNonQuery();
         cmd.CommandText = StockCardEntry.SelectMaxIDSQL();
         sce.ID          = Convert.ToInt32(cmd.ExecuteScalar());
     }
 }
 public static void Save(MySql.Data.MySqlClient.MySqlCommand cmd, StockCardEntry sce)
 {
     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();
     }
 }
示例#3
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();
                }
            }
        }