📄 tj_save.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 counter
{
/// <summary>
/// tj_save 的摘要说明。
/// </summary>
public class tj_save : System.Web.UI.Page
{
public static DataView dv;
public string strwherename="";
public string strcontent="";
public string strwherestr="";
public string strouttype="";
public string stroverwrite="";
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
DataSet myds = new DataSet();
myds = counter.SQLConn.ExecuteSqlForDataSet("select * from CounterInfo");
dv=myds.Tables[0].DefaultView;
if(Session["master"]==null) Session["master"]="";
if(Session["whatcan"]==null) Session["whatcan"]=dv[0].Row["whatcan"].ToString();
if(Session["master"].ToString() != "master" && int.Parse(Session["whatcan"].ToString()) < 6) Response.Redirect("help.aspx?id=004&error=您没有管理自定义统计检索条件库的权限。");
//获取数据
if(Request.Form["wherename"]!=null) strwherename=Request.Form["wherename"].ToString().Trim();
if(Request.Form["content"]!=null) strcontent=Request.Form["content"].ToString().Trim();
if(Request.Form["wherestr"]!=null) strwherestr=Request.Form["wherestr"].ToString().Trim();
if(Request.Form["outtype"]!=null) strouttype=Request.Form["outtype"].ToString().Trim();
if(Request.Form["overwrite"]!=null) stroverwrite=Request.Form["overwrite"].ToString();
//过滤单引号
strwherename=strwherename.Replace("'","");
strwherename=strwherename.Replace("\"","");
strcontent=strcontent.Replace("'","");
strcontent=strcontent.Replace("\"","");
//检查数据
if(strwherename=="") Response.Redirect("help.aspx?id=002&error=请为要存储的检索条件取个名字。");
if(strouttype=="") Response.Redirect("help.aspx?id=002&error=没有指明要输出的内容,请确认是在检索结果页点保存进入本页的。");
}
public string save_search()
{
string strsave_msg="";
string theSql="select * from mysave where name='" + strwherename + "'";
DataSet myds1=new DataSet();
DataView dv1=new DataView();
myds1=counter.SQLConn.ExecuteSqlForDataSet(theSql);
dv1=myds1.Tables[0].DefaultView;
dv1.Table.AcceptChanges();
if((dv1.Count>0) && stroverwrite=="0")
{
strsave_msg="<table width='500' cellspacing='0' align='center' cellpadding='0' border='0'><tr><td colspan='3'><img src='images/photoup.gif'></td></tr><form action='tj_save.aspx' method=post id=form1 name=form1><tr height='30'>";
strsave_msg+="<td width='1' class='backs'><img src='images/touming.gif' width='1' height='1'></td><td width='498'class='backq'> <img src='images/tb_save.gif' align=absmiddle><font style='font-size:16px'> </font>∷∷∷ 保存检索条件 ∷∷∷<br>";
strsave_msg+="<p class='p1'><img src='images/tb_error.gif' align=absmiddle><font style='font-size:15px'> </font><font color=red>注意!!</font><p class='p1'>数据库中已经存在一条名为“"+strwherename+"”的检索条件记录:<p class='p1' style='margin-bottom: 0;'><font class='fonts'>检索条件</font> ";
if(dv1[0].Row["wherestr"].ToString()=="")
{
strsave_msg+="没有检索条件";
}
else
{
strsave_msg+=dv1[0].Row["wherestr"].ToString();
}
strsave_msg+="<p class='p1' style='margin-top: 0;margin-bottom: 0;'><font class='fonts'>查询项目</font> "+dv1[0].Row["outtype"]+"。";
strsave_msg+="<p class='p1' style='margin-top: 0;'><font class='fonts'>说 明</font> "+dv1[0].Row["content"];
strsave_msg+="<p class='p1'>您将要保存的检索条件为:<p class='p1' style='margin-bottom: 0;'><font class='fonts'>检索条件</font> ";
if(strwherestr=="")
{
strsave_msg+="没有检索条件";
}
else
{
strsave_msg+=strwherestr;
}
strsave_msg+="<p class='p1' style='margin-top: 0;margin-bottom: 0;'><font class='fonts'>查询项目</font> "+strouttype+"。";
strsave_msg+="<p class='p1' style='margin-top: 0;'><font class='fonts'>说 明</font> "+strcontent;
strsave_msg+="p class='p1'>请选择您的处理办法——<p class='p1'><INPUT type='radio' name='overwrite' value='0' checked> 将保存的名字改为 <input name='wherename' size='25' class='input' value=\""+strwherename+"\">";
strsave_msg+="<p class='p1' style='margin-top: 0;'><INPUT type='radio' name='overwrite' value='1'> 覆盖原来的条件,以这次提交的为准<p class='p1' style='margin-top: 0;' align='right'><a href='help.aspx?id=002'>帮助</a><a href='javascript:history.back()'>取消</a> ";
strsave_msg+="<a href='javascript:form1.submit();'>保存</a>";
strsave_msg+="<input name='content' size='50' type='hidden' value=\""+strcontent+"\"><input type='hidden' name='wherestr' value=\""+strwherestr+"\"><input type='hidden' name='outtype' value=\""+strouttype+"\"><input type='submit' value=' ' name='save' class='backc2'><font style='font-size:16px'> </font> </td>";
strsave_msg+="<td width='1' class='backs'><img src='images/touming.gif' width='1' height='1'></td></tr></form><tr><td colspan='4'><img src='images/photodown.gif'></td></tr></table><br>";
}
else
{
strwherestr=strwherestr.Replace("'","''");
if((dv1.Count>0) && stroverwrite=="1")
{
theSql="update mysave set ";
theSql+="wherestr=N'"+strwherestr+"',";
theSql+="content=N'"+strcontent+"',";
theSql+="outtype=N'"+strouttype+"'";
theSql+=" where name='"+strwherename+"'";
counter.SQLConn.ExecuteSql(theSql);
}
else
{
theSql="insert into mysave values(N'";
theSql+=strwherename+"',N'";
theSql+=strcontent+"',N'";
theSql+=strwherestr+"',N'";
theSql+=strouttype+"')";
counter.SQLConn.ExecuteSql(theSql);
}
strsave_msg="<table width='500' cellspacing='0' align='center' cellpadding='0' border='0'><tr><td colspan='3'><img src='images/photoup.gif'></td></tr><form action='tj_save.aspx' method=post id=form1 name=form1><tr height='30'>";
strsave_msg+="<td width='1' class='backs'><img src='images/touming.gif' width='1' height='1'></td><td width='498'class='backq'> <img src='images/tb_save.gif' align=absmiddle><font style='font-size:16px'> </font>∷∷∷ 保存检索条件成功 ∷∷∷<br>";
strsave_msg+="<p class='p1'><font color=red>恭喜!!</font><p class='p1'>已经成功的保存了这次检索的条件:<p class='p1'><font class='fonts'>条件名称</font> "+strwherename+"<p class='p1' style='margin-top: 0;'><font class='fonts'>检索条件</font> ";
if(strwherestr=="")
{
strsave_msg+="没有检索条件";
}
else
{
strsave_msg+=strwherestr;
}
strsave_msg+="<p class='p1' style='margin-top: 0;margin-bottom: 0;'><font class='fonts'>查询项目</font> "+strouttype+"。";
strsave_msg+="<p class='p1' style='margin-top: 0;'><font class='fonts'>说 明</font> "+strcontent;
strsave_msg+="<p class='p1' align='right'><a href='tj_search.aspx'>继续</a> <a href='tj_search.aspx'><img src='images/arbutton.gif' align='absmiddle' border='0'></a> <font style='font-size:16px'> </font> </td>";
strsave_msg+="<td width='1' class='backs'><img src='images/touming.gif' width='1' height='1'></td></tr></form><tr><td colspan='4'><img src='images/photodown.gif'></td></tr></table><br>";
}
dv1.Dispose();
return strsave_msg;
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -