169 lines
6.0 KiB
C#
169 lines
6.0 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_MODEL.Page;
|
|
using GThinking.N_WORKFLOW;
|
|
using GThinking.N_MISPRO;
|
|
using GThinking.N_MISPRO.Data;
|
|
using GThinking.N_MISPRO.Utility;
|
|
using System.Text;
|
|
using GThinking.N_CONTROL;
|
|
|
|
namespace GThinking.N_XLXSBJ
|
|
{
|
|
public partial class XSBJYWPZ_BJYXXList : SingleGridBase
|
|
{
|
|
XSBJYWPZ_BJYXX entity = new XSBJYWPZ_BJYXX();
|
|
XSBJYWPZ_BJYXX_M queryentity = new XSBJYWPZ_BJYXX_M();
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
this.UMID = 100860062;
|
|
this.UMName = "销售报价业务配置";
|
|
this.CurMaster = Master;
|
|
this.ModuleGV = ContentGrid;
|
|
this.CurEntity = entity;
|
|
this.CurQueryEntity = queryentity;
|
|
this.sQueryURLTarget = "XSBJYWPZ_BJYXXQuery.aspx";
|
|
this.PageHeight = 600;
|
|
this.PageWidth = 750;
|
|
base.DataKeyNames = new string[] { "XM", "BJY" };
|
|
Master.EnableNewBtn = false;
|
|
Master.EnableCopyBtn = false;
|
|
Master.EnableViewBtn = false;
|
|
Master.EnableEditBtn = false;
|
|
Master.EnableDeleteBtn = false;
|
|
|
|
base.InitPage();
|
|
|
|
if (!IsPostBack)
|
|
{
|
|
Master_OnStandardQuery(null, null);
|
|
}
|
|
}
|
|
|
|
#region 模板继承事件
|
|
|
|
protected override void Master_OnStandardQuery(object sender, EventArgs e)
|
|
{
|
|
base.InitEntityByCondition();
|
|
entity.EntityTable.QuerySelSql = GetQuerySql();
|
|
base.Master_OnStandardQuery(sender, e);
|
|
entity.GridDataBind(ContentGrid, tSession);
|
|
ContentGrid.SelectedIndex = -1;
|
|
}
|
|
|
|
protected override void moduleGV_PageIndexChanging(object sender, GridViewPageEventArgs e)
|
|
{
|
|
base.InitEntityByCondition();
|
|
entity.EntityTable.QuerySelSql = GetQuerySql();
|
|
ContentGrid.SelectedIndex = -1;
|
|
base.moduleGV_PageIndexChanging(sender, e);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 自定义函数
|
|
|
|
private string GetQuerySql()
|
|
{
|
|
base.InitEntityByCondition();
|
|
StringBuilder strSql = new StringBuilder();
|
|
strSql.AppendLine(" select a.XM as XM,case when isnull(XLXSBJZDBJYXX_XH,0)>0 then 'Y' else 'N' end as BJY, ");
|
|
strSql.AppendLine(" XLXSBJZDBJYXX_WHR,XLXSBJZDBJYXX_WHRID,XLXSBJZDBJYXX_WHSJ ");
|
|
strSql.AppendLine(" from ( select distinct XLXSBJD_XMMC as XM from XLXSBJD ");
|
|
strSql.AppendLine(" where 1=1 ) a");
|
|
strSql.AppendLine(" left join XLXSBJZDBJYXX on XLXSBJZDBJYXX_XXLX='XM' and XLXSBJZDBJYXX_XXNR=a.XM ");
|
|
strSql.AppendLine(" where isnull(a.XM,' ')<>' ' ");
|
|
|
|
if (!string.IsNullOrEmpty(CurQueryEntity.FieldByName("XM").Value.Trim()))
|
|
{
|
|
strSql.AppendLine(" and a.XM like :XM ");
|
|
entity.Param.Add("XM", "%" + CurQueryEntity.FieldByName("XM").Value.Trim() + "%");
|
|
}
|
|
|
|
strSql.AppendLine(" order by isnull(XLXSBJZDBJYXX_XH,0) desc,a.XM ");
|
|
|
|
|
|
|
|
return strSql.ToString();
|
|
}
|
|
|
|
private double GetMaxXH()
|
|
{
|
|
TDatabase dberp = TContextDatabases.GetDatabase("DBERP");
|
|
TSQL sql = new TSQL(dberp);
|
|
sql.Add("select max(XLXSBJZDBJYXX_XH) as MAXXH from XLXSBJZDBJYXX");
|
|
DataSet ds = dberp.OpenDataSet(sql);
|
|
if (ds.Tables[0].Rows.Count > 0)
|
|
{
|
|
if (string.IsNullOrEmpty(ds.Tables[0].Rows[0][0].ToString().Trim()))
|
|
{
|
|
return 1;
|
|
}
|
|
else
|
|
{
|
|
return CMISproConvert.StrToFloat(ds.Tables[0].Rows[0][0].ToString().Trim()) + 1;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 控件事件
|
|
|
|
protected void ContentGrid_RowDoubleClick(object sender, GThinking.N_CONTROL.RowDoubleClickEventArgs e)
|
|
{
|
|
TDatabase dberp = TContextDatabases.GetDatabase("DBERP");
|
|
TSQL sql = new TSQL(dberp);
|
|
string sBJY = ContentGrid.DataKeys[ContentGrid.SelectedIndex]["BJY"].ToString().Trim();
|
|
|
|
if (sBJY == "N")
|
|
{
|
|
try
|
|
{
|
|
dberp.BeginTrans();
|
|
sql.Clear();
|
|
sql.Add("insert into XLXSBJZDBJYXX(XLXSBJZDBJYXX_XXLX,XLXSBJZDBJYXX_XH,XLXSBJZDBJYXX_XXNR,XLXSBJZDBJYXX_WHR,XLXSBJZDBJYXX_WHRID,XLXSBJZDBJYXX_WHSJ)");
|
|
sql.Add(" values('XM',:pXH,:pXM, :XLXSBJZDBJYXX_WHR, :XLXSBJZDBJYXX_WHRID, :XLXSBJZDBJYXX_WHSJ)");
|
|
sql.ParamByName("pXH").Value = GetMaxXH();
|
|
sql.ParamByName("pXM").Value = ContentGrid.SelectedDataKey["XM"].ToString().Trim();
|
|
sql.ParamByName("XLXSBJZDBJYXX_WHR").Value = tSession.UserName;
|
|
sql.ParamByName("XLXSBJZDBJYXX_WHRID").Value = tSession.UserId;
|
|
sql.ParamByName("XLXSBJZDBJYXX_WHSJ").Value = DateTime.Now;
|
|
dberp.ExecSQL(sql);
|
|
dberp.CommitTrans();
|
|
}
|
|
|
|
catch (Exception ex)
|
|
{
|
|
ShowMessage(ex.Message);
|
|
dberp.RollbackTrans();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
sql.Clear();
|
|
sql.Add("delete from XLXSBJZDBJYXX where XLXSBJZDBJYXX_XXLX='XM'and XLXSBJZDBJYXX_XXNR=:pXM");
|
|
sql.ParamByName("pXM").Value = ContentGrid.SelectedDataKey["XM"].ToString().Trim();
|
|
dberp.ExecSQL(sql);
|
|
}
|
|
moduleGV_PageIndexChanging(null, null);
|
|
FormAreaUpdate();
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|