145 lines
4.2 KiB
C#
145 lines
4.2 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.OleDb;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using System.Configuration;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Globalization;
|
|
|
|
public partial class admin_files_reg : MyWeb.config
|
|
{
|
|
private Model.ezEntities _db = new Model.ezEntities();
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
|
|
if (isStrNull(Request["num"]))
|
|
{
|
|
reg_time.Text = DateTime.Now.ToString("yyyy-MM-dd");
|
|
}
|
|
else
|
|
{
|
|
int _num = Val(Request["num"]);
|
|
var qry = _db.files.AsEnumerable();
|
|
var prod = qry.Where(q => q.num == _num).FirstOrDefault();
|
|
if (prod != null)
|
|
{
|
|
subject.Text = prod.subject;
|
|
reg_time.Text = prod.reg_time.Value.ToString("yyyy-MM-dd");
|
|
modify_time.Text = "";
|
|
if (prod.modify_time.HasValue)
|
|
{
|
|
modify_time.Text = prod.modify_time.Value.ToString("yyyy/MM/dd");
|
|
}
|
|
paperset.Text = prod.paperset;
|
|
word.Text = prod.word;
|
|
customize_data.Text = prod.customize_data;
|
|
|
|
modifyPanel.Visible = true;
|
|
edit.Visible = true;
|
|
goback.Visible = true;
|
|
add.Visible = false;
|
|
}
|
|
else
|
|
{
|
|
Response.Redirect("index.aspx");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
protected void goback_Click(object sender, EventArgs e)
|
|
{
|
|
Response.Redirect("index.aspx?page=" + Convert.ToString(Request["page"]));
|
|
}
|
|
|
|
|
|
|
|
#region 資料新增
|
|
|
|
protected void add_Click(object sender, EventArgs e)
|
|
{
|
|
if (Page.IsValid) {
|
|
L_msg.Text = "";
|
|
|
|
Model.file files = new Model.file();
|
|
files.subject= subject.Text.Trim();
|
|
files.reg_time= ValDate (reg_time.Text);
|
|
files.modify_time = DateTime.Now;
|
|
files.paperset = paperset.Text;
|
|
files.word = word.Text;
|
|
files.customize_data = customize_data.Text;
|
|
|
|
|
|
try
|
|
{
|
|
_db.files.Add(files);
|
|
_db.SaveChanges();
|
|
|
|
Model.admin_log admin_log = new Model.admin_log();
|
|
admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Files, (int)Model.admin_log.Status.Insert, subject.Text);
|
|
|
|
Response.Redirect("index.aspx");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//L_msg.Text = ex.Message;
|
|
L_msg.Type = alert_type.danger;
|
|
L_msg.Text = "操作失敗";
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 資料修改
|
|
|
|
protected void edit_Click(object sender, EventArgs e)
|
|
{
|
|
if (Page.IsValid)
|
|
{
|
|
L_msg.Text = "";
|
|
|
|
int _num = Val(Request["num"]);
|
|
Model.file files = _db.files.Where(q => q.num == _num).FirstOrDefault();
|
|
if (files != null)
|
|
{
|
|
files.subject = subject.Text.Trim();
|
|
files.reg_time = ValDate(reg_time.Text);
|
|
files.modify_time = DateTime.Now;
|
|
files.paperset = paperset.Text;
|
|
files.word = word.Text;
|
|
files.customize_data = customize_data.Text;
|
|
|
|
}
|
|
|
|
try
|
|
{
|
|
_db.SaveChanges();
|
|
Model.admin_log admin_log = new Model.admin_log();
|
|
admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Files, (int)Model.admin_log.Status.Update, subject.Text);
|
|
|
|
Response.Redirect("index.aspx?page=" + Convert.ToString(Request["page"]));
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
L_msg.Type = alert_type.danger;
|
|
L_msg.Text = "操作失敗";
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
} |