protected void dgCurrancyMaster_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        try
        {
            if (CommonClasses.ValidRights(int.Parse(right.Substring(4, 1)), this, "For Delete"))
            {
                if (!ModifyLog(((Label)(dgCurrancyMaster.Rows[e.RowIndex].FindControl("lblC_Code"))).Text))
                {
                    Bl_CrrancyMaster = new CurrancyMaster_BL();
                    string Curr_Code = ((Label)(dgCurrancyMaster.Rows[e.RowIndex].FindControl("lblC_Code"))).Text;
                    //string Curr_Name = ((Label)(dgCurrancyMaster.Rows[e.RowIndex].FindControl("lblC_CURR_NAME"))).Text;

                    Bl_CrrancyMaster.CURR_CODE = Convert.ToInt32(Curr_Code);
                    if (CommonClasses.CheckUsedInTran("INVOICE_MASTER", "INM_CURR_CODE", "AND ES_DELETE=0", Curr_Code))
                    {
                        //ShowMessage("#Avisos", "You cant delete this record it has used in Components", CommonClasses.MSG_Warning);
                        PanelMsg.Visible = true;
                        lblmsg.Text      = "You can't delete this record it has used in Invoice";
                        ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true);
                    }
                    else if (CommonClasses.CheckUsedInTran("SUPP_PO_MASTER", "SPOM_CURR_CODE", "AND ES_DELETE=0", Curr_Code))
                    {
                        PanelMsg.Visible = true;
                        lblmsg.Text      = "You can't delete this record it has used in Purchase Order";
                        ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true);
                    }
                    else
                    {
                        bool flag = Bl_CrrancyMaster.Delete();
                        if (flag == true)
                        {
                            CommonClasses.WriteLog("Currancy  Master", "Delete", "Currancy Master", Curr_Code, Convert.ToInt32(Curr_Code), Convert.ToInt32(Session["CompanyId"]), Convert.ToInt32(Session["CompanyCode"]), (Session["Username"].ToString()), Convert.ToInt32(Session["UserCode"]));
                            //ShowMessage("#Avisos", CommonClasses.strRegDelSucesso, CommonClasses.MSG_Erro);
                            PanelMsg.Visible = true;
                            lblmsg.Text      = "Record Deleted Successfully";
                            ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true);
                        }
                    }
                }
                LoadCurrancy();
            }
            else
            {
                PanelMsg.Visible = true;
                lblmsg.Text      = "You Have No Rights To Delete";
                ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true);
            }
        }
        catch (Exception Ex)
        {
            CommonClasses.SendError("Currency Master-View", "dgCurrancyMaster_RowDeleting", Ex.Message);
        }
    }