/// <summary>
        /// 订单历史分页查询
        /// </summary>
        /// <param name="Lqc"></param>
        /// <param name="Ltype"></param>
        /// <param name="pageindex"></param>
        /// <param name="pagesize"></param>
        /// <param name="page"></param>
        /// <returns></returns>
        public LTradeOrderInfo GetMultiLTradeOrderWithPage(LQueryCon Lqc, string Ltype, int pageindex, int pagesize, ref int page)
        {
            int i = 0;
            LTradeOrderInfo LdOrderInfo = new LTradeOrderInfo();
            LdOrderInfo.LTdOrderList = new List<LTradeOrder>();
            System.Data.Common.DbDataReader dbreader = null;
            TradeUser TdUser = new TradeUser();
            System.Data.Common.DbParameter OutputParam = DbHelper.CreateDbParameter(JinTong.Jyrj.Data.DataBase.Type,
             "@PageCount", DbParameterType.String, 0, ParameterDirection.Output);
            string SearchCondition = string.Empty;
            try
            {
                string AndStr = string.Empty;
                string PartSearchCondition = string.Empty;
                string ParentOrgID = string.Empty;
                if (!ComFunction.ExistUserLoginID(Lqc.LoginID, ref TdUser))
                {
                    return LdOrderInfo;
                }

                if (UserType.NormalType == TdUser.UType) //普通用户
                {
                    AndStr += string.Format("and userid='{0}' ", TdUser.UserID);
                }
                else
                {
                    if (UserType.OrgType == TdUser.UType && !string.IsNullOrEmpty(TdUser.OrgId))
                    {
                        PartSearchCondition = " and orgid in (select orgid from #tmp) ";
                        ParentOrgID = TdUser.OrgId;
                    }
                    if (!string.IsNullOrEmpty(Lqc.TradeAccount))
                    {
                        AndStr += string.Format(" and [Account] like '{0}%' ", Lqc.TradeAccount);
                    }
                }
                if (!string.IsNullOrEmpty(Lqc.OrgName))
                {
                    //AndStr += string.Format(" and [orgname] like '{0}%' ", Lqc.OrgName);
                    AndStr += string.Format(" and [orgid]='{0}' ", Lqc.OrgName);
                }

                //入库单查询
                if ("2" == Ltype)
                {
                    AndStr += " and overtype='2'";
                }
                else
                {
                    AndStr += " and overtype<>'2'";//平仓单查询
                }
                if ("ALL" != Lqc.ProductName.ToUpper())
                {
                    AndStr += string.Format(" and ProductName='{0}'", Lqc.ProductName);
                }
                if ("ALL" != Lqc.OrderType.ToUpper())
                {
                    AndStr += string.Format(" and ordertype='{0}'", Lqc.OrderType);
                }
                if (!string.IsNullOrEmpty(Lqc.PriceCode))
                {
                    AndStr += string.Format(" and [PriceCode]='{0}' ", Lqc.PriceCode);
                }

                //内部子查询字段列表
                string SumSelectList = "round(isnull(sum(profitValue),0),2) as profitValue,round(isnull(sum(quantity),0),2) as quantity,round(isnull(sum(tradefee),0),2) as tradefee,round(isnull(sum(storagefee),0),2) as storagefee ";
                //选择字段列表
                string selectlist = "orgname,telephone,username,Account,ProductName,historyOrderId,productcode,lossprice,profitPrice,Orderprice,overType,overprice,profitValue,tradefee,storagefee,Overtime,Orderid,ordertype,quantity,ordertime,adjustbase,valuedot,unit,lowerprice ";

                //查询条件
                SearchCondition = string.Format("where overtime >= '{0}' and overtime <='{1}' {2} {3} ",
                    Lqc.StartTime.ToString("yyyy-MM-dd HH:mm:ss.fff"), Lqc.EndTime.ToString("yyyy-MM-dd HH:mm:ss.fff"), AndStr, PartSearchCondition);

                dbreader = DbHelper.RunProcedureGetDataReader("GetRecordFromPageExWithSum",
                     new System.Data.Common.DbParameter[]{
                         DbHelper.CreateDbParameter(JinTong.Jyrj.Data.DataBase.Type,
                    "@selectlist",DbParameterType.String,selectlist,ParameterDirection.Input),
                      DbHelper.CreateDbParameter(JinTong.Jyrj.Data.DataBase.Type,
                    "@SumSelectList",DbParameterType.String,SumSelectList,ParameterDirection.Input),
                       DbHelper.CreateDbParameter(JinTong.Jyrj.Data.DataBase.Type,
                    "@TableSource",DbParameterType.String,"V_L_Trade_Order",ParameterDirection.Input), //表名或视图表
                        DbHelper.CreateDbParameter(JinTong.Jyrj.Data.DataBase.Type,
                    "@TableOrder",DbParameterType.String,"a",ParameterDirection.Input), //排序后的表名称 即子查询结果集的别名
                         DbHelper.CreateDbParameter(JinTong.Jyrj.Data.DataBase.Type,
                    "@SearchCondition",DbParameterType.String,SearchCondition,ParameterDirection.Input),
                          DbHelper.CreateDbParameter(JinTong.Jyrj.Data.DataBase.Type,
                    "@OrderExpression",DbParameterType.String,"order by overtime desc",ParameterDirection.Input),//排序 表达式
                         DbHelper.CreateDbParameter(JinTong.Jyrj.Data.DataBase.Type,
                    "@ParentOrgID",DbParameterType.String,ParentOrgID,ParameterDirection.Input),//父级组织ID
                           DbHelper.CreateDbParameter(JinTong.Jyrj.Data.DataBase.Type,
                    "@PageIndex",DbParameterType.Int,pageindex,ParameterDirection.Input),
                           DbHelper.CreateDbParameter(JinTong.Jyrj.Data.DataBase.Type,
                    "@PageSize",DbParameterType.Int,pagesize,ParameterDirection.Input),
                            OutputParam});
                while (dbreader.Read())
                {
                    LTradeOrder ltradeOrder = new LTradeOrder();
                    ltradeOrder.Telephone = System.DBNull.Value != dbreader["telephone"] ? dbreader["telephone"].ToString() : string.Empty;
                    ltradeOrder.UserName = System.DBNull.Value != dbreader["username"] ? dbreader["username"].ToString() : string.Empty;
                    ltradeOrder.OrgName = System.DBNull.Value != dbreader["orgname"] ? dbreader["orgname"].ToString() : string.Empty;
                    ltradeOrder.TradeAccount = System.DBNull.Value != dbreader["Account"] ? dbreader["Account"].ToString() : string.Empty;
                    ltradeOrder.HistoryOrderId = System.DBNull.Value != dbreader["historyOrderId"] ? dbreader["historyOrderId"].ToString() : string.Empty;
                    ltradeOrder.ProductName = System.DBNull.Value != dbreader["ProductName"] ? dbreader["ProductName"].ToString() : string.Empty;
                    ltradeOrder.ProductCode = System.DBNull.Value != dbreader["productcode"] ? dbreader["productcode"].ToString() : string.Empty;
                    ltradeOrder.OrderPrice = System.DBNull.Value != dbreader["Orderprice"] ? Convert.ToDouble(dbreader["Orderprice"]) : 0;
                    ltradeOrder.OverType = System.DBNull.Value != dbreader["overType"] ? dbreader["overType"].ToString() : string.Empty;
                    ltradeOrder.OverPrice = System.DBNull.Value != dbreader["overprice"] ? Convert.ToDouble(dbreader["overprice"]) : 0;
                    ltradeOrder.ProfitValue = System.DBNull.Value != dbreader["profitValue"] ? Convert.ToDouble(dbreader["profitValue"]) : 0;
                    ltradeOrder.TradeFee = System.DBNull.Value != dbreader["tradefee"] ? Convert.ToDouble(dbreader["tradefee"]) : 0;
                    ltradeOrder.StorageFee = System.DBNull.Value != dbreader["storagefee"] ? Convert.ToDouble(dbreader["storagefee"]) : 0;
                    ltradeOrder.LossPrice = System.DBNull.Value != dbreader["lossprice"] ? Convert.ToDouble(dbreader["lossprice"]) : 0;
                    ltradeOrder.ProfitPrice = System.DBNull.Value != dbreader["profitPrice"] ? Convert.ToDouble(dbreader["profitPrice"]) : 0;
                    ltradeOrder.OverTime = System.DBNull.Value != dbreader["Overtime"] ? Convert.ToDateTime(dbreader["Overtime"]) : DateTime.MinValue;
                    ltradeOrder.OrderId = System.DBNull.Value != dbreader["Orderid"] ? dbreader["Orderid"].ToString() : string.Empty;
                    ltradeOrder.OrderType = System.DBNull.Value != dbreader["ordertype"] ? dbreader["ordertype"].ToString() : string.Empty;
                    ltradeOrder.Quantity = System.DBNull.Value != dbreader["quantity"] ? Convert.ToDouble(dbreader["quantity"]) : 0;
                    ltradeOrder.OrderTime = System.DBNull.Value != dbreader["ordertime"] ? Convert.ToDateTime(dbreader["ordertime"]) : DateTime.MinValue;
                    if ("0" == ltradeOrder.OrderType && DBNull.Value != dbreader["adjustbase"] && DBNull.Value != dbreader["valuedot"] && DBNull.Value != dbreader["quantity"])
                    {
                        ltradeOrder.ProductMoney = System.Math.Round(ltradeOrder.OverPrice / Convert.ToDouble(dbreader["adjustbase"]) * Convert.ToDouble(dbreader["valuedot"]) * Convert.ToDouble(dbreader["quantity"]), 2, MidpointRounding.AwayFromZero);
                    }
                    else
                    {
                        //ltradeOrder.ProductMoney = System.Math.Round(Convert.ToDouble(sqldr["unit"]) * Convert.ToDouble(sqldr["lowerprice"]) * Convert.ToDouble(sqldr["quantity"]), 2, MidpointRounding.AwayFromZero);
                        //卖单入库的货款(即所谓的折旧费) 已经计算在盈亏里面了 所以没有所谓的货款
                        ltradeOrder.ProductMoney = 0;
                    }
                    LdOrderInfo.LTdOrderList.Add(ltradeOrder);
                    i++;
                }
                if (dbreader.NextResult())
                {
                    if (dbreader.Read())
                    {
                        LdOrderInfo.ProfitValue = System.DBNull.Value != dbreader["profitValue"] ? Convert.ToDouble(dbreader["profitValue"]) : 0;
                        LdOrderInfo.Quantity = System.DBNull.Value != dbreader["quantity"] ? Convert.ToDouble(dbreader["quantity"]) : 0;
                        LdOrderInfo.Tradefee = System.DBNull.Value != dbreader["tradefee"] ? Convert.ToDouble(dbreader["tradefee"]) : 0;
                        LdOrderInfo.Storagefee = System.DBNull.Value != dbreader["storagefee"] ? Convert.ToDouble(dbreader["storagefee"]) : 0;
                    }
                }
                LdOrderInfo.Result = true;
                LdOrderInfo.Desc = "查询成功";
            }
            catch (Exception ex)
            {
                ComFunction.WriteErr(ex);
                if (null != LdOrderInfo.LTdOrderList && LdOrderInfo.LTdOrderList.Count > 0)
                {
                    LdOrderInfo.LTdOrderList.Clear();
                }
                LdOrderInfo.Desc = "查询失败";
                LdOrderInfo.Result = false;
            }
            finally
            {
                if (null != dbreader)
                {
                    dbreader.Close();
                    dbreader.Dispose();
                    page = Convert.ToInt32(OutputParam.Value);
                }
            }

            return LdOrderInfo;
        }
        /// <summary>
        /// 订单历史
        /// </summary>
        /// <param name="lqc">查询条件</param>
        /// <param name="ltype">"1"平仓历史 "2"入库历史</param>
        /// <param name="pageindex">第几页,从1开始</param>
        /// <param name="pagesize">每页多少条</param>
        /// <param name="page">输出参数(总页数)</param>
        /// <returns>市价单历史记录</returns>
        public List<LTradeOrder> GetWXLTradeOrder(LQueryCon lqc, string ltype, int pageindex, int pagesize, ref int page)
        {
            var list = new List<LTradeOrder>();
            DbDataReader dbreader = null;
            var tdUser = new TradeUser();
            DbParameter outputParam = DbHelper.CreateDbParameter(JinTong.Jyrj.Data.DataBase.Type,
             "@PageCount", DbParameterType.String, 0, ParameterDirection.Output);
            try
            {
                string andStr = string.Empty;
                string partSearchCondition = string.Empty;
                string parentOrgID = string.Empty;
                if (!ComFunction.ExistUserLoginID(lqc.LoginID, ref tdUser))
                {
                    return list;
                }

                if (UserType.NormalType == tdUser.UType) //普通用户
                {
                    andStr += string.Format("and userid='{0}' ", tdUser.UserID);
                }
                else
                {
                    if (UserType.OrgType == tdUser.UType && !string.IsNullOrEmpty(tdUser.OrgId))
                    {
                        partSearchCondition = " and orgid in (select orgid from #tmp) ";
                        parentOrgID = tdUser.OrgId;
                    }
                    if (!string.IsNullOrEmpty(lqc.TradeAccount))
                    {
                        andStr += string.Format(" and [Account] like '{0}%' ", lqc.TradeAccount);
                    }
                }
                if (!string.IsNullOrEmpty(lqc.OrgName))
                {
                    andStr += string.Format(" and [orgname] like '{0}%' ", lqc.OrgName);
                }

                //入库单查询
                if ("2" == ltype)
                {
                    andStr += " and overtype='2'";
                }
                else
                {
                    andStr += " and overtype<>'2'";//平仓单查询
                }
                if ("ALL" != lqc.ProductName.ToUpper())
                {
                    andStr += string.Format(" and ProductName='{0}'", lqc.ProductName);
                }
                if ("ALL" != lqc.OrderType.ToUpper())
                {
                    andStr += string.Format(" and ordertype='{0}'", lqc.OrderType);
                }

                //内部子查询字段列表
                const string subSelectList = "orgname,Account,ProductName,historyOrderId,productcode,lossprice,profitPrice,Orderprice,overType,overprice,profitValue,tradefee,storagefee,Overtime,Orderid,ordertype,quantity,ordertime,adjustbase,valuedot,unit,lowerprice ";
                //选择字段列表
                const string selectlist = "orgname,Account,ProductName,historyOrderId,productcode,lossprice,profitPrice,Orderprice,overType,overprice,profitValue,tradefee,storagefee,Overtime,Orderid,ordertype,quantity,ordertime,adjustbase,valuedot,unit,lowerprice ";

                //查询条件
                string searchCondition = string.Format("where overtime >= '{0}' and overtime <='{1}' {2} {3} ",
                    lqc.StartTime.ToString("yyyy-MM-dd HH:mm:ss.fff"), lqc.EndTime.ToString("yyyy-MM-dd HH:mm:ss.fff"), andStr, partSearchCondition);

                dbreader = DbHelper.RunProcedureGetDataReader("GetRecordFromPageEx",
                     new[]{
                         DbHelper.CreateDbParameter(JinTong.Jyrj.Data.DataBase.Type,
                    "@selectlist",DbParameterType.String,selectlist,ParameterDirection.Input),
                      DbHelper.CreateDbParameter(JinTong.Jyrj.Data.DataBase.Type,
                    "@SubSelectList",DbParameterType.String,subSelectList,ParameterDirection.Input),
                       DbHelper.CreateDbParameter(JinTong.Jyrj.Data.DataBase.Type,
                    "@TableSource",DbParameterType.String,"V_L_Trade_Order",ParameterDirection.Input), //表名或视图表
                        DbHelper.CreateDbParameter(JinTong.Jyrj.Data.DataBase.Type,
                    "@TableOrder",DbParameterType.String,"a",ParameterDirection.Input), //排序后的表名称 即子查询结果集的别名
                         DbHelper.CreateDbParameter(JinTong.Jyrj.Data.DataBase.Type,
                    "@SearchCondition",DbParameterType.String,searchCondition,ParameterDirection.Input),
                          DbHelper.CreateDbParameter(JinTong.Jyrj.Data.DataBase.Type,
                    "@OrderExpression",DbParameterType.String,"order by overtime desc",ParameterDirection.Input),//排序 表达式
                         DbHelper.CreateDbParameter(JinTong.Jyrj.Data.DataBase.Type,
                    "@ParentOrgID",DbParameterType.String,parentOrgID,ParameterDirection.Input),//父级组织ID
                           DbHelper.CreateDbParameter(JinTong.Jyrj.Data.DataBase.Type,
                    "@PageIndex",DbParameterType.Int,pageindex,ParameterDirection.Input),
                           DbHelper.CreateDbParameter(JinTong.Jyrj.Data.DataBase.Type,
                    "@PageSize",DbParameterType.Int,pagesize,ParameterDirection.Input),
                            outputParam});
                while (dbreader.Read())
                {
                    var ltradeOrder = new LTradeOrder
                    {
                        OrgName = DBNull.Value != dbreader["orgname"] ? dbreader["orgname"].ToString() : string.Empty,
                        TradeAccount =
                            DBNull.Value != dbreader["Account"] ? dbreader["Account"].ToString() : string.Empty,
                        HistoryOrderId =
                            DBNull.Value != dbreader["historyOrderId"]
                                ? dbreader["historyOrderId"].ToString()
                                : string.Empty,
                        ProductName =
                            DBNull.Value != dbreader["ProductName"] ? dbreader["ProductName"].ToString() : string.Empty,
                        ProductCode =
                            DBNull.Value != dbreader["productcode"] ? dbreader["productcode"].ToString() : string.Empty,
                        OrderPrice =
                            DBNull.Value != dbreader["Orderprice"] ? Convert.ToDouble(dbreader["Orderprice"]) : 0,
                        OverType = DBNull.Value != dbreader["overType"] ? dbreader["overType"].ToString() : string.Empty,
                        OverPrice = DBNull.Value != dbreader["overprice"] ? Convert.ToDouble(dbreader["overprice"]) : 0,
                        ProfitValue =
                            DBNull.Value != dbreader["profitValue"] ? Convert.ToDouble(dbreader["profitValue"]) : 0,
                        TradeFee = DBNull.Value != dbreader["tradefee"] ? Convert.ToDouble(dbreader["tradefee"]) : 0,
                        StorageFee =
                            DBNull.Value != dbreader["storagefee"] ? Convert.ToDouble(dbreader["storagefee"]) : 0,
                        LossPrice = DBNull.Value != dbreader["lossprice"] ? Convert.ToDouble(dbreader["lossprice"]) : 0,
                        ProfitPrice =
                            DBNull.Value != dbreader["profitPrice"] ? Convert.ToDouble(dbreader["profitPrice"]) : 0,
                        OverTime =
                            DBNull.Value != dbreader["Overtime"]
                                ? Convert.ToDateTime(dbreader["Overtime"])
                                : DateTime.MinValue,
                        OrderId = DBNull.Value != dbreader["Orderid"] ? dbreader["Orderid"].ToString() : string.Empty,
                        OrderType =
                            DBNull.Value != dbreader["ordertype"] ? dbreader["ordertype"].ToString() : string.Empty,
                        Quantity = DBNull.Value != dbreader["quantity"] ? Convert.ToDouble(dbreader["quantity"]) : 0,
                        OrderTime =
                            DBNull.Value != dbreader["ordertime"]
                                ? Convert.ToDateTime(dbreader["ordertime"])
                                : DateTime.MinValue
                    };
                    ltradeOrder.ProductMoney = "0" == ltradeOrder.OrderType ? Math.Round(ltradeOrder.OverPrice / Convert.ToDouble(dbreader["adjustbase"]) * Convert.ToDouble(dbreader["valuedot"]) * Convert.ToDouble(dbreader["quantity"]), 2, MidpointRounding.AwayFromZero) : 0;
                    list.Add(ltradeOrder);
                }

            }
            catch (Exception ex)
            {
                ComFunction.WriteErr(ex);
                if (null != list && list.Count > 0)
                {
                    list.Clear();
                }
            }
            finally
            {
                if (null != dbreader)
                {
                    dbreader.Close(); dbreader.Dispose();
                    page = Convert.ToInt32(outputParam.Value);
                }
            }
            return list;
        }
示例#3
0
        public String AnalysisXml(string ReqXml)
        {
            string ResXml = string.Empty;
            string ReqCode = string.Empty;
            try
            {
                System.Xml.XmlDocument xmldoc = new System.Xml.XmlDocument();
                xmldoc.LoadXml(ReqXml);

                //请求指令
                ReqCode = xmldoc.SelectSingleNode("JTW91G/MsgData/ReqHeader/ReqCode").InnerText;

                Trade.CTrade trade = new Trade.CTrade();

                string Ltype = xmldoc.SelectSingleNode("JTW91G/MsgData/DataBody/Lqc/Ltype").InnerText;
                int pageindex = Convert.ToInt32(xmldoc.SelectSingleNode("JTW91G/MsgData/DataBody/Lqc/PageIndex").InnerText);
                int pagesize = Convert.ToInt32(xmldoc.SelectSingleNode("JTW91G/MsgData/DataBody/Lqc/PageSize").InnerText); ;
                int page = 0;
                LQueryCon Lcn = new LQueryCon();
                Lcn.LoginID = xmldoc.SelectSingleNode("JTW91G/MsgData/DataBody/LoginId").InnerText;
                Lcn.TradeAccount = xmldoc.SelectSingleNode("JTW91G/MsgData/DataBody/TradeAccount").InnerText;
             //   Lcn.UserType = 0;//客户端没有传递这个值 内部调用默认赋值0 表示普通用户
                Lcn.StartTime = Convert.ToDateTime(xmldoc.SelectSingleNode("JTW91G/MsgData/DataBody/Lqc/StartTime").InnerText);
                Lcn.EndTime = Convert.ToDateTime(xmldoc.SelectSingleNode("JTW91G/MsgData/DataBody/Lqc/EndTime").InnerText);
                Lcn.OrderType = "ALL";
                Lcn.ProductName = "ALL";
                List<LTradeOrder> list = trade.GetLTradeOrder(Lcn, Ltype, pageindex, pagesize, ref page);
                StringBuilder strb = new StringBuilder();
                foreach (LTradeOrder td in list)
                {
                    strb.Append("<HistoryOrder>");
                    strb.AppendFormat("<HistoryOrderId>{0}</HistoryOrderId>", td.HistoryOrderId);
                    strb.AppendFormat("<ProductName>{0}</ProductName>", td.ProductName);
                    strb.AppendFormat("<ProductCode>{0}</ProductCode>", td.ProductCode);
                    strb.AppendFormat("<OrderPrice>{0}</OrderPrice>", td.OrderPrice);
                    strb.AppendFormat("<OverType>{0}</OverType>", td.OverType);
                    strb.AppendFormat("<OverPrice>{0}</OverPrice>", td.OverPrice);
                    strb.AppendFormat("<OrderType>{0}</OrderType>", td.OrderType);
                    strb.AppendFormat("<ProfitValue>{0}</ProfitValue>", td.ProfitValue);
                    strb.AppendFormat("<TradeFee>{0}</TradeFee>", td.TradeFee);
                    strb.AppendFormat("<StorageFee>{0}</StorageFee>", td.StorageFee);
                    strb.AppendFormat("<OverTime>{0}</OverTime>", td.OverTime.ToString(Const.dateformat));
                    strb.AppendFormat("<OrderTime>{0}</OrderTime>", td.OrderTime.ToString(Const.dateformat));
                    strb.AppendFormat("<OrderId>{0}</OrderId>", td.OrderId);
                    strb.AppendFormat("<ProductMoney>{0}</ProductMoney>", td.ProductMoney);
                    strb.AppendFormat("<Quantity>{0}</Quantity>", td.Quantity);
                    strb.AppendFormat("<LossPrice>{0}</LossPrice>", td.LossPrice);
                    strb.AppendFormat("<ProfitPrice>{0}</ProfitPrice>", td.ProfitPrice);
                    strb.Append("</HistoryOrder>");
                }
                if (strb.Length > 0)
                {
                    //响应消息体
                    string DataBody = string.Format("<DataBody><PageCount>{0}</PageCount><HistoryOrders>{1}</HistoryOrders></DataBody>", page, strb);

                    ResXml = GssResXml.GetResXml(ReqCode, ResCode.UL004, ResCode.UL004Desc, DataBody);
                }
                else
                {
                    ResXml = GssResXml.GetResXml(ReqCode, ResCode.UL034, ResCode.UL034Desc, string.Format("<DataBody></DataBody>"));
                }

            }
            catch (Exception ex)
            {
                com.individual.helper.LogNet4.WriteErr(ex);

                //业务处理失败
                ResXml = GssResXml.GetResXml(ReqCode, ResCode.UL005, ResCode.UL005Desc, string.Format("<DataBody></DataBody>"));
            }
            return ResXml;
        }
示例#4
0
        /// <summary>
        /// 挂单历史查询
        /// </summary>
        /// <param name="Lqc">查询条件</param>
        /// <param name="pageindex">第几页,从1开始</param>
        /// <param name="pagesize">每页多少条</param>
        /// <param name="page">输出参数(总页数)</param>
        /// <returns>挂单历史记录</returns>
        public List<LTradeHoldOrder> GetLTradeHoldOrder(LQueryCon Lqc, int pageindex, int pagesize, ref int page)
        {
            List<LTradeHoldOrder> list = new List<LTradeHoldOrder>();
            System.Data.Common.DbDataReader dbreader = null;
            TradeUser TdUser = new TradeUser();
            System.Data.Common.DbParameter OutputParam = DbHelper.CreateDbParameter(JinTong.Jyrj.Data.DataBase.Type,
                 "@PageCount", DbParameterType.String, 0, ParameterDirection.Output);
            try
            {
                string userId = string.Empty;
                string AndStr = string.Empty;
                string PartSearchCondition = string.Empty;
                string ParentOrgID = string.Empty;
                if (!ComFunction.ExistUserLoginID(Lqc.LoginID, ref TdUser))
                {
                    return list;
                }

                if (UserType.NormalType == TdUser.UType) //普通用户
                {
                    AndStr += string.Format("and userid='{0}' ", TdUser.UserID);
                }
                else
                {
                    if (UserType.OrgType == TdUser.UType && !string.IsNullOrEmpty(TdUser.OrgId))
                    {
                        PartSearchCondition = " and orgid in (select orgid from #tmp) ";
                        ParentOrgID = TdUser.OrgId;
                    }
                    if (!string.IsNullOrEmpty(Lqc.TradeAccount))
                    {
                        AndStr += string.Format(" and userid='{0}' ", ComFunction.GetUserId(Lqc.TradeAccount));
                    }
                }

                if ("ALL" != Lqc.ProductName.ToUpper())
                {
                    AndStr += string.Format(" and ProductName='{0}'", Lqc.ProductName);
                }
                if ("ALL" != Lqc.OrderType.ToUpper())
                {
                    AndStr += string.Format(" and ordertype='{0}'", Lqc.OrderType);
                }

                string SubSelectList = "orgname,Account,ProductName,HoldOrderID,productCode,OrderType,HoldPrice,lossPrice,profitPrice,frozenMoney,validtime,ordertime,istrade,OrderID,quantity,tradetime ";
                string selectlist = "orgname,Account,ProductName,HoldOrderID,productCode,OrderType,HoldPrice,lossPrice,profitPrice,frozenMoney,validtime,ordertime,istrade,OrderID,quantity,tradetime ";

                string SearchCondition = string.Format("where tradetime >= '{0}' and tradetime <='{1}' {2} {3} ",
                    Lqc.StartTime.ToString("yyyy-MM-dd HH:mm:ss.fff"), Lqc.EndTime.ToString("yyyy-MM-dd HH:mm:ss.fff"), AndStr,PartSearchCondition);

                dbreader = DbHelper.RunProcedureGetDataReader("GetRecordFromPageEx",
                    new System.Data.Common.DbParameter[]{
                         DbHelper.CreateDbParameter(JinTong.Jyrj.Data.DataBase.Type,
                    "@selectlist",DbParameterType.String,selectlist,ParameterDirection.Input),
                      DbHelper.CreateDbParameter(JinTong.Jyrj.Data.DataBase.Type,
                    "@SubSelectList",DbParameterType.String,SubSelectList,ParameterDirection.Input),
                       DbHelper.CreateDbParameter(JinTong.Jyrj.Data.DataBase.Type,
                    "@TableSource",DbParameterType.String,"V_L_Trade_HoldOrder",ParameterDirection.Input), //表名或视图表
                        DbHelper.CreateDbParameter(JinTong.Jyrj.Data.DataBase.Type,
                    "@TableOrder",DbParameterType.String,"a",ParameterDirection.Input), //排序后的表名称 即子查询结果集的别名
                         DbHelper.CreateDbParameter(JinTong.Jyrj.Data.DataBase.Type,
                    "@SearchCondition",DbParameterType.String,SearchCondition,ParameterDirection.Input),
                          DbHelper.CreateDbParameter(JinTong.Jyrj.Data.DataBase.Type,
                    "@OrderExpression",DbParameterType.String,"order by tradetime desc",ParameterDirection.Input),//排序 表达式
                            DbHelper.CreateDbParameter(JinTong.Jyrj.Data.DataBase.Type,
                    "@ParentOrgID",DbParameterType.String,ParentOrgID,ParameterDirection.Input),//父级组织ID
                           DbHelper.CreateDbParameter(JinTong.Jyrj.Data.DataBase.Type,
                    "@PageIndex",DbParameterType.Int,pageindex,ParameterDirection.Input),
                           DbHelper.CreateDbParameter(JinTong.Jyrj.Data.DataBase.Type,
                    "@PageSize",DbParameterType.Int,pagesize,ParameterDirection.Input),
                            OutputParam});
                while (dbreader.Read())
                {
                    LTradeHoldOrder ltradeHoldOrder = new LTradeHoldOrder();
                    ltradeHoldOrder.OrgName = System.DBNull.Value != dbreader["orgname"] ? dbreader["orgname"].ToString() : string.Empty;
                    ltradeHoldOrder.TradeAccount = System.DBNull.Value != dbreader["Account"] ? dbreader["Account"].ToString() : string.Empty;
                    ltradeHoldOrder.HoldOrderID = System.DBNull.Value != dbreader["HoldOrderID"] ? dbreader["HoldOrderID"].ToString() : string.Empty;
                    ltradeHoldOrder.ProductName = System.DBNull.Value != dbreader["ProductName"] ? dbreader["ProductName"].ToString() : string.Empty;
                    ltradeHoldOrder.ProductCode = System.DBNull.Value != dbreader["productCode"] ? dbreader["productCode"].ToString() : string.Empty;
                    ltradeHoldOrder.OrderType = System.DBNull.Value != dbreader["OrderType"] ? dbreader["OrderType"].ToString() : string.Empty;
                    ltradeHoldOrder.HoldPrice = System.DBNull.Value != dbreader["HoldPrice"] ? Convert.ToDouble(dbreader["HoldPrice"]) : 0;
                    ltradeHoldOrder.LossPrice = System.DBNull.Value != dbreader["lossPrice"] ? Convert.ToDouble(dbreader["lossPrice"]) : 0;
                    ltradeHoldOrder.ProfitPrice = System.DBNull.Value != dbreader["profitPrice"] ? Convert.ToDouble(dbreader["profitPrice"]) : 0;
                    ltradeHoldOrder.FrozenMoney = System.DBNull.Value != dbreader["frozenMoney"] ? Convert.ToDouble(dbreader["frozenMoney"]) : 0;
                    ltradeHoldOrder.ValidTime = System.DBNull.Value != dbreader["validtime"] ? Convert.ToDateTime(dbreader["validtime"]) : DateTime.MinValue;
                    ltradeHoldOrder.OrderTime = System.DBNull.Value != dbreader["ordertime"] ? Convert.ToDateTime(dbreader["ordertime"]) : DateTime.MinValue;
                    ltradeHoldOrder.State = System.DBNull.Value != dbreader["istrade"] ? dbreader["istrade"].ToString() : string.Empty;
                    ltradeHoldOrder.OrderID = System.DBNull.Value != dbreader["OrderID"] ? dbreader["OrderID"].ToString() : string.Empty;
                    ltradeHoldOrder.Quantity = System.DBNull.Value != dbreader["quantity"] ? Convert.ToDouble(dbreader["quantity"]) : 0;
                    ltradeHoldOrder.TradeTime = System.DBNull.Value != dbreader["tradetime"] ? Convert.ToDateTime(dbreader["tradetime"]) : DateTime.MinValue;
                    list.Add(ltradeHoldOrder);
                }

            }
            catch (Exception ex)
            {
                ComFunction.WriteErr(ex);
                if (null != list && list.Count > 0)
                {
                    list.Clear();
                }
            }
            finally
            {
                if (null != dbreader)
                {
                    dbreader.Close(); dbreader.Dispose();
                    page = Convert.ToInt32(OutputParam.Value);
                }
            }
            return list;
        }