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.
D7QUANTAI/DSWeb/Attributes/AttributeCompanyEdit.aspx.cs

237 lines
9.5 KiB
C#

10 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 AttributeCompanyEdit : System.Web.UI.Page
{
private string strHandle;
private string strCheckCompanyID;
private string strUserID;
private string strCompanyAttributeID;
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["checkcompid"] != null)
{
strCheckCompanyID = Request.QueryString["checkcompid"].ToString().Trim();
this.h_compid.Value = strCheckCompanyID;
}
if (Request.QueryString["id"] != null)
{
strCompanyAttributeID = Request.QueryString["id"].ToString().Trim();
this.h_compattrid.Value = strCompanyAttributeID;
}
if (!IsPostBack)
{
if (strCheckCompanyID != null)
{
GetCheckCompanyInfo(strCheckCompanyID);
}
}
}
private void GetCheckCompanyInfo(string tempCheckCompanyID)
{
CompanyEntity companyEntity = new CompanyEntity();
CompanyDA companyDA = new CompanyDA();
companyEntity = companyDA.GetCompanyByID(tempCheckCompanyID);
if (companyEntity != null)
{
if (companyEntity.GID != null)
{
this.txt_company.Value = companyEntity.NAME;
if (strCompanyAttributeID != null)
{
AttributeCompanyDA attributeCompanyDA = new AttributeCompanyDA();
AttributeCompanyEntity attributeCompanyEntity = new AttributeCompanyEntity();
attributeCompanyEntity = attributeCompanyDA.GetCompanyAttributeByID(strCompanyAttributeID);
if (attributeCompanyEntity != null)
{
if (attributeCompanyEntity.GID != null)
{
this.h_attrval.Value = attributeCompanyEntity.AttributeValue;
this.txt_createtime.InnerHtml = attributeCompanyEntity.CreateTime.ToString("yyyy-MM-dd hh:mm:ss");
UserDA userDA = new UserDA();
UserEntity userEntity = new UserEntity();
userEntity = userDA.GetUserSignByID(attributeCompanyEntity.CreateUser);
if(userEntity != null)
{
if(userEntity.Gid != null)
{
this.txt_createuser.InnerHtml = userEntity.ShowName;
}
}
AttributeDA attributeDA = new AttributeDA();
AttributeEntity attributeEntity = new AttributeEntity();
attributeEntity = attributeDA.GetAttributeByID(attributeCompanyEntity.AttributeID);
if(attributeEntity != null)
{
if(attributeEntity.GID != null)
{
h_attrid.Value = attributeEntity.GID;
h_attrname.Value = attributeEntity.Description;
h_typeid.Value = attributeEntity.TypeID;
AttributeTypeDA attributeTypeDA = new AttributeTypeDA();
AttributeTypeEntity attributeTypeEntity = new AttributeTypeEntity();
attributeTypeEntity = attributeTypeDA.GetAttributeTypeByID(attributeEntity.TypeID);
if(attributeTypeEntity != null)
{
if(attributeTypeEntity.GID != null)
{
h_type.Value = attributeTypeEntity.Name;
}
}
}
}
}
}
}
}
}
}
protected void btn_enter_Click(object sender, EventArgs e)
{
int iResult = 0;
AttributeCompanyDA attributeCompanyDA = new AttributeCompanyDA();
AttributeCompanyEntity attributeCompanyEntity = new AttributeCompanyEntity();
string tempAttributeType = "";
tempAttributeType = this.h_type.Value.Trim();
string tempValaaa = this.txt_attrval.InnerHtml;
string tempVal = "";
switch(tempAttributeType)
{
case "bool":
if (Request.Form["ck_true"] != null)
{
if (Request.Form["ck_true"].ToString().Trim().ToLower().Equals("on"))
{
tempVal = "true";
}
else
{
tempVal = "false";
}
}
else if (Request.Form["ck_false"] != null)
{
if (Request.Form["ck_false"].ToString().Trim().ToLower().Equals("on"))
{
tempVal = "false";
}
else
{
tempVal = "true";
}
}
break;
case "string":
if (Request.Form["txt_val"] != null)
{
tempVal = Request.Form["txt_val"].ToString().Trim();
}
break;
default:
break;
}
if (h_compattrid.Value.Trim().Equals(""))
{
attributeCompanyEntity.GID = Guid.NewGuid().ToString();
attributeCompanyEntity.AttributeID = this.h_attrid.Value.Trim();
attributeCompanyEntity.CompanyID = this.h_compid.Value.Trim();
attributeCompanyEntity.AttributeValue = tempVal;
attributeCompanyEntity.CreateUser = strUserID;
if (!attributeCompanyDA.IsSameAttribute(attributeCompanyEntity.GID, attributeCompanyEntity.AttributeID, attributeCompanyEntity.CompanyID))
{
iResult = attributeCompanyDA.InsertCompanyAttribute(attributeCompanyEntity);
if (iResult == 1)
{
this.h_attrval.Value = tempVal;
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>alert('保存成功');</script>");
}
else
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>alert('保存失败');</script>");
}
}
else
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>alert('保存失败 已经指定了此参数,不能重复添加');</script>");
}
}
else
{
attributeCompanyEntity = attributeCompanyDA.GetCompanyAttributeByID(h_compattrid.Value.Trim());
if (attributeCompanyEntity != null)
{
if (attributeCompanyEntity.GID != null)
{
attributeCompanyEntity.AttributeID = this.h_attrid.Value.Trim();
attributeCompanyEntity.CompanyID = this.h_compid.Value.Trim();
attributeCompanyEntity.AttributeValue = tempVal;
attributeCompanyEntity.ModifiedUser = strUserID;
iResult = attributeCompanyDA.UpdateCompanyAttribute(attributeCompanyEntity);
if (iResult == 1)
{
this.h_attrval.Value = tempVal;
Page.ClientScript.RegisterStartupScript(this.GetType(), "key2", "<script>alert('保存成功');</script>");
}
else
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "key2", "<script>alert('保存失败');</script>");
}
}
}
}
}
}
}