コード例 #1
0
    public void InsertVotingQuestion(VotingQuestionInfo votingQuestionInfo)
    {
        String query = "INSERT INTO [dbo].[VotingQuestion] "
                       + "([ClientID] "
                       + ",[EventID] "
                       + ",[QuestionID] "
                       + ",[Question] "
                       + ",[AnswerType] "
                       + ",[CreateUser] "
                       + ",[CreateDate] "
                       + ",[LastModifiedUser] "
                       + ",[LastModifiedDate] ) "
                       + "VALUES "
                       + "(@ClientID "
                       + ",@EventID "
                       + ",@QuestionID "
                       + ",@Question "
                       + ",@AnswerType "
                       + ",@CreateUser "
                       + ",@CreateDate "
                       + ",@LastModifiedUser "
                       + ",@LastModifiedDate) ";

        db.Execute(query, votingQuestionInfo, transaction);
    }
コード例 #2
0
    public void Insert(VotingEventSetupInfo votingEventSetupInfo)
    {
        db.Open();
        transaction = db.BeginTransaction();
        try
        {
            String query = "INSERT INTO VotingEventSetup "
                           + "([ClientID] "
                           + ",[EventID] "
                           + ",[EventDescription] "
                           + ",[EventDate] "
                           + ",[EffectDateFrom] "
                           + ",[EffectDateTo] "
                           + ",[CreateUser] "
                           + ",[CreateDate] "
                           + ",[LastModifiedUser] "
                           + ",[LastModifiedDate] ) "
                           + "VALUES "
                           + "(@ClientID "
                           + ",@EventID "
                           + ",@EventDescription "
                           + ",@EventDate "
                           + ",@EffectDateFrom "
                           + ",@EffectDateTo "
                           + ",@CreateUser "
                           + ",@CreateDate "
                           + ",@LastModifiedUser "
                           + ",@LastModifiedDate ) ";
            db.Execute(query, votingEventSetupInfo, transaction);

            if (votingEventSetupInfo.VotingQuestionList != null)
            {
                for (int i = 0; i < votingEventSetupInfo.VotingQuestionList.Count; i++)
                {
                    VotingQuestionInfo votingQuestionInfo = votingEventSetupInfo.VotingQuestionList[i];
                    votingQuestionInfo.CreateUser       = votingEventSetupInfo.LastModifiedUser;
                    votingQuestionInfo.CreateDate       = DateTime.Now;
                    votingQuestionInfo.LastModifiedUser = votingEventSetupInfo.LastModifiedUser;
                    votingQuestionInfo.LastModifiedDate = DateTime.Now;
                    votingQuestionInfo.ClientID         = votingEventSetupInfo.ClientID;
                    votingQuestionInfo.EventID          = votingEventSetupInfo.EventID;
                    votingQuestionInfo.QuestionID       = i + 1;
                    this.InsertVotingQuestion(votingQuestionInfo);
                }
            }

            transaction.Commit();
        }
        catch
        {
            transaction.Rollback();
            throw;
        }
        finally
        {
            transaction.Dispose();
            transaction = null;
            db.Close();
        }
    }
コード例 #3
0
    public void Update(VotingEventSetupInfo votingEventSetupInfo)
    {
        db.Open();
        transaction = db.BeginTransaction();
        try
        {
            String query = "UPDATE [dbo].[VotingEventSetup] "
                           + "SET "
                           + "[EventDescription] = @EventDescription "
                           + ",[EventDate] = @EventDate "
                           + ",[EffectDateFrom] = @EffectDateFrom "
                           + ",[EffectDateTo] = @EffectDateTo "
                           + ",[LastModifiedUser] = @LastModifiedUser "
                           + ",[LastModifiedDate] = @LastModifiedDate "
                           + "WHERE ClientID = @ClientID AND EventID = @EventID ";
            db.Execute(query, votingEventSetupInfo, transaction);

            this.DeleteVotingQuestion(votingEventSetupInfo.ClientID, votingEventSetupInfo.EventID);

            if (votingEventSetupInfo.VotingQuestionList != null)
            {
                for (int i = 0; i < votingEventSetupInfo.VotingQuestionList.Count; i++)
                {
                    VotingQuestionInfo votingQuestionInfo = votingEventSetupInfo.VotingQuestionList[i];
                    votingQuestionInfo.CreateUser       = votingEventSetupInfo.LastModifiedUser;
                    votingQuestionInfo.CreateDate       = DateTime.Now;
                    votingQuestionInfo.LastModifiedUser = votingEventSetupInfo.LastModifiedUser;
                    votingQuestionInfo.LastModifiedDate = DateTime.Now;
                    votingQuestionInfo.ClientID         = votingEventSetupInfo.ClientID;
                    votingQuestionInfo.EventID          = votingEventSetupInfo.EventID;
                    votingQuestionInfo.QuestionID       = i + 1;
                    this.InsertVotingQuestion(votingQuestionInfo);
                }
            }

            transaction.Commit();
        }
        catch
        {
            transaction.Rollback();
            throw;
        }
        finally {
            transaction.Dispose();
            transaction = null;
            db.Close();
        }
    }