用户控件/委托/事件

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ButtonList_ZXTZ.ascx.cs" Inherits="ButtonList_ZXTZ" %>
   
<link href="stylecss/gridStyle.css" rel="Stylesheet" type="text/css" />
    
<link href="stylecss/style.css" rel="Stylesheet" type="text/css" />
    
<link href="stylecss/input.css" rel="Stylesheet" type="text/css" />
    
<link href="stylecss/TreeStyle.css" rel="Stylesheet" type="text/css" />
    
<link href="stylecss/mystyle.css" rel="Stylesheet" type="text/css" /> 
    
<link href="stylecss/style1.css" rel="Stylesheet" type="text/css" />
 
<table cellpadding="0" cellspacing="0" style="padding:1px;">
    
<tr>
        
<td style="height: 30px;">
                
<asp:imagebutton id="Button4" runat="server" border="0" borderstyle="None" height="21px"
                    imageurl
="Images/toolbar_save.gif" onmouseout="this.src='Images/toolbar_save.gif'"
                    onmouseover
="this.src='Images/toolbar_save_mo.gif'" tooltip="保存" width="61px"
                     CommandName
="save" OnCommand="Button4_Command">
                
</asp:imagebutton>
        
</td>
        
<td></td>
        
<td>
                
<asp:ImageButton ID="ImageButton4" runat="server" Height="21px" ImageUrl="Images/toolbar_print.gif"
                    Width
="61px" onmouseover="this.src='Images/toolbar_print_mo.gif'" 
                    onmouseout
="this.src='Images/toolbar_print.gif'" ToolTip="打印" CommandName="print"
                    OnCommand
="Button4_Command"/>
        
</td>
        
<td></td>
        
<td>
                
<asp:ImageButton ID="ImageButton1" runat="server" Height="21px" ImageUrl="images/toolbar_print_zxtz.gif" 
                onmouseover
="this.src='Images/toolbar_print_zxtz_mo.gif'" onmouseout="this.src='Images/toolbar_print_zxtz.gif'" 
                ToolTip
="打印" CommandName="printPCTZ" OnCommand="Button4_Command"/>
        
</td>
        
<td>
        
</td>
        
<td>
                
<asp:ImageButton ID="ImageButton6" runat="server" Height="21px" ImageUrl="Images/toolbar_close.gif"
                    Width
="61px" BorderStyle="None" onmouseover="this.src='Images/toolbar_close_mo.gif'" 
                    onmouseout
="this.src='Images/toolbar_close.gif'" ToolTip="关闭" CommandName="close" 
                    OnCommand
="Button4_Command" CausesValidation="False" />
         
</td>      
      
</tr>
 
</table>
ascx.cs:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class ButtonList_ZXTZ : System.Web.UI.UserControl
{
    
//public delegate void ButtonClickedEventHandler(object sender, EventArgs e);
   
    
public delegate void ButtonPrintClickedEventHandler(object sender, EventArgs e);
    
public delegate void ButtonPrintPCTZClickedEventHandler(object sender, EventArgs e);//add by roy 2007/09/07
    public delegate void ButtonClosedClikcedEventHandler(object sender, EventArgs e);

    
public delegate void ButtonSaveClickedEventHandler(object sender, EventArgs e);
    
public event         ButtonSaveClickedEventHandler SaveClicked;

    
public event ButtonPrintClickedEventHandler PrintClicked;
    
public event ButtonPrintPCTZClickedEventHandler PrintPCTZClicked;

    
//public delegate void some_delegateEventHandler(object sender, EventArgs e);
    //public event some_delegateEventHandler some_event;
    protected void Page_Load(object sender, EventArgs e)
    
{

    }

    
protected void Button4_Command(object sender, CommandEventArgs e)
    
{
        EventArgs ev 
= new EventArgs();
        
switch (e.CommandName.ToString())
        
{
            
case "save":
                
if (null != ev)
                
{
                    SaveClicked(
this, ev);
                }

                
break;
            
case "print":
                
if (null != ev)
                
{
                    PrintClicked(
this, ev);
                }

                
break;
            
case "printPCTZ":
                
if (null != ev)
                
{
                    PrintPCTZClicked(
this, ev);
                }

                
break;
            
case "close":
                Response.Write(
"<script>window.close();</script>");
                
break;
            
default:
                
break;
        }

    }

    
public void SetButton()
    
{
        
this.ImageButton4.Visible = false;
    }

    
public void SetName(string name)
    
{
        
this.Button4.ToolTip = name;
    }

}

aspx:
<uc1:ButtonList_ZXTZ id="ButtonList1" OnPrintClicked="Print_Click"  Onsome_event="some_method" OnSaveClicked="Save_Click" OnPrintPCTZClicked="PrintPCTZ_Click" runat="server">
                       
</uc1:ButtonList_ZXTZ>
aspx.cs:
protected void Save_Click(object sender, EventArgs e)
    
{
        
this.SetItem();
        
if (string.IsNullOrEmpty(this.Hidden2.Value.Trim()))
        
{
            jctz.Add_JCTZ(temp);
        }

        
else
        
{
            jctz.Update_JCTZ(temp);
        }

        
this.LoadJob(this.Hidden1.Value);       
    }
    protected void Print_Click(object sender, EventArgs e)
    
{
        
this.SetItem();
        
if (string.IsNullOrEmpty(this.Hidden2.Value.Trim()))
        
{
            jctz.Add_JCTZ(temp);
        }

        
else
        
{
            jctz.Update_JCTZ(temp);
        }

        
this.LoadJob(this.Hidden1.Value);
        
if (!this.IsClientScriptBlockRegistered("clientScript"))
        
{
           

            String scriptString = @"<script language=JavaScript>window.showModalDialog('print_storageinform.aspx?type=0&parentid=" + this.Hidden1.Value.Trim().ToString() + "',window,'status:Modeless;edge:raised;unadorned:no;scroll=yes;resizable:yes;center=yes;help:no;dialogWidth:100;DialogHeight:100;');</script>";
            
this.RegisterClientScriptBlock("clientScript", scriptString);
        }

        pubfunc.insert_log(
"打印进仓通知", Request.QueryString["id"].ToString());//记录日志
    }

posted on 2007-11-14 12:52  simhare  阅读(264)  评论(0)    收藏  举报

导航