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", ""); } string tempDescription = ""; if (!Request.Form["txt_description"].ToString().Trim().Equals("")) { tempDescription = Request.Form["txt_description"].ToString().Trim(); } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "key2", ""); } 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", ""); } 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", ""); } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "key4", ""); } } } } 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", ""); } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "key6", ""); } } } } }