[a235fd]: SQLite.Designer / Design / Unique.cs  Maximize  Restore  History

Download this file

113 lines (97 with data), 2.8 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
/********************************************************
* ADO.NET 2.0 Data Provider for SQLite Version 3.X
* Written by Robert Simpson (robert@blackcastlesoft.com)
*
* Released to the public domain, use at your own risk!
********************************************************/
namespace SQLite.Designer.Design
{
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Data;
using System.Data.Common;
using System.Globalization;
[TypeConverter(typeof(ExpandableObjectConverter))]
[DefaultProperty("Enabled")]
internal class Unique : IHaveConnection
{
private bool _isUnique;
private ConflictEnum _conflict = ConflictEnum.Abort;
private Column _column;
internal Unique(Column col)
: this(col, null)
{
}
internal Unique(Column col, DataRow row)
{
_column = col;
if (row != null)
{
_isUnique = (row.IsNull("UNIQUE") == false) ? (bool)row["UNIQUE"] : false;
}
}
#region IHaveConnection Members
[Browsable(false)]
public ViewTableBase DesignTable
{
get { return _column.DesignTable; }
}
public DbConnection GetConnection()
{
return ((IHaveConnection)_column).GetConnection();
}
#endregion
[DefaultValue(false)]
[DisplayName("Enabled")]
[RefreshProperties(RefreshProperties.All)]
[Description("When enabled, all values entered into this column must be unique.")]
public bool Enabled
{
get { return _isUnique; }
set
{
if (value != _isUnique)
{
_isUnique = value;
_column.Table._owner.MakeDirty();
}
}
}
[DefaultValue(ConflictEnum.Abort)]
[DisplayName("On Conflict")]
[RefreshProperties(RefreshProperties.All)]
[Description("Specifies what action to take when the unique constraint on the column is violated.")]
public ConflictEnum Conflict
{
get { return _conflict; }
set
{
if (_conflict != value)
{
_conflict = value;
if (_conflict != ConflictEnum.Abort && _isUnique == false)
_isUnique = true;
_column.Table._owner.MakeDirty();
}
}
}
public override string ToString()
{
if (_isUnique == false)
return Convert.ToString(false, CultureInfo.InvariantCulture);
else
return String.Format(CultureInfo.InvariantCulture, "{0} ({1})", Convert.ToString(true, CultureInfo.InvariantCulture), Convert.ToString(Conflict, CultureInfo.InvariantCulture));
//return Convert.ToString(true);
}
}
public enum ConflictEnum
{
Abort = 2,
Rollback = 0,
Fail = 3,
Ignore = 4,
Replace = 5,
}
}

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks