Exemple #1
0
        ///<summary>Inserts one StateAbbr into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(StateAbbr stateAbbr, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO stateabbr (";

            if (!useExistingPK && isRandomKeys)
            {
                stateAbbr.StateAbbrNum = ReplicationServers.GetKeyNoCache("stateabbr", "StateAbbrNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "StateAbbrNum,";
            }
            command += "Description,Abbr,MedicaidIDLength) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(stateAbbr.StateAbbrNum) + ",";
            }
            command +=
                "'" + POut.String(stateAbbr.Description) + "',"
                + "'" + POut.String(stateAbbr.Abbr) + "',"
                + POut.Int(stateAbbr.MedicaidIDLength) + ")";
            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                stateAbbr.StateAbbrNum = Db.NonQ(command, true, "StateAbbrNum", "stateAbbr");
            }
            return(stateAbbr.StateAbbrNum);
        }
Exemple #2
0
        ///<summary>Inserts one StateAbbr into the database.  Provides option to use the existing priKey.</summary>
        public static long Insert(StateAbbr stateAbbr, bool useExistingPK)
        {
            if (!useExistingPK && PrefC.RandomKeys)
            {
                stateAbbr.StateAbbrNum = ReplicationServers.GetKey("stateabbr", "StateAbbrNum");
            }
            string command = "INSERT INTO stateabbr (";

            if (useExistingPK || PrefC.RandomKeys)
            {
                command += "StateAbbrNum,";
            }
            command += "Description,Abbr,MedicaidIDLength) VALUES(";
            if (useExistingPK || PrefC.RandomKeys)
            {
                command += POut.Long(stateAbbr.StateAbbrNum) + ",";
            }
            command +=
                "'" + POut.String(stateAbbr.Description) + "',"
                + "'" + POut.String(stateAbbr.Abbr) + "',"
                + POut.Int(stateAbbr.MedicaidIDLength) + ")";
            if (useExistingPK || PrefC.RandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                stateAbbr.StateAbbrNum = Db.NonQ(command, true, "StateAbbrNum", "stateAbbr");
            }
            return(stateAbbr.StateAbbrNum);
        }
Exemple #3
0
 ///<summary>Inserts one StateAbbr into the database.  Returns the new priKey.</summary>
 public static long Insert(StateAbbr stateAbbr)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         stateAbbr.StateAbbrNum = DbHelper.GetNextOracleKey("stateabbr", "StateAbbrNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(stateAbbr, true));
             }
             catch (Oracle.ManagedDataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     stateAbbr.StateAbbrNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(stateAbbr, false));
     }
 }
Exemple #4
0
        ///<summary>Updates one StateAbbr in the database.</summary>
        public static void Update(StateAbbr stateAbbr)
        {
            string command = "UPDATE stateabbr SET "
                             + "Description     = '" + POut.String(stateAbbr.Description) + "', "
                             + "Abbr            = '" + POut.String(stateAbbr.Abbr) + "', "
                             + "MedicaidIDLength=  " + POut.Int(stateAbbr.MedicaidIDLength) + " "
                             + "WHERE StateAbbrNum = " + POut.Long(stateAbbr.StateAbbrNum);

            Db.NonQ(command);
        }
Exemple #5
0
 ///<summary>Inserts one StateAbbr into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(StateAbbr stateAbbr)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(stateAbbr, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             stateAbbr.StateAbbrNum = DbHelper.GetNextOracleKey("stateabbr", "StateAbbrNum");                  //Cacheless method
         }
         return(InsertNoCache(stateAbbr, true));
     }
 }
Exemple #6
0
 private void butOK_Click(object sender, EventArgs e)
 {
     if (!IsSelectionMode)
     {
         DialogResult = DialogResult.OK;
         return;
     }
     if (gridMain.GetSelectedIndex() == -1)
     {
         MsgBox.Show(this, "Please select a state.");
         return;
     }
     StateAbbrSelected = (StateAbbr)gridMain.ListGridRows[gridMain.GetSelectedIndex()].Tag;
     DialogResult      = DialogResult.OK;
 }
Exemple #7
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <StateAbbr> TableToList(DataTable table)
        {
            List <StateAbbr> retVal = new List <StateAbbr>();
            StateAbbr        stateAbbr;

            foreach (DataRow row in table.Rows)
            {
                stateAbbr = new StateAbbr();
                stateAbbr.StateAbbrNum     = PIn.Long(row["StateAbbrNum"].ToString());
                stateAbbr.Description      = PIn.String(row["Description"].ToString());
                stateAbbr.Abbr             = PIn.String(row["Abbr"].ToString());
                stateAbbr.MedicaidIDLength = PIn.Int(row["MedicaidIDLength"].ToString());
                retVal.Add(stateAbbr);
            }
            return(retVal);
        }
Exemple #8
0
 ///<summary>Returns true if Update(StateAbbr,StateAbbr) would make changes to the database.
 ///Does not make any changes to the database and can be called before remoting role is checked.</summary>
 public static bool UpdateComparison(StateAbbr stateAbbr, StateAbbr oldStateAbbr)
 {
     if (stateAbbr.Description != oldStateAbbr.Description)
     {
         return(true);
     }
     if (stateAbbr.Abbr != oldStateAbbr.Abbr)
     {
         return(true);
     }
     if (stateAbbr.MedicaidIDLength != oldStateAbbr.MedicaidIDLength)
     {
         return(true);
     }
     return(false);
 }
Exemple #9
0
        private void butAdd_Click(object sender, System.EventArgs e)
        {
            StateAbbr stateAbbrCur = new StateAbbr();

            stateAbbrCur.IsNew = true;
            FormStateAbbrEdit FormSAE = new FormStateAbbrEdit(stateAbbrCur);

            FormSAE.ShowDialog();
            if (FormSAE.DialogResult != DialogResult.OK)
            {
                return;
            }
            _isChanged = true;
            Cache.Refresh(InvalidType.StateAbbrs);
            FillGrid();
        }
Exemple #10
0
        public override bool Equals(object obj)
        {
            var respondent = obj as Respondent;

            if (respondent != null)
            {
                return(RespondentID.ToString().Equals(respondent.RespondentID.ToString(), StringComparison.Ordinal) &&
                       FirstName.Equals(respondent.FirstName) &&
                       LastName.Equals(respondent.LastName) &&
                       EmailAddress.Equals(respondent.EmailAddress) &&
                       AddressLine1.Equals(respondent.AddressLine1) &&
                       AddressLine2.Equals(respondent.AddressLine2) &&
                       City.Equals(respondent.City) &&
                       StateAbbr.Equals(respondent.StateAbbr) &&
                       ZipCode.Equals(respondent.ZipCode) &&
                       LastSurvey.Equals(respondent.LastSurvey));
            }

            return(false);
        }
Exemple #11
0
        private void gridMain_CellDoubleClick(object sender, ODGridClickEventArgs e)
        {
            if (gridMain.GetSelectedIndex() == -1)
            {
                return;
            }
            if (IsSelectionMode)
            {
                StateAbbrSelected = (StateAbbr)gridMain.ListGridRows[gridMain.GetSelectedIndex()].Tag;
                DialogResult      = DialogResult.OK;
                return;
            }
            FormStateAbbrEdit FormSAE = new FormStateAbbrEdit((StateAbbr)gridMain.ListGridRows[gridMain.GetSelectedIndex()].Tag);

            FormSAE.ShowDialog();
            if (FormSAE.DialogResult != DialogResult.OK)
            {
                return;
            }
            _isChanged = true;
            Cache.Refresh(InvalidType.StateAbbrs);
            FillGrid();
        }
Exemple #12
0
        ///<summary>Updates one StateAbbr 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(StateAbbr stateAbbr, StateAbbr oldStateAbbr)
        {
            string command = "";

            if (stateAbbr.Description != oldStateAbbr.Description)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Description = '" + POut.String(stateAbbr.Description) + "'";
            }
            if (stateAbbr.Abbr != oldStateAbbr.Abbr)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Abbr = '" + POut.String(stateAbbr.Abbr) + "'";
            }
            if (stateAbbr.MedicaidIDLength != oldStateAbbr.MedicaidIDLength)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "MedicaidIDLength = " + POut.Int(stateAbbr.MedicaidIDLength) + "";
            }
            if (command == "")
            {
                return(false);
            }
            command = "UPDATE stateabbr SET " + command
                      + " WHERE StateAbbrNum = " + POut.Long(stateAbbr.StateAbbrNum);
            Db.NonQ(command);
            return(true);
        }
Exemple #13
0
 ///<summary>Inserts one StateAbbr into the database.  Returns the new priKey.</summary>
 public static long Insert(StateAbbr stateAbbr)
 {
     return(Insert(stateAbbr, false));
 }
Exemple #14
0
 ///<summary>Inserts one StateAbbr into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(StateAbbr stateAbbr)
 {
     return(InsertNoCache(stateAbbr, false));
 }
 public FormStateAbbrEdit(StateAbbr stateAbbr)
 {
     _stateAbbrCur = stateAbbr;
     InitializeComponent();
     Lan.F(this);
 }