public static void Update(MySql.Data.MySqlClient.MySqlCommand cmd, VendorBalance sc) { cmd.CommandText = sc.GetUpdateSQL(); cmd.ExecuteNonQuery(); foreach (VendorBalanceEntry sce in sc.VENDOR_BALANCE_ENTRIES) { if (sce.ID == 0) { cmd.CommandText = sce.GetInsertSQL(); cmd.ExecuteNonQuery(); cmd.CommandText = VendorBalanceEntry.SelectMaxIDSQL(); sce.ID = Convert.ToInt32(cmd.ExecuteScalar()); } else { cmd.CommandText = sce.GetUpdateSQL(); cmd.ExecuteNonQuery(); } } cmd.CommandText = VendorBalanceEntry.FindByVendorBalance(sc.ID); MySql.Data.MySqlClient.MySqlDataReader r = cmd.ExecuteReader(); IList sces = VendorBalanceEntry.TransformReaderList(r); r.Close(); foreach (VendorBalanceEntry sce in sces) { sce.UPDATED = sc.VENDOR_BALANCE_ENTRIES.Contains(sce); } foreach (VendorBalanceEntry sce in sces) { if (!sce.UPDATED) { cmd.CommandText = VendorBalanceEntry.DeleteSQL(sce.ID); cmd.ExecuteNonQuery(); } } }
public static void UpdateHeader(MySql.Data.MySqlClient.MySqlCommand cmd, VendorBalance sc) { cmd.CommandText = sc.GetUpdateSQL(); cmd.ExecuteNonQuery(); }