Files
N_XLXSBJ----MX/TZYZBJKInfo.aspx.cs
T
2026-08-21 17:03:02 +08:00

343 lines
14 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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;
using GThinking.N_CONTROL;
using GThinking.N_MISPRO.Data;
using GThinking.N_MISPRO.Utility;
using GThinking.N_MISPRO.TableCache;
namespace GThinking.N_XLXSBJ
{
public partial class TZYZBJKInfo : SingleCardBase
{
TZYZBJK entity = new TZYZBJK();
protected void Page_Load(object sender, EventArgs e)
{
this.UMID = 100860152;
this.UMName = "按导体类型电压等级/材料重量调报价";
this.CurMaster = Master;
this.CurEntity = entity;
this.PageHeight = 450;
this.PageWidth = 500;
SetTJYZLable();
if (!this.IsPostBack)
{
InitControls();
}
base.InitPage();
}
#region 模板事件继承
protected override void ReportDataSetAdd()
{
TDatabase db = TContextDatabases.GetDatabase("DBERP");
TSQL sql = new TSQL(db);
sql.Add("select XLXSTZYZ_YZID, XLXSTZYZ_YZMC from XLXSTZYZ where XLXSTZYZ_MXBH='BJD' and XLXSTZYZ_TJYS='K' order by XLXSTZYZ_XSXH,XLXSTZYZ_YZID ");
DataSet ds = db.OpenDataSet(sql);
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
string sYZID = "TZYZ_" + ds.Tables[0].Rows[i]["XLXSTZYZ_YZID"].ToString().Trim();
string sYZMC = ds.Tables[0].Rows[i]["XLXSTZYZ_YZMC"].ToString().Trim();
AddUserReportField("XLXSBJDYZZK", sYZID, sYZMC, "N");
}
base.ReportDataSetAdd();
}
protected override void ReportRecordSetAdd()
{
TDatabase dberp = TContextDatabases.GetDatabase("DBERP");
TSQL sSQL = new TSQL(dberp);
TSQL SQL = new TSQL(dberp);
SQL.Clear();
SQL.Add("select XLXSTZYZ_YZID, XLXSTZYZ_YZMC ");
SQL.Add(" from XLXSTZYZ");
SQL.Add(" where XLXSTZYZ_MXBH = 'BJD' and XLXSTZYZ_TJYS='K' order by XLXSTZYZ_XSXH,XLXSTZYZ_YZID ");
DataSet ds = dberp.OpenDataSet(SQL);
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
sSQL.Add(string.Format(",sum(decode(XLXSBJDYZZK_YZID, '{0}', XLXSBJDYZZK_YZZ, 0)) as TZYZ_{0}", ds.Tables[0].Rows[i][0].ToString().Trim()));
}
sSQL.Text = "select 1" + sSQL.Text + " from XLXSBJDYZZK where XLXSBJDYZZK_JGBID='" + txtJGBID.Value.Trim()
+ "' and XLXSBJDYZZK_DTLX = '" + cbxDTLX.SelectedValue.Trim() + "' and XLXSBJDYZZK_DYDJID = '" + cbxDYDJID.SelectedValue.Trim() + "' ";
AddUserReportSQL("XLXSBJDYZZK", sSQL);
base.ReportRecordSetAdd();
}
protected override void SetControlState()
{
base.SetControlState();
txtWHR.Enabled = false;
datWHSJ.Enabled = false;
# region 给调价因子控件设只读性
if (ControlState == TControlState.ctsInsert || ControlState == TControlState.ctsCopy || ControlState == TControlState.ctsEdit)
{
for (int i = 1; i <= 20; i++)
{
gtNumTextBox txtTJYZ = (gtNumTextBox)Master.ContentFormControl.FindControl("txt" + "TJYZ" + i);
txtTJYZ.Enabled = false;
}
string[] sTJYZList = PageParam.GetRTrimString("TJYZList").Split(',');
for (int i = 0; i < sTJYZList.Length; i++)
{
for (int j = 1; j <= 20; j++)
{
string sTZYZID = "BJ" + j.ToString().PadLeft(2, '0') + "|";
gtNumTextBox txtTJYZ = (gtNumTextBox)Master.ContentFormControl.FindControl("txt" + "TJYZ" + j.ToString().Trim());
if (sTJYZList[i].StartsWith(sTZYZID))
{
txtTJYZ.Enabled = true;
}
}
}
}
#endregion
}
protected override void LoadRecord()
{
if (!IsPostBack)
{
entity.Param.Add("XLXSBJDYZZK_JGBID", PageParam.GetRTrimString("XLXSBJDYZZK_JGBID"));
entity.Param.Add("XLXSBJDYZZK_DTLX", PageParam.GetRTrimString("XLXSBJDYZZK_DTLX"));
entity.Param.Add("XLXSBJDYZZK_DYDJID", PageParam.GetRTrimString("XLXSBJDYZZK_DYDJID"));
entity.Param.Add("XLXSBJDYZZK_YZID", PageParam.GetRTrimString("XLXSBJDYZZK_YZID"));
}
else
{
entity.Param.Add("XLXSBJDYZZK_JGBID", txtJGBID.Value.Trim());
entity.Param.Add("XLXSBJDYZZK_DTLX", txtOLD_DTLX.Value.Trim());
entity.Param.Add("XLXSBJDYZZK_DYDJID", txtOLD_DYDJID.Value.Trim());
entity.Param.Add("XLXSBJDYZZK_YZID", txtYZID.Value.Trim());
}
base.LoadRecord();
txtOLD_DTLX.Value = cbxDTLX.SelectedValue.Trim();
txtOLD_DYDJID.Value = cbxDYDJID.SelectedValue.Trim();
# region 给调价因子控件赋值
TDatabase dberp = TContextDatabases.GetDatabase("DBERP");
TSQL sql = new TSQL(dberp);
sql.Clear();
sql.Add(string.Format(" select XLXSBJDYZZ{0}_YZID, XLXSBJDYZZ{0}_YZZ from XLXSBJDYZZ{0} ", "K"));
sql.Add(string.Format(" where XLXSBJDYZZ{0}_JGBID=:pJGBID and XLXSBJDYZZ{0}_DTLX=:pDTLX ", "K"));
sql.Add(string.Format(" and XLXSBJDYZZ{0}_DYDJID=:pDYDJID ", "K"));
sql.Add(string.Format(" order by XLXSBJDYZZ{0}_YZID", "K"));
sql.ParamByName("pJGBID").Value = txtJGBID.Value.Trim();
sql.ParamByName("pDTLX").Value = cbxDTLX.SelectedValue.Trim();
sql.ParamByName("pDYDJID").Value = cbxDYDJID.SelectedValue.Trim();
DataSet ds = dberp.OpenDataSet(sql);
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
string sYZID = ds.Tables[0].Rows[i][0].ToString().Trim();
double dYZZ = CMISproConvert.StrToFloat(ds.Tables[0].Rows[i][1].ToString().Trim());
if (PageParam.GetRTrimString("TJYZList").Contains(sYZID + "|"))
{
for (int j = 1; j <= 20; j++)
{
string sTZYZID = "BJ" + j.ToString().PadLeft(2, '0');
gtNumTextBox txtTJYZ = (gtNumTextBox)Master.ContentFormControl.FindControl("txt" + "TJYZ" + j.ToString().Trim());
if (sYZID.Equals(sTZYZID))
txtTJYZ.Value = dYZZ;
}
}
}
#endregion
}
protected override void OnNewRecorder()
{
base.OnNewRecorder();
txtJGBID.Value = PageParam.GetRTrimString("XLXSBJDYZZK_JGBID");
txtWHR.Text = tSession.UserName;
txtWHRID.Value = tSession.UserId;
datWHSJ.Text = CMISproConvert.ConvertTime(System.DateTime.Now);
}
protected override void OnCopyRecorder()
{
base.OnCopyRecorder();
txtJGBID.Value = PageParam.GetRTrimString("XLXSBJDYZZK_JGBID");
txtWHR.Text = tSession.UserName;
txtWHRID.Value = tSession.UserId;
datWHSJ.Text = CMISproConvert.ConvertTime(System.DateTime.Now);
}
protected override bool DataLogicValid()
{
if (!base.DataLogicValid()) return false;
if (cbxDTLX.SelectedValue.Trim().Equals(""))
{
ShowMessage("导体类型不允许为空!");
return false;
}
//if (cbxDYDJID.SelectedValue.Trim().Equals(""))
//{
// ShowMessage("电压等级不允许为空!");
// return false;
//}
return true;
}
protected override bool Master_BeforeDeleteAction(object sender, EventArgs e)
{
string sYZIDlist = TZYZBJAInfo.GetYZIDList(PageParam.GetRTrimString("TJYZList"));
entity.EntityTable.DeleteSql = " delete from XLXSBJDYZZK "
+ " where XLXSBJDYZZK_JGBID =:XLXSBJDYZZK_JGBID "
+ " and XLXSBJDYZZK_DTLX=:XLXSBJDYZZK_DTLX and XLXSBJDYZZK_DYDJID=:XLXSBJDYZZK_DYDJID and "
+ CMISproDataBase.GetWhereEqual("XLXSBJDYZZK_YZID", sYZIDlist);
return base.Master_BeforeDeleteAction(sender, e);
}
protected override bool Master_BeforeSaveAction(object sender, EventArgs e)
{
if (!base.Master_BeforeSaveAction(sender, e)) return false;
string sYZIDlist = TZYZBJAInfo.GetYZIDList(PageParam.GetRTrimString("TJYZList"));
entity.EntityTable.UpdateSql = " update XLXSBJDYZZK "
+ " set XLXSBJDYZZK_JGBID =:XLXSBJDYZZK_JGBID "
+ " , XLXSBJDYZZK_DTLX =:XLXSBJDYZZK_DTLX , XLXSBJDYZZK_DYDJID =:XLXSBJDYZZK_DYDJID ,"
+ " XLXSBJDYZZK_WHR=:XLXSBJDYZZK_WHR,XLXSBJDYZZK_WHRID=:XLXSBJDYZZK_WHRID,XLXSBJDYZZK_WHSJ=:XLXSBJDYZZK_WHSJ "
+ " where XLXSBJDYZZK_JGBID =:XLXSBJDYZZK_JGBID "
+ " and XLXSBJDYZZK_DTLX =:OLD_XLXSBJDYZZK_DTLX and XLXSBJDYZZK_DYDJID =:OLD_XLXSBJDYZZK_DYDJID and " + CMISproDataBase.GetWhereEqual("XLXSBJDYZZK_YZID", sYZIDlist);
txtWHR.Text = tSession.UserName;
txtWHRID.Value = tSession.UserId;
datWHSJ.Text = CMISproConvert.ConvertTime(System.DateTime.Now);
return true;
}
protected override bool Master_AfterSaveAction(object sender, EventArgs e)
{
txtOLD_DTLX.Value = cbxDTLX.SelectedValue.Trim();
txtOLD_DYDJID.Value = cbxDYDJID.SelectedValue.Trim();
txtYZID.Value = PageParam.GetRTrimString("FirstYZID");
string sJGBID = txtJGBID.Value.Trim();
string sDTLX = cbxDTLX.SelectedValue.Trim();
string sDYDJID = cbxDYDJID.SelectedValue.Trim().Equals("") ? " " : cbxDYDJID.SelectedValue.Trim();
# region 将调价因子控件值更新至数据库中
TDatabase dberp = TContextDatabases.GetDatabase("DBERP");
TSQL sql = new TSQL(dberp);
sql.Clear();
string sYZIDlist = TZYZBJAInfo.GetYZIDList(PageParam.GetRTrimString("TJYZList"));
dberp.ExecSQL(string.Format(" delete from XLXSBJDYZZ{0} where XLXSBJDYZZ{0}_JGBID='{1}' and XLXSBJDYZZ{0}_DTLX='{2}' "
+ " and XLXSBJDYZZ{0}_DYDJID='{3}' and " + CMISproDataBase.GetWhereEqual("XLXSBJDYZZ{0}_YZID", sYZIDlist)
, "K", sJGBID, sDTLX, sDYDJID));
string[] sTJYZList = PageParam.GetRTrimString("TJYZList").Split(',');
DateTime tNow = DateTime.Now;
for (int i = 0; i < sTJYZList.Length; i++)
{
sql.Clear();
sql.Add(string.Format(" insert into XLXSBJDYZZ{0}(XLXSBJDYZZ{0}_JGBID, XLXSBJDYZZ{0}_DTLX,XLXSBJDYZZ{0}_DYDJID,", "K"));
sql.Add(string.Format(" XLXSBJDYZZ{0}_YZID, XLXSBJDYZZ{0}_YZZ, XLXSBJDYZZ{0}_WHR, XLXSBJDYZZ{0}_WHRID, XLXSBJDYZZ{0}_WHSJ)", "K"));
sql.Add(string.Format(" values(:pJGBID,:pDTLX,:pDYDJID,:pYZID,:pYZZ,:pWHR,:pWHRID,:pWHSJ)"));
sql.ParamByName("pJGBID").Value = sJGBID;
sql.ParamByName("pDTLX").Value = sDTLX;
sql.ParamByName("pDYDJID").Value = sDYDJID;
sql.ParamByName("pWHR").Value = tSession.UserName;
sql.ParamByName("pWHRID").Value = tSession.UserId;
sql.ParamByName("pWHSJ").Value = tNow;
for (int j = 1; j <= 20; j++)
{
string sTZYZID = "BJ" + j.ToString().PadLeft(2, '0') + "|";
gtNumTextBox txtTJYZ = (gtNumTextBox)Master.ContentFormControl.FindControl("txt" + "TJYZ" + j.ToString().Trim());
if (sTJYZList[i].StartsWith(sTZYZID))
{
sql.ParamByName("pYZID").Value = sTZYZID.TrimEnd('|');
sql.ParamByName("pYZZ").Value = txtTJYZ.Value;
dberp.ExecSQL(sql);
}
}
}
#endregion
return base.Master_AfterSaveAction(sender, e);
}
protected override void SetComboxItems()
{
TComboBox.SetComboBox("DBERP", cbxDTLX, "select XLDTCLB_DTCLID,XLDTCLB_WLMC from XLDTCLB where XLDTCLB_WLID =' ' order by XLDTCLB_DTCLID ", false);
TComboBox.SetComboBox("DBERP", cbxDYDJID, "select distinct XLDYDJB_DYDJID as ID,XLDYDJB_DYDJID as Name from XLDYDJB where 1=1 order by ID ", true);
base.SetComboxItems();
}
#endregion
#region 自定义函数
private void InitControls()
{
txtYZID.Value = PageParam.GetRTrimString("FirstYZID");
}
private void SetTJYZLable()
{
string[] sTJYZList = PageParam.GetRTrimString("TJYZList").Split(',');
for (int i = 0; i < sTJYZList.Length; i++)
{
for (int j = 1; j <= 20; j++)
{
string sTZYZID = "BJ" + j.ToString().PadLeft(2, '0') + "|";
gtNumTextBox txtTJYZ = (gtNumTextBox)Master.ContentFormControl.FindControl("txt" + "TJYZ" + j.ToString().Trim());
gtLabel lblTJYZ = (gtLabel)Master.ContentFormControl.FindControl("lbl" + "TJYZ" + j.ToString().Trim());
if (sTJYZList[i].StartsWith(sTZYZID))
{
string s = sTJYZList[i].Replace(sTZYZID, "").Replace("(X)", "") + ":";
lblTJYZ.Text = s;
if (sTJYZList[i].EndsWith("(%)") || sTJYZList[i].EndsWith("(元)"))
{
txtTJYZ.DecimalPlaces = 2;
}
else if (sTJYZList[i].EndsWith("(X)"))
{
txtTJYZ.DecimalPlaces = 4;
}
}
}
}
}
#endregion
}
}