Exemplo n.º 1
0
 static CustomClassCache()
 {
     if (Program.EnableRemoting)
     {
         mDataTableProxy = DataTableServerProxy.GetDataTableProxy();
     }
 }
Exemplo n.º 2
0
 static Helper()
 {
     if (Program.EnableRemoting)
     {
         mDataTableProxy = DataTableServerProxy.GetDataTableProxy();
     }
     mCommands = new Dictionary <int, SqlCommand>();
 }
Exemplo n.º 3
0
        private int GetUnusedID(string strFieldName, object oDeafult)
        {
            if (m_keyvalue == null)
            {
                return(-1);
            }
            DBCustomClass subdbclass = m_dbclass;
            //string sql = string.Format("SELECT * FROM {0}", subdbclass.MainTable);
            //DataTable tbl = Helper.GetDataTable(sql, MainForm.conn);
            DataTable tbl         = Helper.GetDataTableProxy(subdbclass.MainTable, MainForm.conn);
            int       nFieldIndex = -1;

            for (int i = 0; i < subdbclass.DBPrimaryKey.Length; i++)
            {
                m_findkeyvalues[i] = null;// GetNextID(subdbclass.DBPrimaryKey[i]);
                if (subdbclass.DBPrimaryKey[i].ToString().ToLower() == strFieldName.ToLower())
                {
                    nFieldIndex = i;
                }
                else if (m_keyvalue.Contains(subdbclass.DBPrimaryKey[i]))
                {
                    m_findkeyvalues[i] = m_keyvalue[subdbclass.DBPrimaryKey[i]];
                }
            }
            if (oDeafult != null && oDeafult != DBNull.Value)
            {
                m_findkeyvalues[nFieldIndex] = oDeafult;
            }
            else
            {
                m_findkeyvalues[nFieldIndex] = GetNextID(strFieldName);
            }
            if (Program.EnableRemoting && subdbclass.MainTable.Length > 7 && subdbclass.MainTable.Substring(0, 7) == "RTTEST_")
            {
                m_findkeyvalues[nFieldIndex] = Convert.ToInt32(m_findkeyvalues[nFieldIndex]);
                DataTableProxy proxy = DataTableServerProxy.GetDataTableProxy();
                m_findkeyvalues = proxy.UTGetTableID(subdbclass.MainTable, m_findkeyvalues);
            }
            else
            {
                bool bFirstTry = true;
                while (tbl.Rows.Find(m_findkeyvalues) != null)
                {
                    m_findkeyvalues[nFieldIndex] = Convert.ToInt32(m_findkeyvalues[nFieldIndex]) + (bFirstTry == true ? 1 : 1 /*1000*/); // 现在的id太大了
                    bFirstTry = false;
                }
            }
            m_keyvalue[strFieldName] = m_findkeyvalues[nFieldIndex];
            if (oDeafult == DBNull.Value || Convert.ToInt32(m_findkeyvalues[nFieldIndex]) != Convert.ToInt32(oDeafult))
            {
                SetLastID(strFieldName, Convert.ToInt32(m_findkeyvalues[nFieldIndex]));
            }
            return(Convert.ToInt32(m_findkeyvalues[nFieldIndex]));
        }
Exemplo n.º 4
0
        public UniteModel(string mdlname)
        {
            InitializeComponent();
            bool bRet = false;

            if (Program.EnableRemoting)
            {
                mDataTableProxy = DataTableServerProxy.GetDataTableProxy();
                bRet            = mDataTableProxy.UTExistDatabase(Program.Database);
            }
            if (!bRet)
            {
                MessageBox.Show("本库不是主干或分技或没有连接远程数据服务");
                RunUnite = false;
                return;
            }

            mModelName = mdlname;
            InitTables();
        }
Exemplo n.º 5
0
		private void InternalSetDataTable(DataTableProxy proxy)
		{
			ChildSetMember(ref _dataTable, proxy ?? new DataTableProxy((DataTable)null));
		}
Exemplo n.º 6
0
		/// <summary>
		/// Initializes a new instance of the <see cref="DataTableMultipleColumnProxy"/> class. The selected collections determine which columns and rows contribute to this instance.
		/// The group number is determined by the first selected column (or, if no column is selected, by the first column of the data table).
		/// </summary>
		/// <param name="identifier">The identifier of the bundle of columns that are initially set with this constructor.</param>
		/// <param name="table">The underlying table.</param>
		/// <param name="selectedDataRows">The selected data rows.</param>
		/// <param name="selectedDataColumns">The selected data columns.</param>
		/// <exception cref="System.ArgumentNullException">table must not be null.</exception>
		public DataTableMultipleColumnProxy(string identifier, DataTable table, IAscendingIntegerCollection selectedDataRows, IAscendingIntegerCollection selectedDataColumns)
		{
			if (null == identifier)
				throw new ArgumentNullException("identifier");

			if (null == table)
				throw new ArgumentNullException("table");

			_dataColumnBundles = new Dictionary<string, ColumnBundleInfo>();

			_dataTable = new DataTableProxy(table) { ParentObject = this };

			_groupNumber = 0;

			if (null != selectedDataColumns && selectedDataColumns.Count > 0)
				_groupNumber = table.DataColumns.GetColumnGroup(table[selectedDataColumns[0]]);

			var bundle = new ColumnBundleInfo();
			_dataColumnBundles.Add(identifier, bundle);

			int maxRowCount = 0;
			if (selectedDataColumns != null && selectedDataColumns.Count > 0)
			{
				for (int i = 0; i < selectedDataColumns.Count; ++i)
				{
					var col = table[selectedDataColumns[i]];
					if (table.DataColumns.GetColumnGroup(col) == _groupNumber)
					{
						InternalAddDataColumnNoClone(bundle, ReadableColumnProxyBase.FromColumn(col));
						maxRowCount = Math.Max(maxRowCount, col.Count);
					}
				}
			}
			else // nothing selected - use all columns of group number 0
			{
				for (int i = 0; i < table.DataColumnCount; ++i)
				{
					var col = table[i];
					if (table.DataColumns.GetColumnGroup(col) == _groupNumber)
					{
						InternalAddDataColumnNoClone(bundle, ReadableColumnProxyBase.FromColumn(col));
						maxRowCount = Math.Max(maxRowCount, col.Count);
					}
				}
			}

			_useAllAvailableDataRows = null == selectedDataRows || selectedDataRows.Count == 0;

			_participatingDataRows = new AscendingIntegerCollection(_useAllAvailableDataRows ? ContiguousIntegerRange.FromStartAndCount(0, maxRowCount) : selectedDataRows);
		}
Exemplo n.º 7
0
		/// <summary>
		/// Initializes a new instance of the <see cref="DataTableMultipleColumnProxy"/> class.
		/// The table and group number of this instance are set, but no columns are set with this constructor.
		/// </summary>
		/// <param name="table">The underlying table.</param>
		/// <param name="groupNumber">The group number of the data columns this instance should hold.</param>
		/// <exception cref="System.ArgumentNullException">table must not be null.</exception>
		public DataTableMultipleColumnProxy(DataTable table, int groupNumber)
		{
			if (null == table)
				throw new ArgumentNullException("table");

			_dataTable = new DataTableProxy(table) { ParentObject = this };

			_groupNumber = groupNumber;
		}