2026821
This commit is contained in:
@@ -0,0 +1,305 @@
|
||||
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 XLYSList : SingleGridBase
|
||||
{
|
||||
XLYS entity = new XLYS();
|
||||
|
||||
#region Page类事件继承
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
this.UMID = 101421004;
|
||||
this.UMName = "线缆颜色";
|
||||
this.CurMaster = Master;
|
||||
this.ModuleGV = grdContentGrid;
|
||||
this.CurEntity = entity;
|
||||
this.sURLTarget = "XLYSInfo.aspx";
|
||||
this.PageHeight = 500;
|
||||
this.PageWidth = 700;
|
||||
|
||||
base.DataKeyNames = new string[] { "XLYSB_XLYSID", "XLYSB_YSZH" };
|
||||
|
||||
if (!IsPostBack)
|
||||
{
|
||||
InitControls();
|
||||
}
|
||||
|
||||
Master.EnableQueryBtn = false;
|
||||
|
||||
base.InitPage();
|
||||
|
||||
if (!IsPostBack)
|
||||
{
|
||||
Master_OnStandardQuery(null, null);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 模板事件继承
|
||||
protected override void Master_OnStandardQuery(object sender, EventArgs e)
|
||||
{
|
||||
entity.EntityTable.QuerySelSql = GetSQL();
|
||||
|
||||
base.Master_OnStandardQuery(sender, e);
|
||||
|
||||
entity.GridDataBind(grdContentGrid, tSession);
|
||||
}
|
||||
|
||||
protected override bool Master_BeforeDeleteAction(object sender, EventArgs e)
|
||||
{
|
||||
if (!CanDelete(grdContentGrid.SelectedDataKey["XLYSB_XLYSID"].ToString().Trim()))
|
||||
{
|
||||
ShowMessage("当前颜色已被使用,不允许删除!");
|
||||
return false;
|
||||
}
|
||||
return base.Master_BeforeDeleteAction(sender, e);
|
||||
}
|
||||
|
||||
protected override void BeforeDelete(TDatabase db, ref bool ActionIsDone)
|
||||
{
|
||||
entity.Param.Add("XLYSB_XLYSID", grdContentGrid.DataKeys[grdContentGrid.SelectedIndex]["XLYSB_XLYSID"].ToString().Trim());
|
||||
base.BeforeDelete(db, ref ActionIsDone);
|
||||
}
|
||||
|
||||
protected override bool Master_AfterDeleteAction(object sender, EventArgs e)
|
||||
{
|
||||
if (!base.Master_AfterDeleteAction(sender, e))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
entity.EntityTable.QuerySelSql = GetSQL();
|
||||
entity.GridDataBind(grdContentGrid, tSession);
|
||||
grdContentGrid.SelectedIndex = -1;
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void moduleGV_RowDataBound(object sender, GridViewRowEventArgs e)
|
||||
{
|
||||
if (e.Row.RowType == DataControlRowType.DataRow)
|
||||
{
|
||||
if ((e.Row.Cells[3].Text.Trim() != "") && (e.Row.Cells[3].Text.Trim() != " "))
|
||||
{
|
||||
string sYS = "";
|
||||
string[] sYSIDZH = grdContentGrid.DataKeys[e.Row.RowIndex]["XLYSB_YSZH"].ToString().Trim().Split(',');
|
||||
|
||||
// 循环处理 sYSIDZH
|
||||
for (int i = 0; i < sYSIDZH.Length; i++)
|
||||
{
|
||||
sYS = sYS+GetName(sYSIDZH[i]);
|
||||
// 如果不是最后一个元素,则添加逗号
|
||||
if (i < sYSIDZH.Length - 1)
|
||||
{
|
||||
sYS = sYS + ",";
|
||||
}
|
||||
}
|
||||
e.Row.Cells[3].Text = sYS;
|
||||
}
|
||||
if ((e.Row.Cells[2].Text.Trim() != "") && (e.Row.Cells[2].Text.Trim() != " "))
|
||||
{
|
||||
if (e.Row.Cells[2].Text.Trim().Equals("1"))
|
||||
e.Row.Cells[2].Text = "1|单色";
|
||||
else if(e.Row.Cells[2].Text.Trim().Equals("2"))
|
||||
e.Row.Cells[2].Text = "2|双色";
|
||||
else if (e.Row.Cells[2].Text.Trim().Equals("3"))
|
||||
e.Row.Cells[2].Text = "3|三色";
|
||||
}
|
||||
LinkPageParam.AddString("XLYSID", HttpUtility.UrlEncode(grdContentGrid.DataKeys[e.Row.RowIndex]["XLYSB_XLYSID"].ToString().Trim()));
|
||||
}
|
||||
|
||||
base.moduleGV_RowDataBound(sender, e);
|
||||
}
|
||||
|
||||
protected override void moduleGV_PageIndexChanging(object sender, GridViewPageEventArgs e)
|
||||
{
|
||||
this.CurEntity.EntityTable.QuerySelSql = GetSQL();
|
||||
grdContentGrid.SelectedIndex = -1;
|
||||
|
||||
base.moduleGV_PageIndexChanging(sender, e);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 自定义函数
|
||||
public void InitControls()
|
||||
{
|
||||
}
|
||||
|
||||
private string GetSQL()
|
||||
{
|
||||
string sSQL = "";
|
||||
sSQL = " select XLYSB_XLYSID,XLYSB_XLYSMC,XLYSB_XSXH, XLYSB_YSZL, XLYSB_YSZH, " + "\r\n"
|
||||
+ " XLYSB_WHR,XLYSB_WHRID,XLYSB_WHSJ" + "\r\n"
|
||||
+ " from XLYSB" + "\r\n"
|
||||
+ " where 1=1" + "\r\n"
|
||||
+ " order by XLYSB_XSXH";
|
||||
|
||||
return sSQL;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region 控制事件
|
||||
|
||||
protected void btnDRQS_Click(object sender, EventArgs e)
|
||||
{
|
||||
Dictionary<string, string> sQSYS = new Dictionary<string, string>();
|
||||
|
||||
TDatabase dberp = TContextDatabases.GetDatabase("DBERP");
|
||||
TSQL SQL = new TSQL(dberp);
|
||||
|
||||
sQSYS.Add("YE", "黄色;1; ");
|
||||
sQSYS.Add("GN", "绿色;1; ");
|
||||
sQSYS.Add("RD", "红色;1; ");
|
||||
sQSYS.Add("BK", "黑色;1; ");
|
||||
sQSYS.Add("BN", "棕色;1; ");
|
||||
sQSYS.Add("BU", "蓝色;1; ");
|
||||
sQSYS.Add("GY", "灰色;1; ");
|
||||
sQSYS.Add("OG", "橙色;1; ");
|
||||
sQSYS.Add("PK", "粉红;1; ");
|
||||
sQSYS.Add("TQ", "青绿;1; ");
|
||||
sQSYS.Add("VT", "紫色;1; ");
|
||||
sQSYS.Add("WH", "白色;1; ");
|
||||
sQSYS.Add("YG", "黄绿;2;YE,GN");
|
||||
sQSYS.Add("NA", "无色;1; ");
|
||||
sQSYS.Add("RY", "红黄;2;RD,YE");
|
||||
sQSYS.Add("RG", "红绿;2;RD,GN");
|
||||
sQSYS.Add("RU", "红蓝;2;RD,BU");
|
||||
sQSYS.Add("YB", "黄蓝;2;YE,BU");
|
||||
sQSYS.Add("RB", "红黑;2;RD,BK");
|
||||
sQSYS.Add("UG", "蓝绿;2;BU,GN");
|
||||
sQSYS.Add("BW", "黑白;2;BK,WH");
|
||||
sQSYS.Add("RW", "红白;2;RD,WH");
|
||||
sQSYS.Add("WB", "白棕;2;WH,BN");
|
||||
sQSYS.Add("BB", "蓝黑;2;BU,BK");
|
||||
sQSYS.Add("YK", "黄黑;2;YE,BK");
|
||||
sQSYS.Add("BG", "黑绿;2;BK,GN");
|
||||
sQSYS.Add("WU", "白蓝;2;WH,BU");
|
||||
sQSYS.Add("PB", "紫黑;2;VT,BK");
|
||||
sQSYS.Add("WG", "白绿;2;WH,GN");
|
||||
sQSYS.Add("HC", "黑灰;2;BK,GY");
|
||||
sQSYS.Add("SL", "深蓝;1; ");
|
||||
sQSYS.Add("KN", "黑棕;2;BK,BN");
|
||||
|
||||
foreach (string tmpkey in sQSYS.Keys)
|
||||
{
|
||||
if (Isin(tmpkey))
|
||||
continue;
|
||||
string[] sValue = sQSYS[tmpkey].Split(';');
|
||||
SQL.Clear();
|
||||
SQL.Add("insert into XLYSB(XLYSB_XLYSID,XLYSB_XLYSMC,XLYSB_WHR,XLYSB_WHRID,XLYSB_WHSJ,XLYSB_XSXH, XLYSB_YSZL, XLYSB_YSZH)");
|
||||
SQL.Add("values(:XLYSB_XLYSID,:XLYSB_XLYSMC,:XLYSB_WHR,:XLYSB_WHRID,:XLYSB_WHSJ,:XLYSB_XSXH, :XLYSB_YSZL, :XLYSB_YSZH) ");
|
||||
SQL.ParamByName("XLYSB_XLYSID").Value = tmpkey;
|
||||
SQL.ParamByName("XLYSB_XLYSMC").Value = sValue[0].ToString().Trim();
|
||||
SQL.ParamByName("XLYSB_XSXH").Value = GetXH();
|
||||
SQL.ParamByName("XLYSB_YSZL").Value = CMISproConvert.StrToInt(sValue[1].ToString().Trim());
|
||||
SQL.ParamByName("XLYSB_YSZH").Value = sValue[2].ToString().Trim();
|
||||
SQL.ParamByName("XLYSB_WHR").Value = tSession.UserName;
|
||||
SQL.ParamByName("XLYSB_WHRID").Value = tSession.UserId;
|
||||
SQL.ParamByName("XLYSB_WHSJ").Value = MISproUtils.GetServerTime();
|
||||
dberp.ExecSQL(SQL);
|
||||
}
|
||||
ShowMessage("导入成功!");
|
||||
Master_OnStandardQuery(null,null);
|
||||
FormAreaUpdate();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
private string GetName(string sYSID)
|
||||
{
|
||||
//SELECT RTRIM(XLYSB_XLYSID)+'|'+RTRIM(XLYSB_XLYSMC) FROM XLYSB WHERE XLYSB_XLYSID = '';
|
||||
TDatabase dberp = TContextDatabases.GetDatabase("DBERP");
|
||||
TSQL SQL = new TSQL(dberp);
|
||||
SQL.Clear();
|
||||
SQL.Add(" SELECT RTRIM(XLYSB_XLYSID)||'|'||RTRIM(XLYSB_XLYSMC)");
|
||||
SQL.Add(" FROM XLYSB ");
|
||||
SQL.Add(" WHERE XLYSB_XLYSID =:pYSID");
|
||||
SQL.ParamByName("pYSID").Value = sYSID;
|
||||
DataSet ds = dberp.OpenDataSet(SQL);
|
||||
if (ds.Tables[0].Rows.Count > 0)
|
||||
return ds.Tables[0].Rows[0][0].ToString().Trim();
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
private bool Isin(string sYSID)
|
||||
{
|
||||
TDatabase dberp = TContextDatabases.GetDatabase("DBERP");
|
||||
TSQL SQL = new TSQL(dberp);
|
||||
SQL.Clear();
|
||||
SQL.Add(" SELECT 1 FROM XLYSB WHERE XLYSB_XLYSID =:pYSID");
|
||||
SQL.ParamByName("pYSID").Value = sYSID;
|
||||
DataSet ds = dberp.OpenDataSet(SQL);
|
||||
if (ds.Tables[0].Rows.Count > 0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user