///<summary></summary>
        public static void Delete(EmailMessage message)
        {
            if (message.EmailMessageNum == 0)
            {
                return;                                                                                              //this prevents deletion of all commlog entries of something goes wrong.
            }
            string command = "DELETE FROM emailmessage WHERE EmailMessageNum=" + POut.PInt(message.EmailMessageNum); //+";"

            //+"DELETE FROM commlog WHERE EmailMessageNum="+POut.PInt(message.EmailMessageNum);
            try {
                if (RemotingClient.OpenDentBusinessIsLocal)
                {
                    GeneralB.NonQ(command);
                }
                else
                {
                    DtoGeneralNonQ dto = new DtoGeneralNonQ();
                    dto.Command = command;
                    RemotingClient.ProcessCommand(dto);
                }
            }
            catch (Exception e) {
                MessageBox.Show(e.Message);
            }
        }
        ///<summary></summary>
        public static void Insert(EmailMessage message)
        {
            int insertID = 0;

            try {
                if (RemotingClient.OpenDentBusinessIsLocal)
                {
                    insertID = EmailMessageB.Insert(message);
                }
                else
                {
                    DtoEmailMessageInsert dto = new DtoEmailMessageInsert();
                    dto.Message = message;
                    insertID    = RemotingClient.ProcessCommand(dto);
                }
            }
            catch (Exception e) {
                MessageBox.Show(e.Message);
            }
            message.EmailMessageNum = insertID;

            /*
             * int insertID=0;
             * try {
             *      if(RemotingClient.OpenDentBusinessIsLocal) {
             *              if(PrefB.RandomKeys) {
             *                      GeneralB.NonQ(command);
             *              }
             *              else {
             *                      insertID=GeneralB.NonQ(command,true);
             *                      message.EmailMessageNum=insertID;
             *              }
             *      }
             *      else {
             *              DtoGeneralNonQ dto=new DtoGeneralNonQ();
             *              dto.Command=command;
             *              if(PrefB.RandomKeys) {
             *                      RemotingClient.ProcessCommand(dto);
             *              }
             *              else {
             *                      dto.GetInsertID=true;
             *                      insertID=RemotingClient.ProcessCommand(dto);
             *                      message.EmailMessageNum=insertID;
             *              }
             *      }
             * }
             * catch(Exception e) {
             *      MessageBox.Show(e.Message);
             *      return;
             * }*/
        }
Exemple #3
0
 ///<summary>Same as NonQ, 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 int NonQEx(string command, bool getInsertID)
 {
     if (RemotingClient.OpenDentBusinessIsLocal)
     {
         return(GeneralB.NonQ(command, getInsertID));
     }
     else
     {
         DtoGeneralNonQ dto = new DtoGeneralNonQ();
         dto.Command     = command;
         dto.GetInsertID = getInsertID;
         return(RemotingClient.ProcessCommand(dto));
     }
 }
Exemple #4
0
 ///<summary>This throws an exception if it fails for any reason.</summary>
 public static void MakeABackup()
 {
     //try {
     if (RemotingClient.OpenDentBusinessIsLocal)
     {
         MiscDataB.MakeABackup();
     }
     else
     {
         DtoMiscDataMakeABackup dto = new DtoMiscDataMakeABackup();
         RemotingClient.ProcessCommand(dto);
     }
     //}
     //catch(Exception e) {
     //	MessageBox.Show(e.Message);
     //}
 }
Exemple #5
0
 ///<summary></summary>
 public static void Update(Document doc)
 {
     try {
         if (RemotingClient.OpenDentBusinessIsLocal)
         {
             DocumentB.Update(doc);
         }
         else
         {
             DtoDocumentUpdate dto = new DtoDocumentUpdate();
             dto.Doc = doc;
             RemotingClient.ProcessCommand(dto);
         }
     }
     catch (Exception e) {
         MessageBox.Show(e.Message);
     }
 }
 ///<summary></summary>
 public static void Update(EmailMessage message)
 {
     try {
         if (RemotingClient.OpenDentBusinessIsLocal)
         {
             EmailMessageB.Update(message);
         }
         else
         {
             DtoEmailMessageUpdate dto = new DtoEmailMessageUpdate();
             dto.Message = message;
             RemotingClient.ProcessCommand(dto);
         }
     }
     catch (Exception e) {
         MessageBox.Show(e.Message);
     }
 }
Exemple #7
0
 ///<summary></summary>
 public static int NonQEx(string[] commands)
 {
     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);
         }
     }
     return(0);
 }
Exemple #8
0
 ///<summary></summary>
 public static void Update(Def def)
 {
     try {
         if (RemotingClient.OpenDentBusinessIsLocal)
         {
             DefB.Update(def);
         }
         else
         {
             DtoDefUpdate dto = new DtoDefUpdate();
             dto.DefCur = def;
             RemotingClient.ProcessCommand(dto);
         }
     }
     catch (Exception e) {
         MessageBox.Show(e.Message);
         return;
     }
 }
Exemple #9
0
 ///<summary>This query is run with full privileges.  This is for commands generated by the main program, and the user will not have access for injection attacks.  Result is usually number of rows changed, or can be insert id if requested.</summary>
 public static int NonQ(string command, bool getInsertID)
 {
     try {
         if (RemotingClient.OpenDentBusinessIsLocal)
         {
             return(GeneralB.NonQ(command, getInsertID));
         }
         else
         {
             DtoGeneralNonQ dto = new DtoGeneralNonQ();
             dto.Command     = command;
             dto.GetInsertID = getInsertID;
             return(RemotingClient.ProcessCommand(dto));
         }
     }
     catch (Exception e) {
         MessageBox.Show(e.Message);
         return(0);
     }
 }
Exemple #10
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;
        }
Exemple #11
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;
        }
Exemple #12
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;
 }