stringcondition=" and GID in ('"+gids.Replace(",","','")+"')";
varresult=newDBResult();
Databasedb=DatabaseFactory.CreateDatabase();
using(varconn=db.CreateConnection())
{
conn.Open();
vartran=conn.BeginTransaction();
try
{
if(ISCOPYYJ=="1")
{
if(sEFFECTIVEDATE!=""&&sVALIDDATE!="")
{
stringsSQL="INSERT INTO [crm_price_carrier_2]([GID],[LOCKFLAG],[ISISSUE],[LANE],[PODLOAD],[PORTDISCHARGEID],[PORTDISCHARGE],[CARRIER],[VIA],[VIA2],[ETD],[TT],[EFFECTIVEDATE],[VALIDDATE],[COMMODITY],[REMARK],[INPUTBY],[INPUTTIME],[MODIFIEDUSER],[MODIFYTIME],[FEE0],[FEE1],[FEE2],[FEE3],[FEE4],[CTN00],[CTN10],[CTN20],[CTN30],[CTN40],[CTN50],[CTN60],[CTN70],[CTN80],[CTN90],[CTN01],[CTN11],[CTN21],[CTN31],[CTN41],[CTN51],[CTN61],[CTN71],[CTN81],[CTN91],[CTN02],[CTN12],[CTN22],[CTN32],[CTN42],[CTN52],[CTN62],[CTN72],[CTN82],[CTN92],[CTN03],[CTN13],[CTN23],[CTN33],[CTN43],[CTN53],[CTN63],[CTN73],[CTN83],[CTN93],[CTN04],[CTN14],[CTN24],[CTN34],[CTN44],[CTN54],[CTN64],[CTN74],[CTN84],[CTN94])"
+"select newid() as [GID],0 as [LOCKFLAG],0 as [ISISSUE],[LANE],[PODLOAD],[PORTDISCHARGEID],[PORTDISCHARGE],[CARRIER],[VIA],[VIA2],[ETD],[TT],'"+sEFFECTIVEDATE+"' as [EFFECTIVEDATE],'"+sVALIDDATE+"' as [VALIDDATE],[COMMODITY],[REMARK],'"+userid+"' as [INPUTBY],getdate() as [INPUTTIME],'"+userid+"' as [MODIFIEDUSER],getdate() as [MODIFYTIME],[FEE0],[FEE1],[FEE2],[FEE3],[FEE4],[CTN00],[CTN10],[CTN20],[CTN30],[CTN40],[CTN50],[CTN60],[CTN70],[CTN80],[CTN90],[CTN01],[CTN11],[CTN21],[CTN31],[CTN41],[CTN51],[CTN61],[CTN71],[CTN81],[CTN91],[CTN02],[CTN12],[CTN22],[CTN32],[CTN42],[CTN52],[CTN62],[CTN72],[CTN82],[CTN92],[CTN03],[CTN13],[CTN23],[CTN33],[CTN43],[CTN53],[CTN63],[CTN73],[CTN83],[CTN93],[CTN04],[CTN14],[CTN24],[CTN34],[CTN44],[CTN54],[CTN64],[CTN74],[CTN84],[CTN94]"
+" from crm_price_carrier_2 where 1=1"+condition;
varcmdDelete=db.GetSqlStringCommand(sSQL);
db.ExecuteNonQuery(cmdDelete,tran);
}
else
{
stringsSQL="INSERT INTO [crm_price_carrier_2]([GID],[LOCKFLAG],[ISISSUE],[LANE],[PODLOAD],[PORTDISCHARGEID],[PORTDISCHARGE],[CARRIER],[VIA],[VIA2],[ETD],[TT],[EFFECTIVEDATE],[VALIDDATE],[COMMODITY],[REMARK],[INPUTBY],[INPUTTIME],[MODIFIEDUSER],[MODIFYTIME],[FEE0],[FEE1],[FEE2],[FEE3],[FEE4],[CTN00],[CTN10],[CTN20],[CTN30],[CTN40],[CTN50],[CTN60],[CTN70],[CTN80],[CTN90],[CTN01],[CTN11],[CTN21],[CTN31],[CTN41],[CTN51],[CTN61],[CTN71],[CTN81],[CTN91],[CTN02],[CTN12],[CTN22],[CTN32],[CTN42],[CTN52],[CTN62],[CTN72],[CTN82],[CTN92],[CTN03],[CTN13],[CTN23],[CTN33],[CTN43],[CTN53],[CTN63],[CTN73],[CTN83],[CTN93],[CTN04],[CTN14],[CTN24],[CTN34],[CTN44],[CTN54],[CTN64],[CTN74],[CTN84],[CTN94])"
+"select newid() as [GID],0 as [LOCKFLAG],0 as [ISISSUE],[LANE],[PODLOAD],[PORTDISCHARGEID],[PORTDISCHARGE],[CARRIER],[VIA],[VIA2],[ETD],[TT],[EFFECTIVEDATE],[VALIDDATE],[COMMODITY],[REMARK],'"+userid+"' as [INPUTBY],getdate() as [INPUTTIME],'"+userid+"' as [MODIFIEDUSER],getdate() as [MODIFYTIME],[FEE0],[FEE1],[FEE2],[FEE3],[FEE4],[CTN00],[CTN10],[CTN20],[CTN30],[CTN40],[CTN50],[CTN60],[CTN70],[CTN80],[CTN90],[CTN01],[CTN11],[CTN21],[CTN31],[CTN41],[CTN51],[CTN61],[CTN71],[CTN81],[CTN91],[CTN02],[CTN12],[CTN22],[CTN32],[CTN42],[CTN52],[CTN62],[CTN72],[CTN82],[CTN92],[CTN03],[CTN13],[CTN23],[CTN33],[CTN43],[CTN53],[CTN63],[CTN73],[CTN83],[CTN93],[CTN04],[CTN14],[CTN24],[CTN34],[CTN44],[CTN54],[CTN64],[CTN74],[CTN84],[CTN94]"
+" from crm_price_carrier_2 where 1=1"+condition;
varcmdDelete=db.GetSqlStringCommand(sSQL);
db.ExecuteNonQuery(cmdDelete,tran);
}
}
else{
if(sEFFECTIVEDATE!=""&&sVALIDDATE!="")
{
stringsSQL="INSERT INTO [crm_price_carrier_2]([GID],[LOCKFLAG],[ISISSUE],[LANE],[PODLOAD],[PORTDISCHARGEID],[PORTDISCHARGE],[CARRIER],[VIA],[VIA2],[ETD],[TT],[EFFECTIVEDATE],[VALIDDATE],[COMMODITY],[REMARK],[INPUTBY],[INPUTTIME],[MODIFIEDUSER],[MODIFYTIME],[FEE0],[FEE1],[FEE2],[FEE3],[FEE4],[CTN00],[CTN10],[CTN20],[CTN30],[CTN40],[CTN50],[CTN60],[CTN70],[CTN80],[CTN90],[CTN01],[CTN11],[CTN21],[CTN31],[CTN41],[CTN51],[CTN61],[CTN71],[CTN81],[CTN91],[CTN02],[CTN12],[CTN22],[CTN32],[CTN42],[CTN52],[CTN62],[CTN72],[CTN82],[CTN92],[CTN03],[CTN13],[CTN23],[CTN33],[CTN43],[CTN53],[CTN63],[CTN73],[CTN83],[CTN93],[CTN04],[CTN14],[CTN24],[CTN34],[CTN44],[CTN54],[CTN64],[CTN74],[CTN84],[CTN94])"
+"select newid() as [GID],0 as [LOCKFLAG],0 as [ISISSUE],[LANE],[PODLOAD],[PORTDISCHARGEID],[PORTDISCHARGE],[CARRIER],[VIA],[VIA2],[ETD],[TT],'"+sEFFECTIVEDATE+"' as [EFFECTIVEDATE],'"+sVALIDDATE+"' as [VALIDDATE],[COMMODITY],[REMARK],'"+userid+"' as [INPUTBY],getdate() as [INPUTTIME],'"+userid+"' as [MODIFIEDUSER],getdate() as [MODIFYTIME],[FEE0],[FEE1],[FEE2],[FEE3],[FEE4],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0"
+" from crm_price_carrier_2 where 1=1"+condition;
varcmdDelete=db.GetSqlStringCommand(sSQL);
db.ExecuteNonQuery(cmdDelete,tran);
}
else
{
stringsSQL="INSERT INTO [crm_price_carrier_2]([GID],[LOCKFLAG],[ISISSUE],[LANE],[PODLOAD],[PORTDISCHARGEID],[PORTDISCHARGE],[CARRIER],[VIA],[VIA2],[ETD],[TT],[EFFECTIVEDATE],[VALIDDATE],[COMMODITY],[REMARK],[INPUTBY],[INPUTTIME],[MODIFIEDUSER],[MODIFYTIME],[FEE0],[FEE1],[FEE2],[FEE3],[FEE4],[CTN00],[CTN10],[CTN20],[CTN30],[CTN40],[CTN50],[CTN60],[CTN70],[CTN80],[CTN90],[CTN01],[CTN11],[CTN21],[CTN31],[CTN41],[CTN51],[CTN61],[CTN71],[CTN81],[CTN91],[CTN02],[CTN12],[CTN22],[CTN32],[CTN42],[CTN52],[CTN62],[CTN72],[CTN82],[CTN92],[CTN03],[CTN13],[CTN23],[CTN33],[CTN43],[CTN53],[CTN63],[CTN73],[CTN83],[CTN93],[CTN04],[CTN14],[CTN24],[CTN34],[CTN44],[CTN54],[CTN64],[CTN74],[CTN84],[CTN94])"
+"select newid() as [GID],0 as [LOCKFLAG],0 as [ISISSUE],[LANE],[PODLOAD],[PORTDISCHARGEID],[PORTDISCHARGE],[CARRIER],[VIA],[VIA2],[ETD],[TT],[EFFECTIVEDATE],[VALIDDATE],[COMMODITY],[REMARK],'"+userid+"' as [INPUTBY],getdate() as [INPUTTIME],'"+userid+"' as [MODIFIEDUSER],getdate() as [MODIFYTIME],[FEE0],[FEE1],[FEE2],[FEE3],[FEE4],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0"
varsGids=" and GID in ('"+gids.Replace(",","','")+"')";
varsLINKGID=" and LINKGID in ('"+gids.Replace(",","','")+"')";
varresult=newDBResult();
//T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
//string sSQL = "select name from syscolumns where id=object_id('crm_price_carrier_2') and ([name] like 'CTN%')";//[name] like 'FEE%' or
//DataSet ds = T_ALL_DA.GetAllSQL(sSQL);
//
Databasedb=DatabaseFactory.CreateDatabase();
using(varconn=db.CreateConnection())
{
conn.Open();
vartran=conn.BeginTransaction();
try
{
//插入运价的修改次数
//if (ds != null)
//{
// if (ds.Tables[0].Rows.Count > 0)
// {
// for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
// {
// var cmdSQL2 = db.GetSqlStringCommand("INSERT INTO [crm_price_carrier_detail]([GID],[LINKGID],[FIELDNAME],[FIELDTYPE],[FIELDCONTENT],[MODIFIEDUSER],[MODIFYTIME]) "
// + " select newid() as GID,LINKGID,FIELDNAME,FIELDTYPE,FIELDCONTENT=(select top 1 [" + ds.Tables[0].Rows[i]["name"].ToString() + "] from crm_price_carrier_2 where gid=crm_price_carrier_detail.LINKGID),'" + userid + "' as [MODIFIEDUSER],getdate() as [MODIFYTIME] from crm_price_carrier_detail "
// + " where FIELDTYPE=2 and FIELDNAME='" + ds.Tables[0].Rows[i]["name"].ToString() + "' and FIELDCONTENT<>isnull((select top 1 [" + ds.Tables[0].Rows[i]["name"].ToString() + "] from crm_price_carrier_2 where gid=crm_price_carrier_detail.LINKGID),0) and gid in (select top 1 gid from crm_price_carrier_detail as a where FIELDNAME='" + ds.Tables[0].Rows[i]["name"].ToString() + "' and FIELDTYPE=2 and a.LINKGID=crm_price_carrier_detail.LINKGID order by MODIFYTIME desc ) " + sLINKGID);
// db.ExecuteNonQuery(cmdSQL2, tran);
// }
// for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
// {
// var cmdSQL2 = db.GetSqlStringCommand("INSERT INTO [crm_price_carrier_detail]([GID],[LINKGID],[FIELDNAME],[FIELDTYPE],[FIELDCONTENT],[MODIFIEDUSER],[MODIFYTIME])"
// + " select newid() as GID,GID as LINKGID,'" + ds.Tables[0].Rows[i]["name"].ToString() + "' as FIELDNAME,2 as FIELDTYPE,[" + ds.Tables[0].Rows[i]["name"].ToString() + "] as FIELDCONTENT,'" + userid + "' as [MODIFIEDUSER],getdate() as [MODIFYTIME]"
// + " from crm_price_carrier_2"
// + " where LOCKFLAG=0 and ISISSUE=0 and gid not in (select linkgid from crm_price_carrier_detail where FIELDNAME='" + ds.Tables[0].Rows[i]["name"].ToString() + "' and FIELDTYPE=2) " + sGids);
// db.ExecuteNonQuery(cmdSQL2, tran);
// }
// }
//}
varcmdSQL=db.GetSqlStringCommand("update crm_price_carrier_2 set LOCKFLAG=1 where LOCKFLAG=0 and ISISSUE=0"+sGids);
varsLINKGID=" and LINKGID in (select gid from crm_price_carrier_2 where LOCKFLAG=0 and ISISSUE=0)";
//T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
//string sSQL = "select name from syscolumns where id=object_id('crm_price_carrier_2') and ([name] like 'CTN%')";//[name] like 'FEE%' or
//DataSet ds = T_ALL_DA.GetAllSQL(sSQL);
//
varresult=newDBResult();
Databasedb=DatabaseFactory.CreateDatabase();
using(varconn=db.CreateConnection())
{
conn.Open();
vartran=conn.BeginTransaction();
try
{
//插入运价的修改次数
//if (ds != null)
//{
// if (ds.Tables[0].Rows.Count > 0)
// {
// for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
// {
// var cmdSQL2 = db.GetSqlStringCommand("INSERT INTO [crm_price_carrier_detail]([GID],[LINKGID],[FIELDNAME],[FIELDTYPE],[FIELDCONTENT],[MODIFIEDUSER],[MODIFYTIME]) "
// + " select newid() as GID,LINKGID,FIELDNAME,FIELDTYPE,FIELDCONTENT=(select top 1 [" + ds.Tables[0].Rows[i]["name"].ToString() + "] from crm_price_carrier_2 where gid=crm_price_carrier_detail.LINKGID),'" + userid + "' as [MODIFIEDUSER],getdate() as [MODIFYTIME]"
// + " from crm_price_carrier_detail "
// + " where FIELDTYPE=2 and FIELDNAME='" + ds.Tables[0].Rows[i]["name"].ToString() + "' and FIELDCONTENT<>isnull((select top 1 [" + ds.Tables[0].Rows[i]["name"].ToString() + "] from crm_price_carrier_2 where gid=crm_price_carrier_detail.LINKGID),0) and gid in (select top 1 gid from crm_price_carrier_detail as a where FIELDNAME='" + ds.Tables[0].Rows[i]["name"].ToString() + "' and FIELDTYPE=2 and a.LINKGID=crm_price_carrier_detail.LINKGID order by MODIFYTIME desc ) " + sLINKGID);
// db.ExecuteNonQuery(cmdSQL2, tran);
// }
// for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
// {
// var cmdSQL2 = db.GetSqlStringCommand("INSERT INTO [crm_price_carrier_detail]([GID],[LINKGID],[FIELDNAME],[FIELDTYPE],[FIELDCONTENT],[MODIFIEDUSER],[MODIFYTIME])"
// + " select newid() as GID,GID as LINKGID,'" + ds.Tables[0].Rows[i]["name"].ToString() + "' as FIELDNAME,2 as FIELDTYPE,[" + ds.Tables[0].Rows[i]["name"].ToString() + "] as FIELDCONTENT,'" + userid + "' as [MODIFIEDUSER],getdate() as [MODIFYTIME]"
// + " from crm_price_carrier_2"
// + " where LOCKFLAG=0 and ISISSUE=0 and gid not in (select linkgid from crm_price_carrier_detail where FIELDNAME='" + ds.Tables[0].Rows[i]["name"].ToString() + "' and FIELDTYPE=2) ");
// db.ExecuteNonQuery(cmdSQL2, tran);
// }
// }
//}
varcmdDelete=db.GetSqlStringCommand("update crm_price_carrier_2 set LOCKFLAG=1 where LOCKFLAG=0 and ISISSUE=0");
varsGids=" and LINKGID in ('"+gids.Replace(",","','")+"')";
varsGids2=" and GID in ('"+gids.Replace(",","','")+"')";
varresult=newDBResult();
Databasedb=DatabaseFactory.CreateDatabase();
using(varconn=db.CreateConnection())
{
conn.Open();
vartran=conn.BeginTransaction();
try
{
varcmdSQL=db.GetSqlStringCommand("delete crm_price_carrier_detail where FIELDNAME='"+sFIELDNAME+"' and FIELDTYPE="+iFIELDTYPE+sGids);//
db.ExecuteNonQuery(cmdSQL,tran);
cmdSQL=db.GetSqlStringCommand("INSERT INTO [crm_price_carrier_detail]([GID],[LINKGID],[FIELDNAME],[FIELDTYPE],[FIELDCONTENT],[MODIFIEDUSER],[MODIFYTIME]) select newid() as GID,GID as LINKGID,'"+sFIELDNAME+"' as FIELDNAME,"+iFIELDTYPE+" as FIELDTYPE,(case when "+iFIELDTYPE+"=1 then isnull((select top 1 ENUMVALUEID from tSysEnumValue where ENUMTYPEID=97054 and ENUMVALUENAME='"+sFIELDCONTENT+"'),'"+sFIELDCONTENT+"') else '"+sFIELDCONTENT+"' end) as FIELDCONTENT,'"+userid+"',getdate() as [MODIFYTIME] from crm_price_carrier_2 where 1=1"+sGids2);
strSql.Append("select newid() as [GID],[LINKGID],[FIELDNAME],2 as [FIELDTYPE],'' as [FIELDCONTENT],'' as [MODIFIEDUSER],getdate() as [MODIFYTIME],COUNT(*) as hj from [crm_price_carrier_detail] where FIELDTYPE=2 and LINKGID in (select gid from [crm_price_carrier_2] where 1=1");
if(!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" and "+strCondition);
}
strSql.Append(")");
strSql.Append(" group by LINKGID,FIELDNAME order by LINKGID,FIELDNAME");
strSql.Append("select [EnumValueID] as [VALUE],[EnumValueName] as [NAME],([EnumValueID] + ' | ' + [EnumValueName]) as CodeAndName from [tSysEnumValue] where [ENUMTYPEID]=97053 and [EnumValueName] is not null and [EnumValueName]<>'' and [EnumValueName]<>' ' order by [DispIndex]");
returnSetXiaLaKuang(strSql,false);
}
#endregion
#region 取集装箱权限_循环列
staticpublicList<XiaLaKuangModel>GetCtn()
{
varstrSql=newStringBuilder();
strSql.Append("select [EnumValueID] as [VALUE],[EnumValueName] as [NAME],([EnumValueID] + ' | ' + [EnumValueName]) as CodeAndName from [tSysEnumValue] where [ENUMTYPEID]=97051 and [EnumValueName] is not null and [EnumValueName]<>'' and [EnumValueName]<>' ' order by [DispIndex]");
returnSetXiaLaKuang(strSql,false);
}
#endregion
#region 取报价权限_循环列
staticpublicList<XiaLaKuangModel>GetBaoJia()
{
varstrSql=newStringBuilder();
strSql.Append("select [EnumValueID] as [VALUE],[EnumValueName] as [NAME],([EnumValueID] + ' | ' + [EnumValueName]) as CodeAndName from [tSysEnumValue] where [ENUMTYPEID]=97052 and [EnumValueName] is not null and [EnumValueName]<>'' and [EnumValueName]<>' ' order by [DispIndex]");
strSql.Append("select [EnumValueID] as [VALUE],[EnumValueName] as [NAME],([EnumValueID] + ' | ' + [EnumValueName]) as CodeAndName from [tSysEnumValue] where [ENUMTYPEID]=97052 and EnumValueName_2='true' and [EnumValueName] is not null and [EnumValueName]<>'' and [EnumValueName]<>' ' order by [DispIndex]");
returnSetXiaLaKuang(strSql,false);
}
#endregion
#region 启运港,国内港口_下拉框
staticpublicList<XiaLaKuangModel>GetPODLOADList()
{
varstrSql=newStringBuilder();
strSql.Append("SELECT distinct [PODLOAD] as [VALUE],[PODLOAD] as [NAME],[PODLOAD] as CodeAndName FROM [crm_price_carrier_2] order by [PODLOAD]");
strSql.Append("select distinct [PORTDISCHARGEID] as [VALUE],[PORTDISCHARGE] as [NAME],([PORTDISCHARGEID] + ' | ' + [PORTDISCHARGE]) as CodeAndName from [crm_price_carrier_2] ");
if(CODENAME!=""){
strSql.Append(" WHERE PORTDISCHARGEID like '%"+CODENAME+"%' OR PORTDISCHARGE like '%"+CODENAME+"%' ");
}
strSql.Append(" order by [PORTDISCHARGEID],[PORTDISCHARGE]");
returnSetXiaLaKuang(strSql,true);
}
#endregion
#region 中转港,国外港口_下拉框
staticpublicList<XiaLaKuangModel>GetVIAList()
{
varstrSql=newStringBuilder();
strSql.Append("select distinct [VIA] as [VALUE],[VIA] as [NAME],[VIA] as CodeAndName from [crm_price_carrier_2] group by [VIA] order by [VIA]");
returnSetXiaLaKuang(strSql,true);
}
#endregion
#region 船公司_下拉框
staticpublicList<XiaLaKuangModel>GetCARRIERList()
{
varstrSql=newStringBuilder();
strSql.Append("select distinct [CARRIER] as [VALUE],[CARRIER] as [NAME],[CARRIER] as CodeAndName from [crm_price_carrier_2] group by [CARRIER] order by [CARRIER]");