本文整理汇总了C#中System.Data.DataRowView.Field方法的典型用法代码示例。如果您正苦于以下问题:C# DataRowView.Field方法的具体用法?C# DataRowView.Field怎么用?C# DataRowView.Field使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.DataRowView
的用法示例。
在下文中一共展示了DataRowView.Field方法的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: DenyEdit
static public bool DenyEdit(DataRowView r, string columnName, out string message)
{
message = null;
if (!UserModel.Current.Access.IsAdmin && r.Field<bool>("Alert") && r.Field<int>("CreateTaxOfficeId") != SettingsModel.TaxOfficeId)
{
message = "Alerted Remarks can only be changed by originating office (or Admin)";
}
else if (r["CategoryId"].ToString() != "")
{
message = "This kind of sytem generated remark should only be changed via the corresponding special alert button located elsewhere";
}
//system generated Titles aren't editable since they come from the RemarkType table (see Remark_v)
else if (columnName == "Title" && r.Field<int>("RemarkTypeId") != 0)
message = "System generated Titles aren't editable";
return (message != null);
}