📄 filesend.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>
/// SendGuide 的摘要说明。
/// </summary>
public class FileSend : System.Web.UI.Page
{
protected System.Web.UI.WebControls.ListBox ListBoxDep;
protected System.Web.UI.WebControls.LinkButton LinkBtSel;
protected OI.UserControls .Department SelectedDep;
protected System.Web.UI.WebControls.LinkButton LinkBtNext;
protected System.Web.UI.WebControls.ListBox ListBoxMainDep;
protected System.Web.UI.WebControls.ListBox ListBoxSubDep;
protected System.Web.UI.WebControls.Button BtAddAll;
protected System.Web.UI.WebControls.Button BtRemoveAll;
protected System.Web.UI.WebControls.Button BtSubAdd;
protected System.Web.UI.WebControls.Button BtSubRemove;
private OI.DatabaseOper.DatabaseConnect oConn = new OI.DatabaseOper.DatabaseConnect();
protected int nDocumentID;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if(Session["userid"]==null)
{
Response.Write ("<script>window.location.href='../userpass.aspx'</script>");
return;
}
if(!Page.IsPostBack )
{
try
{
nDocumentID = int.Parse(Request.QueryString ["DocumentID"].ToString ());
ViewState["DocumentID"] = nDocumentID.ToString ();
}
catch
{
Response.Redirect ("SendFile.aspx");
}
}
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.LinkBtSel.Click += new System.EventHandler(this.LinkBtSel_Click);
this.BtAddAll.Click += new System.EventHandler(this.BtAddAll_Click);
this.BtRemoveAll.Click += new System.EventHandler(this.BtRemoveAll_Click);
this.BtSubAdd.Click += new System.EventHandler(this.BtSubAdd_Click);
this.BtSubRemove.Click += new System.EventHandler(this.BtSubRemove_Click);
this.LinkBtNext.Click += new System.EventHandler(this.LinkBtNext_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void BindDeps(int depID)
{
string sql="select departmentid,DepartmentName from departments where departmentid="+depID+" OR ParentDepartmentID="+depID;
DataSet ds=new DataSet ();
ds=oConn.getBinding (sql,"Temp");
ListBoxDep.Items .Clear ();
if (ds.Tables[0].Rows .Count >0)
{
ListBoxDep.DataSource =ds.Tables[0].DefaultView ;
ListBoxDep.DataTextField =ds.Tables[0].Columns ["DepartmentName"].ToString ();
ListBoxDep.DataValueField =ds.Tables[0].Columns ["departmentid"].ToString ();
ListBoxDep.DataBind ();
}
}
private void LinkBtSel_Click(object sender, System.EventArgs e)
{
int nDepID=SelectedDep.DEPT_ID ;
BindDeps(nDepID);
}
private void BtAddAll_Click(object sender, System.EventArgs e)
{
if (ListBoxDep.SelectedIndex <0)
{
Page.RegisterStartupScript ("","<script>alert('请选择部门')</script>");
return ;
}
ListBoxMainDep.SelectedIndex =-1;
foreach(ListItem li in ListBoxDep.Items )
{
if (li.Selected && (ListBoxMainDep.Items .FindByValue (li.Value )==null))
{
ListBoxMainDep.Items .Add (li);
}
}
ListBoxDep.SelectedIndex =-1;
ListBoxMainDep.SelectedIndex =-1;
}
private void BtRemoveAll_Click(object sender, System.EventArgs e)
{
if (ListBoxMainDep.SelectedIndex < 0)
{
Page.RegisterStartupScript("","<script>alert('请选择部门');</script>");
return;
}
ListBoxDep.SelectedIndex = -1;
foreach(ListItem li in ListBoxMainDep.Items)
{
if(li.Selected)
{
ListBoxMainDep.Items.Remove(li);
}
}
ListBoxMainDep.SelectedIndex = -1;
ListBoxDep.SelectedIndex = -1;
}
private void LinkBtNext_Click(object sender, System.EventArgs e)
{
if (ListBoxMainDep.Items .Count < 1)
{
Page.RegisterStartupScript ("","<script>alert('请选择主送部门!');</script>");
return;
}
string szSql;
string mSubDep = "";
string mMainDep = "";
string mDepartment;
szSql = "select DepartmentID from Accounts_Users where UserID=" + Session["userid"].ToString();
mDepartment = oConn.GetValueBySql(szSql);
//设置主送单位字段值,单位之间用逗号隔开
szSql = "select * from Document where DocumentID=" + ViewState["DocumentID"].ToString();
ArrayList alist = oConn.getData(szSql);
if ((alist[7].ToString().Trim() != null) && ( alist[7].ToString().Trim() != ""))
mMainDep = ",";
foreach (ListItem li in ListBoxMainDep.Items )
{
mMainDep += li.Value + "," ;
}
mMainDep.Substring(0,mMainDep.Length-1);//去结尾逗号
//设置抄送单位字段值,单位之间用逗号隔开
if ((alist[8].ToString().Trim() != null) && ( alist[8].ToString().Trim() != ""))
mSubDep = ",";
foreach (ListItem li in ListBoxMainDep.Items )
{
mSubDep += li.Value + "," ;
}
mSubDep.Substring(0,mSubDep.Length-1);
szSql = "update Document (MainSendComp,CopySendComp,SendDepartment)values('" + mMainDep + "','" + mSubDep + "','" + mDepartment + "')"
+ " where DocumentID=" + ViewState["DocumentID"].ToString();
oConn.ExecuteSQL(szSql);
Page.RegisterStartupScript ("","<script>alert('文件传送成功');window.location.href='Checked.aspx';</script>");
}
private void BtSubAdd_Click(object sender, System.EventArgs e)
{
if (ListBoxDep.SelectedIndex <0)
{
Page.RegisterStartupScript ("","<script>alert('请选择部门')</script>");
return ;
}
ListBoxSubDep.SelectedIndex =-1;
foreach(ListItem li in ListBoxDep.Items )
{
if (li.Selected && (ListBoxSubDep.Items .FindByValue (li.Value )==null))
{
ListBoxSubDep.Items .Add (li);
}
}
ListBoxDep.SelectedIndex =-1;
ListBoxSubDep.SelectedIndex =-1;
}
private void BtSubRemove_Click(object sender, System.EventArgs e)
{
if (ListBoxSubDep.SelectedIndex < 0)
{
Page.RegisterStartupScript("","<script>alert('请选择部门');</script>");
return;
}
ListBoxDep.SelectedIndex = -1;
foreach(ListItem li in ListBoxSubDep.Items)
{
if(li.Selected)
{
ListBoxSubDep.Items.Remove(li);
}
}
ListBoxSubDep.SelectedIndex = -1;
ListBoxDep.SelectedIndex = -1;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -