private void gridMain_CellDoubleClick(object sender,ODGridClickEventArgs e) { if(IsSelectionMode) { SelectedHcpcs=(Hcpcs)gridMain.Rows[e.Row].Tag; DialogResult=DialogResult.OK; return; } }
//If this table type will exist as cached data, uncomment the CachePattern region below. /* #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 Hcpcses.</summary> private static List<Hcpcs> listt; ///<summary>A list of all Hcpcses.</summary> public static List<Hcpcs> 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 hcpcs"; DataTable table=Cache.GetTableRemotelyIfNeeded(MethodBase.GetCurrentMethod(),command); table.TableName="Hcpcs"; FillCache(table); return table; } ///<summary></summary> public static void FillCache(DataTable table){ //No need to check RemotingRole; no call to db. listt=Crud.HcpcsCrud.TableToList(table); } #endregion */ ///<summary></summary> public static long Insert(Hcpcs hcpcs){ if(RemotingClient.RemotingRole==RemotingRole.ClientWeb){ hcpcs.HcpcsNum=Meth.GetLong(MethodBase.GetCurrentMethod(),hcpcs); return hcpcs.HcpcsNum; } return Crud.HcpcsCrud.Insert(hcpcs); }
///<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 ImportHcpcs(string tempFileName, ProgressArgs progress, ref bool quit) { if (tempFileName == null) { return; } HashSet <string> codeHash = new HashSet <string>(Hcpcses.GetAllCodes()); string[] lines = File.ReadAllLines(tempFileName); string[] arrayHCPCS; Hcpcs hcpcs = new Hcpcs(); 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); } arrayHCPCS = lines[i].Split('\t'); if (codeHash.Contains(arrayHCPCS[0])) //code already exists { continue; } hcpcs.HcpcsCode = arrayHCPCS[0]; hcpcs.DescriptionShort = arrayHCPCS[1]; Hcpcses.Insert(hcpcs); } }
///<summary></summary> public static void Update(Hcpcs hcpcs) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), hcpcs); return; } Crud.HcpcsCrud.Update(hcpcs); }
//If this table type will exist as cached data, uncomment the CachePattern region below. /* #region CachePattern * * private class HcpcsCache : CacheListAbs<Hcpcs> { * protected override List<Hcpcs> GetCacheFromDb() { * string command="SELECT * FROM Hcpcs ORDER BY ItemOrder"; * return Crud.HcpcsCrud.SelectMany(command); * } * protected override List<Hcpcs> TableToList(DataTable table) { * return Crud.HcpcsCrud.TableToList(table); * } * protected override Hcpcs Copy(Hcpcs Hcpcs) { * return Hcpcs.Clone(); * } * protected override DataTable ListToTable(List<Hcpcs> listHcpcss) { * return Crud.HcpcsCrud.ListToTable(listHcpcss,"Hcpcs"); * } * protected override void FillCacheIfNeeded() { * Hcpcss.GetTableFromCache(false); * } * protected override bool IsInListShort(Hcpcs Hcpcs) { * return !Hcpcs.IsHidden; * } * } * * ///<summary>The object that accesses the cache in a thread-safe manner.</summary> * private static HcpcsCache _HcpcsCache=new HcpcsCache(); * * ///<summary>A list of all Hcpcss. Returns a deep copy.</summary> * public static List<Hcpcs> ListDeep { * get { * return _HcpcsCache.ListDeep; * } * } * * ///<summary>A list of all visible Hcpcss. Returns a deep copy.</summary> * public static List<Hcpcs> ListShortDeep { * get { * return _HcpcsCache.ListShortDeep; * } * } * * ///<summary>A list of all Hcpcss. Returns a shallow copy.</summary> * public static List<Hcpcs> ListShallow { * get { * return _HcpcsCache.ListShallow; * } * } * * ///<summary>A list of all visible Hcpcss. Returns a shallow copy.</summary> * public static List<Hcpcs> ListShort { * get { * return _HcpcsCache.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) { * _HcpcsCache.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); * _HcpcsCache.FillCacheFromTable(table); * return table; * } * return _HcpcsCache.GetTableFromCache(doRefreshCache); * } * #endregion */ ///<summary></summary> public static long Insert(Hcpcs hcpcs) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { hcpcs.HcpcsNum = Meth.GetLong(MethodBase.GetCurrentMethod(), hcpcs); return(hcpcs.HcpcsNum); } return(Crud.HcpcsCrud.Insert(hcpcs)); }
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; } SelectedHcpcs=(Hcpcs)gridMain.Rows[gridMain.GetSelectedIndex()].Tag; DialogResult=DialogResult.OK; }
///<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 ImportHcpcs(string tempFileName, ProgressArgs progress, ref bool quit, ref int numCodesImported, ref int numCodesUpdated, bool updateExisting) { if (tempFileName == null) { return; } Dictionary <string, Hcpcs> dictHcpcs = Hcpcses.GetAll().ToDictionary(x => x.HcpcsCode, x => x); string[] lines = File.ReadAllLines(tempFileName); string[] arrayHCPCS; Hcpcs hcpcs = new Hcpcs(); 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); } arrayHCPCS = lines[i].Split('\t'); if (dictHcpcs.ContainsKey(arrayHCPCS[0])) //code already exists { hcpcs = dictHcpcs[arrayHCPCS[0]]; if (updateExisting && hcpcs.DescriptionShort != arrayHCPCS[1]) { hcpcs.DescriptionShort = arrayHCPCS[1]; Hcpcses.Update(hcpcs); numCodesUpdated++; } continue; } hcpcs.HcpcsCode = arrayHCPCS[0]; hcpcs.DescriptionShort = arrayHCPCS[1]; Hcpcses.Insert(hcpcs); numCodesImported++; } }
///<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 ImportHcpcs(string tempFileName,ProgressArgs progress,ref bool quit) { if(tempFileName==null) { return; } HashSet<string> codeHash=new HashSet<string>(Hcpcses.GetAllCodes()); string[] lines=File.ReadAllLines(tempFileName); string[] arrayHCPCS; Hcpcs hcpcs=new Hcpcs(); 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); } arrayHCPCS=lines[i].Split('\t'); if(codeHash.Contains(arrayHCPCS[0])) {//code already exists continue; } hcpcs.HcpcsCode =arrayHCPCS[0]; hcpcs.DescriptionShort =arrayHCPCS[1]; Hcpcses.Insert(hcpcs); } }