372 lines
18 KiB
C#
372 lines
18 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_MISPRO.Data;
|
||
using GThinking.N_MODEL.Page;
|
||
using GThinking.N_MISPRO.Utility;
|
||
using GThinking.N_PUBLIC;
|
||
using GThinking.N_MODEL.Dialog;
|
||
using GThinking.N_CONTROL;
|
||
|
||
namespace GThinking.N_XLXSBJ
|
||
{
|
||
public partial class TZYZJJ3Info : SingleCardBase
|
||
{
|
||
TZYZJJ3 entity = new TZYZJJ3();
|
||
|
||
protected void Page_Load(object sender, EventArgs e)
|
||
{
|
||
this.UMID = 100860026;
|
||
this.UMName = "按销售区域导体材料型号主芯截面调表价";
|
||
this.CurMaster = Master;
|
||
this.CurEntity = entity;
|
||
this.PageHeight = 400;
|
||
this.PageWidth = 500;
|
||
|
||
SetTJYZLable();
|
||
|
||
base.InitPage();
|
||
|
||
if (!this.IsPostBack)
|
||
{
|
||
InitControls();
|
||
}
|
||
}
|
||
|
||
#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='JZJ' and XLXSTZYZ_TJYS='3' 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("XLXSJGBYZZ3", 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 = 'JZJ' and XLXSTZYZ_TJYS='3' 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(XLXSJGBYZZ3_YZID, '{0}', XLXSJGBYZZ3_YZZ, 0)) as TZYZ_{0}", ds.Tables[0].Rows[i][0].ToString().Trim()));
|
||
}
|
||
sSQL.Text = "select 1" + sSQL.Text + " from XLXSJGBYZZ3 where XLXSJGBYZZ3_JGBID='" + txtJGBID.Value.Trim() + "' and XLXSJGBYZZ3_XSQYID='" + cbxXSQYID.SelectedValue + "' and XLXSJGBYZZ3_DTCLID='" + cbxDTCLID.SelectedValue.Trim() + "' and XLXSJGBYZZ3_XLXHID='" + cbxXLXHID.SelectedValue + "' and XLXSJGBYZZ3_ZXJM=" + txtZXJM.Value.ToString() + " ";
|
||
AddUserReportSQL("XLXSJGBYZZ3", 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)
|
||
{
|
||
// 1. 先禁用所有 txtTJYZ1 ~ txtTJYZ10
|
||
for (int i = 1; i <= 20; i++)
|
||
{
|
||
gtNumTextBox txt = FindControl("txtTJYZ" + i) as gtNumTextBox;
|
||
if (txt != null)
|
||
{
|
||
txt.Enabled = false;
|
||
}
|
||
}
|
||
|
||
// 2. 解析 TJYZList,启用匹配的控件
|
||
string[] sTJYZList = PageParam.GetRTrimString("TJYZList").Split(',');
|
||
foreach (string item in sTJYZList)
|
||
{
|
||
// 检查格式:以 "JZ" + 两位数字 + "|" 开头
|
||
if (item.Length >= 5 && item.StartsWith("JZ") && char.IsDigit(item[2]) && char.IsDigit(item[3]) && item[4] == '|')
|
||
{
|
||
string numStr = item.Substring(2, 2); // 提取 "01" ~ "10"
|
||
int index;
|
||
if (int.TryParse(numStr, out index))
|
||
{
|
||
// 注意控件ID不带前导零,如 "txtTJYZ1"
|
||
gtNumTextBox txt = FindControl("txtTJYZ" + index) as gtNumTextBox;
|
||
if (txt != null)
|
||
{
|
||
txt.Enabled = true;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
}
|
||
|
||
protected override void LoadRecord()
|
||
{
|
||
if (!IsPostBack)
|
||
{
|
||
entity.Param.Add("XLXSJGBYZZ3_JGBID", PageParam.GetRTrimString("XLXSJGBYZZ3_JGBID"));
|
||
entity.Param.Add("XLXSJGBYZZ3_XSQYID", PageParam.GetRTrimString("XLXSJGBYZZ3_XSQYID").Equals("") ? " " : PageParam.GetRTrimString("XLXSJGBYZZ3_XSQYID"));
|
||
entity.Param.Add("XLXSJGBYZZ3_DTCLID", PageParam.GetRTrimString("XLXSJGBYZZ3_DTCLID"));
|
||
entity.Param.Add("XLXSJGBYZZ3_XLXHID", PageParam.GetRTrimString("XLXSJGBYZZ3_XLXHID").Equals("") ? " " : PageParam.GetRTrimString("XLXSJGBYZZ3_XLXHID"));
|
||
entity.Param.Add("XLXSJGBYZZ3_ZXJM", PageParam.GetRTrimString("XLXSJGBYZZ3_ZXJM"));
|
||
entity.Param.Add("XLXSJGBYZZ3_YZID", PageParam.GetRTrimString("XLXSJGBYZZ3_YZID"));
|
||
}
|
||
else
|
||
{
|
||
entity.Param.Add("XLXSJGBYZZ3_JGBID", txtJGBID.Value.Trim());
|
||
entity.Param.Add("XLXSJGBYZZ3_XSQYID", txtOLD_XSQYID.Value.Trim().Equals("") ? " " : txtOLD_XSQYID.Value.Trim());
|
||
entity.Param.Add("XLXSJGBYZZ3_DTCLID", txtOLD_DTCLID.Value.Trim());
|
||
entity.Param.Add("XLXSJGBYZZ3_XLXHID", txtOLD_XLXHID.Value.Trim().Equals("") ? " " : txtOLD_XLXHID.Value.Trim());
|
||
entity.Param.Add("XLXSJGBYZZ3_ZXJM", txtOLD_ZXJM.Value.Trim());
|
||
entity.Param.Add("XLXSJGBYZZ3_YZID", txtYZID.Value.Trim());
|
||
}
|
||
base.LoadRecord();
|
||
|
||
txtOLD_XSQYID.Value = cbxXSQYID.SelectedValue.Trim().Equals("") ? " " : cbxXSQYID.SelectedValue.Trim();
|
||
txtOLD_DTCLID.Value = cbxDTCLID.SelectedValue.Trim();
|
||
txtOLD_XLXHID.Value = cbxXLXHID.SelectedValue.Trim().Equals("") ? " " : cbxXLXHID.SelectedValue.Trim();
|
||
txtOLD_ZXJM.Value = txtZXJM.Value.ToString().Trim();
|
||
|
||
# region 给调价因子控件赋值
|
||
TDatabase dberp = TContextDatabases.GetDatabase("DBERP");
|
||
TSQL sql = new TSQL(dberp);
|
||
sql.Add("select XLXSJGBYZZ3_YZID, XLXSJGBYZZ3_YZZ from XLXSJGBYZZ3 where XLXSJGBYZZ3_JGBID=:pJGBID and XLXSJGBYZZ3_XSQYID=:pXSQYID and XLXSJGBYZZ3_DTCLID=:pDTCLID ");
|
||
sql.Add(" and XLXSJGBYZZ3_XLXHID=:pXLXHID and XLXSJGBYZZ3_ZXJM=:pZXJM ");
|
||
sql.Add(" order by XLXSJGBYZZ3_YZID");
|
||
sql.ParamByName("pJGBID").Value = txtJGBID.Value.Trim();
|
||
sql.ParamByName("pXSQYID").Value = cbxXSQYID.SelectedValue.Trim().Equals("") ? " " : cbxXSQYID.SelectedValue.Trim();
|
||
sql.ParamByName("pDTCLID").Value = cbxDTCLID.SelectedValue.Trim();
|
||
sql.ParamByName("pXLXHID").Value =cbxXLXHID.SelectedValue.Trim().Equals("") ? " " : cbxXLXHID.SelectedValue.Trim();
|
||
sql.ParamByName("pZXJM").Value = txtZXJM.Value;
|
||
DataSet ds = dberp.OpenDataSet(sql);
|
||
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
|
||
{
|
||
string sYZID = ds.Tables[0].Rows[i]["XLXSJGBYZZ3_YZID"].ToString().Trim();
|
||
double dYZZ = CMISproConvert.StrToFloat(ds.Tables[0].Rows[i]["XLXSJGBYZZ3_YZZ"].ToString().Trim());
|
||
if (PageParam.GetRTrimString("TJYZList").Contains(sYZID + "|"))
|
||
{
|
||
|
||
if (sYZID.StartsWith("JZ") && sYZID.Length == 4) // 确保格式为 "JZ01" ~ "JZ10"
|
||
{
|
||
string numStr = sYZID.Substring(2, 2); // 提取 "01" ~ "10"
|
||
int index;
|
||
if (int.TryParse(numStr, out index) )
|
||
{
|
||
// 注意控件ID不带前导零,如 "txtTJYZ1"
|
||
gtNumTextBox txt = FindControl("txtTJYZ" + index) as gtNumTextBox;
|
||
if (txt != null)
|
||
{
|
||
txt.Value = dYZZ;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
#endregion
|
||
}
|
||
|
||
protected override void OnNewRecorder()
|
||
{
|
||
base.OnNewRecorder();
|
||
txtJGBID.Value = PageParam.GetRTrimString("XLXSJGBYZZ3_JGBID");
|
||
txtWHR.Text = tSession.UserName;
|
||
txtWHRID.Value = tSession.UserId;
|
||
datWHSJ.Text = CMISproConvert.ConvertTime(DateTime.Now);
|
||
}
|
||
|
||
protected override void OnCopyRecorder()
|
||
{
|
||
base.OnCopyRecorder();
|
||
txtJGBID.Value = PageParam.GetRTrimString("XLXSJGBYZZ3_JGBID");
|
||
txtWHR.Text = tSession.UserName;
|
||
txtWHRID.Value = tSession.UserId;
|
||
datWHSJ.Text = CMISproConvert.ConvertTime(DateTime.Now);
|
||
}
|
||
|
||
protected override bool DataLogicValid()
|
||
{
|
||
if (ControlState == TControlState.ctsInsert || ControlState == TControlState.ctsCopy)
|
||
{
|
||
if (CMISproDataBase.ExistsRecord("DBERP", string.Format("select 1 from XLXSJGBYZZ3 where XLXSJGBYZZ3_JGBID='{0}' and XLXSJGBYZZ3_XSQYID='{1}' and XLXSJGBYZZ3_DTCLID='{2}' and XLXSJGBYZZ3_XLXHID='{3}' and XLXSJGBYZZ3_ZXJM={4}",
|
||
txtJGBID.Value.Trim(), cbxXSQYID.SelectedValue.Trim().Equals("") ? " " : cbxXSQYID.SelectedValue.Trim(), cbxDTCLID.SelectedValue.Trim(), cbxXLXHID.SelectedValue.Trim().Equals("") ? " " : cbxXLXHID.SelectedValue.Trim(), txtZXJM.Value)))
|
||
{
|
||
ShowMessage("已存在编号相同的记录,不允许保存!");
|
||
return false;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (CMISproDataBase.ExistsRecord("DBERP", string.Format(@"select 1 from XLXSJGBYZZ3 where XLXSJGBYZZ3_JGBID='{0}' and XLXSJGBYZZ3_XSQYID='{1}' and XLXSJGBYZZ3_DTCLID='{2}' and XLXSJGBYZZ3_XLXHID='{3}' and XLXSJGBYZZ3_ZXJM={4}
|
||
and (XLXSJGBYZZ3_XSQYID<>'{5}' or XLXSJGBYZZ3_DTCLID<>'{6}' or XLXSJGBYZZ3_XLXHID<>'{7}' or XLXSJGBYZZ3_ZXJM<>{8}) ",
|
||
txtJGBID.Value.Trim(), cbxXSQYID.SelectedValue.Trim().Equals("") ? " " : cbxXSQYID.SelectedValue.Trim(), cbxDTCLID.SelectedValue.Trim(), cbxXLXHID.SelectedValue.Trim().Equals("") ? " " : cbxXLXHID.SelectedValue.Trim(), txtZXJM.Value,
|
||
txtOLD_XSQYID.Value.Trim().Equals("") ? " " : txtOLD_XSQYID.Value.Trim(), txtOLD_DTCLID.Value.Trim(), txtOLD_XLXHID.Value.Trim().Equals("") ? " " : txtOLD_XLXHID.Value.Trim(), txtOLD_ZXJM.Value.Trim())))
|
||
{
|
||
ShowMessage("已存在编号相同的记录,不允许保存!");
|
||
return false;
|
||
}
|
||
}
|
||
return base.DataLogicValid();
|
||
}
|
||
|
||
protected override bool Master_BeforeSaveAction(object sender, EventArgs e)
|
||
{
|
||
if (!base.Master_BeforeSaveAction(sender, e)) return false;
|
||
|
||
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_XSQYID.Value = cbxXSQYID.SelectedValue.Trim().Equals("") ? " " : cbxXSQYID.SelectedValue.Trim();
|
||
txtOLD_DTCLID.Value = cbxDTCLID.SelectedValue.Trim();
|
||
txtOLD_XLXHID.Value = cbxXLXHID.SelectedValue.Trim().Equals("") ? " " : cbxXLXHID.SelectedValue.Trim();
|
||
txtOLD_ZXJM.Value = txtZXJM.Value.ToString().Trim();
|
||
txtYZID.Value = PageParam.GetRTrimString("FirstYZID");
|
||
|
||
# region 将调价因子控件值更新至数据库中
|
||
TDatabase dberp = TContextDatabases.GetDatabase("DBERP");
|
||
TSQL sql = new TSQL(dberp);
|
||
sql.Add("delete from XLXSJGBYZZ3 where XLXSJGBYZZ3_JGBID=:pJGBID and XLXSJGBYZZ3_XSQYID =:pXSQYID and XLXSJGBYZZ3_DTCLID =:pDTCLID and XLXSJGBYZZ3_XLXHID=:pXLXHID and XLXSJGBYZZ3_ZXJM=:pZXJM");
|
||
sql.ParamByName("pJGBID").Value = txtJGBID.Value.Trim();
|
||
sql.ParamByName("pXSQYID").Value = cbxXSQYID.SelectedValue.Trim().Equals("") ? " " : cbxXSQYID.SelectedValue.Trim();
|
||
sql.ParamByName("pDTCLID").Value = cbxDTCLID.SelectedValue.Trim();
|
||
sql.ParamByName("pXLXHID").Value = cbxXLXHID.SelectedValue.Trim().Equals("") ? " " : cbxXLXHID.SelectedValue.Trim();
|
||
sql.ParamByName("pZXJM").Value = txtZXJM.Value;
|
||
DataSet ds = dberp.OpenDataSet(sql);
|
||
|
||
string[] sTJYZList = PageParam.GetRTrimString("TJYZList").Split(',');
|
||
DateTime tNow = DateTime.Now;
|
||
for (int i = 0; i < sTJYZList.Length; i++)
|
||
{
|
||
sql.Clear();
|
||
sql.Add("insert into XLXSJGBYZZ3(XLXSJGBYZZ3_JGBID,XLXSJGBYZZ3_XSQYID,XLXSJGBYZZ3_DTCLID,XLXSJGBYZZ3_XLXHID,XLXSJGBYZZ3_ZXJM,XLXSJGBYZZ3_YZID,XLXSJGBYZZ3_YZZ,XLXSJGBYZZ3_WHR,XLXSJGBYZZ3_WHRID,XLXSJGBYZZ3_WHSJ)");
|
||
sql.Add(" values(:pJGBID,:pXSQYID,:pDTCLID,:pXLXHID,:pZXJM,:pYZID,:pYZZ,:pWHR,:pWHRID,:pWHSJ)");
|
||
sql.ParamByName("pJGBID").Value = txtJGBID.Value.Trim();
|
||
sql.ParamByName("pXSQYID").Value = cbxXSQYID.SelectedValue.Trim().Equals("") ? " " : cbxXSQYID.SelectedValue.Trim();
|
||
sql.ParamByName("pDTCLID").Value = cbxDTCLID.SelectedValue.Trim();
|
||
sql.ParamByName("pXLXHID").Value = cbxXLXHID.SelectedValue.Trim().Equals("") ? " " : cbxXLXHID.SelectedValue.Trim();
|
||
sql.ParamByName("pZXJM").Value = txtZXJM.Value;
|
||
sql.ParamByName("pWHR").Value = tSession.UserName;
|
||
sql.ParamByName("pWHRID").Value = tSession.UserId;
|
||
sql.ParamByName("pWHSJ").Value = tNow;
|
||
|
||
string item = sTJYZList[i];
|
||
|
||
// 检查是否以 "JZ" + 两位数字 + "|" 开头
|
||
if (item.Length >= 5 && item.StartsWith("JZ") && char.IsDigit(item[2]) && char.IsDigit(item[3]) && item[4] == '|')
|
||
{
|
||
string numStr = item.Substring(2, 2); // 提取 "01" ~ "10"
|
||
int index;
|
||
if (int.TryParse(numStr, out index) )
|
||
{
|
||
// 动态构造控件ID(不带前导零)
|
||
gtNumTextBox txt = FindControl("txtTJYZ" + index) as gtNumTextBox;
|
||
if (txt != null)
|
||
{
|
||
sql.ParamByName("pYZID").Value = "JZ" + numStr; // 保持 "JZ01" 格式
|
||
sql.ParamByName("pYZZ").Value = txt.Value;
|
||
dberp.ExecSQL(sql);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
return base.Master_AfterSaveAction(sender, e);
|
||
}
|
||
|
||
protected override void SetComboxItems()
|
||
{
|
||
if (ControlState == TControlState.ctsBrowse)
|
||
{
|
||
TComboBox.SetComboBox("DBERP", cbxXSQYID, string.Format("select XSQY_XSQYID,XSQY_XSQYMC from XSQY where XSQY_XSQYID='{0}' order by XSQY_XSQYID ", cbxXSQYID.SelectedValue.Trim()), false);
|
||
|
||
cbxXLXHID.ClearItems();
|
||
cbxXLXHID.Items.Add(new ListItem(cbxXLXHID.SelectedValue.Trim(), cbxXLXHID.SelectedValue.Trim()));
|
||
}
|
||
else if (ControlState == TControlState.ctsCopy || ControlState == TControlState.ctsInsert || ControlState == TControlState.ctsEdit)
|
||
{
|
||
TComboBox.SetComboBox("DBERP", cbxXSQYID, "select XSQY_XSQYID,XSQY_XSQYMC from XSQY where isnull(XSQY_TYBZ,' ')<>'Y' order by XSQY_XSQYID ", true);
|
||
|
||
TComboBox.SetComboBox("DBERP", cbxXLXHID, string.Format("select XLXHB_XLXHID as ID,XLXHB_XLXHID as Name from XLXHB where isnull(XLXHB_TYBZ,'N')<>'Y' and XLXHB_DTCLID='{0}' order by ID ", cbxDTCLID.SelectedValue.Trim()), true);
|
||
}
|
||
base.SetComboxItems();
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 自定义函数
|
||
|
||
private void InitControls()
|
||
{
|
||
TComboBox.SetComboBox("DBERP", cbxDTCLID, "select XLDTCLB_DTCLID,XLDTCLB_WLMC from XLDTCLB where XLDTCLB_WLID =' ' order by XLDTCLB_DTCLID ", false);
|
||
}
|
||
|
||
private void SetTJYZLable()
|
||
{
|
||
string[] sTJYZList = PageParam.GetRTrimString("TJYZList").Split(',');
|
||
for (int i = 0; i < sTJYZList.Length; i++)
|
||
{
|
||
string item = sTJYZList[i];
|
||
|
||
// 检查格式:以 "JZ" + 两位数字 + "|" 开头
|
||
if (item.Length >= 5 && item.StartsWith("JZ") && char.IsDigit(item[2]) && char.IsDigit(item[3]) && item[4] == '|')
|
||
{
|
||
string numStr = item.Substring(2, 2); // 提取 "01" ~ "10"
|
||
int index;
|
||
if (int.TryParse(numStr, out index))
|
||
{
|
||
// 动态构造控件ID(不带前导零)
|
||
gtLabel lbl = FindControl("lblTJYZ" + index) as gtLabel;
|
||
if (lbl != null)
|
||
{
|
||
// 去掉 "JZxx|" 前缀,加上 ":"
|
||
lbl.Text = item.Substring(5) + ":";
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 控件事件
|
||
|
||
protected void cbxDTCLID_SelectedIndexChanged(object sender, EventArgs e)
|
||
{
|
||
TComboBox.SetComboBox("DBERP", cbxXLXHID, string.Format("select XLXHB_XLXHID as ID,XLXHB_XLXHID as Name from XLXHB where isnull(XLXHB_TYBZ,'N')<>'Y' and XLXHB_DTCLID='{0}' order by ID ", cbxDTCLID.SelectedValue.Trim()), true);
|
||
}
|
||
|
||
#endregion
|
||
}
|
||
}
|