0

I am developing winform application using C# and I need to simplfy. So please help me anyone how to Simplfy below my code . I have given below am using code.

try
        {
            object countnew = ((DataTable)grid_cheque.DataSource).Compute("Count(ChequeStatus)", "ChequeStatus = 'New'");
            object countIssued = ((DataTable)grid_cheque.DataSource).Compute("Count(ChequeStatus)", "ChequeStatus = 'Issued'");
            object countCancelled = ((DataTable)grid_cheque.DataSource).Compute("Count(ChequeStatus)", "ChequeStatus = 'Cancelled'");
            object countDishonour = ((DataTable)grid_cheque.DataSource).Compute("Count(ChequeStatus)", "ChequeStatus = 'DisHonour'");

            this.lblNew.Text = ERPModule.isnull(Convert.ToString(countnew), "0");
            this.lbl_Issued.Text = ERPModule.isnull(Convert.ToString(countIssued), "0");
            this.lblCancel.Text = ERPModule.isnull(Convert.ToString(countCancelled), "0");
            this.lbldishonour.Text = ERPModule.isnull(Convert.ToString(countDishonour), "0");
        }
        catch (Exception ex)
        {

        }
Nagarajan M
  • 2,101
  • 2
  • 9
  • 7
  • Crystal ball says that the Default property is the problem, this code won't work when it creates a new Form object every time you use it. Workaround is auto frm = Accounts...Default; frm.Show(); frm.BringToFront(); – Hans Passant Sep 29 '17 at 09:49

1 Answers1

0

based on answer :

How can I bring my application window to the front?

Control.BringToFront will bring a control to the front of the hosting control, for example you might bring a TextBox in front of a Label to make sure that the label's whitespace does not obscure part of the TextBox. Form has inherited this from Control, and it can be used to change the z-order of the Form when it is an MDI child - i.e. the Form is hosted in another Form. It will not bring a form in front of another application.