示例#1
0
		//If this table type will exist as cached data, uncomment the CachePattern region below and edit.
		//#region CachePattern
		////This region can be eliminated if this is not a table type with cached data.
		////If leaving this region in place, be sure to add RefreshCache and FillCache 
		////to the Cache.cs file with all the other Cache types.

		/////<summary>A list of all UCUMs.</summary>
		//private static List<Ucum> listt;

		/////<summary>A list of all UCUMs.</summary>
		//public static List<Ucum> Listt{
		//	get {
		//		if(listt==null) {
		//			RefreshCache();
		//		}
		//		return listt;
		//	}
		//	set {
		//		listt=value;
		//	}
		//}

		/////<summary></summary>
		//public static DataTable RefreshCache(){
		//	//No need to check RemotingRole; Calls GetTableRemotelyIfNeeded().
		//	string command="SELECT * FROM ucum ORDER BY ItemOrder";//stub query probably needs to be changed
		//	DataTable table=Cache.GetTableRemotelyIfNeeded(MethodBase.GetCurrentMethod(),command);
		//	table.TableName="UCUM";
		//	FillCache(table);
		//	return table;
		//}

		/////<summary></summary>
		//public static void FillCache(DataTable table){
		//	//No need to check RemotingRole; no call to db.
		//	listt=Crud.UcumCrud.TableToList(table);
		//}
		//#endregion

		///<summary></summary>
		public static long Insert(Ucum ucum){
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb){
				ucum.UcumNum=Meth.GetLong(MethodBase.GetCurrentMethod(),ucum);
				return ucum.UcumNum;
			}
			return Crud.UcumCrud.Insert(ucum);
		}
示例#2
0
		private void gridMain_CellDoubleClick(object sender,ODGridClickEventArgs e) {
			if(IsSelectionMode) {
				SelectedUcum=(Ucum)gridMain.Rows[e.Row].Tag;
				DialogResult=DialogResult.OK;
				return;
			}
		}
示例#3
0
        ///<summary>Called after file is downloaded.  Throws exceptions.  It is assumed that this is called from a worker thread.  Progress delegate will be called every 100th iteration to inform thread of current progress. Quit flag can be set at any time in order to quit importing prematurely.</summary>
        public static void ImportUcum(string tempFileName, ProgressArgs progress, ref bool quit)
        {
            if (tempFileName == null)
            {
                return;
            }
            HashSet <string> codeHash = new HashSet <string>(Ucums.GetAllCodes());

            string[] lines = File.ReadAllLines(tempFileName);
            string[] arrayUcum;
            Ucum     ucum = new Ucum();

            for (int i = 0; i < lines.Length; i++)       //each loop should read exactly one line of code. and each line of code should be a unique code
            {
                if (quit)
                {
                    return;
                }
                if (i % 100 == 0)
                {
                    progress(i + 1, lines.Length);
                }
                arrayUcum = lines[i].Split('\t');
                if (codeHash.Contains(arrayUcum[0]))                 //code already exists
                {
                    continue;
                }
                ucum.UcumCode    = arrayUcum[0];
                ucum.Description = arrayUcum[1];
                ucum.IsInUse     = false;
                Ucums.Insert(ucum);
            }
        }
示例#4
0
		private void butOK_Click(object sender,EventArgs e) {
			//not even visible unless IsSelectionMode
			if(gridMain.GetSelectedIndex()==-1) {
				MsgBox.Show(this,"Please select an item first.");
				return;
			}
			SelectedUcum=(Ucum)gridMain.Rows[gridMain.GetSelectedIndex()].Tag;
			DialogResult=DialogResult.OK;
		}
示例#5
0
 ///<summary></summary>
 public static void Update(Ucum ucum)
 {
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         Meth.GetVoid(MethodBase.GetCurrentMethod(), ucum);
         return;
     }
     Crud.UcumCrud.Update(ucum);
 }
示例#6
0
        //If this table type will exist as cached data, uncomment the CachePattern region below and edit.

        /*
         #region CachePattern
         *
         * private class UcumCache : CacheListAbs<Ucum> {
         *      protected override List<Ucum> GetCacheFromDb() {
         *              string command="SELECT * FROM Ucum ORDER BY ItemOrder";
         *              return Crud.UcumCrud.SelectMany(command);
         *      }
         *      protected override List<Ucum> TableToList(DataTable table) {
         *              return Crud.UcumCrud.TableToList(table);
         *      }
         *      protected override Ucum Copy(Ucum Ucum) {
         *              return Ucum.Clone();
         *      }
         *      protected override DataTable ListToTable(List<Ucum> listUcums) {
         *              return Crud.UcumCrud.ListToTable(listUcums,"Ucum");
         *      }
         *      protected override void FillCacheIfNeeded() {
         *              Ucums.GetTableFromCache(false);
         *      }
         *      protected override bool IsInListShort(Ucum Ucum) {
         *              return !Ucum.IsHidden;
         *      }
         * }
         *
         * ///<summary>The object that accesses the cache in a thread-safe manner.</summary>
         * private static UcumCache _UcumCache=new UcumCache();
         *
         * ///<summary>A list of all Ucums. Returns a deep copy.</summary>
         * public static List<Ucum> ListDeep {
         *      get {
         *              return _UcumCache.ListDeep;
         *      }
         * }
         *
         * ///<summary>A list of all visible Ucums. Returns a deep copy.</summary>
         * public static List<Ucum> ListShortDeep {
         *      get {
         *              return _UcumCache.ListShortDeep;
         *      }
         * }
         *
         * ///<summary>A list of all Ucums. Returns a shallow copy.</summary>
         * public static List<Ucum> ListShallow {
         *      get {
         *              return _UcumCache.ListShallow;
         *      }
         * }
         *
         * ///<summary>A list of all visible Ucums. Returns a shallow copy.</summary>
         * public static List<Ucum> ListShort {
         *      get {
         *              return _UcumCache.ListShallowShort;
         *      }
         * }
         *
         * ///<summary>Refreshes the cache and returns it as a DataTable. This will refresh the ClientWeb's cache and the ServerWeb's cache.</summary>
         * public static DataTable RefreshCache() {
         *      return GetTableFromCache(true);
         * }
         *
         * ///<summary>Fills the local cache with the passed in DataTable.</summary>
         * public static void FillCacheFromTable(DataTable table) {
         *      _UcumCache.FillCacheFromTable(table);
         * }
         *
         * ///<summary>Always refreshes the ClientWeb's cache.</summary>
         * public static DataTable GetTableFromCache(bool doRefreshCache) {
         *      if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
         *              DataTable table=Meth.GetTable(MethodBase.GetCurrentMethod(),doRefreshCache);
         *              _UcumCache.FillCacheFromTable(table);
         *              return table;
         *      }
         *      return _UcumCache.GetTableFromCache(doRefreshCache);
         * }
         *
         #endregion
         */

        ///<summary></summary>
        public static long Insert(Ucum ucum)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                ucum.UcumNum = Meth.GetLong(MethodBase.GetCurrentMethod(), ucum);
                return(ucum.UcumNum);
            }
            return(Crud.UcumCrud.Insert(ucum));
        }
示例#7
0
        ///<summary>Called after file is downloaded.  Throws exceptions.  It is assumed that this is called from a worker thread.  Progress delegate will be called every 100th iteration to inform thread of current progress. Quit flag can be set at any time in order to quit importing prematurely.</summary>
        public static void ImportUcum(string tempFileName, ProgressArgs progress, ref bool quit, ref int numCodesImported, ref int numCodesUpdated,
                                      bool updateExisting)
        {
            if (tempFileName == null)
            {
                return;
            }
            Dictionary <string, Ucum> dictUcums = Ucums.GetAll().ToDictionary(x => x.UcumCode, x => x);

            string[] lines = File.ReadAllLines(tempFileName);
            string[] arrayUcum;
            Ucum     ucum = new Ucum();

            for (int i = 0; i < lines.Length; i++)       //each loop should read exactly one line of code. and each line of code should be a unique code
            {
                if (quit)
                {
                    return;
                }
                if (i % 100 == 0)
                {
                    progress(i + 1, lines.Length);
                }
                arrayUcum = lines[i].Split('\t');
                if (dictUcums.ContainsKey(arrayUcum[0]))                 //code already exists
                {
                    ucum = dictUcums[arrayUcum[0]];
                    if (updateExisting && ucum.Description != arrayUcum[1])
                    {
                        ucum.Description = arrayUcum[1];
                        Ucums.Update(ucum);
                        numCodesUpdated++;
                    }
                    continue;
                }
                ucum.UcumCode    = arrayUcum[0];
                ucum.Description = arrayUcum[1];
                ucum.IsInUse     = false;
                Ucums.Insert(ucum);
                numCodesImported++;
            }
        }
示例#8
0
		///<summary>Called after file is downloaded.  Throws exceptions.  It is assumed that this is called from a worker thread.  Progress delegate will be called every 100th iteration to inform thread of current progress. Quit flag can be set at any time in order to quit importing prematurely.</summary>
		public static void ImportUcum(string tempFileName,ProgressArgs progress,ref bool quit) {
			if(tempFileName==null) {
				return;
			}
			HashSet<string> codeHash=new HashSet<string>(Ucums.GetAllCodes());
			string[] lines=File.ReadAllLines(tempFileName);
			string[] arrayUcum;
			Ucum ucum=new Ucum();
			for(int i=0;i<lines.Length;i++) {//each loop should read exactly one line of code. and each line of code should be a unique code
				if(quit) {
					return;
				}
				if(i%100==0) {
					progress(i+1,lines.Length);
				}
				arrayUcum=lines[i].Split('\t');
				if(codeHash.Contains(arrayUcum[0])) {//code already exists
					continue;
				}
				ucum.UcumCode			=arrayUcum[0];
				ucum.Description	=arrayUcum[1];
				ucum.IsInUse			=false;
				Ucums.Insert(ucum);
			}
		}