private void chk_Orders_OnChange(object sender, EventArgs e)
        {
            try
            {
                SalesOrderDBaccess    SO = new SalesOrderDBaccess();
                PurchaseOrderDBaccess PO = new PurchaseOrderDBaccess();
                if (rbn_SaleM.Checked)
                {
                    if (chk_Orders.Checked)
                    {
                        String Status = "Delivered";
                        grid_PurSales.DataSource = SO.getDeliveredSalesOrders(Status);
                    }
                    else
                    {
                        grid_PurSales.DataSource = SO.getSalesOrders();
                    }
                }
                if (rbn_PurM.Checked)
                {
                    if (chk_Orders.Checked)
                    {
                        String Status = "Received";
                        grid_PurSales.DataSource = PO.getRecievedPurchaseOrders(Status);
                    }
                    else
                    {
                        grid_PurSales.DataSource = PO.getPurchaseOrders();
                    }
                }
            }

            catch (SqlException)
            {
                MetroMessageBox.Show(this, "\n\nConnecton Failed", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (FormatException)
            {
                MetroMessageBox.Show(this, "\n\nInvalid Format", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (OutOfMemoryException)
            {
                MetroMessageBox.Show(this, "\n\nInsuffisent memory", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception)
            {
                MetroMessageBox.Show(this, "\n\nERROR", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 private void rbn_PurM_CheckedChanged(object sender, EventArgs e)
 {
     try
     {
         PurchaseOrderDBaccess PO = new PurchaseOrderDBaccess();
         if (rbn_PurM.Checked)
         {
             lb_del.Visible = false;
             lb_res.Visible = true;
             if (chk_Orders.Checked)
             {
                 String Status = "Received";
                 grid_PurSales.DataSource = PO.getRecievedPurchaseOrders(Status);
             }
             else
             {
                 grid_PurSales.DataSource = PO.getPurchaseOrders();
             }
         }
     }
     catch (SqlException)
     {
         MetroMessageBox.Show(this, "\n\nConnecton Failed", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     catch (FormatException)
     {
         MetroMessageBox.Show(this, "\n\nInvalid Format", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     catch (OutOfMemoryException)
     {
         MetroMessageBox.Show(this, "\n\nInsuffisent memory", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     catch (Exception)
     {
         MetroMessageBox.Show(this, "\n\nERROR", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }