Exemplo n.º 1
0
        public void Switch(TableResolver resolver, DataRow row)
        {
            TkDebug.AssertArgumentNull(resolver, "resolver", null);
            TkDebug.AssertArgumentNull(row, "row", null);

            object value = row[NickName];

            row.BeginEdit();
            try
            {
                if (value == DBNull.Value)
                {
                    switch (NullValueProcess)
                    {
                    case SwitchNullProcessMethod.OpenValue:
                        row[NickName] = OpenValue;
                        break;

                    case SwitchNullProcessMethod.ThrowException:
                        throw new WebPostException(ErrorMessage);
                    }
                }
                else if (value.ToString() == OpenValue)
                {
                    row[NickName] = CloseValue;
                }
                else
                {
                    row[NickName] = OpenValue;
                }
                if (UpdateTrackField)
                {
                    resolver.UpdateTrackField(UpdateKind.Update, row);
                }
            }
            finally
            {
                row.EndEdit();
            }
            resolver.SetCommands(AdapterCommand.Update);
            resolver.UpdateDatabase();
        }