2026821
This commit is contained in:
@@ -0,0 +1,309 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Configuration;
|
||||
using System.Collections;
|
||||
using System.Web;
|
||||
using System.Web.Security;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Web.UI.WebControls.WebParts;
|
||||
using System.Web.UI.HtmlControls;
|
||||
using GThinking.N_MODEL.Page;
|
||||
using GThinking.N_MISPRO.Utility;
|
||||
using GThinking.N_MISPRO;
|
||||
using GThinking.N_PUBLIC;
|
||||
using GThinking.N_MISPRO.Data;
|
||||
|
||||
namespace GThinking.N_XLJC
|
||||
{
|
||||
public partial class XLBZLXInfo : SingleCardBase
|
||||
{
|
||||
XLBZLX entity = new XLBZLX();
|
||||
|
||||
#region Page事件
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
this.UMID = 101421003;
|
||||
this.UMName = "线缆标准类型";
|
||||
this.CurMaster = Master;
|
||||
this.CurEntity = entity;
|
||||
this.PageHeight = 400;
|
||||
this.PageWidth = 500;
|
||||
|
||||
base.InitPage();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 模板事件继承
|
||||
|
||||
protected override void LoadRecord()
|
||||
{
|
||||
if (!IsPostBack)
|
||||
{
|
||||
entity.Param.Add("XLBZ_XLBZID", PageParam.GetRTrimString("XLBZ_XLBZID").Trim());
|
||||
}
|
||||
else
|
||||
{
|
||||
entity.Param.Add("XLBZ_XLBZID", txtOld_XLBZID.Value.Trim());
|
||||
}
|
||||
|
||||
base.LoadRecord();
|
||||
txtOld_XLBZID.Value = txtXLBZID.Text.Trim();
|
||||
}
|
||||
|
||||
protected override void SetControlState()
|
||||
{
|
||||
base.SetControlState();
|
||||
|
||||
string sXLBZID = txtXLBZID.Text.Trim();
|
||||
string sSQL = "";
|
||||
bool bAction_XLBZID = true;
|
||||
bool bAction_XLDZSC = true;
|
||||
if (ControlState == TControlState.ctsInsert || ControlState == TControlState.ctsCopy || ControlState == TControlState.ctsEdit)
|
||||
{
|
||||
if (!sXLBZID.Equals(""))
|
||||
{
|
||||
sSQL = string.Format("select TOP 1 XLDZBZ_XLBZID from XLDZBZ where 1=1 ");
|
||||
if (CMISproDataBase.ExistsRecord("DBERP", sSQL))
|
||||
{
|
||||
bAction_XLDZSC = false;
|
||||
sSQL = string.Format("select TOP 1 XLDZBZ_XLBZID from XLDZBZ where 1=1 and XLDZBZ_XLBZID like '{0}%' ", sXLBZID);
|
||||
if (CMISproDataBase.ExistsRecord("DBERP", sSQL))
|
||||
{
|
||||
bAction_XLBZID = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (CMISproDataBase.ExistsRecord("DBERP", string.Format("select XLXLB_XLBZID from XLXLB where XLXLB_XLBZID ='{0}' "
|
||||
+ " union all select XLLXB_XLBZID from XLLXB where XLLXB_XLBZID ='{0}' "
|
||||
+ " union all select XLXZB_XLBZID from XLXZB where XLXZB_XLBZID ='{0}' "
|
||||
+ " union all select XLXXB_XLBZID from XLXXB where XLXXB_XLBZID ='{0}' "
|
||||
+ " union all select XLDTB_XLBZID from XLDTB where XLDTB_XLBZID ='{0}' "
|
||||
+ " union all select XLZXBZ_XLBZID from XLZXBZ where XLZXBZ_XLBZID ='{0}'"
|
||||
+ " union all select top 1 XLXSCLQD_XLBZID from XLXSCLQD where XLXSCLQD_XLBZID ='{0}' ", sXLBZID.Trim())))
|
||||
{
|
||||
bAction_XLBZID = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bAction_XLBZID = true;
|
||||
sSQL = string.Format("select TOP 1 XLDZBZ_XLBZID from XLDZBZ where 1=1 ");
|
||||
if (CMISproDataBase.ExistsRecord("DBERP", sSQL))
|
||||
{
|
||||
bAction_XLDZSC = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bAction_XLBZID = false;
|
||||
bAction_XLDZSC = false;
|
||||
}
|
||||
txtXLBZID.Enabled = bAction_XLBZID;
|
||||
chkDZSC.Enabled = bAction_XLDZSC;
|
||||
|
||||
txtWHR.Enabled = false;
|
||||
datWHSJ.Enabled = false;
|
||||
}
|
||||
|
||||
protected override void OnNewRecorder()
|
||||
{
|
||||
base.OnNewRecorder();
|
||||
txtWHR.Text = tSession.UserName;
|
||||
txtWHRID.Value = tSession.UserId;
|
||||
datWHSJ.Value = CMISproConvert.ConvertTime(DateTime.Now);
|
||||
chkDZSC.Checked = false;
|
||||
|
||||
txtOld_XLBZID.Value = "";
|
||||
|
||||
}
|
||||
|
||||
protected override void OnCopyRecorder()
|
||||
{
|
||||
base.OnCopyRecorder();
|
||||
txtWHR.Text = tSession.UserName;
|
||||
txtWHRID.Value = tSession.UserId;
|
||||
datWHSJ.Value = CMISproConvert.ConvertTime(DateTime.Now);
|
||||
txtXLBZID.Text = "";
|
||||
txtOld_XLBZID.Value = "";
|
||||
chkDZSC.Checked = false;
|
||||
}
|
||||
|
||||
protected override bool Master_BeforeSaveAction(object sender, EventArgs e)
|
||||
{
|
||||
string sOLDXLBZID = txtOld_XLBZID.Value.Trim();
|
||||
string sXLBZID = txtXLBZID.Text.Trim();
|
||||
string sXLBZLXMC = txtXLBZMC.Text.Trim();
|
||||
string sSQL = "";
|
||||
if (ControlState == TControlState.ctsInsert || ControlState == TControlState.ctsCopy)
|
||||
{
|
||||
if (chkDZSC.Checked)
|
||||
{
|
||||
sSQL = string.Format("select TOP 1 XLBZ_XLBZID from XLBZ where 1=1 and XLBZ_DZSC = 'Y' and len(XLBZ_XLBZID) <10 ");
|
||||
if (CMISproDataBase.ExistsRecord("DBERP", sSQL))
|
||||
{
|
||||
ShowMessage("已有定制生产标准,不允许保存!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
sSQL = string.Format("select TOP 1 XLBZ_XLBZID from XLBZ where 1=1 and XLBZ_XLBZID = '{0}' ", sXLBZID);
|
||||
if (CMISproDataBase.ExistsRecord("DBERP", sSQL))
|
||||
{
|
||||
ShowMessage("已存在编号相同的记录,不允许保存!");
|
||||
return false;
|
||||
}
|
||||
sSQL = string.Format("select TOP 1 XLBZ_XLBZLXMC from XLBZ where 1=1 and XLBZ_XLBZLXMC = '{0}' ", sXLBZLXMC);
|
||||
if (CMISproDataBase.ExistsRecord("DBERP", sSQL))
|
||||
{
|
||||
ShowMessage("已存在标准类型名称相同的记录,不允许保存!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (sXLBZID.Equals(sOLDXLBZID))
|
||||
{
|
||||
if (chkDZSC.Checked)
|
||||
{
|
||||
sSQL = string.Format("select TOP 1 XLBZ_XLBZID from XLBZ where 1=1 and XLBZ_DZSC = 'Y' and len(XLBZ_XLBZID) <10 and XLBZ_XLBZID <> '{0}' ", sXLBZID);
|
||||
if (CMISproDataBase.ExistsRecord("DBERP", sSQL))
|
||||
{
|
||||
ShowMessage("已有定制生产标准,不允许保存!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
sSQL = string.Format("select TOP 1 XLBZ_XLBZLXMC from XLBZ where 1=1 and XLBZ_XLBZLXMC = '{0}' and XLBZ_XLBZID <> '{1}' ", sXLBZLXMC, sXLBZID);
|
||||
if (CMISproDataBase.ExistsRecord("DBERP", sSQL))
|
||||
{
|
||||
ShowMessage("已存在标准类型名称相同的记录,不允许保存!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//先校验编号是否重复
|
||||
sSQL = string.Format("select TOP 1 XLBZ_XLBZID from XLBZ where 1=1 and XLBZ_XLBZID = '{0}' ", sXLBZID);
|
||||
if (CMISproDataBase.ExistsRecord("DBERP", sSQL))
|
||||
{
|
||||
ShowMessage("已存在编号相同的记录,不允许保存!");
|
||||
return false;
|
||||
}
|
||||
sSQL = string.Format("select TOP 1 XLBZ_XLBZLXMC from XLBZ where 1=1 and XLBZ_XLBZLXMC = '{0}' and XLBZ_XLBZID <> '{1}' ", sXLBZLXMC, sOLDXLBZID);
|
||||
if (CMISproDataBase.ExistsRecord("DBERP", sSQL))
|
||||
{
|
||||
ShowMessage("已存在标准类型名称相同的记录,不允许保存!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (chkDZSC.Checked)
|
||||
{
|
||||
sSQL = string.Format("select TOP 1 XLBZ_XLBZID from XLBZ where 1=1 and XLBZ_DZSC = 'Y' and len(XLBZ_XLBZID) <10 and XLBZ_XLBZID <> '{0}' ", sOLDXLBZID);
|
||||
if (CMISproDataBase.ExistsRecord("DBERP", sSQL))
|
||||
{
|
||||
ShowMessage("已有定制生产标准,不允许保存!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return base.Master_BeforeSaveAction(sender, e);
|
||||
}
|
||||
|
||||
protected override bool Master_AfterSaveAction(object sender, EventArgs e)
|
||||
{
|
||||
if (!base.Master_AfterSaveAction(sender, e))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
txtOld_XLBZID.Value = txtXLBZID.Text.Trim();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override bool Master_BeforeDeleteAction(object sender, EventArgs e)
|
||||
{
|
||||
string sXLBZID = txtXLBZID.Text.Trim();
|
||||
if (!sXLBZID.Equals("") && CMISproDataBase.ExistsRecord("DBERP", string.Format("select XLXLB_XLBZID from XLXLB where XLXLB_XLBZID ='{0}' "
|
||||
+ " union all select XLLXB_XLBZID from XLLXB where XLLXB_XLBZID ='{0}' "
|
||||
+ " union all select XLXZB_XLBZID from XLXZB where XLXZB_XLBZID ='{0}' "
|
||||
+ " union all select XLXXB_XLBZID from XLXXB where XLXXB_XLBZID ='{0}' "
|
||||
+ " union all select XLDTB_XLBZID from XLDTB where XLDTB_XLBZID ='{0}' "
|
||||
+ " union all select XLZXBZ_XLBZID from XLZXBZ where XLZXBZ_XLBZID ='{0}'"
|
||||
+ " union all select top 1 XLXSCLQD_XLBZID from XLXSCLQD where XLXSCLQD_XLBZID ='{0}' ", sXLBZID.Trim())))
|
||||
{
|
||||
ShowMessage("该标准类型已被使用,不允许删除!");
|
||||
return false;
|
||||
}
|
||||
|
||||
string sSQL = string.Format("select TOP 1 XLDZBZ_XLBZID from XLDZBZ where 1=1 and XLDZBZ_XLBZID like '{0}%' ", sXLBZID);
|
||||
if (CMISproDataBase.ExistsRecord("DBERP", sSQL))
|
||||
{
|
||||
|
||||
ShowMessage("该标准类型存在线缆定制标准,不允许删除!");
|
||||
return false;
|
||||
}
|
||||
|
||||
return base.Master_BeforeDeleteAction(sender, e);
|
||||
}
|
||||
|
||||
protected override void AfterSave(TDatabase db, ref bool ActionIsDone)
|
||||
{
|
||||
TSQL SQL = new TSQL(db);
|
||||
SQL.Clear();
|
||||
SQL.Add(" merge into XLBZ a ");
|
||||
SQL.Add(" using ");
|
||||
SQL.Add("( ");
|
||||
SQL.Add("select ");
|
||||
SQL.Add(" XLBZ_XLBZID, ");
|
||||
SQL.Add(" row_number() ");
|
||||
SQL.Add(" over(order by XLBZ_PX,XLBZ_XLBZID) as XH ");
|
||||
SQL.Add(" from XLBZ");
|
||||
SQL.Add(" where 1=1 and len(XLBZ_XLBZID) < 10 ");
|
||||
SQL.Add(" ) b ");
|
||||
SQL.Add(" on( ");
|
||||
SQL.Add(" a.XLBZ_XLBZID=b.XLBZ_XLBZID and len(a.XLBZ_XLBZID) < 10 ");
|
||||
SQL.Add(" ) ");
|
||||
SQL.Add(" when matched then update set a.XLBZ_PX=b.XH ");
|
||||
db.ExecSQL(SQL);
|
||||
|
||||
SQL.Clear();
|
||||
SQL.Add("select XLBZ_PX from XLBZ where XLBZ_XLBZID=:pXLBZID");
|
||||
SQL.ParamByName("pXLBZID").Value = txtXLBZID.Text.Trim();
|
||||
DataSet ds = db.OpenDataSet(SQL);
|
||||
if (ds.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
txtPX.Value = CMISproConvert.StrToFloat(ds.Tables[0].Rows[0]["XLBZ_PX"].ToString());
|
||||
}
|
||||
|
||||
base.AfterSave(db, ref ActionIsDone);
|
||||
}
|
||||
|
||||
protected override void SetComboxItems()
|
||||
{
|
||||
base.SetComboxItems();
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region 控件事件
|
||||
|
||||
#endregion
|
||||
|
||||
#region 自定义函数
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user