Ejemplo n.º 1
0
        protected void btSimRe_Click(object sender, EventArgs e)
        {
            bool a = false, b = false;

            for (int i = 0; i < gvEquipList.Rows.Count; i++)
            {
                Equip equip    = EquipDAO.GetEquipByID(Convert.ToInt32(gvEquipList.DataKeys[i].Value));
                int   id_equip = equip.id_equip;
                if (((CheckBox)gvEquipList.Rows[i].FindControl("chbxEliminar")).Checked)
                {
                    a = true;
                    int returncode = EquipDAO.RemoveEquip(id_equip);
                    if (returncode == 2)
                    {
                        lbErro.Text = "Não foi possivel remover este equipamento :" + equip.descri + "\nDevido a haver reserva(s) deste equipamento.";
                        MPE_Erro.Show();
                        b = true;
                    }
                    else if (returncode == 3)
                    {
                        lbErro.Text = "Não foi possivel remover este equipamento :" + equip.descri + "\nDevido a haver denuncia(s) deste equipamento.";
                        MPE_Erro.Show();
                        b = true;
                    }

                    continue;
                }
            }
            MPE_Rem.Hide();
            if (a == true)
            {
                if (b == true)
                {
                    DataBindGrid();
                    String str = "<script>alertify.success('Remoção feita com sucesso em alguns casos!');</script>";
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "Script", str, false);
                }
                else
                {
                    DataBindGrid();
                    String str = "<script>alertify.success('Remoção feita com sucesso!');</script>";
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "Script", str, false);
                }
            }
            else
            {
                DataBindGrid();
                String str = "<script>alertify.error('Não há nada para remover!');</script>";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "Script", str, false);
            }
        }