451 lines
18 KiB
C#
451 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_MODEL.Page;
|
|
using GThinking.N_MISPRO.Data;
|
|
using GThinking.N_PUBLIC;
|
|
using System.Text;
|
|
using GThinking.N_MISPRO.Utility;
|
|
using GThinking.N_CONTROL;
|
|
using GThinking.N_MISPRO.TableCache;
|
|
|
|
|
|
|
|
namespace GThinking.N_XLXSBJ
|
|
{
|
|
public partial class TZYZJJCList : SingleGridBase
|
|
{
|
|
TZYZJJC entity = new TZYZJJC();
|
|
TZYZJJC_M qryEntity = new TZYZJJC_M();
|
|
DataSet dsTJYSA = new DataSet();
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
this.UMID = 100860166;
|
|
this.UMName = "按产品特性调表价";
|
|
this.CurMaster = Master;
|
|
this.ModuleGV = ContentGrid;
|
|
this.CurEntity = entity;
|
|
this.CurQueryEntity = qryEntity;
|
|
this.sURLTarget = "TZYZJJCInfo.aspx";
|
|
this.sQueryURLTarget = "TZYZJJCQuery.aspx";
|
|
this.PageHeight = 600;
|
|
this.PageWidth = 750;
|
|
|
|
base.DataKeyNames = new string[] { "XLXSJGBYZZC_JGBID", "XLXSJGBYZZC_CPTX", "minYZID" };
|
|
|
|
ContentGrid.FindColumnByFieldName("XLXSJGBYZZC_JGBID").Visible = false;
|
|
|
|
if (!IsPostBack)
|
|
{
|
|
if (!PageParam.GetRTrimString("JGBID").Equals(""))
|
|
CurQueryEntity.FieldByName("JGBID").Value = PageParam.GetRTrimString("JGBID");
|
|
else
|
|
CurQueryEntity.FieldByName("JGBID").Value = GetDefaultJGBID();
|
|
}
|
|
|
|
|
|
CanDeleteCheckedRows = true;
|
|
base.InitPage();
|
|
|
|
InitControl();
|
|
if (!IsPostBack)
|
|
{
|
|
if (!PageParam.GetRTrimString("JGBID").Equals(""))
|
|
Master_OnStandardQuery(null, null);
|
|
else
|
|
{
|
|
if (IsDefaultExecute)
|
|
Master_OnStandardQuery(null, null);
|
|
else
|
|
{
|
|
|
|
this.Master.StandardNewButton.OnClientClick = "alert('请先查询调价表!');";
|
|
this.Master.StandardCopyButton.OnClientClick = "alert('请先查询调价表!');";
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
#region 模板事件继承
|
|
protected override void Master_OnStandardQuery(object sender, EventArgs e)
|
|
{
|
|
entity.EntityTable.QuerySelSql = GetSQL();
|
|
base.Master_OnStandardQuery(sender, e);
|
|
entity.GridDataBind(ContentGrid, tSession);
|
|
|
|
if (CurQueryEntity.FieldByName("JGBID").Value.Trim().Equals(""))
|
|
{
|
|
this.Master.StandardNewButton.OnClientClick = "alert('请先查询调价表!');";
|
|
this.Master.StandardCopyButton.OnClientClick = "alert('请先查询调价表!');";
|
|
}
|
|
else
|
|
{
|
|
this.Master.StandardNewButton.OnClientClick = "OpenCardForm('INSERT');return false;";
|
|
this.Master.StandardCopyButton.OnClientClick = "OpenCardForm('COPY');return false;";
|
|
}
|
|
TPageParams pageParams = new TPageParams();
|
|
pageParams.AddString("XLXSJGBYZZC_JGBID", CurQueryEntity.FieldByName("JGBID").Value.Trim());
|
|
pageParams.AddString("TJYZList", txtTJYZList.Value.Trim());
|
|
pageParams.AddString("FirstYZID", txtFirstYZID.Value.Trim());
|
|
SetNewFormParam(pageParams);
|
|
}
|
|
|
|
protected override void BeforeDelete(TDatabase db, ref bool ActionIsDone)
|
|
{
|
|
string sYZIDlist = TZYZBJAInfo.GetYZIDList(txtTJYZList.Value.Trim());
|
|
entity.EntityTable.DeleteSql = " delete from XLXSJGBYZZC where XLXSJGBYZZC_JGBID=:XLXSJGBYZZC_JGBID and XLXSJGBYZZC_CPTX =:XLXSJGBYZZC_CPTX and "
|
|
+ CMISproDataBase.GetWhereEqual("XLXSJGBYZZC_YZID", sYZIDlist);
|
|
entity.Param.Add("XLXSJGBYZZC_JGBID", this.ContentGrid.SelectedDataKey["XLXSJGBYZZC_JGBID"].ToString().Trim());
|
|
entity.Param.Add("XLXSJGBYZZC_CPTX", this.ContentGrid.SelectedDataKey["XLXSJGBYZZC_CPTX"].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(ContentGrid, tSession);
|
|
ContentGrid.SelectedIndex = -1;
|
|
return true;
|
|
}
|
|
|
|
protected override void moduleGV_PageIndexChanging(object sender, GridViewPageEventArgs e)
|
|
{
|
|
entity.EntityTable.QuerySelSql = GetSQL();
|
|
ContentGrid.SelectedIndex = -1;
|
|
|
|
base.moduleGV_PageIndexChanging(sender, e);
|
|
}
|
|
|
|
protected override void moduleGV_RowDataBound(object sender, GridViewRowEventArgs e)
|
|
{
|
|
if (e.Row.RowType == DataControlRowType.DataRow)
|
|
{
|
|
LinkPageParam.AddString("XLXSJGBYZZC_JGBID", ContentGrid.DataKeys[e.Row.RowIndex]["XLXSJGBYZZC_JGBID"].ToString().Trim());
|
|
LinkPageParam.AddString("XLXSJGBYZZC_CPTX", ContentGrid.DataKeys[e.Row.RowIndex]["XLXSJGBYZZC_CPTX"].ToString().Trim());
|
|
LinkPageParam.AddString("XLXSJGBYZZC_YZID", ContentGrid.DataKeys[e.Row.RowIndex]["minYZID"].ToString().Trim());
|
|
LinkPageParam.AddString("TJYZList", txtTJYZList.Value.Trim());
|
|
}
|
|
|
|
base.moduleGV_RowDataBound(sender, e);
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#region 自定义函数
|
|
private void InitControl()
|
|
{
|
|
|
|
}
|
|
|
|
private bool XSWHR()
|
|
{
|
|
if (!PageParam.GetRTrimString("TJYZID").Equals("") && (!PageParam.GetRTrimString("TJYZID").Contains(",")) && string.IsNullOrEmpty(PageParam.GetRTrimString("SQDH")))
|
|
return true;
|
|
return false;
|
|
}
|
|
|
|
//判断模块是否存在并且是否有权限
|
|
private bool CheckModule(string sUMID)
|
|
{
|
|
int iUMID = CMISproConvert.StrToInt(sUMID);
|
|
UserRight UR = OpRightUtils.GetUserRight(tSession.UserId, iUMID);
|
|
return (DSActiveModule.IsActiveModule(iUMID) && UR.Open);
|
|
}
|
|
|
|
private string GetSQL()
|
|
{
|
|
base.InitEntityByCondition();
|
|
InitGridView();
|
|
string sYZIDlist = TZYZBJAInfo.GetYZIDList(txtTJYZList.Value.Trim());
|
|
StringBuilder sSQL = new StringBuilder();
|
|
sSQL.AppendLine("select :pJGBID as XLXSJGBYZZC_JGBID,XLXSJGBYZZC_CPTX ");
|
|
sSQL.AppendLine(" ,minYZID");
|
|
if (XSWHR())
|
|
{
|
|
sSQL.AppendLine(" , WHR, WHSJ ");
|
|
}
|
|
else
|
|
{
|
|
sSQL.AppendLine(" ,' ' as WHR, ' ' as WHSJ ");
|
|
}
|
|
for (int i = 0; i < dsTJYSA.Tables[0].Rows.Count; i++)
|
|
{
|
|
sSQL.AppendLine(string.Format(",TZYZ_{0}", dsTJYSA.Tables[0].Rows[i][0].ToString().Trim()));
|
|
}
|
|
sSQL.AppendLine(" from ");
|
|
sSQL.AppendLine(" ( ");
|
|
sSQL.AppendLine(" select XLXSJGBYZZC_CPTX,min(XLXSJGBYZZC_YZID) as minYZID ");
|
|
if (XSWHR())
|
|
{
|
|
sSQL.AppendLine(" ,WHR,WHSJ ");
|
|
}
|
|
for (int i = 0; i < dsTJYSA.Tables[0].Rows.Count; i++)
|
|
{
|
|
sSQL.AppendLine(string.Format(",sum(CASE XLXSJGBYZZC_YZID WHEN '{0}' THEN XLXSJGBYZZC_YZZ ELSE 0 END) as TZYZ_{0}", dsTJYSA.Tables[0].Rows[i][0].ToString().Trim()));
|
|
}
|
|
sSQL.AppendLine(" from ");
|
|
sSQL.AppendLine(" (");
|
|
sSQL.AppendLine(" select distinct XLXSJGBYZZC_CPTX,XLXSJGBYZZC_YZID,XLXSJGBYZZC_YZZ");
|
|
if (XSWHR())
|
|
{
|
|
sSQL.AppendLine(" ,XLXSJGBYZZC_WHR as WHR,XLXSJGBYZZC_WHSJ as WHSJ ");
|
|
}
|
|
|
|
sSQL.AppendLine(" from XLXSJGBYZZC YZZ1");
|
|
if (string.IsNullOrEmpty(CurQueryEntity.FieldByName("JGBID").Value.Trim()))
|
|
{
|
|
sSQL.AppendLine(" where 1<>1 ");
|
|
}
|
|
else
|
|
{
|
|
sSQL.AppendLine(" where YZZ1.XLXSJGBYZZC_JGBID = :pJGBID ");
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(CurQueryEntity.FieldByName("CPTX").Value.Trim()))
|
|
{
|
|
sSQL.AppendLine(" and YZZ1.XLXSJGBYZZC_CPTX = :pCPTX ");
|
|
entity.Param.Add("pCPTX", CurQueryEntity.FieldByName("CPTX").Value.Trim());
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(sYZIDlist))
|
|
{
|
|
sSQL.AppendLine(" and " + CMISproDataBase.GetWhereEqual("YZZ1.XLXSJGBYZZC_YZID", sYZIDlist));
|
|
}
|
|
sSQL.AppendLine(" ) tmp");
|
|
sSQL.AppendLine(" group by XLXSJGBYZZC_CPTX ");
|
|
if (XSWHR())
|
|
{
|
|
sSQL.AppendLine(" , WHR, WHSJ ");
|
|
}
|
|
sSQL.AppendLine(" ) a ");
|
|
sSQL.AppendLine(" where 1=1 ");
|
|
sSQL.AppendLine(" order by XLXSJGBYZZC_CPTX ");
|
|
entity.Param.Add("pJGBID", CurQueryEntity.FieldByName("JGBID").Value.Trim());
|
|
return sSQL.ToString();
|
|
}
|
|
|
|
private void InitGridView()
|
|
{
|
|
TDatabase dberp = TContextDatabases.GetDatabase("DBERP");
|
|
TSQL SQL = new TSQL(dberp);
|
|
|
|
SQL.Clear();
|
|
SQL.Add("select XLXSTZYZ_YZID, XLXSTZYZ_YZMC, XLXSTZYZ_JJFS ");
|
|
SQL.Add(" from XLXSTZYZ");
|
|
SQL.Add(" where XLXSTZYZ_MXBH = 'JZJ' and XLXSTZYZ_TJYS='C' ");
|
|
SQL.Add(" and XLXSTZYZ_JGBID = :pJGBID");
|
|
if (!string.IsNullOrEmpty(PageParam.GetRTrimString("TJYZID")))
|
|
{
|
|
SQL.Add(" and " + CMISproDataBase.GetWhereEqual("XLXSTZYZ_YZID", PageParam.GetRTrimString("TJYZID").Trim()));
|
|
}
|
|
SQL.Add("order by XLXSTZYZ_YZID,XLXSTZYZ_XSXH");
|
|
SQL.ParamByName("pJGBID").Value = CurQueryEntity.FieldByName("JGBID").Value.Trim();
|
|
DataSet ds = dberp.OpenDataSet(SQL);
|
|
dsTJYSA = ds;
|
|
txtTJYZList.Value = "";
|
|
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
|
|
{
|
|
if (i == 0)
|
|
txtFirstYZID.Value = ds.Tables[0].Rows[i]["XLXSTZYZ_YZID"].ToString().Trim();
|
|
|
|
string sJJFSMC = "";
|
|
int iXSWS = 2;
|
|
//加价类型的基价因子小数位数按BJU002设置的来
|
|
if (ds.Tables[0].Rows[i]["XLXSTZYZ_JJFS"].ToString().Trim().Equals("JJ"))
|
|
{
|
|
//iXSWS = CMISproConvert.StrToInt(GetOption("BJU002"));
|
|
iXSWS = 5;
|
|
sJJFSMC = "(元)";
|
|
}
|
|
else if (ds.Tables[0].Rows[i]["XLXSTZYZ_JJFS"].ToString().Trim().Equals("JD") || ds.Tables[0].Rows[i]["XLXSTZYZ_JJFS"].ToString().Trim().Equals("KD"))
|
|
{
|
|
sJJFSMC = "(%)";
|
|
}
|
|
AddColumn("TZYZ_" + ds.Tables[0].Rows[i]["XLXSTZYZ_YZID"].ToString().Trim(), ds.Tables[0].Rows[i]["XLXSTZYZ_YZMC"].ToString().Trim() + sJJFSMC, iXSWS, 80);
|
|
txtTJYZList.Value += ds.Tables[0].Rows[i]["XLXSTZYZ_YZID"].ToString().Trim() + "|" + ds.Tables[0].Rows[i]["XLXSTZYZ_YZMC"].ToString().Trim() + sJJFSMC + ",";
|
|
}
|
|
txtTJYZList.Value = txtTJYZList.Value.TrimEnd(',');
|
|
if (XSWHR())
|
|
{
|
|
AddColumn("WHR", "维护人", 72);
|
|
AddColumn("WHSJ", "维护时间", TDateTimeEditKinds.dtDateTime);
|
|
}
|
|
}
|
|
|
|
private string GetDefaultJGBID()
|
|
{
|
|
TDatabase dberp = TContextDatabases.GetDatabase("DBERP");
|
|
TSQL SQL = new TSQL(dberp);
|
|
SQL.Add("SELECT XLXSJGB_JGBID from XLXSJGB where XLXSJGB_MXBH='JZJ' and XLXSJGB_TJYS='C' order by XLXSJGB_JGBID");
|
|
DataSet ds = dberp.OpenDataSet(SQL);
|
|
if (ds.Tables[0].Rows.Count > 0)
|
|
{
|
|
return ds.Tables[0].Rows[0][0].ToString().Trim();
|
|
}
|
|
else
|
|
return "";
|
|
}
|
|
|
|
public static string GetTJYZMC(string sTJYZID, string sMXBH)
|
|
{
|
|
string sTJYZMC = "";
|
|
TDatabase dberp = TContextDatabases.GetDatabase("DBERP");
|
|
TSQL SQL = new TSQL(dberp);
|
|
SQL.Clear();
|
|
SQL.Add(" select XLXSTZYZ_YZMC from XLXSTZYZ where XLXSTZYZ_MXBH = :pMXBH and XLXSTZYZ_YZID = :pYZID ");
|
|
SQL.ParamByName("pMXBH").Value = sMXBH;
|
|
SQL.ParamByName("pYZID").Value = sTJYZID;
|
|
DataSet ds = dberp.OpenDataSet(SQL);
|
|
if (ds.Tables[0].Rows.Count > 0)
|
|
{
|
|
sTJYZMC = ds.Tables[0].Rows[0]["XLXSTZYZ_YZMC"].ToString().Trim();
|
|
}
|
|
return sTJYZMC;
|
|
}
|
|
|
|
|
|
|
|
private void OpenInfo(TPageCallAction tpCallAction)
|
|
{
|
|
TPageParams LinkPageParam = new TPageParams();
|
|
LinkPageParam.UrlPath = "TZYZJJCInfo.aspx";
|
|
LinkPageParam.AddString("XLXSJGBYZZC_JGBID", ContentGrid.DataKeys[ContentGrid.SelectedIndex]["XLXSJGBYZZC_JGBID"].ToString().Trim());
|
|
LinkPageParam.AddString("XLXSJGBYZZC_CPTX", ContentGrid.DataKeys[ContentGrid.SelectedIndex]["XLXSJGBYZZC_CPTX"].ToString().Trim());
|
|
LinkPageParam.AddString("XLXSJGBYZZC_YZID", ContentGrid.DataKeys[ContentGrid.SelectedIndex]["minYZID"].ToString().Trim());
|
|
LinkPageParam.AddString("TJYZList", txtTJYZList.Value.Trim());
|
|
LinkPageParam.CallAction = tpCallAction;
|
|
OpenDialog(LinkPageParam);
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 控件事件
|
|
|
|
protected void ContentGrid_RowDoubleClick(object sender, GThinking.N_CONTROL.RowDoubleClickEventArgs e)
|
|
{
|
|
OpenInfo(TPageCallAction.pcaBrowse);
|
|
}
|
|
|
|
protected void btnXHTX_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
TPageParams pageParams = new TPageParams();
|
|
pageParams.UrlPath = "XLXHCPTXWHList.aspx";
|
|
OpenDialog(pageParams);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region GridView增加列
|
|
|
|
/// <summary>
|
|
/// 设置etCheckBox列的属性
|
|
/// </summary>
|
|
/// <param name="sDataField"></param>
|
|
/// <param name="HeadText"></param>
|
|
/// <param name="Width"></param>
|
|
/// <param name="CheckBox"></param>
|
|
private void AddColumn(string sDataField, string HeadText, int Width, TEditType CheckBox)
|
|
{
|
|
BoundField Column = new BoundField();
|
|
Column.DataField = sDataField;
|
|
Column.HeaderText = HeadText;
|
|
Column.ItemStyle.Width = (Unit)Width;
|
|
Column.HeaderStyle.Width = (Unit)Width;
|
|
ContentGrid.Columns.Add(Column);
|
|
|
|
gtGridView_Column ColumnEx = new gtGridView_Column();
|
|
ColumnEx.DataField = sDataField;
|
|
ColumnEx.EditType = TEditType.etCheckBox;
|
|
ContentGrid.ColumnsEx.Insert(0, ColumnEx);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设置etString列的属性
|
|
/// </summary>
|
|
/// <param name="sDataField"></param>
|
|
/// <param name="HeadText"></param>
|
|
/// <param name="Width"></param>
|
|
private void AddColumn(string sDataField, string HeadText, int Width)
|
|
{
|
|
BoundField Column = new BoundField();
|
|
Column.DataField = sDataField;
|
|
Column.HeaderText = HeadText;
|
|
Column.ItemStyle.Width = (Unit)Width;
|
|
Column.HeaderStyle.Width = (Unit)Width;
|
|
ContentGrid.Columns.Add(Column);
|
|
|
|
gtGridView_Column ColumnEx = new gtGridView_Column();
|
|
ColumnEx.DataField = sDataField;
|
|
ColumnEx.EditType = TEditType.etString;
|
|
ColumnEx.ShowHint = true;
|
|
ContentGrid.ColumnsEx.Insert(0, ColumnEx);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设置etNumber列的属
|
|
/// </summary>
|
|
/// <param name="sDataField"></param>
|
|
/// <param name="HeadText"></param>
|
|
/// <param name="NumberDecimalPlace"></param>
|
|
/// <param name="Width"></param>
|
|
private void AddColumn(string sDataField, string HeadText, int NumberDecimalPlace, int Width)
|
|
{
|
|
BoundField Column = new BoundField();
|
|
Column.DataField = sDataField;
|
|
Column.HeaderText = HeadText;
|
|
Column.ItemStyle.Width = (Unit)Width;
|
|
Column.HeaderStyle.Width = (Unit)Width;
|
|
Column.ItemStyle.HorizontalAlign = HorizontalAlign.Right;
|
|
ContentGrid.Columns.Add(Column);
|
|
|
|
gtGridView_Column ColumnEx = new gtGridView_Column();
|
|
ColumnEx.DataField = sDataField;
|
|
ColumnEx.EditType = TEditType.etNumber;
|
|
ColumnEx.ShowHint = true;
|
|
ColumnEx.NumberDecimalPlace = NumberDecimalPlace;
|
|
ContentGrid.ColumnsEx.Insert(0, ColumnEx);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设置etDateTime列的属性
|
|
/// </summary>
|
|
/// <param name="sDataField"></param>
|
|
/// <param name="HeadText"></param>
|
|
/// <param name="DateTimeKind"></param>
|
|
/// <param name="Width"></param>
|
|
private void AddColumn(string sDataField, string HeadText, TDateTimeEditKinds DateTimeKind)
|
|
{
|
|
BoundField Column = new BoundField();
|
|
Column.DataField = sDataField;
|
|
Column.HeaderText = HeadText;
|
|
Column.ItemStyle.Width = (Unit)(DateTimeKind == TDateTimeEditKinds.dtDateTime ? 125 : 72);
|
|
Column.HeaderStyle.Width = (Unit)(DateTimeKind == TDateTimeEditKinds.dtDateTime ? 125 : 72);
|
|
ContentGrid.Columns.Add(Column);
|
|
|
|
gtGridView_Column ColumnEx = new gtGridView_Column();
|
|
ColumnEx.DataField = sDataField;
|
|
ColumnEx.EditType = TEditType.etDateTime;
|
|
ColumnEx.DateTimeEditKins = DateTimeKind;
|
|
ContentGrid.ColumnsEx.Insert(0, ColumnEx);
|
|
}
|
|
|
|
|
|
#endregion
|
|
}
|
|
}
|