示例#1
0
        private static void DeleteNonPermanentIssuesQuestions()
        {
            const string cmdText = "DELETE FROM IssuesQuestions WHERE NOT IssueId IN (1,2)";
            var          cmd     = VoteDb.GetCommand(cmdText);

            VoteDb.ExecuteNonQuery(cmd);
        }
示例#2
0
 public void UpdateValue(TableInfo tableInfo, ColumnInfo columnInfo,
                         DataRow row, string newValue)
 {
     try
     {
         using (var cn = VoteDb.GetOpenConnection() as MySqlConnection)
         {
             string template = "UPDATE {0} SET {1} = @NewValue WHERE {2}";
             string where = string.Join(" AND ",
                                        tableInfo.PrimaryKeyColumns.Select(col => col + "=@" + col));
             string sqlText = string.Format(template, tableInfo.Name,
                                            columnInfo.Name, where);
             var command = new MySqlCommand(sqlText, cn);
             VoteDb.AddCommandParameter(command, "NewValue", newValue);
             foreach (string keyColumn in tableInfo.PrimaryKeyColumns)
             {
                 VoteDb.AddCommandParameter(command, keyColumn, row[keyColumn]);
             }
             VoteDb.ExecuteNonQuery(command);
         }
     }
     catch (Exception ex)
     {
         AppendStatusText("An error occurred updating value: {0}",
                          ex.Message);
     }
 }
示例#3
0
        private static void DeleteNonPermanentQuestionsJurisdictions()
        {
            const string cmdText = "DELETE FROM QuestionsJurisdictions WHERE QuestionId > 1000";
            var          cmd     = VoteDb.GetCommand(cmdText);

            VoteDb.ExecuteNonQuery(cmd);
        }
示例#4
0
        public static int UpdatePoliticianElectionsAllRows(string newValue)
        {
            const string cmdText = "UPDATE Sitemap SET PoliticianElections=@newValue";
            var          cmd     = VoteDb.GetCommand(cmdText, -1);

            VoteDb.AddCommandParameter(cmd, "newValue", newValue);
            return(VoteDb.ExecuteNonQuery(cmd));
        }
示例#5
0
        public static int UpdateMustHaveStatementAllRows(bool newValue)
        {
            const string cmdText = "UPDATE Sitemap SET MustHaveStatement=@newValue";
            var          cmd     = VoteDb.GetCommand(cmdText, -1);

            VoteDb.AddCommandParameter(cmd, "newValue", newValue);
            return(VoteDb.ExecuteNonQuery(cmd));
        }
示例#6
0
        public static int UpdateMinimumCandidatesAllRows(int newValue)
        {
            const string cmdText = "UPDATE Sitemap SET MinimumCandidates=@newValue";
            var          cmd     = VoteDb.GetCommand(cmdText, -1);

            VoteDb.AddCommandParameter(cmd, "newValue", newValue);
            return(VoteDb.ExecuteNonQuery(cmd));
        }
示例#7
0
        public static int UpdateColumnAllRows(Column column, object newValue)
        {
            var cmdText = "UPDATE Sitemap SET {0}=@newValue";

            cmdText = string.Format(cmdText, GetColumnName(column));
            var cmd = VoteDb.GetCommand(cmdText, -1);

            VoteDb.AddCommandParameter(cmd, "newValue", newValue);
            return(VoteDb.ExecuteNonQuery(cmd));
        }
        public static int UpdateIsOfficesAllIdentified(bool newValue,
                                                       string stateCode, int officeLevel, string countyCode = "",
                                                       string localCode = "")
        {
            const string cmdText = "UPDATE OfficesAllIdentified" +
                                   " SET IsOfficesAllIdentified=@newValue WHERE StateCode=@StateCode" +
                                   " AND OfficeLevel=@OfficeLevel AND CountyCode=@CountyCode" +
                                   " AND LocalCode=@LocalCode";
            var cmd = VoteDb.GetCommand(cmdText, -1);

            VoteDb.AddCommandParameter(cmd, "StateCode", stateCode);
            VoteDb.AddCommandParameter(cmd, "OfficeLevel", officeLevel);
            VoteDb.AddCommandParameter(cmd, "CountyCode", countyCode);
            VoteDb.AddCommandParameter(cmd, "LocalCode", localCode);
            VoteDb.AddCommandParameter(cmd, "newValue", newValue);
            return(VoteDb.ExecuteNonQuery(cmd));
        }
示例#9
0
 private void UpdateValue(TableInfo tableInfo, ColumnInfo columnInfo,
                          DataRow row, string value)
 {
     if (columnInfo.Size > 0 && value.Length > columnInfo.Size)
     {
         MessageBox.Show(string.Format("The new text length exceeds the maximum for this column of {0}",
                                       columnInfo.Size), "Cannot Update New Value", MessageBoxButtons.OK,
                         MessageBoxIcon.Error);
     }
     else
     {
         using (var cn = VoteDb.GetOpenConnection() as MySqlConnection)
         {
             try
             {
                 string template = "UPDATE {0} SET {1} = @NewValue WHERE {2}";
                 string where = string.Join(" AND ",
                                            tableInfo.PrimaryKeyColumns.Select(col => col + "=@" + col));
                 string sqlText = string.Format(template, tableInfo.Name,
                                                columnInfo.Name, where);
                 var command = new MySqlCommand(sqlText, cn);
                 VoteDb.AddCommandParameter(command, "NewValue", value);
                 foreach (string keyColumn in tableInfo.PrimaryKeyColumns)
                 {
                     VoteDb.AddCommandParameter(command, keyColumn, row[keyColumn]);
                 }
                 VoteDb.ExecuteNonQuery(command);
             }
             catch (Exception ex)
             {
                 AppendStatusText("An error occurred updating value: {0}",
                                  ex.Message);
             }
         }
     }
 }