Esempio n. 1
0
        ///<summary></summary>
        public static void Insert(Def def)
        {
            int defNum;

            try {
                if (RemotingClient.OpenDentBusinessIsLocal)
                {
                    defNum = DefB.Insert(def);
                }
                else
                {
                    DtoDefInsert dto = new DtoDefInsert();
                    dto.DefCur = def;
                    defNum     = RemotingClient.ProcessCommand(dto);
                }
            }
            catch (Exception e) {
                MessageBox.Show(e.Message);
                return;
            }
            def.DefNum = defNum;
        }
Esempio n. 2
0
        ///<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);
        }
Esempio n. 3
0
 ///<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());
     }
 }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        ///<summary>Inserts a new document into db, creates a filename based on Cur.DocNum, and then updates the db with this filename.  Also attaches the document to the current patient.</summary>
        public static void Insert(Document doc, Patient pat)
        {
            int insertID = 0;

            try {
                if (RemotingClient.OpenDentBusinessIsLocal)
                {
                    insertID = DocumentB.Insert(doc, pat.LName + pat.FName, pat.PatNum);
                }
                else
                {
                    DtoDocumentInsert dto = new DtoDocumentInsert();
                    dto.Doc    = doc;
                    dto.PatLF  = pat.LName + pat.FName;
                    dto.PatNum = pat.PatNum;
                    insertID   = RemotingClient.ProcessCommand(dto);
                }
            }
            catch (Exception e) {
                MessageBox.Show(e.Message);
            }
            doc.DocNum = insertID;
        }
Esempio n. 6
0
 ///<summary>We need to get away from this due to poor support from databases.  For now, each command will be sent entirely separately.  This never returns number of rows affected.</summary>
 public static int NonQ(string[] commands)
 {
     try {
         for (int i = 0; i < commands.Length; i++)
         {
             if (RemotingClient.OpenDentBusinessIsLocal)
             {
                 GeneralB.NonQ(commands[i], false);
             }
             else
             {
                 DtoGeneralNonQ dto = new DtoGeneralNonQ();
                 dto.Command     = commands[i];
                 dto.GetInsertID = false;
                 RemotingClient.ProcessCommand(dto);
             }
         }
     }
     catch (Exception e) {
         MessageBox.Show(e.Message);
     }
     return(0);
 }
 private void butOK_Click(object sender, System.EventArgs e)
 {
     if (checkConnectServer.Checked)
     {
         if (textPort.errorProvider1.GetError(textPort) != "")
         {
             MsgBox.Show(this, "Please fix data entry errors first.");
             return;
         }
         string originalServer = RemotingClient.ServerName;
         int    originalPort   = RemotingClient.ServerPort;
         RemotingClient.ServerName = comboServerName2.Text;
         RemotingClient.ServerPort = PIn.PInt(textPort.Text);
         DtoLogin dto = new DtoLogin();
         dto.Database   = comboDatabase2.Text;
         dto.OdUser     = textUser2.Text;
         dto.OdPassHash = UserodB.EncryptPassword(textPassword2.Text);
         try{
             RemotingClient.ProcessCommand(dto);
             RemotingClient.OpenDentBusinessIsLocal = false;
         }
         catch (Exception ex) {
             RemotingClient.ServerName = originalServer;
             RemotingClient.ServerPort = originalPort;
             MessageBox.Show(ex.Message);
             return;
         }
     }
     else
     {
         OpenDentBusiness.DataConnection dcon;
         //Try to connect to the database directly
         try {
             DBtype = DatabaseType.MySql;
             if (listType.SelectedIndex == 1)
             {
                 DBtype = DatabaseType.Oracle;
             }
             dcon = new OpenDentBusiness.DataConnection(DBtype);
             if (textConnectionString.Text.Length > 0)
             {
                 dcon.SetDb(textConnectionString.Text, "", DBtype);
             }
             else
             {
                 dcon.SetDb(comboComputerName.Text, comboDatabase.Text, textUser.Text, textPassword.Text, "", "", DBtype);
             }
             //a direct connection does not utilize lower privileges.
         }
         catch (Exception ex) {
             MessageBox.Show(                    //Lan.g(this,"Could not establish connection to database."));
                 ex.Message);
             return;
         }
         RemotingClient.OpenDentBusinessIsLocal = true;
     }
     try{
         XmlWriterSettings settings = new XmlWriterSettings();
         settings.Indent      = true;
         settings.IndentChars = ("    ");
         using (XmlWriter writer = XmlWriter.Create("FreeDentalConfig.xml", settings)) {
             writer.WriteStartElement("ConnectionSettings");
             if (RemotingClient.OpenDentBusinessIsLocal)
             {
                 writer.WriteStartElement("DatabaseConnection");
                 writer.WriteStartElement("ComputerName");
                 writer.WriteString(comboComputerName.Text);
                 writer.WriteEndElement();
                 writer.WriteStartElement("Database");
                 writer.WriteString(comboDatabase.Text);
                 writer.WriteEndElement();
                 writer.WriteStartElement("User");
                 writer.WriteString(textUser.Text);
                 writer.WriteEndElement();
                 writer.WriteStartElement("Password");
                 writer.WriteString(textPassword.Text);
                 writer.WriteEndElement();
                 writer.WriteStartElement("NoShowOnStartup");
                 if (checkNoShow.Checked)
                 {
                     writer.WriteString("True");
                 }
                 else
                 {
                     writer.WriteString("False");
                 }
                 writer.WriteEndElement();
                 writer.WriteEndElement();
             }
             else
             {
                 writer.WriteStartElement("ServerConnection");
                 writer.WriteStartElement("ComputerName");
                 writer.WriteString(comboServerName2.Text);
                 writer.WriteEndElement();
                 writer.WriteStartElement("ServerPort");
                 writer.WriteString(textPort.Text);
                 writer.WriteEndElement();
                 writer.WriteStartElement("Database");
                 writer.WriteString(comboDatabase2.Text);
                 writer.WriteEndElement();
                 writer.WriteEndElement();
             }
             writer.WriteStartElement("DatabaseType");
             if (listType.SelectedIndex == 0)
             {
                 writer.WriteString("MySql");
             }
             else
             {
                 writer.WriteString("Oracle");
             }
             writer.WriteEndElement();
             writer.WriteEndElement();
             writer.Flush();
         }                //using writer
     }
     catch {
         //data not saved.
     }
     //fyiReporting.RDL.DataSource.SetOpenDentalConnectionString(
     //	"Server="+ComputerName+";Database="+Database+";User ID="+DbUser+";Password="******";CharSet=utf8");
     DialogResult = DialogResult.OK;
 }