예제 #1
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();
        }
    }
예제 #2
0
 public void Save(VotingEventSetupInfo votingEventSetupInfo)
 {
     if (this.IsExisted(votingEventSetupInfo.ClientID, votingEventSetupInfo.EventID))
     {
         this.Update(votingEventSetupInfo);
     }
     else
     {
         this.Insert(votingEventSetupInfo);
     }
 }
예제 #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();
        }
    }