internal void Insert(SqlCommand cm, DonateBook book) { if (!this.IsDirty) { return; } cm.Parameters.Clear(); cm.CommandType = CommandType.StoredProcedure; cm.CommandText = "[app_donate].[donate_insert]"; cm.Parameters.AddWithValue("@donateid", _donateid); cm.Parameters.AddWithValue("@amount", _amount); cm.Parameters.AddWithValue("@donatecode", book.DonateType); cm.Parameters.AddWithValue("@paycode", _paidtype); cm.Parameters.AddWithValue("@memo", _memo); cm.Parameters.AddWithValue("@book_id", book.Id); cm.Parameters.AddWithValue("@regdate", book.RegDate); cm.Parameters.AddWithValue("@username", _username); cm.Parameters.Add("@newid", SqlDbType.Int).Direction = ParameterDirection.Output; cm.Parameters.Add("@newlastchanged", SqlDbType.Timestamp).Direction = ParameterDirection.Output; cm.ExecuteNonQuery(); _id = (int)cm.Parameters["@newid"].Value; _lastchanged = (byte[])cm.Parameters["@newlastchanged"].Value; MarkOld(); }
internal void DeleteSelf(SqlCommand cm, DonateBook books) { if (!this.IsDirty) { return; } if (this.IsNew) { return; } Delete(cm, _id, _username); MarkNew(); }
internal void Update(SqlCommand cm, DonateBook parent) { RaiseListChangedEvents = false; foreach (Donate item in DeletedList) { item.DeleteSelf(cm, parent); } DeletedList.Clear(); foreach (Donate item in this) { if (item.IsNew) { item.Insert(cm, parent); } else { item.Update(cm, parent); } } RaiseListChangedEvents = true; }
internal void Update(SqlCommand cm, DonateBook books) { if (!this.IsDirty) { return; } cm.Parameters.Clear(); cm.CommandType = CommandType.StoredProcedure; cm.CommandText = "[app_donate].[donate_update]"; cm.Parameters.AddWithValue("@id", _id); cm.Parameters.AddWithValue("@amount", _amount); cm.Parameters.AddWithValue("@paycode", _paidtype); cm.Parameters.AddWithValue("@memo", _memo); cm.Parameters.AddWithValue("@donateCode", books.DonateType); cm.Parameters.AddWithValue("@username", _username); cm.Parameters.AddWithValue("@lastchanged", _lastchanged); cm.Parameters.Add("@newlastchanged", SqlDbType.Timestamp).Direction = ParameterDirection.Output; cm.ExecuteNonQuery(); _lastchanged = (byte[])cm.Parameters["@newlastchanged"].Value; }