strSql.Append(",(CASE ORSTATUS WHEN '8' THEN '确认订舱' WHEN '0' THEN '审核通过' WHEN '1' THEN '提交审核' WHEN '2' THEN '驳回' WHEN '4' THEN '退舱' else '录入状态' end) as ORSTATUSREF ");
strSql.Append(",(SELECT CUSTNO FROM V_OP_BILL V WHERE V.BSNO=B.BSNO) as CUSTNO ");
strSql.Append(",(SELECT MBLNO FROM V_OP_BILL V WHERE V.BSNO=B.BSNO) as MBLNOREF,MBLNO,SALEDEPT,BSSOURCE,BSSOURCEDETAIL,(select top 1 sale from info_client where SHORTNAME=B.CUSTOMERNAME) DEFSALE ");
strSql.Append(",(CASE ORSTATUS WHEN '8' THEN '确认订舱' WHEN '0' THEN '审核通过' WHEN '1' THEN '提交审核' WHEN '2' THEN '驳回' WHEN '4' THEN '退舱' else '录入状态' end) as ORSTATUSREF ");
strSql.Append(",(SELECT CUSTNO FROM V_OP_BILL V WHERE V.BSNO=B.BSNO) as CUSTNO ");
strSql.Append(",(SELECT MBLNO FROM V_OP_BILL V WHERE V.BSNO=B.BSNO) as MBLNOREF,MBLNO,SALEDEPT,BSSOURCE,BSSOURCEDETAIL,(select top 1 sale from info_client where SHORTNAME=B.CUSTOMERNAME) DEFSALE ");
strSql.Append(",(CASE ORSTATUS WHEN '8' THEN '确认订舱' WHEN '0' THEN '审核通过' WHEN '1' THEN '提交审核' WHEN '2' THEN '驳回' WHEN '4' THEN '退舱' else '录入状态' end) as ORSTATUSREF ");
strSql.Append(",(SELECT CUSTNO FROM V_OP_BILL V WHERE V.BSNO=B.BSNO) as CUSTNO ");
strSql.Append(",(SELECT MBLNO FROM V_OP_BILL V WHERE V.BSNO=B.BSNO) as MBLNOREF,MBLNO,SALEDEPT,BSSOURCE,BSSOURCEDETAIL,(select top 1 sale from info_client where SHORTNAME=B.CUSTOMERNAME) DEFSALE ");
varcmdInsert=db.GetSqlStringCommand(@"insert into crm_seaeorderctn (CTN_ID,ORDNO,CTNNUM,CTNALL,REMARK) values (newid(),'"+headData.ORDNO+"',"+enumValue.CTNNUM+",'"+enumValue.CTNALL+"','"+enumValue.REMARK+"')");
db.ExecuteNonQuery(cmdInsert,tran);
}
else
{
varcmdUpdate=db.GetSqlStringCommand(@"update crm_seaeorderctn set CTNNUM="+enumValue.CTNNUM+",CTNALL='"+enumValue.CTNALL+"',REMARK='"+enumValue.REMARK+"' where ORDNO='"+enumValue.ORDNO+"' AND CTN_ID='"+enumValue.CTN_ID+"'");
strSql.Append(",(CASE ORSTATUS WHEN '8' THEN '确认订舱' WHEN '0' THEN '审核通过' WHEN '1' THEN '提交审核' WHEN '2' THEN '驳回' WHEN '4' THEN '退舱' else '录入状态' end) as ORSTATUSREF ");
strSql.Append(",(SELECT CUSTNO FROM V_OP_BILL V WHERE V.BSNO=B.BSNO) as CUSTNO ");
strSql.Append(",(SELECT MBLNO FROM V_OP_BILL V WHERE V.BSNO=B.BSNO) as MBLNOREF,SALEDEPT,BSSOURCE,BSSOURCEDETAIL,(select top 1 sale from info_client where SHORTNAME=B.CUSTOMERNAME) DEFSALE ");
varblUpSQL="insert into Op_SeaCover(CID,BSNO,COVERTITLE,COVERCONTEXT,OPERATOR,OPTIME,ISSYS) values(NEWID(),'"+BSNO+"','销售订舱确认','"+headData.REMARK+"','"+OPNAME+"','"+DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")+"','1')";
boolbl=T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
USERID=T_ALL_DA.GetStrSQL("GID","select top 1 GID from [user] where SHOWNAME='"+headData.SALE+"'");
strSql.AppendLine("SELECT top 20 BSNO ORDNO,BSNO,BSSTATUS as ORSTATUS,BLTYPE,BSDATE, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='MBLNO' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then MBLNO else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='MBLNO' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS MBLNO, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='SHIPPER' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then SHIPPER else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='SHIPPER' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS SHIPPER, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='CONSIGNEE' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then CONSIGNEE else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='CONSIGNEE' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS CONSIGNEE, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='NOTIFYPARTY' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then NOTIFYPARTY else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='NOTIFYPARTY' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS NOTIFYPARTY, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='VESSEL' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then VESSEL else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='VESSEL' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS VESSEL, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='VOYNO' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then VOYNO else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='VOYNO' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS VOYNO, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='PlACERECEIPT' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then PlACERECEIPT else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='PlACERECEIPT' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS PlACERECEIPT, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='PORTLOAD' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then PORTLOAD else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='PORTLOAD' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS PORTLOAD, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='PORTDISCHARGE' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then PORTDISCHARGE else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='PORTDISCHARGE' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS PORTDISCHARGE, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='PLACEDELIVERY' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then PLACEDELIVERY else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='PLACEDELIVERY' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS PLACEDELIVERY, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='BLFRT' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then BLFRT else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='BLFRT' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS BLFRT, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='SERVICE' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then [SERVICE] else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='SERVICE' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS [SERVICE], ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='MARKS' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then MARKS else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='MARKS' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS MARKS, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='DESCRIPTION' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then [DESCRIPTION] else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='DESCRIPTION' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS [DESCRIPTION], ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='GOODSNAME' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then GOODSNAME else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='GOODSNAME' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS GOODSNAME, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='GROSSWEIGHT' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then GROSSWEIGHT else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='GROSSWEIGHT' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS GROSSWEIGHT, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='MEASUREMENT' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then MEASUREMENT else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='MEASUREMENT' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS MEASUREMENT, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='PKGS' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then PKGS else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='PKGS' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS PKGS, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='KINDPKGS' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then KINDPKGS else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='KINDPKGS' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS KINDPKGS, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='KGS' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then KGS else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='KGS' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS KGS, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='CBM' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then CBM else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='CBM' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS CBM, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='TOTALNO' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then TOTALNO else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='TOTALNO' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS TOTALNO, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='CNTR' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then CNTR else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='CNTR' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS CNTRTOTAL, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='CARGOID' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then CARGOID else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='CARGOID' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS CARGOID, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='DCLASS' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then DCLASS else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='DCLASS' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS DCLASS, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='DUNNO' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then DUNNO else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='DUNNO' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS DUNNO, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='REEFERF' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then REEFERF else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='REEFERF' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS REEFERF, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='TEMPID' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then TEMPID else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='TEMPID' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS TEMPID, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='TEMPSET' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then TEMPSET else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='TEMPSET' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS TEMPSET, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='BOOKINGDESCRIPTION' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then BOOKINGDESCRIPTION else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='BOOKINGDESCRIPTION' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS REMARK, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='DPAGE' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then DPAGE else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='DPAGE' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS DPAGE, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='DLABEL' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then DLABEL else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='DLABEL' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS DLABEL, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='LINKMAN' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then LINKMAN else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='LINKMAN' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS LINKMAN, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='ISSUEWAY' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then ISSUEWAY else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='ISSUEWAY' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS ISSUETYPE, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='BILLNUM' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then BILLNUM else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='BILLNUM' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS BILLNUM, ");
strSql.AppendLine("(Select name from Company where companyID=B.companyID) as CUSTOMERNAME, ");
strSql.Append("SELECT top 50 BSNO ORDNO,BSNO,BSSTATUS as ORSTATUS,BLTYPE,BSDATE, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='MBLNO' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then MBLNO else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='MBLNO' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS MBLNO, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='SHIPPER' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then SHIPPER else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='SHIPPER' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS SHIPPER, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='CONSIGNEE' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then CONSIGNEE else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='CONSIGNEE' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS CONSIGNEE, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='NOTIFYPARTY' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then NOTIFYPARTY else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='NOTIFYPARTY' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS NOTIFYPARTY, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='VESSEL' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then VESSEL else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='VESSEL' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS VESSEL, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='VOYNO' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then VOYNO else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='VOYNO' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS VOYNO, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='PlACERECEIPT' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then PlACERECEIPT else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='PlACERECEIPT' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS PlACERECEIPT, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='PORTLOAD' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then PORTLOAD else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='PORTLOAD' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS PORTLOAD, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='PORTDISCHARGE' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then PORTDISCHARGE else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='PORTDISCHARGE' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS PORTDISCHARGE, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='PLACEDELIVERY' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then PLACEDELIVERY else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='PLACEDELIVERY' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS PLACEDELIVERY, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='BLFRT' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then BLFRT else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='BLFRT' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS BLFRT, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='SERVICE' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then [SERVICE] else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='SERVICE' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS [SERVICE], ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='MARKS' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then MARKS else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='MARKS' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS MARKS, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='DESCRIPTION' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then [DESCRIPTION] else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='DESCRIPTION' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS [DESCRIPTION], ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='GOODSNAME' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then GOODSNAME else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='GOODSNAME' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS GOODSNAME, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='GROSSWEIGHT' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then GROSSWEIGHT else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='GROSSWEIGHT' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS GROSSWEIGHT, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='MEASUREMENT' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then MEASUREMENT else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='MEASUREMENT' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS MEASUREMENT, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='PKGS' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then PKGS else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='PKGS' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS PKGS, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='KINDPKGS' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then KINDPKGS else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='KINDPKGS' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS KINDPKGS, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='KGS' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then KGS else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='KGS' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS KGS, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='CBM' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then CBM else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='CBM' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS CBM, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='TOTALNO' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then TOTALNO else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='TOTALNO' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS TOTALNO, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='CNTR' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then CNTR else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='CNTR' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS CNTRTOTAL, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='CARGOID' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then CARGOID else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='CARGOID' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS CARGOID, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='DCLASS' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then DCLASS else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='DCLASS' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS DCLASS, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='DUNNO' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then DUNNO else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='DUNNO' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS DUNNO, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='REEFERF' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then REEFERF else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='REEFERF' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS REEFERF, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='TEMPID' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then TEMPID else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='TEMPID' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS TEMPID, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='TEMPSET' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then TEMPSET else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='TEMPSET' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS TEMPSET, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='BOOKINGDESCRIPTION' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then BOOKINGDESCRIPTION else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='BOOKINGDESCRIPTION' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS REMARK, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='DPAGE' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then DPAGE else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='DPAGE' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS DPAGE, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='DLABEL' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then DLABEL else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='DLABEL' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS DLABEL, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='LINKMAN' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then LINKMAN else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='LINKMAN' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS LINKMAN, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='ISSUEWAY' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then ISSUEWAY else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='ISSUEWAY' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS ISSUETYPE, ");
strSql.AppendLine("case when (select COUNT(*) from dbo.BookingCargoSpaceChange where userID != '' and fieldName='BILLNUM' and isContainer=0 and dbo.BookingCargoSpaceChange.BSNO=B.BSNO and del_sign=0)=0 then BILLNUM else (select fieldValue from dbo.BookingCargoSpaceChange where userID != '' and fieldName='BILLNUM' and isContainer=0 and BSNO=B.BSNO and del_sign=0) end AS BILLNUM, ");
strSql.Append("(Select name from Company where companyID=B.companyID) as CUSTOMERNAME, ");
/*strSql.AppendLine("if(exists(select * from BookingCargoContainer where "+strCondition+" and del_sign is null)) ");
strSql.AppendLine("begin ");
strSql.AppendLine("select CTN_ID as id,BSNO,CTN,CTNNUM,CNTRNO,SEALNO,PKGS,KGS,CBM,KINDPKGS,[CTN_EXHIBIT] as CTNALL,CTNCODE,SIZE,REMARK ");
strSql.AppendLine("from BookingCargoContainer where "+strCondition+" and (del_sign=0 or del_sign is null) ");
strSql.AppendLine("end ");
strSql.AppendLine("else ");
strSql.AppendLine("begin ");
strSql.AppendLine("select CTN_ID as id,BSNO,CTN,CTNNUM,CNTRNO,SEALNO,PKGS,KGS,CBM,KINDPKGS,[CTN_EXHIBIT] as CTNALL,CTNCODE,SIZE,REMARK ");
strSql.AppendLine("from BookingCargoContainer where "+strCondition+" and (del_sign!=1) ");
strSql.AppendLine("UNION ");
strSql.AppendLine("select distinct A.CTN_ID as id,A.BSNO, ");
strSql.AppendLine("(select B.fieldValue from BookingCargoSpaceChange as B where B.changeID=A.changeID and B.isContainer=1 and B.fieldName='CTN' ) as CTN, ");
strSql.AppendLine("(select B.fieldValue from BookingCargoSpaceChange as B where B.changeID=A.changeID and B.isContainer=1 and B.fieldName='CTNNUM' ) as CTNNUM, ");
strSql.AppendLine("(select B.fieldValue from BookingCargoSpaceChange as B where B.changeID=A.changeID and B.isContainer=1 and B.fieldName='CNTRNO' ) as CNTRNO, ");
strSql.AppendLine("(select B.fieldValue from BookingCargoSpaceChange as B where B.changeID=A.changeID and B.isContainer=1 and B.fieldName='SEALNO' ) as SEALNO, ");
strSql.AppendLine("(select B.fieldValue from BookingCargoSpaceChange as B where B.changeID=A.changeID and B.isContainer=1 and B.fieldName='PKGS' ) as PKGS, ");
strSql.AppendLine("(select B.fieldValue from BookingCargoSpaceChange as B where B.changeID=A.changeID and B.isContainer=1 and B.fieldName='KGS' ) as KGS, ");
strSql.AppendLine("(select B.fieldValue from BookingCargoSpaceChange as B where B.changeID=A.changeID and B.isContainer=1 and B.fieldName='CBM' ) as CBM, ");
strSql.AppendLine("(select B.fieldValue from BookingCargoSpaceChange as B where B.changeID=A.changeID and B.isContainer=1 and B.fieldName='KINDPKGS' ) as KINDPKGS, ");
strSql.AppendLine("(select top 1 C.boxType from BookingCargoSpaceChange as B left join BoxTypeInfo as C on B.fieldValue=C.boxTypeID where B.changeID=A.changeID and B.isContainer=1 and B.fieldName='CTN' and C.del_sign=0 ) as CTNALL, ");
strSql.AppendLine("'' as CTNCODE,'' as SIZE,'' as REMARK ");
strSql.AppendLine("from BookingCargoSpaceChange as A ");
strSql.AppendLine("where A."+strCondition+" and A.del_sign=0 and A.CTN_ID!='' ");
strSql.AppendLine("end ");*/
strSql.AppendLine("if(exists(select * from BookingCargoSpaceChange where "+strCondition+" and isContainer=1 and del_sign=0)) ");
strSql.AppendLine("begin ");
strSql.AppendLine("select distinct A.CTN_ID as id,A.BSNO, ");
strSql.AppendLine("(select B.fieldValue from BookingCargoSpaceChange as B where B.changeID=A.changeID and B.isContainer=1 and B.fieldName='CTN' ) as CTN, ");
strSql.AppendLine("(select B.fieldValue from BookingCargoSpaceChange as B where B.changeID=A.changeID and B.isContainer=1 and B.fieldName='CTNNUM' ) as CTNNUM, ");
strSql.AppendLine("(select B.fieldValue from BookingCargoSpaceChange as B where B.changeID=A.changeID and B.isContainer=1 and B.fieldName='CNTRNO' ) as CNTRNO, ");
strSql.AppendLine("(select B.fieldValue from BookingCargoSpaceChange as B where B.changeID=A.changeID and B.isContainer=1 and B.fieldName='SEALNO' ) as SEALNO, ");
strSql.AppendLine("(select B.fieldValue from BookingCargoSpaceChange as B where B.changeID=A.changeID and B.isContainer=1 and B.fieldName='PKGS' ) as PKGS, ");
strSql.AppendLine("(select B.fieldValue from BookingCargoSpaceChange as B where B.changeID=A.changeID and B.isContainer=1 and B.fieldName='KGS' ) as KGS, ");
strSql.AppendLine("(select B.fieldValue from BookingCargoSpaceChange as B where B.changeID=A.changeID and B.isContainer=1 and B.fieldName='CBM' ) as CBM, ");
strSql.AppendLine("(select B.fieldValue from BookingCargoSpaceChange as B where B.changeID=A.changeID and B.isContainer=1 and B.fieldName='KINDPKGS' ) as KINDPKGS, ");
strSql.AppendLine("(select top 1 C.boxType from BookingCargoSpaceChange as B left join BoxTypeInfo as C on B.fieldValue=C.boxTypeID where B.changeID=A.changeID and B.isContainer=1 and B.fieldName='CTN' and C.del_sign=0 ) as CTNALL, ");
strSql.AppendLine("'' as CTNCODE,'' as SIZE,'' as REMARK ");
strSql.AppendLine("from BookingCargoSpaceChange as A ");
strSql.AppendLine("where A."+strCondition+" and A.del_sign=0 and A.CTN_ID!='' ");
varcmdInsertCtn=db.GetSqlStringCommand(@"insert into op_ctn_modify (GID,APPLYTYPE,MODIFYID,CTN_ID,BSNO,CTNCODE,[SIZE],CTN,CTNNUM,TEU,CTNALL,CNTRNO,SEALNO,PKGS,KGS,CBM,REMARK,KINDPKGS,TAREWEIGHT,GOODSNAME,CTNSTATUS,MASTERNO,WEIGHTYPE,WEIGHKGS,WEIGHATTN,WEIGHTEL,WEIGHSIGN,WEIGHDATE,TRUCKER,TRUCKFEE,FREESTORAGEDAY,STORAGEDAY,STORAGEPRICE,STORAGEFEE,
varcmdInsertCtn=db.GetSqlStringCommand(@"insert into op_ctn_modify (GID,APPLYTYPE,MODIFYID,CTN_ID,BSNO,CTNCODE,[SIZE],CTN,CTNNUM,TEU,CTNALL,CNTRNO,SEALNO,PKGS,KGS,CBM,REMARK,KINDPKGS,TAREWEIGHT,GOODSNAME,CTNSTATUS,MASTERNO,WEIGHTYPE,WEIGHKGS,WEIGHATTN,WEIGHTEL,WEIGHSIGN,WEIGHDATE,TRUCKER,TRUCKFEE,FREESTORAGEDAY,STORAGEDAY,STORAGEPRICE,STORAGEFEE,
// var cmdupdateModify = db.GetSqlStringCommand("update ch_fee_modify set applystatus=2,audituser=@audituser,audittime=@audittime where FEEID=@GID and applystatus=1");
db.GetSqlStringCommand("update op_seae set bsno=bsno"+strSql.ToString());
db.ExecuteNonQuery(cmdupdate,tran);
varcmdupdate2=
db.GetSqlStringCommand("update crm_seaeorder set bsno=bsno"+strSql.ToString());
db.ExecuteNonQuery(cmdupdate2,tran);
varcmdupdate3=
db.GetSqlStringCommand("update op_seae_modify set APPLYSTATUS=0,AUDITUSER='"+userid+"',AUDITTIME=GETDATE() where APPLYID='"+NewData.APPLYID+"'");
db.ExecuteNonQuery(cmdupdate3,tran);
}
varcmddeleteCtn=
db.GetSqlStringCommand("delete from op_ctn where BSNO='"+NewData.BSNO+"'");
db.ExecuteNonQuery(cmddeleteCtn,tran);
varcmdInsertCtn=db.GetSqlStringCommand(@"insert into op_ctn (CTN_ID,BSNO,CTNCODE,[SIZE],CTN,CTNNUM,TEU,CTNALL,CNTRNO,SEALNO,PKGS,KGS,CBM,REMARK,KINDPKGS,TAREWEIGHT,GOODSNAME,CTNSTATUS,MASTERNO,WEIGHTYPE,WEIGHKGS,WEIGHATTN,WEIGHTEL,WEIGHSIGN,WEIGHDATE,TRUCKER,TRUCKFEE,FREESTORAGEDAY,STORAGEDAY,STORAGEPRICE,STORAGEFEE,
db.GetSqlStringCommand("update op_seae_modify set APPLYSTATUS=4,AUDITREMARK='"+reason+"',AUDITUSER='"+userid+"',AUDITTIME=GETDATE() where APPLYID='"+NewData.APPLYID+"'");
strSql.Append(" select case AUDITOR WHEN '' then ");
strSql.Append(" (select email from userinfo where userid in (select userid from login where companyID=FORWARDER) and departmentID='CompanyMaster') ");
strSql.Append(" else (select email from userinfo where userid=AUDITOR) end ReceiverEmail ");
strSql.Append(" ,case AUDITOR WHEN '' then ");
strSql.Append(" (select username from userinfo where userid in (select userid from login where companyID=FORWARDER) and departmentID='CompanyMaster') ");
strSql.Append(" else (select username from userinfo where userid=AUDITOR) end Receivername ");
str=" (OP='"+username+"' OR SALE='"+username+"' or CUSTSERVICE='"+username+"' or DOC='"+username+"' or INPUTBY='"+username+"')";
}
elseif(visiblerange=="5")
{
varuserstr=newStringBuilder();
userstr.Append(" select SHOWNAME from VW_user where COMPANYID in (select COMPANYID from user_authority_range_company where userid='"+userid+"' and AUTHORITYID='"+AUTHORITYID+"' and VISIBLERANGE=1)");
str=" (OP='"+Convert.ToString(reader["SHOWNAME"])+"' OR SALE='"+Convert.ToString(reader["SHOWNAME"])+"' OR CUSTSERVICE='"+Convert.ToString(reader["SHOWNAME"])+"' OR DOC='"+Convert.ToString(reader["SHOWNAME"])+"' OR INPUTBY='"+Convert.ToString(reader["SHOWNAME"])+"' ";
}
else
{
str=str+" or OP='"+Convert.ToString(reader["SHOWNAME"])+"' OR SALE='"+Convert.ToString(reader["SHOWNAME"])+"' OR CUSTSERVICE='"+Convert.ToString(reader["SHOWNAME"])+"' OR DOC='"+Convert.ToString(reader["SHOWNAME"])+"' OR INPUTBY='"+Convert.ToString(reader["SHOWNAME"])+"' ";
userstr.Append(" select OPID,(select SHOWNAME from [user] where GID=user_authority_range_op.OPID) SHOWNAME from user_authority_range_op where userid='"+userid+"' and AUTHORITYID='"+AUTHORITYID+"' and VISIBLERANGE=1");
str=" (OP='"+Convert.ToString(reader["SHOWNAME"])+"' OR SALE='"+Convert.ToString(reader["SHOWNAME"])+"' OR CUSTSERVICE='"+Convert.ToString(reader["SHOWNAME"])+"' OR DOC='"+Convert.ToString(reader["SHOWNAME"])+"' OR INPUTBY='"+Convert.ToString(reader["SHOWNAME"])+"' ";
str=str+" or OP='"+Convert.ToString(reader["SHOWNAME"])+"' OR SALE='"+Convert.ToString(reader["SHOWNAME"])+"' OR CUSTSERVICE='"+Convert.ToString(reader["SHOWNAME"])+"' OR DOC='"+Convert.ToString(reader["SHOWNAME"])+"' OR INPUTBY='"+Convert.ToString(reader["SHOWNAME"])+"' ";
userstr.Append(" select SHOWNAME from [user] where GID in (select USERID from user_company where COMPANYID='"+companyid+"') and GID in (select userid from user_baseinfo where DEPTNAME='"+deptname+"')");
str=" (OP='"+Convert.ToString(reader["SHOWNAME"])+"' OR SALE='"+Convert.ToString(reader["SHOWNAME"])+"' OR CUSTSERVICE='"+Convert.ToString(reader["SHOWNAME"])+"' OR DOC='"+Convert.ToString(reader["SHOWNAME"])+"' OR INPUTBY='"+Convert.ToString(reader["SHOWNAME"])+"' ";
str=str+" or OP='"+Convert.ToString(reader["SHOWNAME"])+"' OR SALE='"+Convert.ToString(reader["SHOWNAME"])+"' OR CUSTSERVICE='"+Convert.ToString(reader["SHOWNAME"])+"' OR DOC='"+Convert.ToString(reader["SHOWNAME"])+"' OR INPUTBY='"+Convert.ToString(reader["SHOWNAME"])+"' ";
str=" (OP='"+Convert.ToString(reader["SHOWNAME"])+"' OR SALE='"+Convert.ToString(reader["SHOWNAME"])+"' OR CUSTSERVICE='"+Convert.ToString(reader["SHOWNAME"])+"' OR DOC='"+Convert.ToString(reader["SHOWNAME"])+"' OR INPUTBY='"+Convert.ToString(reader["SHOWNAME"])+"' ";
str=str+" or OP='"+Convert.ToString(reader["SHOWNAME"])+"' OR SALE='"+Convert.ToString(reader["SHOWNAME"])+"' OR CUSTSERVICE='"+Convert.ToString(reader["SHOWNAME"])+"' OR DOC='"+Convert.ToString(reader["SHOWNAME"])+"' OR INPUTBY='"+Convert.ToString(reader["SHOWNAME"])+"'";
userstr.Append(" select userid from VW_user where COMPANYID in (select COMPANYID from user_authority_range_company where userid='"+userid+"' and AUTHORITYID='"+AUTHORITYID+"' and VISIBLERANGE=1)");
str=str+" or APPLYUSER='"+Convert.ToString(reader["userid"])+"' ";
};
}
str=str+")";
reader.Close();
}
}
elseif(visiblerange=="6")
{
varuserstr=newStringBuilder();
userstr.Append(" select OPID,(select SHOWNAME from [user] where GID=user_authority_range_op.OPID) SHOWNAME from user_authority_range_op where userid='"+userid+"' and AUTHORITYID='"+AUTHORITYID+"' and VISIBLERANGE=1");
str=str+" or APPLYUSER='"+Convert.ToString(reader["OPID"])+"' ";
};
}
str=str+")";
reader.Close();
}
}
elseif(visiblerange=="2")
{
varrangeDa=newRangeDA();
vardeptname=rangeDa.GetDEPTNAME(userid);
varuserstr=newStringBuilder();
userstr.Append(" select GID from [user] where GID in (select USERID from user_company where COMPANYID='"+companyid+"') and GID in (select userid from user_baseinfo where DEPTNAME='"+deptname+"')");