Solved

loading indicator when a try fails.

Posted on 2008-06-18
3
190 Views
Last Modified: 2013-12-16
I need to implement a loading indicator.

try
                {
                    cellPriceValue = ((Excel.Range)(inputRange.Cells[rowCount, pricesColumn]));
                    bool CheckNumeric = IsNumeric(cellPriceValue.Value2.ToString());

                    if (cellPriceValue.Value2.ToString().Length > 0 || cellPriceValue.Value2 != null)
                    {
                        if (cellPriceValue.Value2.ToString() == "Stones" || cellPriceValue.Value2.ToString() == "Tough")
                        {
                            currRow = rowCount + 1; //  skip a row to where the discounts are
                            break;
                        }

                        cellGradeValue = ((Excel.Range)(inputRange.Cells[rowCount, 15]));
                        gradeName = cellGradeValue.Value2.ToString();

                        InitialPrices.InitialPriceReportingServiceWS.InitialPriceReportingService WS = new InitialPrices.InitialPriceReportingServiceWS.InitialPriceReportingService();
                        int GradeCodeDetailID = 0;
                        string Status = null;
                        WS.GetGradeCodeDetailID(gradeName, ref  GradeCodeDetailID, ref Status);
                           
                        if (CheckNumeric)
                        {
                            Price = (decimal)cellPriceValue.Value2;
                            sum_prices += Price;
                         
                        }
                        else
                        {
                            InsertPriceListLoadError(PLHO.price_list_hdr_id.ToString(),
                                GradeCodeDetailID, rowCount + 1, gradeName, null, 'E',
                                "Price contains a non-numeric value.");
                        }

                       
                        count_rows += 1;
                           
                           
                        // Look at errors 'E'

                        if (GradeCodeDetailID == -1)
                        {
                             InsertPriceListLoadError(PLHO.price_list_hdr_id.ToString(), GradeCodeDetailID, rowCount + 1, gradeName, Price, 'E',
                             "Grade Code not found in Grade Code Details table.");

                        }
                           
                        if ((Price) < 0.00M)
                        {
                              InsertPriceListLoadError(PLHO.price_list_hdr_id.ToString(), GradeCodeDetailID, rowCount + 1, gradeName, Price, 'E',
                                "Price cannot be negative.");
                        }

                        for (int i = 0; i < 4; i++)
                        {
                           for (int j = 0; j < 3; j++)
                           {
                              if ((double)(discounts[i, j]) >= 0.00)
                              {
                                 if ((i == 2) && (j == 2)) break;
                                    InsertPriceListLoadError(PLHO.price_list_hdr_id.ToString(), GradeCodeDetailID, rowCount + 1, discountnames[i, j],
                                    discounts[i, j], 'E', "Discount cannot be positive.");
                              }
                           }

                         }
                         ///////////////////////
                           

                         // Look at warnings 'W'
                         if ((Price) > 1000.00M)
                         {
                            InsertPriceListLoadError(PLHO.price_list_hdr_id, GradeCodeDetailID, rowCount + 1, gradeName,
                                              Price, 'W', "Price is over $1000.00.  Please confirm with SP&P.");

                         }
                         if ((Price) == 0.00M)
                         {
                            InsertPriceListLoadError(PLHO.price_list_hdr_id, GradeCodeDetailID, rowCount + 1, gradeName,
                                              (decimal)(0.00), 'W', "Grade has no price.  Please confirm with SP&P.");
                         }
                           
                                       
                        }
                     
                    }

                   catch
                   {
                       Console.WriteLine("Blank Price encountered.  Likely a blank row.");
                   }

            }

In the catch this takes alot of time.
Can I put a loading thing.
0
Comment
Question by:mathieu_cupryk
  • 2
3 Comments
 
LVL 29

Accepted Solution

by:
anarki_jimbel earned 500 total points
Comment Utility
Not very clear what you want to achieve. From the first glance I'd say you code will fail if cell values are not numeric. And yes - execution goes to the catch block, just to see the mesage ("Blank Price encountered.  Likely a blank row.").

I'd check values in the try block if they are numeric (e.g., not blank string). You may use TryParse() function (you already asked the question about checking numeric values recently).

0
 

Author Comment

by:mathieu_cupryk
Comment Utility
this is not good enough.
0
 
LVL 29

Expert Comment

by:anarki_jimbel
Comment Utility
Again, not sure what you mean saying "this is not good enough."
My answer is not good enough? Checking if values are numbers not good enough? Your code is not good enough?

Try to understand: most people here are quite busy people. If you want to get fast reply with a solution to your problem try to be more clear and more precise. If experts ask you to clarify your question, like I did,  - probably it worth to do so (not just replying that answer is not good enough).

Your code is lacking comments , really, no comments at all. It is pretty hard to understand what you are doing. You are not giving any hints. How can we solve the problem?
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now