SysFName.aspx.cs
上传用户:tiancihang
上传日期:2014-03-12
资源大小:21387k
文件大小:8k
源码类别:

.net编程

开发平台:

C#

  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Collections;
  5. using System.Web;
  6. using System.Web.Security;
  7. using System.Web.UI;
  8. using System.Web.UI.WebControls;
  9. using System.Web.UI.WebControls.WebParts;
  10. using System.Web.UI.HtmlControls;
  11. using com.etong.DAL.FC;
  12. using System.IO;
  13. using System.Net;
  14. public partial class SysManage_SysFName : System.Web.UI.Page
  15. {
  16.     //protected System.Web.UI.WebControls.TextBox FDirName;
  17.     protected void Page_Load(object sender, EventArgs e)
  18.     {
  19.         if (!IsPostBack)
  20.         {
  21.             EtongWord EWord = new EtongWord();
  22.             DataView dv = new DataView();
  23.             try
  24.             {
  25.                 dv = EWord.GetAllFName();
  26.                 GridView1.DataSource = dv;
  27.                 GridView1.DataBind();
  28.                 TB_Condition.Attributes.Add("onkeypress", "javascript:return EnterTextBox();");
  29.             }
  30.             catch (Exception ex)
  31.             {
  32.                 ClientScript.RegisterStartupScript(this.GetType(), "errMessage", "<script>alert('" + ex.Message.Replace("'", "").Replace("rn", "") + "');</script>");
  33.                 return;
  34.             }
  35.             
  36.         }
  37.     }
  38.     protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
  39.     {
  40.         int currentpageindex;
  41.         currentpageindex = Convert.ToInt32(e.NewPageIndex);
  42.         if (currentpageindex == -2)
  43.         {
  44.             TextBox txtNewPageIndex;
  45.             txtNewPageIndex = GridView1.BottomPagerRow.FindControl("LinkTextBoxNewPage") as TextBox;
  46.             if (txtNewPageIndex != null)
  47.             {
  48.                 try
  49.                 {
  50.                     currentpageindex = Convert.ToInt32(txtNewPageIndex.Text) - 1;
  51.                 }
  52.                 catch
  53.                 {
  54.                     currentpageindex = 0;
  55.                 }
  56.             }
  57.         }
  58.         currentpageindex = currentpageindex < 0 ? 0 : currentpageindex;
  59.         currentpageindex = currentpageindex >= GridView1.PageCount ? GridView1.PageCount - 1 : currentpageindex;
  60.         GridView1.PageIndex = currentpageindex;
  61.         EtongWord EWord = new EtongWord();
  62.         DataView dv = EWord.GetAllFName();
  63.         GridView1.DataSource = dv;
  64.         GridView1.DataBind();
  65.     }
  66.     protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
  67.     {
  68.         int iOpID = Convert.ToInt32(GridView1.DataKeys[e.NewEditIndex].Value);
  69.         string sURL = "SysFNameModify.aspx?strN=M&strOp=" + iOpID;
  70.         //Response.Redirect(sURL);
  71.         this.ClientScript.RegisterStartupScript(this.GetType(), "0", "<script> window.showModalDialog('" + sURL + "','系统文件修改','help:0;dialogWidth:600px;dialogHeight:400px,location=no,status=no;');</script>");
  72.     }
  73.     protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
  74.     {
  75.         try
  76.         {
  77.             int serialid = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Value.ToString());
  78.             EtongWord EWord = new EtongWord();
  79.             EWord.FID = serialid;
  80.             DataView dv = new DataView();
  81.             dv = EWord.GetRoleFNameByCondition();
  82.             if (dv.Table.Rows.Count > 0)
  83.             {
  84.                 ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:此文档其它业务角色正在使用,无法删除!');</script>");
  85.                 return;
  86.             }
  87.             EWord.Delete();
  88.             GridView1.DataSource = EWord.GetAllFName();
  89.             GridView1.DataBind();
  90.             ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:删除记录成功!');</script>");
  91.         }
  92.         catch (Exception ex)
  93.         {
  94.             ClientScript.RegisterStartupScript(this.GetType(), "errorMessage", "<script>alert('" + ex.Message.Replace("'", "").Replace("rn", "") + "');</script>");
  95.         }
  96.     }
  97.     protected void IB_Search_Click(object sender, ImageClickEventArgs e)
  98.     {
  99.         EtongWord EWord = new EtongWord();
  100.         if (DDL_Condition.SelectedValue == "1")
  101.         {
  102.             if (TB_Condition.Text == null || TB_Condition.Text.Trim() == "") ;
  103.             else
  104.             {
  105.                 try
  106.                 {
  107.                     EWord.FID = Convert.ToInt32(TB_Condition.Text);
  108.                 }
  109.                 catch
  110.                 {
  111.                     this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:编号查询指允许输入数据,请输入数字!');", true);
  112.                     return;
  113.                 }
  114.             }
  115.         }
  116.         else if (DDL_Condition.SelectedValue == "2")
  117.         {
  118.             EWord.FName = TB_Condition.Text.Trim();
  119.         }
  120.         else
  121.         {
  122.             this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:请输入系统查询条件!');", true);
  123.             return;
  124.         }
  125.         DataView dv = new DataView();
  126.         dv = EWord.GetFNameByCondition();
  127.         GridView1.DataSource = dv;
  128.         GridView1.DataBind();
  129.     }
  130.     protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
  131.     {
  132.         if (e.Row.RowType == DataControlRowType.DataRow)
  133.         {
  134.             int iRow;
  135.             iRow = e.Row.DataItemIndex;
  136.             iRow = iRow % 2;
  137.             if (iRow > 0)
  138.                 e.Row.Attributes.Add("OnMouseOut", "this.style.backgroundColor='#f0f0f0';");
  139.             else
  140.                 e.Row.Attributes.Add("OnMouseOut", "this.style.backgroundColor='White';");
  141.             e.Row.Attributes.Add("OnMouseOver", "this.style.backgroundColor='#E8F2FA';");
  142.         }
  143.     }
  144.     protected void IMG2_Click(object sender, ImageClickEventArgs e)
  145.     {
  146.         string[] al;
  147.         string FName = FDirName.Value;
  148.         if (FName.Trim() != "")
  149.         {
  150.             al = FName.Split('.');
  151.             if (al.Length == 2)
  152.             {
  153.                 string FExName = al[1].ToString();
  154.                 if (FExName != "doc" && FExName != "xls")
  155.                 {
  156.                     this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:系统只接受 “doc” 和 “xls”文档!');", true);
  157.                     return;
  158.                 }
  159.                 else
  160.                 {
  161.                     try
  162.                     {
  163.                         int starti = FName.Length - (FName.Split('\').GetValue(FName.Split('\').Length - 1)).ToString().Length;
  164.                         FName = FName.Substring(starti, FName.Length - starti);
  165.                         string FDir = Server.MapPath(Request.ServerVariables["PATH_INFO"]);
  166.                         al = FDir.Split('\');
  167.                         FDir = FDir.Substring(0, FDir.Length - al[al.Length - 1].Length - al[al.Length - 2].Length - 1);
  168.                         FDirName.PostedFile.SaveAs(FDir + "workflow\doc\" + FName);
  169.                         ClientScript.RegisterStartupScript(this.GetType(), "Message", "<script>alert('系统提示:“" + FName + "”模版上传成功!');</script>");
  170.                     }
  171.                     catch (Exception ex)
  172.                     {
  173.                         ClientScript.RegisterStartupScript(this.GetType(), "errMessage", "<script>alert('" + ex.Message.Replace("'", "").Replace("rn", "") + "');</script>");
  174.                     }
  175.                 }
  176.             }
  177.             else
  178.             {
  179.                 this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:输入的文件格式不正确!');", true);
  180.             }
  181.         }
  182.         else
  183.         {
  184.             this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:请选择要上传的模版文件!');", true);
  185.         }
  186.         //FDirName
  187.         //FDirName.
  188.     }
  189. }