📄 copyunit.aspx.cs
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace OI.SendMessage
{
/// <summary>
/// CopyUnit 的摘要说明。
/// </summary>
public class CopyUnit : System.Web.UI.Page
{
protected System.Web.UI.WebControls.ImageButton ImageButton1;
protected System.Web.UI.WebControls.Button ButtonAdd;
protected System.Web.UI.WebControls.Button ButtonSub;
protected System.Web.UI.WebControls.ListBox ListBoxUnit;
protected OI.UserControls .Department DepartmentGet;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if (Session["userid"]==null)
{
Response.Write ("<script>alert('超时,请重新登录');top.location.href='../userpass.aspx';</script>");
return ;
}
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.ButtonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
this.ButtonSub.Click += new System.EventHandler(this.ButtonSub_Click);
this.ImageButton1.Click += new System.Web.UI.ImageClickEventHandler(this.ImageButton1_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void ImageButton1_Click(object sender, System.Web.UI.ImageClickEventArgs e)
{
bool isHave=false;
string strValue="";
for(int i=0;i<ListBoxUnit.Items .Count ;i++)
{
if(i==0)
{
isHave=true;
strValue=ListBoxUnit.Items [i].Value ;
}
else
{
strValue+=","+ListBoxUnit.Items [i].Value ;
}
}
if(!isHave)
{
Page.RegisterStartupScript ("","<script>alert('列表框中没有部门')</script>");
return;
}
string javascript="<script>opener.Form1.TextBoxCopyRecord.value=\""+ strValue +"\";window.close();</script>";
Page.RegisterStartupScript ("",javascript);
}
private void ButtonAdd_Click(object sender, System.EventArgs e)
{
ListItem li=new ListItem (DepartmentGet.DEPT_NAME);
if(ListBoxUnit.Items .FindByValue (li.Value )==null&&(li.Value !=null||li.Value !=""))
ListBoxUnit.Items .Add (li);
ListBoxUnit.SelectedIndex =-1;
}
private void ButtonSub_Click(object sender, System.EventArgs e)
{
int nCount=0;
foreach(ListItem li in ListBoxUnit.Items )
{
if(li.Selected )
{
nCount++ ;
}
}
string[] strText=new string [nCount];
nCount=0;
foreach(ListItem li in ListBoxUnit.Items )
{
if(li.Selected )
{
strText[nCount++]=li.Text ;
}
}
for(int i=0;i<nCount;i++)
{
ListBoxUnit.Items .Remove (ListBoxUnit.Items .FindByText (strText[i]));
}
ListBoxUnit.SelectedIndex =-1;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -