public static int DeleteByEmailDate(string email, DateTime date) { const string cmdText = "DELETE FROM Donations WHERE Email=@email AND Date=@date"; var cmd = VoteDb.GetCommand(cmdText); VoteDb.AddCommandParameter(cmd, "Email", email); VoteDb.AddCommandParameter(cmd, "Date", date); return(VoteDb.ExecuteNonQuery(cmd)); }
public static int UpdateOfficeKeyByOfficeKey(string newValue, string officeKey) { const string cmdText1 = "UPDATE Politicians SET LiveOfficeKey=@newValue WHERE LiveOfficeKey=@OfficeKey"; var cmd1 = VoteDb.GetCommand(cmdText1, -1); VoteDb.AddCommandParameter(cmd1, "OfficeKey", officeKey); VoteDb.AddCommandParameter(cmd1, "newValue", newValue); var count = VoteDb.ExecuteNonQuery(cmd1); const string cmdText2 = "UPDATE Politicians SET TemporaryOfficeKey=@newValue WHERE TemporaryOfficeKey=@OfficeKey"; var cmd2 = VoteDb.GetCommand(cmdText2, -1); VoteDb.AddCommandParameter(cmd2, "OfficeKey", officeKey); VoteDb.AddCommandParameter(cmd2, "newValue", newValue); return(count + VoteDb.ExecuteNonQuery(cmd2)); }
//public static int UpdatePassword(string newValue, string email) //{ // return PartiesEmails.UpdatePartyPassword(newValue, email); //} //public static int UpdatePhone(string newValue, string email) //{ // return PartiesEmails.UpdatePartyContactPhone(newValue, email); //} public static int UpdateColumn(Column column, object newValue, string email) { var cmdText = "UPDATE PartiesEmails SET {0}=@newValue WHERE PartyEmail=@PartyEmail"; PartiesEmails.Column partiesEmailsColumn; switch (column) { case Column.Email: partiesEmailsColumn = PartiesEmails.Column.PartyEmail; break; case Column.FirstName: partiesEmailsColumn = PartiesEmails.Column.PartyContactFirstName; break; case Column.LastName: partiesEmailsColumn = PartiesEmails.Column.PartyContactLastName; break; case Column.PartyKey: partiesEmailsColumn = PartiesEmails.Column.PartyKey; break; case Column.Password: partiesEmailsColumn = PartiesEmails.Column.PartyPassword; break; case Column.Phone: partiesEmailsColumn = PartiesEmails.Column.PartyContactPhone; break; default: throw new Exception("VolunteersView invalid column"); } cmdText = string.Format(cmdText, PartiesEmails.GetColumnName(partiesEmailsColumn)); var cmd = VoteDb.GetCommand(cmdText, -1); VoteDb.AddCommandParameter(cmd, "PartyEmail", email); VoteDb.AddCommandParameter(cmd, "newValue", newValue); return(VoteDb.ExecuteNonQuery(cmd)); }
public static void Insert( string email, string password, string partyKey, string firstName, string lastName, string phone, int commandTimeout = -1) { const string cmdText = "INSERT INTO PartiesEmails (PartyEmail,PartyPassword,PartyKey," + "PartyContactFName,PartyContactLName,PartyContactPhone,PartyContactTitle,IsVolunteer,DateStamp) " + "VALUES (@PartyEmail,@PartyPassword,@PartyKey,@PartyContactFirstName,@PartyContactLastName," + "@PartyContactPhone,@PartyContactTitle,@IsVolunteer,@DateStamp)"; var cmd = VoteDb.GetCommand(cmdText, commandTimeout); VoteDb.AddCommandParameter(cmd, "PartyEmail", email); VoteDb.AddCommandParameter(cmd, "PartyPassword", password); VoteDb.AddCommandParameter(cmd, "PartyKey", partyKey); VoteDb.AddCommandParameter(cmd, "PartyContactFirstName", firstName); VoteDb.AddCommandParameter(cmd, "PartyContactLastName", lastName); VoteDb.AddCommandParameter(cmd, "PartyContactPhone", phone); VoteDb.AddCommandParameter(cmd, "PartyContactTitle", string.Empty); VoteDb.AddCommandParameter(cmd, "IsVolunteer", true); VoteDb.AddCommandParameter(cmd, "DateStamp", DateTime.UtcNow); VoteDb.ExecuteNonQuery(cmd); }
public static void UpdateAdInfo(int orgId, string adUrl, bool imageFileChanged, string adImageName, byte[] adImage) { if (imageFileChanged) { const string cmdText = "UPDATE Organizations SET AdUrl=@AdUrl,AdImageName=@AdImageName," + "AdImage=@AdImage WHERE OrgId=@OrgId"; var cmd = VoteDb.GetCommand(cmdText, -1); VoteDb.AddCommandParameter(cmd, "OrgId", orgId); VoteDb.AddCommandParameter(cmd, "AdUrl", adUrl); VoteDb.AddCommandParameter(cmd, "AdImageName", adImageName); VoteDb.AddCommandParameter(cmd, "AdImage", adImage); VoteDb.ExecuteNonQuery(cmd); } else { const string cmdText = "UPDATE Organizations SET AdUrl=@AdUrl WHERE OrgId=@OrgId"; var cmd = VoteDb.GetCommand(cmdText, -1); VoteDb.AddCommandParameter(cmd, "OrgId", orgId); VoteDb.AddCommandParameter(cmd, "AdUrl", adUrl); VoteDb.ExecuteNonQuery(cmd); } }