301 lines
11 KiB
C#
301 lines
11 KiB
C#
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_MISPRO;
|
|
using GThinking.N_MODEL.Page;
|
|
using GThinking.N_MISPRO.Data;
|
|
using GThinking.N_MISPRO.Utility;
|
|
using GThinking.N_PUBLIC;
|
|
using System.Collections.Generic;
|
|
|
|
namespace GThinking.N_XLJC
|
|
{
|
|
public partial class XLYSInfo : SingleCardBase
|
|
{
|
|
XLYS entity = new XLYS();
|
|
|
|
#region Page类事件继承
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
this.UMID = 101421004;
|
|
this.UMName = "线缆颜色";
|
|
this.CurMaster = Master;
|
|
this.CurEntity = entity;
|
|
this.PageHeight = 400;
|
|
this.PageWidth = 500;
|
|
|
|
if (!this.IsPostBack)
|
|
{
|
|
InitControl();
|
|
}
|
|
|
|
base.InitPage();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 模板事件继承
|
|
|
|
protected override void SetControlState()
|
|
{
|
|
base.SetControlState();
|
|
if (ControlState == TControlState.ctsEdit)
|
|
{
|
|
if (!CanDelete(txtXLYSID.Text.ToString().Trim()))
|
|
txtXLYSID.Enabled = false;
|
|
}
|
|
txtWHR.Enabled = false;
|
|
datWHSJ.Enabled = false;
|
|
}
|
|
|
|
protected override void LoadRecord()
|
|
{
|
|
if (!this.IsPostBack)
|
|
{
|
|
entity.Param.Add("XLYSB_XLYSID", PageParam.GetRTrimString("XLYSID").Trim());
|
|
}
|
|
else
|
|
{
|
|
entity.Param.Add("XLYSB_XLYSID", txtXLYSID_OLD.Value.Trim());
|
|
}
|
|
base.LoadRecord();
|
|
}
|
|
|
|
protected override void OnNewRecorder()
|
|
{
|
|
base.OnNewRecorder();
|
|
|
|
txtXLYSID.Text = "";
|
|
txtXLYSMC.Text = "";
|
|
hidWHRID.Value = tSession.UserId;
|
|
txtWHR.Text = tSession.UserName;
|
|
datWHSJ.Value = CMISproConvert.ConvertTime(DateTime.Now);
|
|
}
|
|
|
|
protected override void OnCopyRecorder()
|
|
{
|
|
base.OnCopyRecorder();
|
|
|
|
txtXLYSID.Text = "";
|
|
txtXLYSMC.Text = "";
|
|
hidWHRID.Value = tSession.UserId;
|
|
txtWHR.Text = tSession.UserName;
|
|
datWHSJ.Value = CMISproConvert.ConvertTime(System.DateTime.Now);
|
|
}
|
|
|
|
protected override bool DataLogicValid()
|
|
{
|
|
bool bReturn = base.DataLogicValid();
|
|
string sYSMC = txtXLYSMC.Text.ToString().Trim();
|
|
string[] sYSID = cbxYSZH.SelectedValue.ToString().Trim().Split(',');
|
|
|
|
if (cbxYSZL.SelectedValue.ToString().Trim().Equals("1"))
|
|
cbxYSZH.SelectedValue = "";
|
|
else if (cbxYSZL.SelectedValue.ToString().Trim().Equals("2"))
|
|
{
|
|
if (cbxYSZH.SelectedValue.ToString().Trim().Equals(""))
|
|
{
|
|
ShowMessage("【" + sYSMC + "】是双色,颜色组合不允许为空!");
|
|
return false;
|
|
}
|
|
else if (sYSID.Length != 2)
|
|
{
|
|
ShowMessage("【" + sYSMC + "】是双色,请选择两种颜色组合!");
|
|
return false;
|
|
}
|
|
}
|
|
TDatabase dberp = TContextDatabases.GetDatabase("DBERP");
|
|
TSQL SQL = new TSQL(dberp);
|
|
SQL.Clear();
|
|
|
|
if (ControlState == TControlState.ctsEdit && !txtXLYSID_OLD.Value.Trim().Equals(txtXLYSID.Text.Trim()))
|
|
{
|
|
SQL.Clear();
|
|
SQL.Add("select 1 from XLYSB where (XLYSB_YSZH=:pYSZH1 or XLYSB_YSZH=:pYSZH2) and XLYSB_XLYSID <> :pYSID and XLYSB_YSZL= 2 ");
|
|
if (cbxYSZH.SelectedValue.ToString().Trim().Equals(""))
|
|
{
|
|
SQL.ParamByName("pYSZH1").Value = "";
|
|
SQL.ParamByName("pYSZH2").Value = "";
|
|
}
|
|
else
|
|
{
|
|
SQL.ParamByName("pYSZH1").Value = cbxYSZH.SelectedValue.ToString().Trim();
|
|
SQL.ParamByName("pYSZH2").Value = sYSID[1] + ',' + sYSID[0];
|
|
}
|
|
SQL.ParamByName("pYSID").Value = txtXLYSID_OLD.Value.ToString().Trim();
|
|
DataSet ds = dberp.OpenDataSet(SQL);
|
|
if (ds.Tables[0].Rows.Count > 0)
|
|
{
|
|
ShowMessage("颜色组合重复,不允许保存!");
|
|
return false;
|
|
}
|
|
|
|
SQL.Clear();
|
|
SQL.Add("select XLYSB_XLYSMC from XLYSB where XLYSB_XLYSMC=:pYSMC and XLYSB_XLYSID<>:pYSID ");
|
|
SQL.ParamByName("pYSID").Value = txtXLYSID_OLD.Value.ToString().Trim();
|
|
SQL.ParamByName("pYSMC").Value = txtXLYSMC.Text.ToString().Trim();
|
|
ds = dberp.OpenDataSet(SQL);
|
|
if (ds.Tables[0].Rows.Count > 0)
|
|
{
|
|
ShowMessage("颜色名称重复,不允许保存!");
|
|
return false;
|
|
}
|
|
if (cbxYSZL.SelectedValue.ToString().Trim().Equals(""))
|
|
{
|
|
ShowMessage("颜色种类不允许为空!");
|
|
return false;
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
|
|
SQL.Add("select 1 from XLYSB where (XLYSB_YSZH=:pYSZH1 or XLYSB_YSZH=:pYSZH2) and XLYSB_XLYSID <> :pYSID and XLYSB_YSZL= 2 ");
|
|
if (cbxYSZH.SelectedValue.ToString().Trim().Equals(""))
|
|
{
|
|
SQL.ParamByName("pYSZH1").Value = "";
|
|
SQL.ParamByName("pYSZH2").Value = "";
|
|
}
|
|
else
|
|
{
|
|
SQL.ParamByName("pYSZH1").Value = cbxYSZH.SelectedValue.ToString().Trim();
|
|
SQL.ParamByName("pYSZH2").Value = sYSID[1] + ',' + sYSID[0];
|
|
}
|
|
SQL.ParamByName("pYSID").Value = txtXLYSID.Text.ToString().Trim();
|
|
DataSet ds = dberp.OpenDataSet(SQL);
|
|
if (ds.Tables[0].Rows.Count > 0)
|
|
{
|
|
ShowMessage("颜色组合重复,不允许保存!");
|
|
return false;
|
|
}
|
|
|
|
SQL.Clear();
|
|
SQL.Add("select XLYSB_XLYSMC from XLYSB where XLYSB_XLYSMC=:pYSMC and XLYSB_XLYSID<>:pYSID ");
|
|
SQL.ParamByName("pYSID").Value = txtXLYSID.Text.ToString().Trim();
|
|
SQL.ParamByName("pYSMC").Value = txtXLYSMC.Text.ToString().Trim();
|
|
ds = dberp.OpenDataSet(SQL);
|
|
if (ds.Tables[0].Rows.Count > 0)
|
|
{
|
|
ShowMessage("颜色名称重复,不允许保存!");
|
|
return false;
|
|
}
|
|
if (cbxYSZL.SelectedValue.ToString().Trim().Equals(""))
|
|
{
|
|
ShowMessage("颜色种类不允许为空!");
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return bReturn;
|
|
}
|
|
|
|
|
|
protected override bool Master_BeforeSaveAction(object sender, EventArgs e)
|
|
{
|
|
if (ControlState == TControlState.ctsInsert || ControlState == TControlState.ctsCopy)
|
|
{
|
|
txtXSXH.Value = GetXH().ToString().Trim();
|
|
}
|
|
return base.Master_BeforeSaveAction(sender, e);
|
|
}
|
|
|
|
protected override bool Master_AfterSaveAction(object sender, EventArgs e)
|
|
{
|
|
txtXLYSID_OLD.Value = txtXLYSID.Text.Trim();
|
|
return base.Master_AfterSaveAction(sender, e);
|
|
}
|
|
|
|
protected override bool Master_BeforeDeleteAction(object sender, EventArgs e)
|
|
{
|
|
if (!CanDelete(txtXLYSID.Text.ToString().Trim()))
|
|
{
|
|
ShowMessage("当前颜色已被使用,不允许删除!");
|
|
return false;
|
|
}
|
|
return base.Master_BeforeDeleteAction(sender, e);
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
#region 自定义函数
|
|
|
|
private void InitControl()
|
|
{
|
|
cbxYSZL.ClearItems();
|
|
cbxYSZL.Items.Add(new ListItem("单色", "1"));
|
|
cbxYSZL.Items.Add(new ListItem("双色", "2"));
|
|
|
|
string sSetYSZH = "select XLYSB_XLYSID,XLYSB_XLYSMC from XLYSB where XLYSB_YSZL = 1 order by XLYSB_XSXH ";
|
|
TDatabase dberp = TContextDatabases.GetDatabase("DBERP");
|
|
TSQL sSQL = new TSQL(dberp);
|
|
sSQL.Add(sSetYSZH);
|
|
DataSet ds = dberp.OpenDataSet(sSQL);
|
|
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
|
|
{
|
|
cbxYSZH.Items.Add(new ListItem(ds.Tables[0].Rows[i]["XLYSB_XLYSMC"].ToString().Trim(), ds.Tables[0].Rows[i]["XLYSB_XLYSID"].ToString().Trim()));
|
|
}
|
|
}
|
|
|
|
|
|
private int GetXH()
|
|
{
|
|
int iXH = 0;
|
|
string SQL = "select max(XLYSB_XSXH) as XLYSB_XSXH from XLYSB where 1=1 ";
|
|
TDatabase dberp = TContextDatabases.GetDatabase("DBERP");
|
|
TSQL sSQL = new TSQL(dberp);
|
|
sSQL.Add(SQL);
|
|
DataSet ds = dberp.OpenDataSet(sSQL);
|
|
iXH = CMISproConvert.StrToInt(ds.Tables[0].Rows[0][0].ToString().Trim());
|
|
return iXH + 1;
|
|
}
|
|
|
|
private bool CanDelete(string sXLYSID)
|
|
{
|
|
TDatabase dberp = TContextDatabases.GetDatabase("DBERP");
|
|
TSQL SQL = new TSQL(dberp);
|
|
SQL.Clear();
|
|
SQL.Add(" select 1 from XLJYCLB where XLJYCLB_XLYSID=:pCL");
|
|
SQL.Add(" union all ");
|
|
SQL.Add(" select 1 from XLHTCLB where XLHTCLB_XLYSID=:pCL");
|
|
SQL.Add(" union all ");
|
|
SQL.Add(" select 1 from XLWHCLB where XLWHCLB_XLYSID=:pCL");
|
|
SQL.Add(" union all ");
|
|
SQL.Add(" select 1 from XLFZCLB where XLFZCLB_XLYSID=:pCL");
|
|
SQL.Add(" union all ");
|
|
SQL.Add(" select 1 from XLXLB where XLXLB_XLYSID=:pCL");
|
|
SQL.Add(" union all ");
|
|
SQL.Add(" select 1 from XLXXB where XLXXB_XXYS=:pCL");
|
|
SQL.Add(" union all ");
|
|
SQL.Add(" select 1 from XLSDYSB where XLSDYSB_XZSD like :CL ");
|
|
SQL.ParamByName("pCL").Value = sXLYSID;
|
|
SQL.ParamByName("CL").Value = "%"+sXLYSID+"%";
|
|
DataSet ds = dberp.OpenDataSet(SQL);
|
|
if (ds.Tables[0].Rows.Count > 0)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
string[] sXLYS = new string[] { "YE","GN","RD","BK","BN","BU","GY","OG","PK","TQ","VT","WH","YG","NA","RY","RG","RU","YB","RB",
|
|
"UG","BW","RW","WB","BB","YK","BG","WU","PB","WG","HC","SL","KN" };
|
|
|
|
for (int i = 0; i < sXLYS.Length; i++)
|
|
{
|
|
if (sXLYSID == sXLYS[i])
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|