Files
17168ERP/web/admin/project/news_reg.aspx.cs
2025-08-29 01:27:25 +08:00

145 lines
4.1 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_project_new_reg : MyWeb.config
{
private Model.ezEntities _db = new Model.ezEntities();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (isStrNull(Request["num"]))
{
}
else
{
int _num = Val(Request["num"]);
var qry = _db.projects.AsEnumerable();
var prod = qry.Where(q => q.num == _num).FirstOrDefault();
if (prod != null)
{
subject.Text = prod.subject;
if (prod.kind.HasValue)
{
kind_txt.Value = prod.project_kind.kind.ToString();
kind.Value = prod.kind.ToString();
}
if (prod.actItem_num.HasValue)
{
actItem_num_txt.Value = prod.actItem.subject.ToString();
actItem_num.Value = prod.actItem_num.ToString();
}
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.project project = new Model.project();
project.subject = subject.Text;
if (!isStrNull(kind.Value)) { project.kind = Val(kind.Value); }
if (!isStrNull(actItem_num.Value)) { project.actItem_num = Val(actItem_num.Value); }
project.demo = demo.Text;
project.reg_time = DateTime.Now;
try
{
_db.projects.Add(project);
_db.SaveChanges();
Model.admin_log admin_log = new Model.admin_log();
admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Project, (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.project project = _db.projects.Where(q => q.num == _num).FirstOrDefault();
if (project != null)
{
project.subject = subject.Text;
if (!isStrNull(kind.Value)) { project.kind = Val(kind.Value); }
if (!isStrNull(actItem_num.Value)) { project.actItem_num = Val(actItem_num.Value); }
project.demo = demo.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.Project, (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 = ex.InnerException.Message;
L_msg.Text = "操作失敗";
}
}
}
#endregion
}