289 lines
13 KiB
C#
289 lines
13 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using SuperMap.RealEstate.ServiceModel;
|
|
using SuperMap.RealEstate.Utility;
|
|
using SuperMap.RealEstate.Web.UI;
|
|
using SuperMap.RealEstate.Web.UI.WebControls;
|
|
using SuperMap.RealEstate.Web.Utility;
|
|
using SuperMap.RealEstate.CoreFrameWork.Dictionary.Business;
|
|
|
|
namespace SuperMap.RealEstate.ExchangeData.Modules.MachineInfo
|
|
{
|
|
public partial class FIELDENUMPage : SuperMap.RealEstate.Web.UI.PageValid
|
|
{
|
|
#region 方法 -> 页面加载
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
//类型下拉框改变时列表,按钮状态也改变
|
|
if (IsPostBack)
|
|
{
|
|
if (!String.IsNullOrEmpty(Request["ID"]))
|
|
{
|
|
if (FIELDENUM1.State())
|
|
{
|
|
AddButton.Enabled = true;
|
|
for (int i = 0; i < GridViewEx1.Rows.Count; i++)
|
|
{
|
|
GridViewEx1.HeaderRow.Cells[2].Visible = true;
|
|
GridViewEx1.Rows[i].Cells[2].Visible = true;
|
|
GridViewEx1.HeaderRow.Cells[1].Visible = true;
|
|
GridViewEx1.Rows[i].Cells[1].Visible = true;
|
|
GridViewEx1.Enabled = true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
AddButton.Enabled = false;
|
|
for (int i = 0; i < GridViewEx1.Rows.Count; i++)
|
|
{
|
|
GridViewEx1.HeaderRow.Cells[2].Visible = false;
|
|
GridViewEx1.Rows[i].Cells[2].Visible = false;
|
|
GridViewEx1.HeaderRow.Cells[1].Visible = false;
|
|
GridViewEx1.Rows[i].Cells[1].Visible = false;
|
|
GridViewEx1.Enabled = false;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
GridViewEx1.Enabled = false;
|
|
AddButton.Enabled = false;
|
|
}
|
|
LableLoad();
|
|
return;
|
|
}
|
|
//载入数据
|
|
ButtonDelete.Enabled = FIELDENUM1.LoadData();
|
|
//GridViewEx1.SelectingWithInit<Business.FIELDENUM>(ObjectDataSource1, GridPageEx1);
|
|
if (!String.IsNullOrEmpty(Request["ID"]))
|
|
{
|
|
string sql = "SELECT FIELDENUM_CONTROLTYPE FROM HIGHWAY_EXCHANGE.T_FIELDENUM WHERE FIELDENUM_ID = " +
|
|
Request["ID"].ToDecrypt() + "";
|
|
Business.FIELDENUM _FIELDENUM = new Business.FIELDENUM(this.Transaction);
|
|
DataTable dt = _FIELDENUM.ExecuteDataTable(sql);
|
|
if (dt.Rows[0]["FIELDENUM_CONTROLTYPE"].ToString() == "1")
|
|
{
|
|
GridViewEx1.Enabled = false;
|
|
AddButton.Enabled = false;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
AddButton.Enabled = false;
|
|
}
|
|
//列表加载
|
|
GridViewLoad();
|
|
SetControlConfirm(ButtonDelete, "您确认删除该记录,删除后将无法恢复数据?");
|
|
SetControlClientAction(ButtonSave);
|
|
//GridViewEx1.SetOpenControl(AddButton);
|
|
//注册遮罩式窗口关闭脚本
|
|
SetControlClosePopDialog(ButtonClose);
|
|
LableLoad();
|
|
}
|
|
#endregion
|
|
|
|
#region 方法 -> 保存数据
|
|
protected void ButtonSave_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
string _FIELDENUM_ID = "";
|
|
//判断是新增还是修改
|
|
if (String.IsNullOrEmpty(Request["ID"]))
|
|
{
|
|
Business.FIELDENUM _FIELDENUM = new Business.FIELDENUM(Transaction);
|
|
string sqls = "SELECT FIELDENUM_ID FROM HIGHWAY_EXCHANGE.V_FIELDENUM WHERE FIELDENUM_PID = " +
|
|
Request["FIELDENUM_PID"].ToDecrypt();
|
|
DataTable dt = _FIELDENUM.ExecuteDataTable(sqls);
|
|
//判断未获取到传入的值时的修改
|
|
if (dt.Rows[0][0].ToString() == "")
|
|
{
|
|
FieldEnum fieldEnum = new FieldEnum(Transaction);
|
|
fieldEnum.FieldEnum_ID_Encrypt = Request["FIELDENUM_PID"];
|
|
if (fieldEnum.Select())
|
|
{
|
|
_FIELDENUM.FIELDENUM_PID = fieldEnum.FieldEnum_ID;
|
|
_FIELDENUM.FIELDENUM_MUST = short.Parse(FIELDENUM1.GetMust());
|
|
_FIELDENUM.FIELDENUM_CONTROLTYPE = short.Parse(FIELDENUM1.GetControltype());
|
|
_FIELDENUM.FIELDENUM_BATCH = short.Parse(FIELDENUM1.GetBatch());
|
|
_FIELDENUM.FIELDENUM_INITIALVALUE = FIELDENUM1.GetInitialvalue();
|
|
_FIELDENUM.FIELDENUM_INDEX = fieldEnum.FieldEnum_Index;
|
|
_FIELDENUM.STAFF_ID = PassportInfo.ID;
|
|
_FIELDENUM.STAFF_NAME = PassportInfo.Name;
|
|
_FIELDENUM.OPERATE_DATE = DateTime.Now;
|
|
_FIELDENUM.FIELDENUM_STATUS = fieldEnum.FieldEnum_Status.ToInt16();
|
|
_FIELDENUM.Insert();
|
|
|
|
_FIELDENUM_ID = _FIELDENUM.FIELDENUM_ID_Encrypt;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
_FIELDENUM_ID = dt.Rows[0][0].ToEncrypt();
|
|
|
|
string sql = "UPDATE HIGHWAY_EXCHANGE.T_FIELDENUM SET FIELDENUM_MUST = " + FIELDENUM1.GetMust() +
|
|
",FIELDENUM_CONTROLTYPE = " + FIELDENUM1.GetControltype() + ",FIELDENUM_INITIALVALUE = '" +
|
|
FIELDENUM1.GetInitialvalue() + "',FIELDENUM_BATCH = " + FIELDENUM1.GetBatch() +
|
|
"WHERE FIELDENUM_ID = " + dt.Rows[0][0].ToString();
|
|
_FIELDENUM.ExecuteNonQuery(sql, null);
|
|
}
|
|
bool _RefreshType = ButtonDelete.Enabled;
|
|
RefreshOpenerGridPage(_RefreshType ? RefreshGridPageType.Update : RefreshGridPageType.Insert);
|
|
}
|
|
else
|
|
{
|
|
_FIELDENUM_ID = Request["ID"];
|
|
//调用方法获取默认值
|
|
FIELDENUM1.GetValue(this.PassportInfo.ID.ToString(), this.PassportInfo.Name, DateTime.Now.ToString());
|
|
//刷新类型
|
|
bool _RefreshType = ButtonDelete.Enabled;
|
|
//保存数据
|
|
ButtonDelete.Enabled = FIELDENUM1.Save();
|
|
//刷新弹出页列表
|
|
RefreshOpenerGridPage(_RefreshType ? RefreshGridPageType.Update : RefreshGridPageType.Insert);
|
|
}
|
|
//提示信息
|
|
Alert("保存成功!", 3);
|
|
//刷新当前页并传入值
|
|
ExecClientScript("$('#pop-dialog-frame-GridViewEx1Page',parent.parent.document).attr('src', " +
|
|
"'/ExchangeData/Modules/MachineInfo/FIELDENUMPage.aspx?ID=" + _FIELDENUM_ID + "&type=" + Request["type"] +
|
|
"&FIELDENUM_PID=" + Request["FIELDENUM_PID"] + "&FIELDENUM_NAME=" + Request["FIELDENUM_NAME"] +
|
|
"&PopDialogPageName=F_R_GridPageEx1&PopDialogName=GridViewEx1Page&r=0.7778587905853764')");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//回滚事务
|
|
Transaction.Rollback();
|
|
//记录日志
|
|
ErrorLogHelper.Write(ex);
|
|
#if DEBUG
|
|
Alert("保存失败!可能的原因:\n" + ex.Message);
|
|
#else
|
|
Alert("保存失败!");
|
|
#endif
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 方法 -> 列表加载
|
|
private void GridViewLoad()
|
|
{
|
|
//GridView加载数据
|
|
Business.FIELDENUM _FIELDENUM = new Business.FIELDENUM(this.Transaction);
|
|
if (!String.IsNullOrEmpty(Request["ID"]))
|
|
{
|
|
string sql = @"SELECT FIELDENUM_ID,FIELDENUM_INITIALVALUE,FIELDENUM_INDEX,FIELDENUM_DESC
|
|
FROM HIGHWAY_EXCHANGE.T_FIELDENUM WHERE FIELDENUM_PID = " + Request["ID"].ToDecrypt() + "";
|
|
DataTable dt = _FIELDENUM.ExecuteDataTable(sql);
|
|
dt.DefaultView.Sort = "FIELDENUM_INDEX,FIELDENUM_ID";
|
|
GridViewEx1.DataSource = dt.DefaultView.ToTable();
|
|
GridViewEx1.DataBind();
|
|
}
|
|
else
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 方法 -> GridView行绑定
|
|
protected void GridViewEx1_RowDataBound(object sender, GridViewRowEventArgs e)
|
|
{
|
|
if (e.Row.RowType == DataControlRowType.DataRow)
|
|
{
|
|
//删除按钮绑定参数
|
|
LinkButton LinkButtonDelete = (LinkButton)e.Row.Cells[1].FindControl("Delete");
|
|
LinkButtonDelete.CommandArgument = e.Row.RowIndex.ToString();
|
|
SetControlConfirm(LinkButtonDelete, "您确认删除该记录,删除后将无法恢复数据?");
|
|
//修改按钮绑定单机弹窗事件
|
|
LinkButton LinkButtonUpdate = (LinkButton)e.Row.FindControl("Update");
|
|
string FIELDENUM_ID = GridViewEx1.DataKeys[e.Row.RowIndex].Value.ToEncrypt();
|
|
LinkButtonUpdate.OnClientClick = GridViewEx1.GetOpenPopDialogClientScript(
|
|
"../MachineInfo/FIELDENUMOperation.aspx?PID=" + Request["ID"] + "&ID=" + FIELDENUM_ID +
|
|
"&FIELDENUM_PID=" + Request["FIELDENUM_PID"] + "&FIELDENUM_NAME=" + Request["FIELDENUM_NAME"], 500, 300);
|
|
//判断按钮显示与否
|
|
if (!GridViewEx1.Enabled)
|
|
{
|
|
e.Row.Cells[1].Visible = false;
|
|
e.Row.Cells[2].Visible = false;
|
|
}
|
|
}
|
|
else if (e.Row.RowType == DataControlRowType.Header)
|
|
{
|
|
//判断按钮标题显示与否
|
|
if (!GridViewEx1.Enabled)
|
|
{
|
|
e.Row.Cells[1].Visible = false;
|
|
e.Row.Cells[2].Visible = false;
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 方法 -> 删除
|
|
protected void Delete_Command(object sender, CommandEventArgs e)
|
|
{
|
|
//获取传入的值,绑定删除事件
|
|
int i = int.Parse(e.CommandArgument.ToString());
|
|
string FIELDENUM_ID = GridViewEx1.DataKeys[i].Value.ToString();
|
|
string sql = "DELETE FROM HIGHWAY_EXCHANGE.T_FIELDENUM WHERE FIELDENUM_ID = " + FIELDENUM_ID + "";
|
|
Business.FIELDENUM _FIELDENUM = new Business.FIELDENUM(this.Transaction);
|
|
_FIELDENUM.ExecuteNonQuery(sql, null);
|
|
Alert("删除成功!", 3);
|
|
GridViewLoad();
|
|
}
|
|
#endregion
|
|
|
|
#region 方法 -> 添加
|
|
protected void AddButton_CallBackClick(object sender, ClientSetEventArgs e)
|
|
{
|
|
//添加下拉选项
|
|
e.ClientScript = this.GetOpenPopDialogClientScript("FIELDENUMOperation.aspx?ID=&PID=" + Request["ID"] +
|
|
"&FIELDENUM_PID=" + Request["FIELDENUM_PID"] + "&FIELDENUM_NAME=" + Request["FIELDENUM_NAME"],
|
|
"FIELDENUMOperation", 500, 300, true, false, true);
|
|
}
|
|
#endregion
|
|
|
|
#region 方法 -> 加载时获取标题
|
|
public void LableLoad()
|
|
{
|
|
//标题绑定
|
|
Title.Text = Request["FIELDENUM_NAME"].ToDecrypt();
|
|
}
|
|
#endregion
|
|
|
|
#region 方法 -> 删除
|
|
protected void ButtonDelete_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
//删除数据
|
|
ButtonDelete.Enabled = !FIELDENUM1.Delete();
|
|
//刷新弹出页列表
|
|
RefreshOpenerGridPage(RefreshGridPageType.Delete);
|
|
//提示信息
|
|
Alert("删除成功!", 3);
|
|
ClosePopDialog();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//回滚事务
|
|
Transaction.Rollback();
|
|
//记录日志
|
|
ErrorLogHelper.Write(ex);
|
|
#if DEBUG
|
|
Alert("删除失败!可能的原因:\n" + ex.Message);
|
|
#else
|
|
Alert("删除失败!");
|
|
#endif
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
} |