public void UpdateDescription(LotterySequenceGenerator updatedModel)
        {
            using (OleDbConnection conn = DatabaseConnectionFactory.GetDataSource())
                using (OleDbCommand command = new OleDbCommand())
                {
                    command.CommandType = CommandType.Text;
                    command.CommandText = " UPDATE lottery_seq_gen SET description= @description " +
                                          " WHERE ID = @id AND seqgencd = @seqgencd AND active = true";
                    command.Parameters.AddWithValue("@description", StringUtils.Truncate(updatedModel.GetDescription(), MAX_LEN_DESCRIPTION));
                    command.Parameters.AddWithValue("@id", updatedModel.GetID());
                    command.Parameters.AddWithValue("@seqgencd", updatedModel.GetSeqGenCode());
                    command.Connection = conn;
                    conn.Open();
                    OleDbTransaction transaction = conn.BeginTransaction();
                    command.Transaction = transaction;
                    int result = command.ExecuteNonQuery();

                    if (result < 0)
                    {
                        transaction.Rollback();
                        throw new Exception(String.Format(ResourcesUtils.GetMessage("lot_dao_impl_msg2"), updatedModel.GetDescription()));
                    }
                    transaction.Commit();
                }
        }
Beispiel #2
0
 private void FocusItemOnLotterySequenceGenerators(int sequenceGenIdOrSeqId)
 {
     foreach (ListViewItem item in lvSeqGenDescriptions.Items)
     {
         LotterySequenceGenerator seqGen = (LotterySequenceGenerator)item.Tag;
         if (seqGen.GetSeqGenCode() == sequenceGenIdOrSeqId || seqGen.GetID() == sequenceGenIdOrSeqId)
         {
             item.Selected = true;
             item.EnsureVisible();
             break;
         }
     }
 }