예제 #1
0
 private void btnAddList_Click(object sender, System.EventArgs e)
 {
     if (this.JudgeIsNull(txtCount.Text, "数量"))
     {
         return;
     }
     if (!this.JudgeIsNum(txtCount.Text, "数量"))
     {
         return;
     }
     if (decimal.Parse(txtCount.Text) <= 0)
     {
         Popup("数量必需大于零");
         return;
     }
     if (this.DataGrid1.Items.Count > 0)
     {
         //放入清单
         foreach (DataGridItem dgi in this.DataGrid1.Items)
         {
             OrderBookDetail productList = new OrderBookDetail();
             productList.cnnOrderCount = decimal.Parse(txtCount.Text);
             productList.cnvcInvCode   = dgi.Cells[0].Text;
             GetProductListTable(productList.ToTable());
         }
         BindProduct();
     }
     BindGrid();
     this.DataGrid1.Visible = false;
     this.DataGrid2.Visible = true;
 }
예제 #2
0
        /// <summary>
        /// Get converted Order Book
        /// </summary>
        /// <param name="pair">Trading pair</param>
        /// <returns>OrderBook object</returns>
        public static async Task <OrderBook> GetOrderBookConverted(this ITradeOgre service, string pair)
        {
            var buys  = new List <OrderBookDetail>();
            var sells = new List <OrderBookDetail>();

            var books = await service.GetOrderBook(pair);

            foreach (var buy in books.Buy)
            {
                var book = new OrderBookDetail {
                    Quantity = buy.Key, Price = buy.Value
                };
                buys.Add(book);
            }
            foreach (var sell in books.Sell)
            {
                var book = new OrderBookDetail {
                    Quantity = sell.Key, Price = sell.Value
                };
                sells.Add(book);
            }

            return(new OrderBook {
                Buys = buys, Sells = sells
            });
        }
예제 #3
0
        /// <summary>
        /// Get 1st price with the most resistance at or above specified volume
        /// </summary>
        /// <param name="symbol">String of trading pair</param>
        /// <param name="volume">Volume to set buy price</param>
        /// <returns>Decimal of price</returns>
        public OrderBookDetail GetResistance(string symbol, decimal volume)
        {
            decimal         resistance = 0.00000000M;
            OrderBookDetail response;
            int             i         = 0;
            int             precision = 0;
            var             orderBook = GetOrderBook(symbol);

            while (orderBook == null && i < 3)
            {
                Task.WaitAll(Task.Delay(1000));
                orderBook = GetOrderBook(symbol);
                i++;
            }

            if (_competition)
            {
                var obPrice       = orderBook.asks[i].price;
                var trimedPrice   = obPrice.ToString().TrimEnd('0');
                var price         = Convert.ToDecimal(trimedPrice);
                var thisPrecision = BitConverter.GetBytes(decimal.GetBits(price)[3])[2];
                response = new OrderBookDetail
                {
                    price     = price,
                    precision = thisPrecision,
                    position  = 0
                };

                return(response);
            }

            var staleMate = StaleMateCheck(orderBook.bids.Take(2).ToArray(), orderBook.asks.Take(2).ToArray(), volume);

            if (!staleMate)
            {
                for (i = 0; i < orderBook.asks.Length; i++)
                {
                    var obPrice       = orderBook.asks[i].price;
                    var trimedPrice   = obPrice.ToString().TrimEnd('0');
                    var price         = Convert.ToDecimal(trimedPrice);
                    var thisPrecision = BitConverter.GetBytes(decimal.GetBits(price)[3])[2];
                    precision = thisPrecision > precision ? thisPrecision : precision;
                    var vol = orderBook.asks[i].price * orderBook.asks[i].quantity;

                    if (vol >= volume)
                    {
                        resistance = orderBook.asks[i].price;
                        break;
                    }
                }
            }
            response = new OrderBookDetail
            {
                price     = resistance,
                precision = precision,
                position  = i
            };

            return(response);
        }
예제 #4
0
 protected void btnPercent_Click(object sender, System.EventArgs e)
 {
     if (this.JudgeIsNull(txtPercent.Text, "百分比"))
     {
         return;
     }
     if (!this.JudgeIsNum(txtPercent.Text, "百分比"))
     {
         return;
     }
     if (Session["ProductList"] != null)
     {
         DataTable dtProductList = (DataTable)Session["ProductList"];
         foreach (DataRow drProductList in dtProductList.Rows)
         {
             OrderBookDetail detail = new OrderBookDetail(drProductList);
             detail.cnnOrderCount           = Convert.ToDecimal(Math.Ceiling(Convert.ToDouble(detail.cnnOrderCount) * double.Parse(txtPercent.Text) / 100));
             detail.cnnSum                  = Math.Round(detail.cnnOrderCount * detail.cnnPrice, 2);
             drProductList["cnnOrderCount"] = detail.cnnOrderCount;
             drProductList["cnnSum"]        = detail.cnnSum;
         }
         Session["ProductList"] = dtProductList;
     }
     BindGrid();
     this.DataGrid1.Visible = false;
     Session["vwProduct"]   = null;
     BindProduct();
     this.DataGrid2.Visible = true;
 }
예제 #5
0
        private void GetProductListTable(DataTable dtOrderBookDetail)
        {
            DataTable dtProductList = null;

            if (Session["ProductList"] == null)
            {
                OrderBookDetail detail = new OrderBookDetail();
                dtProductList = detail.ToTable().Clone();
                dtProductList.Columns.Add("cnvcinvname");
                dtProductList.Columns.Add("cnfretailprice");
                dtProductList.Columns.Add("cnvcProduceUnitCode");
                dtProductList.Columns.Add("cnvccomunitname");
                dtProductList.Columns.Add("cnnsum");
            }
            else
            {
                dtProductList = (DataTable)Session["ProductList"];
            }
            this.DataTableConvert(dtOrderBookDetail, "cnvcinvcode", "cnvcinvname", "tbInventory", "cnvcinvcode", "cnvcinvname", "");
            this.DataTableConvert(dtOrderBookDetail, "cnvcinvcode", "cnfretailprice", "tbInventory", "cnvcinvcode", "cnfretailprice", "");
            this.DataTableConvert(dtOrderBookDetail, "cnvcinvcode", "cnvcProduceUnitCode", "tbInventory", "cnvcinvcode", "cnvcProduceUnitCode", "");
            this.DataTableConvert(dtOrderBookDetail, "cnvcProduceUnitCode", "cnvccomunitname", "tbComputationUnit", "cnvccomunitcode", "cnvccomunitname", "");
            object[] oArray = new object[dtOrderBookDetail.Columns.Count];
            dtOrderBookDetail.Rows[0].ItemArray.CopyTo(oArray, 0);
            dtProductList.Rows.Add(oArray);
            foreach (DataRow dr in dtProductList.Rows)
            {
                //Entity.Inventory inv = new AMSApp.zhenghua.Entity.Inventory(dr);
                double sum = Convert.ToDouble(dr["cnnordercount"].ToString()) * Convert.ToDouble(dr["cnfretailprice"].ToString());
                dr["cnnsum"] = sum;
            }
            Session["ProductList"] = dtProductList;
        }
예제 #6
0
        private void BindProduct()
        {
            string strSql = "select cnvcinvcode,cnvcinvname,cnfretailprice,cnvcProduceUnitCode from tbinventory "
                            + " where cnbProductBill=1  "
//+" and CONVERT(char(10),cndSDate,121) <= CONVERT(char(10),getdate(),121) "
//+" AND CONVERT(char(10),isnull(cndEDate,getdate()),121)>=CONVERT(char(10),getdate(),121) "
                            + " and CONVERT(char(10),isnull(cndSDate,CONVERT(datetime,'9999-12-31')),121)<=CONVERT(char(10),getdate(),121) "
                            + " AND CONVERT(char(10),isnull(cndEDate,getdate()),121)>=CONVERT(char(10),getdate(),121) "

                            + " and cnvcinvcode like '%" + this.txtProductCode.Text + "%' and cnvcinvname like '%" + this.txtProductName.Text + "%'";
            DataTable dtProduct = Helper.Query(strSql);

            if (Session["ProductList"] != null)
            {
                DataTable dtProductList = (DataTable)Session["ProductList"];
                foreach (DataRow drProductList in dtProductList.Rows)
                {
                    OrderBookDetail detail = new OrderBookDetail(drProductList);
                    DataRow[]       dr     = dtProduct.Select("cnvcinvcode='" + detail.cnvcInvCode + "'");
                    if (dr.Length > 0)
                    {
                        dtProduct.Rows.Remove(dr[0]);
                    }
                }
            }
            this.DataTableConvert(dtProduct, "cnvcProduceUnitCode", "cnvccomunitname", "tbComputationUnit", "cnvccomunitcode", "cnvccomunitname", "");
            this.DataGrid1.DataSource = dtProduct;
            this.DataGrid1.DataBind();
            this.DataGrid1.Visible = true;
            this.DataGrid2.Visible = false;
        }
예제 #7
0
        private void chkSame_CheckedChanged(object sender, System.EventArgs e)
        {
            //使用同期数据
            if (chkSame.Checked)
            {
                string strOrderBook = "select top 1 cnnOrderSerialNo from tbOrderBook where cnvcOperID='" + this.oper.strLoginID + "' and  convert(char(10),cndOrderDate,120) = '" +
                                      DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd") + "'";
//				string strOrderBook = "select top 1 cnnOrderSerialNo from tbOrderBook where cnvcOperID='"+this.oper.strLoginID+"' and  convert(char(10),cndOrderDate,120) = '" +
//					DateTime.Now.ToString("yyyy-MM-dd") + "'";
                DataTable dtOrderBook = Helper.Query(strOrderBook);
                if (dtOrderBook.Rows.Count > 0)
                {
                    string strOrderSerialNo = dtOrderBook.Rows[0][0].ToString();
                    if (strOrderSerialNo != "")
                    {
                        string    strOrderBookDetail = "select * from tbOrderBookDetail where cnnOrderSerialNo=" + strOrderSerialNo;
                        DataTable dtOrderBookDetail  = Helper.Query(strOrderBookDetail);
                        this.DataTableConvert(dtOrderBookDetail, "cnvcinvcode", "cnvcinvname", "tbInventory", "cnvcinvcode", "cnvcinvname", "");
                        this.DataTableConvert(dtOrderBookDetail, "cnvcinvcode", "cnfretailprice", "tbInventory", "cnvcinvcode", "cnfretailprice", "");
                        this.DataTableConvert(dtOrderBookDetail, "cnvcinvcode", "cnvcProduceUnitCode", "tbInventory", "cnvcinvcode", "cnvcProduceUnitCode", "");
                        this.DataTableConvert(dtOrderBookDetail, "cnvcProduceUnitCode", "cnvccomunitname", "tbComputationUnit", "cnvccomunitcode", "cnvccomunitname", "");
                        dtOrderBookDetail.Columns.Add("cnnSum");
                        //DataTable dtProduct = Helper.Query(strSql);
                        if (Session["ProductList"] != null)
                        {
                            DataTable dtProductList = (DataTable)Session["ProductList"];
                            foreach (DataRow drOrderBookDetail in dtOrderBookDetail.Rows)
                            {
                                OrderBookDetail detail = new OrderBookDetail(drOrderBookDetail);
                                DataRow[]       dr     = dtProductList.Select("cnvcinvcode='" + detail.cnvcInvCode + "'");
                                if (dr.Length == 0)
                                {
                                    double sum = Convert.ToDouble(drOrderBookDetail["cnnordercount"].ToString()) * Convert.ToDouble(drOrderBookDetail["cnfretailprice"].ToString());
                                    drOrderBookDetail["cnnsum"] = sum;

                                    object[] oArray = new object[dtProductList.Columns.Count];
                                    drOrderBookDetail.ItemArray.CopyTo(oArray, 0);
                                    dtProductList.Rows.Add(oArray);
                                }
                            }
                            Session["ProductList"] = dtProductList;
                            //GetProductListTable(dtProductList);
                        }
                        else
                        {
                            foreach (DataRow drOrderBookDetail in dtOrderBookDetail.Rows)
                            {
                                OrderBookDetail detail = new OrderBookDetail(drOrderBookDetail);

                                double sum = Convert.ToDouble(drOrderBookDetail["cnnordercount"].ToString()) * Convert.ToDouble(drOrderBookDetail["cnfretailprice"].ToString());
                                drOrderBookDetail["cnnsum"] = sum;
                            }
                            Session["ProductList"] = dtOrderBookDetail;
                        }
                        btnOrderDetail_Click(null, null);
                    }
                }
            }
        }
예제 #8
0
        private void btnBatchAddList_Click(object sender, System.EventArgs e)
        {
            //批量放入清单
            try
            {
                if (this.DataGrid1.Items.Count > 0)
                {
                    //放入清单

                    foreach (DataGridItem dgi in this.DataGrid1.Items)
                    {
                        string strCount = ((TextBox)dgi.Cells[4].Controls[1]).Text;
                        if (this.JudgeIsNull(strCount))
                        {
                            continue;
                        }
                        if (!this.JudgeIsNum(strCount, "数量"))
                        {
                            return;
                        }
                        if (decimal.Parse(strCount) <= 0)
                        {
                            Popup("数量必需大于零");
                            return;
                        }
                        OrderBookDetail productList = new OrderBookDetail();
                        productList.cnnOrderCount = decimal.Parse(strCount);
                        productList.cnvcInvCode   = dgi.Cells[0].Text;
                        this.GetProductListTable(productList.ToTable());
                    }
                    BindProduct();
                }
                if ((DataGrid1.CurrentPageIndex == DataGrid1.PageCount - 1) && DataGrid1.Items.Count == 1)
                {
                    if (DataGrid1.CurrentPageIndex - 1 > 1)
                    {
                        DataGrid1.CurrentPageIndex = DataGrid1.CurrentPageIndex - 1;
                    }
                    else
                    {
                        DataGrid1.CurrentPageIndex = 0;
                    }
                }
                BindGrid();
                this.DataGrid1.Visible = false;
                this.DataGrid2.Visible = true;
            }
            catch (Exception ex)
            {
                Popup(ex.Message);
            }
        }
예제 #9
0
        public void AddOrder(OrderBook orderBook, DataTable dtOrderBookDetail, OperLog operLog)      //,BusiLog busiLog)
        {
            using (SqlConnection conn = ConnectionPool.BorrowConnection())
            {
                //conn.Open();

                SqlTransaction trans = conn.BeginTransaction();
                try
                {
                    string   strSysTime = SqlHelper.ExecuteScalar(trans, CommandType.Text, "select getdate()").ToString();
                    DateTime dtSysTime  = DateTime.Parse(strSysTime);

                    OrderSerialNo serialNo = new OrderSerialNo();
                    serialNo.cnvcFill    = "0";
                    serialNo.cnnSerialNo = Convert.ToDecimal(EntityMapping.Create(serialNo, trans));

                    orderBook.cnnOrderSerialNo = serialNo.cnnSerialNo;
                    orderBook.cndOrderDate     = dtSysTime;
                    orderBook.cnvcOrderOperID  = operLog.cnvcOperID;
                    EntityMapping.Create(orderBook, trans);
                    foreach (DataRow drOrderBookDetail in dtOrderBookDetail.Rows)
                    {
                        OrderBookDetail detail = new OrderBookDetail(drOrderBookDetail);
                        detail.cnnOrderSerialNo = serialNo.cnnSerialNo;
                        detail.cndOperDate      = dtSysTime;
                        detail.cnvcOperID       = operLog.cnvcOperID;
                        EntityMapping.Create(detail, trans);
                    }
                    operLog.cndOperDate  = dtSysTime;
                    operLog.cnvcComments = "订单流水:" + orderBook.cnnOrderSerialNo;
                    EntityMapping.Create(operLog, trans);

                    trans.Commit();
                }
                catch (SqlException sex)
                {
                    trans.Rollback();
                    LogAdapter.WriteDatabaseException(sex);
                    throw sex;
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    LogAdapter.WriteFeaturesException(ex);
                    throw ex;
                }
                finally
                {
                    ConnectionPool.ReturnConnection(conn);
                }
            }
        }
예제 #10
0
        //订单更新产品
        public void UpdateDetail(OrderBookDetail detail, OperLog operLog)       //,BusiLog busiLog)
        {
            using (SqlConnection conn = ConnectionPool.BorrowConnection())
            {
                //conn.Open();

                SqlTransaction trans = conn.BeginTransaction();
                try
                {
                    string   strSysTime = SqlHelper.ExecuteScalar(trans, CommandType.Text, "select getdate()").ToString();
                    DateTime dtSysTime  = DateTime.Parse(strSysTime);

                    OrderBookDetail oldDetail = new OrderBookDetail();
                    oldDetail.cnnOrderSerialNo = detail.cnnOrderSerialNo;
                    oldDetail.cnvcProductCode  = detail.cnvcProductCode;
                    oldDetail = EntityMapping.Get(oldDetail, trans) as OrderBookDetail;

                    oldDetail.cnnOrderCount = detail.cnnOrderCount;
                    oldDetail.cnnSum        = detail.cnnOrderCount * oldDetail.cnnPrice;
                    oldDetail.cnvcOperID    = detail.cnvcOperID;
                    oldDetail.cndOperDate   = dtSysTime;
                    EntityMapping.Update(oldDetail, trans);

                    operLog.cndOperDate  = dtSysTime;
                    operLog.cnvcComments = "订单流水:" + detail.cnnOrderSerialNo.ToString();
                    EntityMapping.Create(operLog, trans);

                    trans.Commit();
                }
                catch (SqlException sex)
                {
                    trans.Rollback();
                    LogAdapter.WriteDatabaseException(sex);
                    throw sex;
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    LogAdapter.WriteFeaturesException(ex);
                    throw ex;
                }
                finally
                {
                    ConnectionPool.ReturnConnection(conn);
                }
            }
        }
예제 #11
0
        private void DataGrid2_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
        {
            try
            {
                string strCount = ((TextBox)e.Item.Cells[8].Controls[0]).Text;

                if (this.JudgeIsNull(strCount, "数量"))
                {
                    return;
                }
                if (!this.JudgeIsNum(strCount, "数量"))
                {
                    return;
                }
                if (decimal.Parse(strCount) <= 0)
                {
                    Popup("数量必需大于零");
                    return;
                }


                OrderBookDetail detail = new OrderBookDetail();
                detail.cnnOrderSerialNo = decimal.Parse(txtOrderSerialNo.Text);
                detail.cnvcProductCode  = e.Item.Cells[3].Text;
                detail.cnnOrderCount    = decimal.Parse(((TextBox)e.Item.Cells[8].Controls[0]).Text);
                detail.cnvcOperID       = oper.strLoginID;

                OperLog operLog = new OperLog();
                operLog.cnvcOperID   = oper.strLoginID;
                operLog.cnvcDeptID   = oper.strDeptID;
                operLog.cnvcOperType = "订单修改产品";

                OrderFacade order = new OrderFacade();
                order.UpdateDetail(detail, operLog);
                Popup("修改成功");
                this.DataGrid2.EditItemIndex = -1;
                BindDetail(txtOrderSerialNo.Text);
            }
            catch (Exception ex)
            {
                Popup(ex.Message);
            }
        }
예제 #12
0
        private void DataGrid1_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
        {
            if (e.CommandName == "putin")
            {
                //放入清单
                string strCount = ((TextBox)e.Item.Cells[4].Controls[1]).Text;

                if (this.JudgeIsNull(strCount, "数量"))
                {
                    return;
                }
                if (!this.JudgeIsNum(strCount, "数量"))
                {
                    return;
                }
                if (decimal.Parse(strCount) <= 0)
                {
                    Popup("数量必需大于零");
                    return;
                }

                OrderBookDetail productList = new OrderBookDetail();
                productList.cnnOrderCount = decimal.Parse(((TextBox)e.Item.Cells[4].Controls[1]).Text);
                productList.cnvcInvCode   = e.Item.Cells[0].Text;
                GetProductListTable(productList.ToTable());
                if ((DataGrid1.CurrentPageIndex == DataGrid1.PageCount - 1) && DataGrid1.Items.Count == 1)
                {
                    if (DataGrid1.CurrentPageIndex - 1 > 1)
                    {
                        DataGrid1.CurrentPageIndex = DataGrid1.CurrentPageIndex - 1;
                    }
                    else
                    {
                        DataGrid1.CurrentPageIndex = 0;
                    }
                }
                BindProduct();
            }
        }
예제 #13
0
        //订单删除产品
        public void DeleteDetail(OrderBookDetail detail, OperLog operLog)       //,BusiLog busiLog)
        {
            using (SqlConnection conn = ConnectionPool.BorrowConnection())
            {
                //conn.Open();

                SqlTransaction trans = conn.BeginTransaction();
                try
                {
                    EntityMapping.Delete(detail, trans);

                    string   strSysTime = SqlHelper.ExecuteScalar(trans, CommandType.Text, "select getdate()").ToString();
                    DateTime dtSysTime  = DateTime.Parse(strSysTime);

                    operLog.cndOperDate  = dtSysTime;
                    operLog.cnvcComments = "订单流水:" + detail.cnnOrderSerialNo.ToString() + ",产品编码:" + detail.cnvcInvCode;
                    EntityMapping.Create(operLog, trans);
                    //EntityMapping.Create(busiLog, trans);
                    trans.Commit();
                }
                catch (SqlException sex)
                {
                    trans.Rollback();
                    LogAdapter.WriteDatabaseException(sex);
                    throw sex;
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    LogAdapter.WriteFeaturesException(ex);
                    throw ex;
                }
                finally
                {
                    ConnectionPool.ReturnConnection(conn);
                }
            }
        }
        private void DataGrid2_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
        {
            try
            {
                OrderBookDetail detail = new OrderBookDetail();
                detail.cnnOrderSerialNo = decimal.Parse(txtOrderSerialNo.Text);
                detail.cnvcInvCode      = e.Item.Cells[3].Text;

                OperLog operLog = new OperLog();
                operLog.cnvcOperID   = oper.strLoginID;
                operLog.cnvcDeptID   = oper.strDeptID;
                operLog.cnvcOperType = "订单删除产品";

                OrderFacade order = new OrderFacade();
                order.DeleteDetail(detail, operLog);
                Popup("删除成功");
                BindDetail(txtOrderSerialNo.Text);
            }
            catch (Exception ex)
            {
                Popup(ex.Message);
            }
        }
        public void Update(ProExchange.JSON.API.Notifications.OrderBook response)
        {
            lock (this)
            {
                OrderBook orderbook;
                var isNew = orderbooks.TryGetValue(response.Symbol, out orderbook);

                switch (response.Type)
                {
                    case OrderBookType.FULL:
                        orderbook = new OrderBook();
                        orderbooks[response.Symbol] = orderbook;
                        break;
                    case OrderBookType.INCREMENTAL:
                        var next = NextVersion(orderbook);
                        if (next != response.Version)
                            RequestFullOrderBook(response.Symbol);
                        break;
                    default:
                        return;
                }

                foreach (var data in response.List)
                {
                    var side = orderbook.Sides[(int)data.Side.SimplifyOrderSide()];
                    OrderBookDetail detail;
                    if (!side.TryGetValue(data.Price, out detail))
                    {
                        detail = new OrderBookDetail(data.Price);
                        side.Add(detail.Price, detail);
                    }
                    detail.Quantity += data.Size;
                    if (detail.Quantity == 0) side.Remove(detail.Price);
                }
                orderbook.Version = response.Version;
            }
        }
예제 #16
0
        public void AddOrder(OrderBook orderBook, DataTable dtOrderBookDetail, OperLog operLog)      //,BusiLog busiLog)
        {
            using (SqlConnection conn = ConnectionPool.BorrowConnection())
            {
                //conn.Open();

                SqlTransaction trans = conn.BeginTransaction();
                try
                {
                    string   strSysTime = SqlHelper.ExecuteScalar(trans, CommandType.Text, "select getdate()").ToString();
                    DateTime dtSysTime  = DateTime.Parse(strSysTime);


                    if (orderBook.cnnOrderSerialNo > 0)
                    {
                        OrderBook oldOrder = new OrderBook();
                        oldOrder.cnnOrderSerialNo = orderBook.cnnOrderSerialNo;
                        oldOrder = EntityMapping.Get(oldOrder, trans) as OrderBook;
                        if (oldOrder == null)
                        {
                            throw new Exception("订单未找到");
                        }
                        oldOrder.cnvcOperID        = orderBook.cnvcOperID;
                        oldOrder.cnvcOrderType     = orderBook.cnvcOrderType;
                        oldOrder.cnvcProduceDeptID = orderBook.cnvcProduceDeptID;
                        oldOrder.cnvcOrderDeptID   = orderBook.cnvcOrderDeptID;

                        if (oldOrder.cnvcOrderType == "WDO" || oldOrder.cnvcOrderType == "WDOSELF")
                        {
                            oldOrder.cndArrivedDate  = orderBook.cndArrivedDate;
                            oldOrder.cnvcLinkPhone   = orderBook.cnvcLinkPhone;
                            oldOrder.cnvcShipAddress = orderBook.cnvcShipAddress;
                            oldOrder.cnvcCustomName  = orderBook.cnvcCustomName;
                        }
                        oldOrder.cndShipDate  = orderBook.cndShipDate;
                        oldOrder.cndOrderDate = orderBook.cndOrderDate;
                        EntityMapping.Update(oldOrder, trans);

                        SqlHelper.ExecuteNonQuery(trans, CommandType.Text, "delete from tborderbookdetail where cnnorderserialno=" + orderBook.cnnOrderSerialNo.ToString());
                        foreach (DataRow drOrderBookDetail in dtOrderBookDetail.Rows)
                        {
                            OrderBookDetail detail = new OrderBookDetail(drOrderBookDetail);
                            detail.cnnOrderSerialNo = orderBook.cnnOrderSerialNo;
                            EntityMapping.Create(detail, trans);
                        }
                    }
                    else
                    {
                        OrderSerialNo serialNo = new OrderSerialNo();
                        serialNo.cnvcFill    = "0";
                        serialNo.cnnSerialNo = Convert.ToDecimal(EntityMapping.Create(serialNo, trans));

                        orderBook.cnnOrderSerialNo = serialNo.cnnSerialNo;
                        orderBook.cndOperDate      = dtSysTime;
                        orderBook.cnvcOperID       = operLog.cnvcOperID;
                        EntityMapping.Create(orderBook, trans);

                        //SqlHelper.ExecuteNonQuery(trans,CommandType.Text,"delete from tborderbookdetail where cnnorderserialno="+orderBook.cnnOrderSerialNo.ToString())	;
                        foreach (DataRow drOrderBookDetail in dtOrderBookDetail.Rows)
                        {
                            OrderBookDetail detail = new OrderBookDetail(drOrderBookDetail);
                            detail.cnnOrderSerialNo = serialNo.cnnSerialNo;
                            EntityMapping.Create(detail, trans);
                        }
                    }

                    operLog.cndOperDate  = dtSysTime;
                    operLog.cnvcComments = "订单流水:" + orderBook.cnnOrderSerialNo;
                    EntityMapping.Create(operLog, trans);

                    trans.Commit();
                }
                catch (SqlException sex)
                {
                    trans.Rollback();
                    LogAdapter.WriteDatabaseException(sex);
                    throw sex;
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    LogAdapter.WriteFeaturesException(ex);
                    throw ex;
                }
                finally
                {
                    ConnectionPool.ReturnConnection(conn);
                }
            }
        }