c# 委托

在EXtgrid类中

 public delegate bool DeleteEvent(string selStr);

    public DeleteEvent OnDeleteEvent{get;set;}

  protected void btnDelete_Click(object sender, EventArgs e)     {         DoDelete();     }

    public void DoDelete()     {        

string sel = GetRowsSelected();        

if (sel == "")      

   {             Alert.Show("请选择一条数据!");          

   return;         }      

   if (OnDeleteEvent != null)//委托给使用者实现      

   {            

try            

{                

if (OnDeleteEvent(sel))                

{                     Alert.Show("删除成功!");                     BindGrid();                 }             

    else                

{                     Alert.Show("删除失败!");                 }             }         

    catch            

{                 Alert.Show("删除失败!数据存在引用关系,请查找");             }         }     }

 

在继承Extgrid类的页面中,实现委托删除操作

private bool deleteRecord(string recordID)
  {
     int flag = 0;
   try
   {
    string wherecondition="";
    wherecondition=" where SEQ in("+recordID+")";
                t_access = new B_CardAccess(this.connStr);
                flag=t_access.ExecuteDelRecord(wherecondition);
    this.Log("删除");
    
   }
   catch
   {
               
   }
   if (flag > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
  }

转载于:https://www.cnblogs.com/woshare/p/4304963.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值