///<summary>For one patient. This should be followed by Documents.Refresh</summary> public static List <DocAttach> Refresh(int patNum) { string command = "SELECT * FROM docattach WHERE PatNum = " + POut.PInt(patNum); DataSet ds = null; try { if (RemotingClient.OpenDentBusinessIsLocal) { ds = GeneralB.GetTable(command); } else { DtoGeneralGetTable dto = new DtoGeneralGetTable(); dto.Command = command; ds = RemotingClient.ProcessQuery(dto); } } catch (Exception e) { MessageBox.Show(e.Message); } DataTable table = ds.Tables[0]; List <DocAttach> list = new List <DocAttach>(); //[table.Rows.Count]; DocAttach attach; for (int i = 0; i < table.Rows.Count; i++) { attach = new DocAttach(); attach.DocAttachNum = PIn.PInt(table.Rows[i][0].ToString()); attach.PatNum = PIn.PInt(table.Rows[i][1].ToString()); attach.DocNum = PIn.PInt(table.Rows[i][2].ToString()); list.Add(attach); } return(list); }
///<summary>Same as GetCount, but will throw exception if query fails instead of displaying message.</summary> public static string GetCountEx(string command) { if (RemotingClient.OpenDentBusinessIsLocal) { return(GeneralB.GetTable(command).Tables[0].Rows[0][0].ToString()); } else { DtoGeneralGetTable dto = new DtoGeneralGetTable(); dto.Command = command; return(RemotingClient.ProcessQuery(dto).Tables[0].Rows[0][0].ToString()); } }
///<summary>DataSet cannot be null.</summary> public static DataSet ProcessQuery(DtoQueryBase dto) { if (dto.GetType() == typeof(DtoGeneralGetTable)) { return(GeneralB.GetTable(((DtoGeneralGetTable)dto).Command)); } else if (dto.GetType() == typeof(DtoGeneralGetTableLow)) { return(GeneralB.GetTableLow(((DtoGeneralGetTableLow)dto).Command)); } else if (dto.GetType() == typeof(DtoGeneralGetDataSet)) { return(GeneralB.GetDataSet(((DtoGeneralGetDataSet)dto).Commands)); } else if (dto.GetType() == typeof(DtoAccountModuleGetAll)) { return(AccountModuleB.GetAll(((DtoAccountModuleGetAll)dto).PatNum)); } else if (dto.GetType() == typeof(DtoChartModuleGetAll)) { return(ChartModuleB.GetAll(((DtoChartModuleGetAll)dto).PatNum, ((DtoChartModuleGetAll)dto).IsAuditMode)); } else if (dto.GetType() == typeof(DtoCovCatRefresh)) { return(CovCatB.Refresh()); } else if (dto.GetType() == typeof(DtoDefRefresh)) { return(DefB.Refresh()); } else if (dto.GetType() == typeof(DtoPrefRefresh)) { return(PrefB.Refresh()); } else if (dto.GetType() == typeof(DtoProcedureRefresh)) { return(ProcedureB.Refresh(((DtoProcedureRefresh)dto).PatNum)); } else if (dto.GetType() == typeof(DtoUserodRefresh)) { return(UserodB.Refresh()); } else { throw new Exception("OpenDentServer.BusinessLayer.ProcessObject(dto) is missing a case for " + dto.GetType().ToString()); } }
///<summary>Same as GetTable, but will throw exception if query fails instead of displaying message. Used in ClassConvertDatabase and any place where we want to be able to suppress the exception message or handle it differently.</summary> public static DataTable GetTableEx(string command) { DataTable retVal; if (RemotingClient.OpenDentBusinessIsLocal) { retVal = GeneralB.GetTable(command).Tables[0].Copy(); } else { DtoGeneralGetTable dto = new DtoGeneralGetTable(); dto.Command = command; retVal = RemotingClient.ProcessQuery(dto).Tables[0].Copy(); } retVal.TableName = ""; //this is needed for FormQuery dataGrid return(retVal); }
///<summary>Use this for count(*) queries. They are always guaranteed to return one and only one value. Not any faster, just handier. Can also be used when retrieving prefs manually, since they will also return exactly one value</summary> public static string GetCount(string command) { try { if (RemotingClient.OpenDentBusinessIsLocal) { return(GeneralB.GetTable(command).Tables[0].Rows[0][0].ToString()); } else { DtoGeneralGetTable dto = new DtoGeneralGetTable(); dto.Command = command; return(RemotingClient.ProcessQuery(dto).Tables[0].Rows[0][0].ToString()); } } catch (Exception e) { MessageBox.Show(e.Message); return(""); } }
/* * ///<summary></summary> * public static Document[] GetAllWithPat(int patNum) { * string command="SELECT * FROM document WHERE WithPat="+POut.PInt(patNum); * return RefreshAndFill(command); * }*/ private static Document[] RefreshAndFill(string command) { DataSet ds = null; try { if (RemotingClient.OpenDentBusinessIsLocal) { ds = GeneralB.GetTable(command); } else { DtoGeneralGetTable dto = new DtoGeneralGetTable(); dto.Command = command; ds = RemotingClient.ProcessQuery(dto); } } catch (Exception e) { MessageBox.Show(e.Message); } DataTable table = ds.Tables[0]; Document[] List = new Document[table.Rows.Count]; for (int i = 0; i < table.Rows.Count; i++) { List[i] = new Document(); List[i].DocNum = PIn.PInt(table.Rows[i][0].ToString()); List[i].Description = PIn.PString(table.Rows[i][1].ToString()); List[i].DateCreated = PIn.PDate(table.Rows[i][2].ToString()); List[i].DocCategory = PIn.PInt(table.Rows[i][3].ToString()); List[i].WithPat = PIn.PInt(table.Rows[i][4].ToString()); List[i].FileName = PIn.PString(table.Rows[i][5].ToString()); List[i].ImgType = (ImageType)PIn.PInt(table.Rows[i][6].ToString()); List[i].IsFlipped = PIn.PBool(table.Rows[i][7].ToString()); List[i].DegreesRotated = PIn.PInt(table.Rows[i][8].ToString()); List[i].ToothNumbers = PIn.PString(table.Rows[i][9].ToString()); List[i].Note = PIn.PString(table.Rows[i][10].ToString()); List[i].SigIsTopaz = PIn.PBool(table.Rows[i][11].ToString()); List[i].Signature = PIn.PString(table.Rows[i][12].ToString()); } return(List); }
///<summary>Only used in FormDefinitions</summary> public static Def[] GetCatList(int myCat) { string command = "SELECT * from definition" + " WHERE category = '" + myCat + "'" + " ORDER BY ItemOrder"; DataSet ds = null; try { if (RemotingClient.OpenDentBusinessIsLocal) { ds = GeneralB.GetTable(command); } else { DtoGeneralGetTable dto = new DtoGeneralGetTable(); dto.Command = command; ds = RemotingClient.ProcessQuery(dto); } } catch (Exception e) { MessageBox.Show(e.Message); } DataTable table = ds.Tables[0]; Def[] List = new Def[table.Rows.Count]; for (int i = 0; i < table.Rows.Count; i++) { List[i] = new Def(); List[i].DefNum = PIn.PInt(table.Rows[i][0].ToString()); List[i].Category = (DefCat)PIn.PInt(table.Rows[i][1].ToString()); List[i].ItemOrder = PIn.PInt(table.Rows[i][2].ToString()); List[i].ItemName = PIn.PString(table.Rows[i][3].ToString()); List[i].ItemValue = PIn.PString(table.Rows[i][4].ToString()); List[i].ItemColor = Color.FromArgb(PIn.PInt(table.Rows[i][5].ToString())); List[i].IsHidden = PIn.PBool(table.Rows[i][6].ToString()); } return(List); }
///<summary>This is used for queries written by the user. If using the server component, it uses the user with lower privileges to prevent injection attack.</summary> public static DataTable GetTableLow(string command) { try { DataTable retVal; if (RemotingClient.OpenDentBusinessIsLocal) { retVal = GeneralB.GetTable(command).Tables[0].Copy(); } else { DtoGeneralGetTableLow dto = new DtoGeneralGetTableLow(); dto.Command = command; retVal = RemotingClient.ProcessQuery(dto).Tables[0].Copy(); } retVal.TableName = ""; //this is needed for FormQuery dataGrid return(retVal); } catch (Exception e) { MessageBox.Show(e.Message); return(new DataTable()); } }
private static Signal[] RefreshAndFill(string command) { //we don't want an error message to show, because that can cause a cascade of a large number of error messages. DataTable table = null; try { if (RemotingClient.OpenDentBusinessIsLocal) { table = GeneralB.GetTable(command).Tables[0]; } else { DtoGeneralGetTable dto = new DtoGeneralGetTable(); dto.Command = command; table = RemotingClient.ProcessQuery(dto).Tables[0]; } } catch { //MessageBox.Show(e.Message); return(new Signal[0]); } Signal[] List = new Signal[table.Rows.Count]; for (int i = 0; i < table.Rows.Count; i++) { List[i] = new Signal(); List[i].SignalNum = PIn.PInt(table.Rows[i][0].ToString()); List[i].FromUser = PIn.PString(table.Rows[i][1].ToString()); List[i].ITypes = (InvalidTypes)PIn.PInt(table.Rows[i][2].ToString()); List[i].DateViewing = PIn.PDate(table.Rows[i][3].ToString()); List[i].SigType = (SignalType)PIn.PInt(table.Rows[i][4].ToString()); List[i].SigText = PIn.PString(table.Rows[i][5].ToString()); List[i].SigDateTime = PIn.PDateT(table.Rows[i][6].ToString()); List[i].ToUser = PIn.PString(table.Rows[i][7].ToString()); List[i].AckTime = PIn.PDateT(table.Rows[i][8].ToString()); } Array.Sort(List); return(List); }