示例#1
0
        ///<summary>Inserts one WebForms_Preference into the database.  Provides option to use the existing priKey.</summary>
        public static long Insert(WebForms_Preference webForms_Preference, bool useExistingPK)
        {
            string command = "INSERT INTO webforms_preference (";

            if (useExistingPK)
            {
                command += "DentalOfficeID,";
            }
            command += "ColorBorder,CultureName,DisableSignatures) VALUES(";
            if (useExistingPK)
            {
                command += POut.Long(webForms_Preference.DentalOfficeID) + ",";
            }
            command +=
                POut.Int(webForms_Preference.ColorBorder.ToArgb()) + ","
                + "'" + POut.String(webForms_Preference.CultureName) + "',"
                + POut.Bool(webForms_Preference.DisableSignatures) + ")";
            if (useExistingPK)
            {
                DataCore.NonQ(command);
            }
            else
            {
                webForms_Preference.DentalOfficeID = DataCore.NonQ(command, true);
            }
            return(webForms_Preference.DentalOfficeID);
        }
示例#2
0
        ///<summary>Updates one WebForms_Preference in the database.</summary>
        public static void Update(WebForms_Preference webForms_Preference)
        {
            string command = "UPDATE webforms_preference SET "
                             + "ColorBorder      =  " + POut.Int(webForms_Preference.ColorBorder.ToArgb()) + ", "
                             + "CultureName      = '" + POut.String(webForms_Preference.CultureName) + "', "
                             + "DisableSignatures=  " + POut.Bool(webForms_Preference.DisableSignatures) + " "
                             + "WHERE DentalOfficeID = " + POut.Long(webForms_Preference.DentalOfficeID);

            DataCore.NonQ(command);
        }
示例#3
0
        ///<summary>Inserts many WebForms_Preferences into the database.  Provides option to use the existing priKey.</summary>
        public static void InsertMany(List <WebForms_Preference> listWebForms_Preferences, bool useExistingPK)
        {
            StringBuilder sbCommands = null;
            int           index      = 0;
            int           countRows  = 0;

            while (index < listWebForms_Preferences.Count)
            {
                WebForms_Preference webForms_Preference = listWebForms_Preferences[index];
                StringBuilder       sbRow = new StringBuilder("(");
                bool hasComma             = false;
                if (sbCommands == null)
                {
                    sbCommands = new StringBuilder();
                    sbCommands.Append("INSERT INTO webforms_preference (");
                    if (useExistingPK)
                    {
                        sbCommands.Append("DentalOfficeID,");
                    }
                    sbCommands.Append("ColorBorder,CultureName,DisableSignatures) VALUES ");
                    countRows = 0;
                }
                else
                {
                    hasComma = true;
                }
                if (useExistingPK)
                {
                    sbRow.Append(POut.Long(webForms_Preference.DentalOfficeID)); sbRow.Append(",");
                }
                sbRow.Append(POut.Int(webForms_Preference.ColorBorder.ToArgb())); sbRow.Append(",");
                sbRow.Append("'" + POut.String(webForms_Preference.CultureName) + "'"); sbRow.Append(",");
                sbRow.Append(POut.Bool(webForms_Preference.DisableSignatures)); sbRow.Append(")");
                if (sbCommands.Length + sbRow.Length + 1 > TableBase.MaxAllowedPacketCount && countRows > 0)
                {
                    DataCore.NonQ(sbCommands.ToString());
                    sbCommands = null;
                }
                else
                {
                    if (hasComma)
                    {
                        sbCommands.Append(",");
                    }
                    sbCommands.Append(sbRow.ToString());
                    countRows++;
                    if (index == listWebForms_Preferences.Count - 1)
                    {
                        DataCore.NonQ(sbCommands.ToString());
                    }
                    index++;
                }
            }
        }
示例#4
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <WebForms_Preference> TableToList(DataTable table)
        {
            List <WebForms_Preference> retVal = new List <WebForms_Preference>();
            WebForms_Preference        webForms_Preference;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                webForms_Preference = new WebForms_Preference();
                webForms_Preference.DentalOfficeID    = PIn.Long(table.Rows[i]["DentalOfficeID"].ToString());
                webForms_Preference.ColorBorder       = Color.FromArgb(PIn.Int(table.Rows[i]["ColorBorder"].ToString()));
                webForms_Preference.CultureName       = PIn.String(table.Rows[i]["CultureName"].ToString());
                webForms_Preference.DisableSignatures = PIn.Bool(table.Rows[i]["DisableSignatures"].ToString());
                retVal.Add(webForms_Preference);
            }
            return(retVal);
        }
示例#5
0
 private bool SavePrefs(bool includeAutoFillBirthdatePref = false)
 {
     Cursor = Cursors.WaitCursor;
     if (!WebForms_Preferences.SetPreferences(_webFormPref, urlOverride: textboxWebHostAddress.Text.Trim()))
     {
         Cursor = Cursors.Default;
         MsgBox.Show(this, "Either the registration key provided by the dental office is incorrect or the Host Server Address cannot be found.");
         return(false);
     }
     _webFormPrefOld = _webFormPref.Copy();
     if (Prefs.UpdateString(PrefName.WebHostSynchServerURL, textboxWebHostAddress.Text.Trim()) ||
         (includeAutoFillBirthdatePref && Prefs.UpdateBool(PrefName.WebFormsAutoFillNameAndBirthdate, checkAutoFillNameAndBirthdate.Checked)))
     {
         DataValid.SetInvalid(InvalidType.Prefs);
     }
     Cursor = Cursors.Default;
     return(true);
 }
示例#6
0
 private void FetchValuesFromWebServer()
 {
     try {
         String WebHostSynchServerURL = PrefC.GetString(PrefName.WebHostSynchServerURL);
         textboxWebHostAddress.Text = WebHostSynchServerURL;
         butSave.Enabled            = false;
         if ((WebHostSynchServerURL == WebFormL.SynchUrlStaging) || (WebHostSynchServerURL == WebFormL.SynchUrlDev))
         {
             WebFormL.IgnoreCertificateErrors();
         }
         Cursor          = Cursors.WaitCursor;
         _dentalOfficeID = WebUtils.GetDentalOfficeID();
         if (_dentalOfficeID == 0)
         {
             Cursor = Cursors.Default;
             MsgBox.Show(this, "Either the registration key provided by the dental office is incorrect or the Host Server Address cannot be found.");
             return;
         }
         if (WebForms_Preferences.TryGetPreference(out _webFormPref))
         {
             butWebformBorderColor.BackColor = _webFormPref.ColorBorder;
             _sheetDefAddress = WebUtils.GetSheetDefAddress();
             checkDisableWebFormSignatures.Checked = _webFormPref.DisableSignatures;
             if (string.IsNullOrEmpty(_webFormPref.CultureName))                    //Just in case.
             {
                 _webFormPref.CultureName = System.Globalization.CultureInfo.CurrentCulture.Name;
                 WebForms_Preferences.SetPreferences(_webFormPref);
             }
             _webFormPrefOld = _webFormPref.Copy();
         }
     }
     catch (Exception ex) {
         Cursor = Cursors.Default;
         MessageBox.Show(ex.Message);
     }
     FillGrid();            //Also gets sheet def list from server
     Cursor = Cursors.Default;
 }
示例#7
0
        ///<summary>Updates one WebForms_Preference in the database.  Uses an old object to compare to, and only alters changed fields.  This prevents collisions and concurrency problems in heavily used tables.  Returns true if an update occurred.</summary>
        public static bool Update(WebForms_Preference webForms_Preference, WebForms_Preference oldWebForms_Preference)
        {
            string command = "";

            if (webForms_Preference.ColorBorder != oldWebForms_Preference.ColorBorder)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ColorBorder = " + POut.Int(webForms_Preference.ColorBorder.ToArgb()) + "";
            }
            if (webForms_Preference.CultureName != oldWebForms_Preference.CultureName)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "CultureName = '" + POut.String(webForms_Preference.CultureName) + "'";
            }
            if (webForms_Preference.DisableSignatures != oldWebForms_Preference.DisableSignatures)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "DisableSignatures = " + POut.Bool(webForms_Preference.DisableSignatures) + "";
            }
            if (command == "")
            {
                return(false);
            }
            command = "UPDATE webforms_preference SET " + command
                      + " WHERE DentalOfficeID = " + POut.Long(webForms_Preference.DentalOfficeID);
            DataCore.NonQ(command);
            return(true);
        }
示例#8
0
 ///<summary>Inserts one WebForms_Preference into the database.  Returns the new priKey.</summary>
 public static long Insert(WebForms_Preference webForms_Preference)
 {
     return(Insert(webForms_Preference, false));
 }