using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Services; using DSWeb.MvcShipping.Models.MsChFee; using Microsoft.Practices.EnterpriseLibrary.Data; using System.Text; using System.Data; using DSWeb.EntityDA; namespace DSWebMobileService { /// /// ChfeeAuditServer 的摘要说明 /// [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [System.ComponentModel.ToolboxItem(false)] // 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。 // [System.Web.Script.Services.ScriptService] public class ChfeeAuditServer : System.Web.Services.WebService { [WebMethod] public string HelloWorld() { return "Hello World"; } [WebMethod] public static List GetDataList(string gid, string bsno, int type, string optype, string isAll, string userid, string username, string companyid) { var rangstr = GetRangDAStr(type, optype, userid, username, companyid); var WorkFlowNameM = "FeeModifyAudit"; var WorkFlowName = "FeeRecvPayAudit"; if (optype == "op_seae") { WorkFlowNameM = "FeeModifyAudit"; WorkFlowName = "FeeRecvPayAudit"; } if (optype == "op_seai") { WorkFlowNameM = "FeeSeaiModifyAudit"; WorkFlowName = "FeeSeaiRecvPayAudit"; } if (optype == "op_aire") { WorkFlowNameM = "AireFeeModify"; WorkFlowName = "AireFeeAudit"; } if (optype == "op_airi") { WorkFlowNameM = "AiriFeeModify"; WorkFlowName = "AiriFeeAudit"; } if (optype == "op_apply") { WorkFlowNameM = "ApplyFeeModify"; WorkFlowName = "ApplyFeeAudit"; } if (optype == "op_bulk") { WorkFlowNameM = "BulkFeeModify"; WorkFlowName = "BulkFeeAudit"; } if (optype == "op_other" || optype == "tMsWlPcHead") { WorkFlowNameM = "FeeOpOtherModifyAudit"; WorkFlowName = "FeeOpOpOtherRecvPayAudit"; } if (optype == "op_railway") { WorkFlowNameM = "RailwayFeeModify"; WorkFlowName = "RailwayFeeAudit"; } if (optype == "op_railway") { WorkFlowNameM = "RailwayFeeModify"; WorkFlowName = "RailwayFeeAudit"; } var strSql = new StringBuilder(); strSql.Append("SELECT top 1 "); strSql.Append("GId,ch_fee.BsNo,FeeStatus,"); strSql.Append("(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99024 and EnumValueID=ch_fee.FeeStatus) as FeeStatus_Ref"); strSql.Append(",FeeType,"); strSql.Append("(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99020 and EnumValueID=ch_fee.FeeType) as FeeType_Ref"); strSql.Append(",FeeName,"); strSql.Append("FeeDescription,CustomerType,CustomerName,"); strSql.Append("Unit,UnitPrice,Quantity,TaxRate,TaxUnitPrice,NoTaxAmount,Amount,AccTaxRate,Currency,ExChangerate,ch_fee.Reason"); strSql.Append(",Remark,Commissionrate,Settlement,Invoice,OrderAmount,OrderInvoice,SubmitDate"); strSql.Append(",Auditoperator,AuditDate,EnteroPerator,EnterDate,DebitNo,IsDebit,IsOpen"); strSql.Append(",(select ShowName from [user] where GID=ch_fee.EnteroPerator) as OpName"); strSql.Append(",IsAdvancedpay,Sort,IsInvoice,FeeFrt,IsCrmOrderFee,AuditStatus,InvoiceNum"); strSql.Append(",ChequeNum,WmsOutBsNo,LineNum"); if (isAll == "1") { strSql.Append(",dbo.[GetUsingStep](wu.WORKFLOWID,wu.currentid,'" + userid + "',wu.stepno) as IsAudit "); strSql.Append(" from ch_fee left join workflow_using wu on wu.bsno=ch_fee.GID "); strSql.Append(" where ch_fee.GId='" + gid + "' "); /*if (type != 0) strSql.Append(" and ch_fee.FeeType=" + type); strSql.Append(" and dbo.[GetUsingStep](wu.WORKFLOWID,wu.currentid,'" + userid + "',wu.stepno)>0 and (wu.WORKFLOWID=dbo.[GetBSNOWorkFlowID]('" + WorkFlowName + "',ch_fee.GID) or wu.WORKFLOWID=dbo.[GetBSNOWorkFlowID]('" + WorkFlowNameM + "',ch_fee.GID)) ");*/ } else if (isAll == "2") { strSql.Append(",0 as IsAudit "); strSql.Append(" from ch_fee "); strSql.Append(" where ch_fee.GId='" + gid + "' "); /*if (type != 0) strSql.Append(" and ch_fee.FeeType=" + type); strSql.Append(" and ch_fee.FeeStatus=0 AND ch_fee.GID IN (select distinct billno from workflow_do where auditor='" + userid + "' ) ");*/ } else { strSql.Append(",dbo.[GetUsingStep](wu.WORKFLOWID,wu.currentid,'" + userid + "',wu.stepno) as IsAudit "); strSql.Append(" from ch_fee left join workflow_using wu on wu.bsno=ch_fee.GID and wu.FINISHED=0 "); strSql.Append(" where ch_fee.GId='" + gid + "' "); /*if (type != 0) strSql.Append(" and ch_fee.FeeType=" + type);*/ } strSql.Append(" order by sort,LineNum "); return SetData(strSql); } private static List SetData(StringBuilder strSql) { var bodyList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { MsChFee data = new MsChFee(); #region Set DB data to Object data.GId = Convert.ToString(reader["GId"]); data.BsNo = Convert.ToString(reader["BsNo"]); data.FeeStatus = Convert.ToInt16(reader["FeeStatus"]); data.FeeStatus_Ref = Convert.ToString(reader["FeeStatus_Ref"]); data.FeeType = Convert.ToDecimal(reader["FeeType"]); data.FeeName = Convert.ToString(reader["FeeName"]); data.FeeDescription = Convert.ToString(reader["FeeDescription"]); data.CustomerType = Convert.ToString(reader["CustomerType"]); data.CustomerName = Convert.ToString(reader["CustomerName"]); data.Unit = Convert.ToString(reader["Unit"]); if (reader["UnitPrice"] != DBNull.Value) data.UnitPrice = Convert.ToDecimal(reader["UnitPrice"]); if (reader["Quantity"] != DBNull.Value) data.Quantity = Convert.ToDecimal(reader["Quantity"]); if (reader["TaxRate"] != DBNull.Value) data.TaxRate = Convert.ToDecimal(reader["TaxRate"]); if (reader["TaxUnitPrice"] != DBNull.Value) data.TaxUnitPrice = Convert.ToDecimal(reader["TaxUnitPrice"]); if (reader["NoTaxAmount"] != DBNull.Value) data.NoTaxAmount = Convert.ToDecimal(reader["NoTaxAmount"]); data.Amount = Convert.ToDecimal(reader["Amount"]); if (reader["AccTaxRate"] != DBNull.Value) data.AccTaxRate = Convert.ToDecimal(reader["AccTaxRate"]); data.Currency = Convert.ToString(reader["Currency"]); if (reader["ExChangerate"] != DBNull.Value) data.ExChangerate = Convert.ToDecimal(reader["ExChangerate"]); data.Reason = Convert.ToString(reader["Reason"]); data.Remark = Convert.ToString(reader["Remark"]); data.Commissionrate = Convert.ToDecimal(reader["Commissionrate"]); data.Settlement = Convert.ToDecimal(reader["Settlement"]); if (reader["Invoice"] != DBNull.Value) data.Invoice = Convert.ToDecimal(reader["Invoice"]); data.OrderAmount = Convert.ToDecimal(reader["OrderAmount"]); data.OrderInvoice = Convert.ToDecimal(reader["OrderInvoice"]); if (reader["SubmitDate"] != DBNull.Value) data.SubmitDate = Convert.ToDateTime(reader["SubmitDate"]); data.Auditoperator = Convert.ToString(reader["Auditoperator"]); if (reader["AuditDate"] != DBNull.Value) data.AuditDate = Convert.ToDateTime(reader["AuditDate"]); data.EnteroPerator = Convert.ToString(reader["EnteroPerator"]); data.OpName = Convert.ToString(reader["OpName"]); if (reader["EnterDate"] != DBNull.Value) data.EnterDate = Convert.ToDateTime(reader["EnterDate"]); data.DebitNo = Convert.ToString(reader["DebitNo"]); data.IsDebit = Convert.ToString(reader["IsDebit"]); data.IsOpen = Convert.ToString(reader["IsOpen"]); data.IsAdvancedpay = Convert.ToString(reader["IsAdvancedpay"]); data.Sort = Convert.ToString(reader["Sort"]); data.IsInvoice = Convert.ToString(reader["IsInvoice"]); data.FeeFrt = Convert.ToString(reader["FeeFrt"]); data.IsCrmOrderFee = Convert.ToString(reader["IsCrmOrderFee"]); data.AuditStatus = Convert.ToDecimal(reader["AuditStatus"]); data.InvoiceNum = Convert.ToString(reader["InvoiceNum"]); data.ChequeNum = Convert.ToString(reader["ChequeNum"]); data.WmsOutBsNo = Convert.ToString(reader["WmsOutBsNo"]); data.LineNum = Convert.ToDecimal(reader["LineNum"]); if (reader["IsAudit"] != DBNull.Value) data.IsAudit = Convert.ToString(reader["IsAudit"]); #endregion bodyList.Add(data); } reader.Close(); } return bodyList; } public static string GetRangDAStr(int type, string optype, string userid, string username, string companyid) { string str = ""; string modustr = ""; if (type == 1) { if (optype == "op_seae") { modustr = "modRecvFeeManagement"; } else if (optype == "op_apply") { modustr = "modApplyRecvFeeManagement"; } else if (optype == "op_seai") { modustr = "modSeaiRecvFeeManagement"; } else if (optype == "op_aire") { modustr = "modAireRecvFeeManagement"; } else if (optype == "op_airi") { modustr = "modAiriRecvFeeManagement"; } else if (optype == "op_other" || optype == "tMsWlPcHead") { modustr = "modOtherRecvFeeManagement"; } else if (optype == "op_bulk") { modustr = "modBulkRecvFeeManagement"; } else if (optype == "op_railway") { modustr = "modRailwayRecvFeeManagement"; } else if (optype == "import_main") { modustr = "modImportTrade"; } } else if (type == 2) { if (optype == "op_seae") { modustr = "modPayFeeManagement"; } else if (optype == "op_apply") { modustr = "modApplyPayFeeManagement"; } else if (optype == "op_seai") { modustr = "modSeaiPayFeeManagement"; } else if (optype == "op_aire") { modustr = "modAirePayFeeManagement"; } else if (optype == "op_airi") { modustr = "modAiriPayFeeManagement"; } else if (optype == "op_other" || optype == "tMsWlPcHead") { modustr = "modOtherPayFeeManagement"; } else if (optype == "op_bulk") { modustr = "modBulkPayFeeManagement"; } else if (optype == "op_railway") { modustr = "modRailwayPayFeeManagement"; } else if (optype == "import_main") { modustr = "modImportTrade"; } } var strSql = new StringBuilder(); strSql.Append("SELECT "); strSql.Append(" VISIBLERANGE,OPERATERANGE "); strSql.Append(" from VW_User_Authority "); strSql.Append(" where [NAME]='" + modustr + "' and USERID='" + userid + "' and ISDELETE=0"); string visiblerange = "4"; string operaterange = "4"; Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { visiblerange = Convert.ToString(reader["VISIBLERANGE"]); operaterange = Convert.ToString(reader["OPERATERANGE"]); break; } reader.Close(); } if (visiblerange == "4") { str = " ENTEROPERATOR='" + userid + "'"; } else if (visiblerange == "3") { str = " ENTEROPERATOR='" + userid + "'"; } else if (visiblerange == "2") { var rangeDa = new RangeDA(); var deptname = rangeDa.GetDEPTNAME(userid); str = " ENTEROPERATOR in (select USERID from user_company where COMPANYID='" + companyid + "') and ENTEROPERATOR in (select userid from user_baseinfo where DEPTNAME='" + deptname + "')"; } else if (visiblerange == "1") { str = " ENTEROPERATOR in (select USERID from user_company where COMPANYID='" + companyid + "') "; } else if (visiblerange == "0") { str = " 1=1 "; } return str; } } }