📄 workview.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 WorkGroupManager.work
{
/// <summary>
/// WorkView 的摘要说明。
/// </summary>
public class WorkView : WorkGroupManager.WebFormBase
{
protected System.Web.UI.WebControls.DataGrid DataGrid1;
protected System.Web.UI.WebControls.Label Label2;
protected System.Web.UI.WebControls.Label Label3;
protected System.Web.UI.WebControls.LinkButton LinkButton1;
protected System.Web.UI.WebControls.Label Label4;
private string[] OrderType=new string[2]{"0","填写时间"};
protected Work.WorkService ws=new Work.WorkService();
protected System.Web.UI.WebControls.Panel p1;
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.Panel pE;
protected System.Web.UI.WebControls.Panel pP;
protected Work.work work=new Work.work();
protected System.Web.UI.WebControls.Label lbtask;
protected System.Web.UI.WebControls.DropDownList ddlType;
private string[] pks;
private void Page_Load(object sender, System.EventArgs e)
{
this.VerifyPage();
pks=this.GetCurrentPks(this,false);
this.Pagesecurity();
ViewState["pk1"]=pks[0];
ViewState["pk2"]=pks[1];
ViewState["pk3"]=pks[2];
// 在此处放置用户代码以初始化页面
if(!Page.IsPostBack)
{
//处理DataGrid控件(绑定DataGrid控件 -> 检查是否需要定位 -> 给导航文本赋值)
if(HandleDataGrid(this, ViewState["sql"].ToString(), DataGrid1, "Data1", Label2, Label3, Label4,OrderType) == false)
this.Response.Redirect("../Error.aspx?errmsg=在处理数据时发生错误。");
this.ModScan(Session["user"].ToString().Trim(),pks[1].Trim(),pks[2].Trim());
}
else
{
//检查回发的请求操作是否是要进入上页或下页
if(PageNavigate(this, DataGrid1, "Data1", Label2, Label3, Label4) == false)
this.Response.Redirect("../Error.aspx?errmsg=在处理数据时发生错误。");
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.ddlType.SelectedIndexChanged += new System.EventHandler(this.ddlType_SelectedIndexChanged);
this.LinkButton1.Click += new System.EventHandler(this.LinkButton1_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void LinkButton1_Click(object sender, System.EventArgs e)
{
try
{
string[] pk = {"Hidden1","Hidden2","Hidden3"};
string[] DataTypes = {"string","string","DateTime"};
object[] obj=this.GetPk("CheckBox1",DataTypes,pk,this.DataGrid1);
this.work.tNO=obj[0].ToString();
this.work.tExecutor=obj[1].ToString();
this.work.exDate=DateTime.Parse(obj[2].ToString());
if(this.ws.DeleteWork(this.work))
{
BindDataGrid(this,ViewState["sql"].ToString(),this.DataGrid1,"Data1",true,OrderType);
//对页面导航文本进行重新赋值
PageNavigatorText(DataGrid1,Label2, Label3, Label4);
}
}
catch(Exception ex)
{
this.BaseService.Write("工作记录删除");
this.BaseService.Write(ex.Message);
}
}
private void Pagesecurity()
{
string sql=string.Format("任务编号='{0}' and 执行人='{1}'",pks[0],pks[1]);
switch(Session["station"].ToString().Trim())
{
//执行人
case "0":
sql=string.Format("{0} and 执行人是否浏览<>'1'",sql);
this.pP.Visible=false;
break;
//发布人
case "1":
sql=string.Format("{0} and 发布人是否浏览<>'1'",sql);
this.pE.Visible=false;
break;
//管理员
case "2":
this.p1.Visible=false;
break;
}
ViewState["sql"]=this.ws.selectSql(sql);
}
private void ModScan(string user,string Executor,string Promulgator)
{
string sql=string.Empty;
if(user==Executor)
{
sql=string.Format("UPDATE 工作记录表 SET 执行人是否浏览 = '1' WHERE (执行人 = '{0}') and (执行人是否浏览 = '0')",user.Trim());
}
else if(user==Promulgator)
{
sql=string.Format("UPDATE 工作记录表 SET 发布人是否浏览 = '1' WHERE (发布人 = '{0}') and (发布人是否浏览 = '0')",user.Trim());
}
this.BaseService.CreateDataSetFromSql(sql);
}
private void ddlType_SelectedIndexChanged(object sender, System.EventArgs e)
{
string sql=string.Format("任务编号='{0}' and 执行人='{1}'",pks[0],pks[1]);
try
{
//执行人
if(Session["station"].ToString().Trim()=="0")
{
switch(this.ddlType.SelectedItem.Value.ToString().Trim())
{
//未浏览
case "0":
sql=string.Format("{0} and (执行人是否浏览='0')",sql,Session["user"].ToString().Trim());
break;
//已浏览
case "1":
sql=string.Format("{0} and (执行人是否浏览='1')",sql,Session["user"].ToString().Trim());
break;
}
}
//发布人
else if(Session["station"].ToString().Trim()=="1")
{
switch(this.ddlType.SelectedItem.Value.ToString().Trim())
{
//未浏览
case "0":
sql=string.Format("{0} and (发布人是否浏览='0')",sql,Session["user"].ToString().Trim());
break;
//已浏览
case "1":
sql=string.Format("{0} and (发布人是否浏览='1')",sql,Session["user"].ToString().Trim());
break;
}
}
ViewState["sql"]=this.ws.selectSql(sql);
//处理DataGrid控件(绑定DataGrid控件 -> 检查是否需要定位 -> 给导航文本赋值)
if(HandleDataGrid(this, ViewState["sql"].ToString(), DataGrid1, "Data", Label2, Label3, Label4,OrderType) == false)
this.Response.Redirect("../Error.aspx?errmsg=在处理数据时发生错误。");
}
catch(Exception e1)
{
this.BaseService.Write ("浏览状态选择时产生异常。");
this.BaseService.Write (e1.Message);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -