- using System;
- using System.Data;
- using System.Configuration;
- using System.Collections.Generic;
- using System.Web;
- using System.Web.Security;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.WebControls.WebParts;
- using System.Web.UI.HtmlControls;
- public partial class FileBooks_UpFilesAdd : System.Web.UI.Page
- {
- //模板
- Model.Files MR = new Model.Files();
- //业务
- BLL.Files BR = new BLL.Files();
- protected void Page_Load(object sender, EventArgs e)
- {
- LoginLogic.MatchLoad("../", "FileBooks_UpFilesAdd");
- if (!IsPostBack)
- {
- DropLoadSet();
- }
- }
- public void DropLoadSet()
- {
- //密级
- KeyValue_MJ.DataTextField = "Text";
- KeyValue_MJ.DataValueField = "Value";
- KeyValue_MJ.DataSource = EnumGet.MiJiGetEnum();
- KeyValue_MJ.DataBind();
- KeyValue_MJ.SelectedIndex = KeyValue_MJ.Items.Count - 1;
- //紧急
- KeyValue_JJDJ.DataTextField = "Text";
- KeyValue_JJDJ.DataValueField = "Value";
- KeyValue_JJDJ.DataSource = EnumGet.JinJiGetEnum();
- KeyValue_JJDJ.DataBind();
- KeyValue_JJDJ.SelectedIndex = KeyValue_JJDJ.Items.Count - 1;
- //文件分类
- KeyValue_WJFL.DataTextField = "Text";
- KeyValue_WJFL.DataValueField = "Value";
- KeyValue_WJFL.DataSource = EnumGet.WenJianGetEnum();
- KeyValue_WJFL.DataBind();
- KeyValue_WJFL.SelectedIndex = KeyValue_WJFL.Items.Count - 1;
- //公文
- KeyValue_GWLB.DataTextField = "Text";
- KeyValue_GWLB.DataValueField = "Value";
- KeyValue_GWLB.DataSource = EnumGet.GongWenGetEnum();
- KeyValue_GWLB.DataBind();
- KeyValue_GWLB.SelectedIndex = KeyValue_GWLB.Items.Count - 1;
- //卷案
- KeyValue_SSJA.DataTextField = "ANMC";
- KeyValue_SSJA.DataValueField = "ID";
- KeyValue_SSJA.DataSource = EnumGet.RollGetEnum();
- KeyValue_SSJA.DataBind();
- KeyValue_SSJA.SelectedIndex = KeyValue_SSJA.Items.Count - 1;
- }
- /// <summary>
- /// 上传一个文件
- /// </summary>
- /// <returns></returns>
- public string UPdateFile()
- {
- if (!string.IsNullOrEmpty(this.KeyValue_FJPath.PostedFile.FileName))
- {
- string fulname = this.KeyValue_FJPath.PostedFile.FileName;
- string filename = fulname.Substring(fulname.LastIndexOf("\") + 1);
- string type = fulname.Substring(fulname.LastIndexOf(".") + 1);
- if (type == "aspx" || type == "asp" || type == "exe")
- {
- throw new Exception("不允许上传执行性文件");
- }
- string GuidStr = Guid.NewGuid().ToString() + "-" + filename;
- string FileUpdatePathFull = AppDomain.CurrentDomain.BaseDirectory + "FileBooks\UpLoadFiles\" + GuidStr;
- this.KeyValue_FJPath.PostedFile.SaveAs(FileUpdatePathFull);
- return GuidStr;
- }
- else
- {
- return "";
- }
- }
- protected void Button1_Click(object sender, EventArgs e)
- {
- try
- {
- if (KeyValue_WJH.Text == "")
- {
- throw new Exception("文件号不能为空!");
- }
- if (KeyValue_BJBT.Text == "")
- {
- throw new Exception("文件标题不能为空!");
- }
- DateTime QKeyValue_FWRQ = new DateTime();
- if (!DateTime.TryParse(KeyValue_FWRQ.Text, out QKeyValue_FWRQ))
- {
- throw new Exception("发文日期格式不正确!");
- }
- int QDYYS = 0;
- if (!int.TryParse(KeyValue_DYYS.Text, out QDYYS))
- {
- throw new Exception("打印页数不正确!");
- }
- int QWJYS = 0;
- if (!int.TryParse(KeyValue_WJYS.Text, out QWJYS))
- {
- throw new Exception("文件页数不正确!");
- }
- MR.WJH = KeyValue_WJH.Text;
- MR.BJBT = KeyValue_BJBT.Text;
- MR.FWDW = KeyValue_FWDW.Text;
- MR.MJ = KeyValue_MJ.SelectedValue;
- MR.WJFL = KeyValue_WJFL.SelectedValue;
- MR.WJYS = QWJYS;
- MR.BZ = KeyValue_BZ.Text;
- MR.FJPath = UPdateFile();
- MR.WJZTC = KeyValue_WJZTC.Text;
- MR.WJFBT = KeyValue_WJFBT.Text;
- MR.FWRQ = QKeyValue_FWRQ;
- MR.JJDJ = KeyValue_JJDJ.SelectedValue;
- MR.GWLB = KeyValue_GWLB.SelectedValue;
- MR.DYYS = QDYYS;
- MR.SSJA = KeyValue_SSJA.SelectedValue;
- MR.SCR = SessionInclude.SessionId;
- BR.Add(MR);
- MessageBox.Show("添加成功");
- KeyValue_WJH.Text = "";
- KeyValue_BJBT.Text = "";
- KeyValue_FWDW.Text = "";
- KeyValue_WJYS.Text = "";
- KeyValue_WJZTC.Text = "";
- KeyValue_WJFBT.Text = "";
- KeyValue_FWRQ.Text = "";
- KeyValue_DYYS.Text = "";
- }
- catch (Exception exp)
- {
- MessageBox.Show(exp.Message);
- }
- }
- }