コード例 #1
0
    protected void dgItemCategory_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        try
        {
            if (CommonClasses.ValidRights(int.Parse(right.Substring(4, 1)), this, "For Delete"))
            {
                if (!ModifyLog(((Label)(dgItemCategory.Rows[e.RowIndex].FindControl("lblI_CAT_CODE"))).Text))
                {
                    BL_ItemCategoryMaster = new ItemCategoryMaster_BL();
                    string i_cat_code = ((Label)(dgItemCategory.Rows[e.RowIndex].FindControl("lblI_CAT_CODE"))).Text;
                    string i_cat_name = ((Label)(dgItemCategory.Rows[e.RowIndex].FindControl("lblI_CAT_NAME"))).Text;

                    BL_ItemCategoryMaster.I_CAT_CODE = Convert.ToInt32(i_cat_code);
                    if (CommonClasses.CheckUsedInTran("ITEM_MASTER", "I_CAT_CODE", "AND ES_DELETE=0", i_cat_code))
                    {
                        PanelMsg.Visible = true;
                        lblmsg.Text      = "You cant delete this record it has used in Item Master";
                        ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true);

                        //ShowMessage("#Avisos", "You cant delete this record it has used in Components", CommonClasses.MSG_Warning);
                    }
                    else
                    {
                        bool flag = BL_ItemCategoryMaster.Delete();
                        if (flag == true)
                        {
                            CommonClasses.WriteLog("Item Category Master", "Delete", "Item Category Master", i_cat_code, Convert.ToInt32(i_cat_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);
                        }
                    }
                    //}
                    LoadCategory();
                }
            }
            else
            {
                PanelMsg.Visible = true;
                lblmsg.Text      = "You Have No Rights To Delete";
                ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true);
            }
        }
        catch (Exception Ex)
        {
            CommonClasses.SendError("Item Category Master-View", "GridView1_RowDeleting", Ex.Message);
        }
    }