Inheritance: ArgumentException
        public void Verify_ExceptionThrownAndMessageContainsExpectedStrng_DoesnThrowExpection()
        {
            var constraint = CreateConstraint(typeof(ArgumentNullException), "argument1");
            var actualException = new ArgumentNullException("argument1");

            constraint.Verify(actualException);
        }
Beispiel #2
0
        /// <summary>
        /// Logs and rethrow the exception.
        /// </summary>
        /// <param name="message">Error message.</param>
        /// <param name="inputName">Name of input type.</param>
        /// <param name="traceProps">custom properties, add more dimensions to this, so it will be easy to trace and query.</param>
        private void LogAndThrowArgumentNullException(string message, string inputName, Dictionary <string, string> traceProps)
        {
            var argumentException = new System.ArgumentNullException(message, inputName);

            this.logger.TraceInformation(argumentException.Message, traceProps);
            throw argumentException;
        }
        public void Verify_ExceptionThrownMessageDoesntContainExpectedString_ThrowsException()
        {
            var constraint = CreateConstraint(typeof(ArgumentNullException), "argument1");
            var actualException = new ArgumentNullException("argument52");

            NUnit.Framework.Assert.Throws<AssertFailedException>(() => constraint.Verify(actualException));
        }
        protected AcquireTokenHandlerBase(Authenticator authenticator, TokenCache tokenCache, string resource, ClientKey clientKey, TokenSubjectType subjectType, bool callSync)
        {
            this.Authenticator = authenticator;
            this.CallState = CreateCallState(this.Authenticator.CorrelationId, callSync);
            Logger.Information(this.CallState, 
                string.Format("=== Token Acquisition started:\n\tAuthority: {0}\n\tResource: {1}\n\tClientId: {2}\n\tCacheType: {3}\n\tAuthentication Target: {4}\n\t",
                authenticator.Authority, resource, clientKey.ClientId,
                (tokenCache != null) ? tokenCache.GetType().FullName + string.Format(" ({0} items)", tokenCache.Count) : "null",
                subjectType));

            this.tokenCache = tokenCache;

            if (string.IsNullOrWhiteSpace(resource))
            {
                var ex = new ArgumentNullException("resource");
                Logger.Error(this.CallState, ex);
                throw ex;
            }

            this.Resource = (resource != NullResource) ? resource : null;
            this.ClientKey = clientKey;
            this.TokenSubjectType = subjectType;

            this.LoadFromCache = (tokenCache != null);
            this.StoreToCache = (tokenCache != null);
            this.SupportADFS = false;
        }
        public async Task <IHttpActionResult> GetExceptionNull()
        {
            System.ArgumentNullException nullEx = new System.ArgumentNullException("testfield", "testing field gak boleh null");
            this.loggingService.Log(nullEx);

            return(Ok());
        }
        public void TestArgumentNullException()
        {
            ArgumentNullException ex = new ArgumentNullException("testArgument", "testArgument is out of range");
            this.ExecuteExceptionHandler(ex);

            this.mockFactory.VerifyAllExpectationsHaveBeenMet();
        }
        public HttpResponseMessage Authenticate([FromBody] SystemUser user)
        {
            if (user == null)
            {
                var ex = new ArgumentNullException("user");
                return Request.CreateResponse(HttpStatusCode.InternalServerError, ex);
            }

            if ((user = SystemUser.Authenticate(user.Username, user.Password)) != null)
            {
                var authUser = new SystemUser
                {
                    Id = user.Id,
                    Username = user.Username,
                };
                authUser.GenerateAuthToken();
                ApplicationContext.AddAuthenticatedUser(authUser);

                return Request.CreateResponse(HttpStatusCode.OK, authUser);
            }
            else
            {
                return Request.CreateResponse(HttpStatusCode.Forbidden);
            }
        }
Beispiel #8
0
        public void Constructor_StoresException()
        {
            var exception = new ArgumentNullException("foo");
            var poison = new Poison<int>(42, exception);

            Assert.Equal(new ExceptionDetails(exception), poison.Exception, GenericEqualityComparer<ExceptionDetails>.ByAllMembers());
        }
		public void ConstructorWithParamNameWorks() {
			var ex = new ArgumentNullException("someParam");
			Assert.IsTrue((object)ex is ArgumentNullException, "is ArgumentNullException");
			Assert.AreEqual(ex.ParamName, "someParam", "ParamName");
			Assert.IsTrue(ex.InnerException == null, "InnerException");
			Assert.AreEqual(ex.Message, "Value cannot be null.\nParameter name: someParam");
		}
        public void ConstructorTestFailedNoLanguage()
        {
            ArgumentNullException expected = new ArgumentNullException("language", "Provided language must not be null or empty.");
            ArgumentNullException actual = Assert.Throws<ArgumentNullException>(() => new SeriesDetails(this.testExtractionPath, string.Empty));

            Assert.Equal(expected.Message, actual.Message);
        }
        public static bool TryOpen(this IDbConnection connection, out Exception exception)
        {
            exception = null;

            try
            {
                if (connection == null)
                {
                    exception = new ArgumentNullException("connection");
                    return false;
                }

                if (connection.State == ConnectionState.Open)
                {
                    return true;
                }

                connection.Open();

                return true;
            }
            catch (Exception ex)
            {
                exception = ex;
                return false;
            }
        }
        public void ExceptionMessages_are_concatenated_by_GetSafeMessage()
        {
            var inner = new InvalidOperationException();
            var outer = new ArgumentNullException("Eine Message", inner);

            Assert.Equal(outer.Message + " ---> " + inner.Message, outer.GetSafeMessage());
        }
 public void TestBackupRestoreCallbackExceptionHandling()
 {
     var ex = new ArgumentNullException();
     var test = new DatabaseFileTestHelper("database", "backup", true);
     Assert.Inconclusive("ESENT bug means instance isn't torn down correctly");
     test.TestRestoreCallbackExceptionHandling(ex);
 }
		public void ConstructorWithParamNameAndMessageWorks() {
			var ex = new ArgumentNullException("someParam", "The message");
			Assert.IsTrue((object)ex is ArgumentNullException, "is ArgumentNullException");
			Assert.AreEqual(ex.ParamName, "someParam", "ParamName");
			Assert.IsTrue(ex.InnerException == null, "InnerException");
			Assert.AreEqual(ex.Message, "The message");
		}
Beispiel #15
0
        public static Assembly LoadAssembly(string assemblyPath)
        {
            Assembly assembly = null;

            try
            {
                if (WzdUtils.FAddIn == null)
                {
                    ArgumentNullException exception = new ArgumentNullException("WzdUtils.FAddIn");

                    WzdUtils.Application_ThreadException(null, new ThreadExceptionEventArgs(exception));
                }
                else
                {
                    string path = WzdUtils.GetServerPath(WzdUtils.FAddIn, true);
                    path = path.Remove(path.LastIndexOf('\\')) + assemblyPath;
                    String fullDllName = path;
                    buffer = System.IO.File.ReadAllBytes(fullDllName);
                    assembly = Assembly.Load(buffer);
                }
            }
            catch (Exception ex)
            {
                WzdUtils.Application_ThreadException(null, new ThreadExceptionEventArgs(ex));
            }

            return assembly;
        }
Beispiel #16
0
        public static string installOrUpgrade()
        {
            //if its not configured then we can continue
            if (ApplicationContext.Current == null || ApplicationContext.Current.IsConfigured)
            {
                throw new AuthenticationException("The application is already configured");
            }

            LogHelper.Info<p>("Running 'installOrUpgrade' service");

            var result = ApplicationContext.Current.DatabaseContext.CreateDatabaseSchemaAndDataOrUpgrade();
            
            // Remove legacy umbracoDbDsn configuration setting if it exists and connectionstring also exists
            if (ConfigurationManager.ConnectionStrings[Umbraco.Core.Configuration.GlobalSettings.UmbracoConnectionName] != null)
            {
                Umbraco.Core.Configuration.GlobalSettings.RemoveSetting(Umbraco.Core.Configuration.GlobalSettings.UmbracoConnectionName);
            }
            else
            {
                var ex = new ArgumentNullException(string.Format("ConfigurationManager.ConnectionStrings[{0}]", Umbraco.Core.Configuration.GlobalSettings.UmbracoConnectionName), "Install / upgrade did not complete successfully, umbracoDbDSN was not set in the connectionStrings section");
                LogHelper.Error<p>("", ex);
                throw ex;
            }

            var js = new JavaScriptSerializer();
            var jsonResult = js.Serialize(result);
            return jsonResult;
        }
        internal void Arrange()
        {
            try
            {
                this.AppointmentGroups.ToDictionary(ag => ag.GroupId);
            }
            catch (ArgumentNullException ane)
            {
                ArgumentNullException ex = new ArgumentNullException(EX_ANEMSG, ane);
                throw ex;
            }
            catch (ArgumentException ae)
            {
                ArgumentException ex = new ArgumentException(EX_AEMSG, "AppointmentGroups", ae);
                throw ex;
            }

            foreach (var group in this.AppointmentGroups)
            {
                var movedItem = group.Where(a => a.GroupId != group.GroupId).FirstOrDefault();
                if (movedItem != default(Appointment))
                {
                    group.Remove(movedItem);
                    this.AppointmentGroups.Where(g => g.GroupId == movedItem.GroupId).First().Add(movedItem);
                }
            }
        }
        public void LogMessageCallbackTest()
        {
            StatusLogger.MessageLogged += MessageLoggedCallback;

            const string messageText = "Test Message";
            const string messageSource = "MessageSource";
            const MessageType messageType = MessageType.Error;
            const string innerExceptionText = "Inner Exception TEST";
            const string exceptionText = "This is an exception.";
            ArgumentNullException exception = new ArgumentNullException(exceptionText, new ArgumentException(innerExceptionText));
            Message messageToLog = new Message(messageText, messageSource, messageType, exception);

            StatusLogger.LogMessage(messageToLog);

            Assert.IsTrue(resetEvent.WaitOne(TimeoutValue));
            Assert.IsNotNull(messageReceived);
            Assert.AreEqual(messageText, messageReceived.Text);
            Assert.AreEqual(messageSource, messageReceived.Source);
            Assert.AreEqual(messageType, messageReceived.Level);
            Assert.AreEqual(exceptionText, messageReceived.Exception.Message);
            Assert.AreEqual(innerExceptionText, messageReceived.Exception.InnerException.Message);

            // Test that another message is not logged if unsubscribed
            resetEvent.Reset();
            StatusLogger.MessageLogged -= MessageLoggedCallback;
            StatusLogger.LogMessage(messageToLog);
            Assert.IsFalse(resetEvent.WaitOne(TimeoutValue));
        }
 protected override void Given()
 {
     base.Given();
     _thrownException = new ArgumentNullException();
     _config = new CircuitBreakerConfig();
     _circuitBreaker = new CircuitBreaker(_config);
 }
        public void ActivateOptionsTestLogFolderSet()
        {
            string tempPath = Path.Combine(System.IO.Path.GetTempPath() + "foobar");
            if (Directory.Exists(tempPath))
            {
                Directory.Delete(tempPath, true);
            }

            LogExceptionToFileFilter filter = new LogExceptionToFileFilter();
            filter.ExceptionLogFolder = tempPath;

            filter.ActivateOptions();

            var exception = new ArgumentNullException();
            ILoggerRepository logRepository = Substitute.For<ILoggerRepository>();

            var evt = new LoggingEvent(typeof(LogExceptionToFileFilterTests), logRepository, "test logger", Level.Debug, "test message", exception);

            var filterResult = filter.Decide(evt);
            Assert.AreEqual(FilterDecision.Neutral, filterResult);

            Assert.IsTrue(evt.Properties.Contains("log4net:syslog-exception-log"), "has an exception log param");
            Assert.IsTrue(Directory.Exists(tempPath));

            Assert.IsTrue(File.Exists(evt.Properties["log4net:syslog-exception-log"].ToString()), "exception file exists");

            Directory.Delete(tempPath, true);
        }
        public void BuildExceptionStringMessageTest()
        {
            var ex = new ArgumentNullException("", "fakeMessage") { Source = "fakeSource" };
            var expected = "<strong>myMessage</strong><br /><br /><strong>fakeMessage</strong><br /><br />";

            Assert.AreEqual(expected, ExceptionsHelper.BuildExceptionString(ex, "myMessage"));
        }
Beispiel #22
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            if (reader == null)
            {
                Exception e = new System.ArgumentNullException("reader");
                options.LogThrownException(e);
                throw e;
            }
            if (serializer == null)
            {
                Exception e = new System.ArgumentNullException("serializer");
                options.LogThrownException(e);
                throw e;
            }

            JToken token = JToken.Load(reader);

            if (token.Type == JTokenType.Array)
            {
                return(token.ToObject <List <T> >());
            }
            return(new List <T> {
                token.ToObject <T>()
            });
        }
		public void DefaultConstructorWorks() {
			var ex = new ArgumentNullException();
			Assert.IsTrue((object)ex is ArgumentNullException, "is ArgumentNullException");
			Assert.IsTrue(ex.ParamName == null, "ParamName");
			Assert.IsTrue(ex.InnerException == null, "InnerException");
			Assert.AreEqual(ex.Message, "Value cannot be null.");
		}
Beispiel #24
0
        public NGinRootStateAttribute( Type rootStateType, params Type[] constructorParameterTypes )
        {
            // make sure type is not null
            if ( rootStateType == null )
            {
                string message = "The given root state type must not be null.";
                ArgumentNullException argnEx = new ArgumentNullException( "rootStateType", message );
                throw argnEx;
            }

            // make sure defined state type inherits from abstract class RHFSM.State
            if ( !rootStateType.IsSubclassOf( typeof( NGin.Core.States.RHFSM.State ) ) )
            {
                string message = "The defined state type must be a subclass of " + typeof( NGin.Core.States.RHFSM.State ).FullName + ".";
                InvalidOperationException invopEx = new InvalidOperationException( message );
                throw invopEx;
            }

            if ( constructorParameterTypes == null )
            {
                string message = "The given constructor parameter types must not be null.";
                ArgumentNullException argnEx = new ArgumentNullException( "constructorParameterTypes", message );
                throw argnEx;
            }

            this.RootStateType = rootStateType;
            this.ConstructorParameterTypes = constructorParameterTypes;
        }
		public void TestBindingManagerDataErrorEventArgs ()
		{
			Exception ex = new ArgumentNullException ();

			BindingManagerDataErrorEventArgs e = new BindingManagerDataErrorEventArgs (ex);

			Assert.AreEqual (ex, e.Exception, "A1");
		}
 public void TypePropertiesAreCorrect()
 {
     Assert.AreEqual(typeof(ArgumentNullException).GetClassName(), "Bridge.ArgumentNullException", "Name");
     object d = new ArgumentNullException();
     Assert.True(d is ArgumentNullException, "is ArgumentNullException");
     Assert.True(d is ArgumentException, "is ArgumentException");
     Assert.True(d is Exception, "is Exception");
 }
Beispiel #27
0
        public void DeserializeTestFailedNoNode()
        {
            Actor target = new Actor();
            ArgumentNullException expected = new ArgumentNullException("node", "Provided node must not be null.");
            ArgumentNullException actual = Assert.Throws<ArgumentNullException>(() => target.Deserialize(null));

            Assert.Equal(expected.Message, actual.Message);
        }
 public static void IfArgumentNull(object argument, string argumentName, Func<Exception, Exception> modifier = null)
 {
     if (argument == null)
     {
         var ex = new ArgumentNullException(argumentName);
         ThrowInternal(ex, modifier);
     }
 }
		public void ConstructorWithMessageAndInnerExceptionWorks() {
			var inner = new Exception("a");
			var ex = new ArgumentNullException("The message", inner);
			Assert.IsTrue((object)ex is ArgumentNullException, "is ArgumentException");
			Assert.IsTrue(ex.ParamName == null, "ParamName");
			Assert.IsTrue(ReferenceEquals(ex.InnerException, inner), "InnerException");
			Assert.AreEqual(ex.Message, "The message");
		}
 public void BuildExceptionTitleInnerExceptionTest()
 {
     var innerEx = new NotImplementedException();
     var ex = new ArgumentNullException("message", innerEx) { Source = "fakeSource" };
     
     var expected = "System.ArgumentNullException - fakeSource";
     Assert.AreEqual(expected, ExceptionsHelper.BuildExceptionTitle(ex));
 }
        public void ItThrowsAnArgumentNullExceptionIfTheModelIsNull()
        {
            var expectedException = new ArgumentNullException(typeof(CreateBoardGameGeekUserDefinitionRequest).ToString());

            Exception exception = Assert.Throws<ArgumentNullException>(() => autoMocker.ClassUnderTest.CreateUserDefintion(null, currentUser));

            Assert.AreEqual(expectedException.Message, exception.Message);
        }
        public void ItThrowsAnArgumentNullExceptionIfThePlayerIsNull()
        {
            var expectedException = new ArgumentNullException("createPlayerRequest");

            Exception exception = Assert.Throws<ArgumentNullException>(() => _autoMocker.ClassUnderTest.CreatePlayer(null, _currentUser));

            Assert.AreEqual(expectedException.Message, exception.Message);
        }
        public void BuildExceptionStringInnerExceptionTest()
        {
            var innerEx = new NotImplementedException("fakeInnerMessage");
            var ex = new ArgumentNullException("fakeMessage", innerEx) { Source = "fakeSource" };

            var expected = "<strong>fakeMessage</strong><br /><br /><br /><br /><i><u>Inner Exception:</u></i><br /><strong>fakeInnerMessage</strong><br /><br />";
            Assert.AreEqual(expected, ExceptionsHelper.BuildExceptionString(ex));
        }
        public byte[] BlobStrToBa(string blobString)
        {
            if (blobString == null)
            {
                Exception e = new System.ArgumentNullException("blobString");
                options.LogThrownException(e);
                throw e;
            }

            // Convert a base 16 encoded blob string to an array of 8 bit bytes
            const int dwordBase      = Constants.Base16;
            const int charsPerByte   = Constants.CharsPerByte;
            int       bAlength       = blobString.Length / charsPerByte;
            var       conglomerateBa = new byte[bAlength];

            // Since the input can be any string, check to see that we have base 16 characters
            if (blobString.Length > 0)
            {
                bool isBase16 = true;
                // assume all is well, but scan through the string for anything outside of base 16 encoding.
                foreach (Char cVal in blobString.ToUpper())
                {
                    if (!(cVal.Equals('A') || cVal.Equals('B') || cVal.Equals('C') || cVal.Equals('D') || cVal.Equals('E') || cVal.Equals('F') ||
                          cVal.Equals('0') || cVal.Equals('1') || cVal.Equals('2') || cVal.Equals('3') || cVal.Equals('4') || cVal.Equals('5') ||
                          cVal.Equals('6') || cVal.Equals('7') || cVal.Equals('8') || cVal.Equals('9')))
                    {
                        isBase16 = false;
                        log.DebugFormat("***** Error: Input character Not in Base16 Format:  \"{0}\"", cVal);
                    }
                }
                if (isBase16)
                {
                    for (int i = 0; i < bAlength; i++)
                    {
                        // interpret the string contents as base 16 (hex) data
                        int    byteIndex  = i * charsPerByte;
                        string byteString = blobString.Substring(byteIndex, charsPerByte);
                        conglomerateBa[i] = Convert.ToByte(byteString, dwordBase);
                    }
                    // assign the result reference to the output parameter
                    return(conglomerateBa);
                }
                else
                {
                    log.Debug("***** Error:  One or more input characters is NOT in Base16 Format!");
                    return(conglomerateBa);
                }
            }
            log.Debug("***** Error:  Cannot convert a NULL blob string!");
            return(conglomerateBa);
        }
Beispiel #35
0
 public Windows.Foundation.IAsyncOperationWithProgress <IBuffer, uint> ReadAsync(IBuffer buffer, uint count, InputStreamOptions options)
 {
     return(System.Runtime.InteropServices.WindowsRuntime.AsyncInfo.Run <IBuffer, uint>((token, progress) =>
     {
         return System.Threading.Tasks.Task.Run(async() =>
         {
             uint len = 0;
             bool result = false;
             if (internalStream != null)
             {
                 System.Diagnostics.Debug.WriteLine("ReadAsync request - count: " + count.ToString() + " bytes  at " + ReadDataIndex.ToString() + " - Stream Size: " + internalStream.Size + " Stream position: " + internalStream.Position + " Track size: " + GetLength().ToString());
                 if (ReadDataIndex + count > internalStream.Size)
                 {
                     // Fill the buffer
                     result = await FillInternalStream(ReadDataIndex + count);
                     if (result != true)
                     {
                         System.ArgumentNullException ex = new System.ArgumentNullException("Exception while reading CD Track");
                         throw ex;
                     }
                 }
                 if (internalStream != null)
                 {
                     var inputStream = internalStream.GetInputStreamAt(ReadDataIndex);
                     if (inputStream != null)
                     {
                         inputStream.ReadAsync(buffer, count, options).AsTask().Wait();
                         len = buffer.Length;
                         ReadDataIndex += len;
                         System.Diagnostics.Debug.WriteLine("ReadAsync return : " + buffer.Length.ToString() + " bytes  at " + (ReadDataIndex - len).ToString() + " - Stream Size: " + internalStream.Size + " Stream position: " + internalStream.Position + " Track size: " + GetLength().ToString());
                     }
                 }
             }
             progress.Report(len);
             return buffer;
         });
     }));
 }
Beispiel #36
0
        // Setup the client handler for HTTP proxy tunneling if needed
        private static void InitWrHandler(WebRequestHandler wrhandler)
        {
            if (wrhandler == null)
            {
                Exception e = new System.ArgumentNullException("wrhandler");
                options.LogThrownException(e);
                throw e;
            }

            // NOTE: System Store "MY" corresponds to the current user's certificate store.
            // This code assumes that the IAS server's certificate and key (in PFX form) have been installed in the current user's certificate store.
            X509Store localHostCertStore = new X509Store(Constants.CurrentUserCertStore, StoreLocation.CurrentUser);

            localHostCertStore.Open(OpenFlags.ReadOnly | OpenFlags.OpenExistingOnly);
            X509Certificate2Collection usersFullCollection = (X509Certificate2Collection)localHostCertStore.Certificates;

            string subjectName = Properties.Settings.Default.IASCertSubject;

            X509Certificate2Collection iasCollection = (X509Certificate2Collection)usersFullCollection.Find(X509FindType.FindBySubjectName, subjectName, false);
            X509Certificate2           iasCert       = iasCollection.Find(X509FindType.FindBySubjectName, subjectName, false)[0];

            wrhandler.ClientCertificates.Add(iasCert);
        }
        /// <summary>
        /// Wait for the client to send its response
        /// </summary>
        /// <param name="data"></param>
        public void Wait(object data)
        {
            try
            {
                if (data == null)
                {
                    Exception e = new System.ArgumentNullException("data");
                    options.LogThrownException(e);
                    throw e;
                }

                ClientTransaction client = (ClientTransaction)data;

                // We will wait until the timeout
                // During this time, if the client sends its response then the server shall kill this Wait Thread for the client transaction
                // to prevent removal of the client from the Client database
                bool timeOut = TimedOut();

                // If timed out, remove the client from the database
                if (timeOut)
                {
                    log.Debug("Client " + client.ID + " timed out");
                    ClientDatabase.RemoveTransaction(client);
                }
            }
            catch (Exception e)
            {
                if (e.Message.Contains("Thread was being aborted"))
                {
                    log.Debug("Client Thread was killed. ");
                }
                else
                {
                    log.Debug("ThreadWait: Wait failed. " + e.Message);
                }
            }
        }
Beispiel #38
0
        protected void txtItemCode_TextChanged(object sender, EventArgs e)
        {
            GridViewRow currentRow = (GridViewRow)((TextBox)sender).Parent.Parent;
            int         rowIndex   = currentRow.RowIndex;
            TextBox     textBox    = (sender as TextBox);

            var itemData = unitOfWork.ItemRepository.Find(f => f.ItemCode == textBox.Text.Trim());//seller.GetItemInformation(textBox.Text.Trim());
            int result;

            if (itemData != null)
            {
                #region Code is working fine for HSN search , but now need to get the logic of Purchase register
                if (int.TryParse(textBox.Text, NumberStyles.Integer, CultureInfo.InvariantCulture, out result) && !string.IsNullOrEmpty(textBox.Text.Trim()) && textBox.Text.Length == 8)
                {
                    try
                    {
                        string type = string.Empty;
                        // added to check whether new HSN IS NOTIFIED OR NOT
                        if (itemData.IsNotified.Value)
                        {
                            //BindNotifiedHSN(itemData.GST_MST_ITEM_NOTIFIED, lvHSNData);
                            // ScriptManager.RegisterStartupScript(Page, Page.GetType(), "myModalhsn", "$('#myModalhsn').modal();", true);
                            //upModal.Update();
                        }
                        if (itemData != null)
                        {
                            TextBox txtDescription = (TextBox)currentRow.FindControl("txtGoodService");
                            TextBox txtUnit        = (TextBox)currentRow.FindControl("txtUnit");
                            txtDescription.Text = itemData.Description;
                            txtUnit.Text        = itemData.Unit;
                        }
                    }
                    catch (System.ArgumentNullException arguEx)
                    {
                        System.ArgumentNullException formatErr = new System.ArgumentNullException("Null value was passed.");
                    }
                }
            }
            else
            {
                textBox.Text = string.Empty;
                TextBox txtDescription  = (TextBox)currentRow.FindControl("txtGoodService");
                TextBox txtUnit         = (TextBox)currentRow.FindControl("txtUnit");
                TextBox txtQty          = (TextBox)currentRow.FindControl("txtQty");
                Label   txtTaxableValue = (Label)currentRow.FindControl("txtTaxableValue");
                TextBox txtRate         = (TextBox)currentRow.FindControl("txtRate");
                Label   txtTotal        = (Label)currentRow.FindControl("txtTotal");
                TextBox txtDiscount     = (TextBox)currentRow.FindControl("txtDiscount");


                txtDescription.Text  = string.Empty;
                txtUnit.Text         = string.Empty;
                txtDiscount.Text     = string.Empty;
                txtQty.Text          = string.Empty;
                txtTaxableValue.Text = string.Empty;
                txtRate.Text         = string.Empty;
                txtTotal.Text        = string.Empty;
                //TODO:DISPLAY MESSAGE thet item does not exist.
            }

            #endregion
        }