You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

161 lines
6.0 KiB
C#

12 months ago
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using DSWeb.Models;
using DSWeb.EntityDA;
namespace DSWeb.Attributes
{
public partial class TypeEdit : System.Web.UI.Page
{
private string strHandle;
private string strAttributeTypeID;
private string strUserID;
protected void Page_Load(object sender, EventArgs e)
{
if (Session["USERID"] != null)
{
strUserID = Session["USERID"].ToString();
}
if (Request.QueryString["handle"] != null)
{
strHandle = Request.QueryString["handle"].ToString().Trim().ToLower();
}
if (Request.QueryString["id"] != null)
{
strAttributeTypeID = Request.QueryString["id"].ToString();
this.h_typeid.Value = strAttributeTypeID;
}
if (strAttributeTypeID != null)
{
AttributeTypeEntity attributeTypeEntity = new AttributeTypeEntity();
AttributeTypeDA attributeTypeDA = new AttributeTypeDA();
attributeTypeEntity = attributeTypeDA.GetAttributeTypeByID(strAttributeTypeID);
if (attributeTypeEntity != null)
{
if (attributeTypeEntity.GID != null)
{
this.txt_name.Value = attributeTypeEntity.Name;
this.txt_description.Value = attributeTypeEntity.Description;
this.txt_sort.Value = attributeTypeEntity.Sort.ToString();
UserEntity userEntity = new UserDA().GetUserSignByID(attributeTypeEntity.CreateUser);
if (userEntity != null)
{
if (userEntity.Gid != null)
{
this.txt_createuser.InnerHtml = userEntity.ShowName;
}
}
this.txt_createtime.InnerHtml = attributeTypeEntity.CreateTime.ToString("yyyy-MM-dd HH:mm:ss");
}
}
}
}
protected void btn_enter_Click(object sender, EventArgs e)
{
int iResult = 0;
string tempName = "";
if (!Request.Form["txt_name"].ToString().Trim().Equals(""))
{
tempName = Request.Form["txt_name"].ToString().Trim();
}
else
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>alert('参数类型不能为空');</script>");
}
string tempDescription = "";
if (!Request.Form["txt_description"].ToString().Trim().Equals(""))
{
tempDescription = Request.Form["txt_description"].ToString().Trim();
}
else
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "key2", "<script>alert('参数类型描述信息不能为空');</script>");
}
int tempSort = 0;
if (!Request.Form["txt_sort"].ToString().Trim().Equals(""))
{
tempSort = int.Parse(Request.Form["txt_sort"].ToString().Trim());
}
else
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "key2", "<script>alert('参数类型排序值不能为空');</script>");
}
if (h_typeid.Value.Trim() != "")
{
string tempAttributeTypeID = h_typeid.Value.Trim();
AttributeTypeEntity attributeTypeEntity = new AttributeTypeEntity();
AttributeTypeDA attributeTypeDA = new AttributeTypeDA();
attributeTypeEntity = attributeTypeDA.GetAttributeTypeByID(tempAttributeTypeID);
if (attributeTypeEntity != null)
{
if (attributeTypeEntity.GID != null)
{
attributeTypeEntity.Name = tempName;
attributeTypeEntity.Description = tempDescription;
attributeTypeEntity.Sort = tempSort;
attributeTypeEntity.ModifiedUser = strUserID;
iResult = attributeTypeDA.UpdateAttributeType(attributeTypeEntity);
if (iResult == 1)
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "key3", "<script>alert('保存成功');</script>");
}
else
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "key4", "<script>alert('保存失败');</script>");
}
}
}
}
else
{
AttributeTypeEntity attributeTypeEntity = new AttributeTypeEntity();
AttributeTypeDA attributeTypeDA = new AttributeTypeDA();
attributeTypeEntity.GID = Guid.NewGuid().ToString();
attributeTypeEntity.Name = tempName;
attributeTypeEntity.Description = tempDescription;
attributeTypeEntity.Sort = tempSort;
attributeTypeEntity.CreateUser = strUserID;
iResult = attributeTypeDA.InsertAttributeType(attributeTypeEntity);
if (iResult == 1)
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "key5", "<script>alert('保存成功');</script>");
}
else
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "key6", "<script>alert('保存失败');</script>");
}
}
}
}
}