本文整理汇总了C#中System.Data.DataRowView.DetachRow方法的典型用法代码示例。如果您正苦于以下问题:C# DataRowView.DetachRow方法的具体用法?C# DataRowView.DetachRow怎么用?C# DataRowView.DetachRow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.DataRowView
的用法示例。
在下文中一共展示了DataRowView.DetachRow方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckClientActiveRules
/// <summary>
///
/// </summary>
/// <param name="clientRow"></param>
/// <param name="proposedActive"></param>
/// <param name="message"></param>
/// <param name="reasonRequired"></param>
/// <param name="reason"></param>
/// <returns>true = save was allowed, false = further action required</returns>
public bool CheckClientActiveRules(DataRowView clientRow, bool proposedActive, out string message, out bool reasonRequired, string reason = null)
{
//nugget: this DataTable.ColumnChanging => Exception based approach doesn't really work out...
//nugget: good to document and remember since it's conceptually appealing
//nugget: unfortunately the UI checkbox still flips itself even if the underlying field doesn't
//nugget: DataTable.ColumnChanging: if (error) { e.Row.CancelEdit(); e.Row.SetColumnError(e.Column, err); throw (new Exception(err)); }
message = null;
reasonRequired = false;
//sponsor rules...
if (clientRow.Field<bool>("IsSponsor"))
{
//make sure not PCS'ed, which should be resolved via PCS specific logic elsewhere
if (IsPCS)
{
message = "Resolving PCS status will clear de-active.";
return (false);
}
//otherwise get Reason for hitting Active ...
if (reason == null) //... and no reason has been provided yet, ...
{
message = !proposedActive ? "Why deactivating this Household?\n(if Suspension or PCS, use those buttons)" :
"Why allowing this Household to be active again?";
reasonRequired = true; // indicate reason required
return (false);
}
// ReSharper disable InconsistentNaming
using (var Sponsor_Active_u = new iTRAACProc("Sponsor_Active_u"))
// ReSharper restore InconsistentNaming
{
Sponsor_Active_u["@SponsorGUID"] = GUID;
Sponsor_Active_u["@RemarkTypeId"] = 23 * (!proposedActive ? 1 : -1); //! necessary because it's a "deactivated" oriented status
Sponsor_Active_u["@Reason"] = reason;
CacheTables(Sponsor_Active_u);
}
if (!proposedActive) ShowDeactiveMembers = true;
OnPropertyChanged("ShowDeactiveMembers");
HouseMembers = HouseMembers; //for some reason OnPropertyChanged("HouseMembers") didn't refresh the Members Grid, i don't have a good guess but this little hack worked immediately so i'm moving on
OnPropertyChanged("Fields");
return (true); //no further processing desired after special sponsor level sproc
}
//spousal rules...
//if attempting to deactivate spouse, let them know the rules...
if (clientRow.Field<bool>("IsSpouse") && !proposedActive)
{
message = "Only valid way to deactivate Spouse is by *official* divorce (\"Legal Separation\" is not sufficient).\r\n"+
"Use the hidden Divorce button to the left of the Spouse.";
return (false);
}
//if this is just a fresh new row the user doesn't want to fill out, just whack it straight away
if (clientRow.Row.RowState == DataRowState.Added)
{
clientRow.DetachRow();
//can't track an IsModified "undo" anymore now that i've had to move to a flat property that's set by everything that can be dirty:
//OnPropertyChanged("IsModified");
return (true);
}
//finally! set the flag...
clientRow.Row.SetReadonlyField("Active", proposedActive);
OnPropertyChanged("DependentsSelectionList");
IsModified = true;
return (true); //return success
}
示例2: Remove
static public void Remove(DataRowView remarkRow, string comments)
{
//if this remark row hasn't been saved to the DB yet, then just whack it here client side and forget about it
if (remarkRow.Row.RowState == DataRowState.Added)
{
remarkRow.DetachRow();
return;
}
remarkRow.Row.SetReadonlyField("DeleteReason", comments);
/* this going straight to the DB approach was a little overzealous i think...
RemarkRow.AcceptChanges(); //nix the dirty flag for this edit because we're saving to DB immediately
//can't using() because scope drops and nulls out the Proc object out before the background thread executes
//but ExecuteNonQueryBackground() calls Dispose when it's done so should be ok
iTRAACProc Remark_d = new iTRAACProc("Remark_d");
Remark_d["@RemarkGUID"] = RemarkRow["RowGUID"];
Remark_d["@Reason"] = Comments;
Remark_d.ExecuteNonQueryBackground("Delete Remark: ", false);
*/
}