Exemplo n.º 1
0
        /// <summary>
        /// 删除订单方法
        /// </summary>
        /// <param name="storeId"></param>
        /// <returns></returns>
        public static Boolean DelStoreOrderItem(string storeOrderID)
        {
            Boolean        temp       = true;
            string         connString = DBHelper.connString;
            SqlTransaction tr         = null;
            SqlConnection  conn       = new SqlConnection(connString);

            conn.Open();
            tr = conn.BeginTransaction();
            try
            {
                BLL.CommonClass.ChangeLogs cl_h_info = new BLL.CommonClass.ChangeLogs("OrderGoods", "ordergoodsID");
                cl_h_info.AddRecordtran(tr, storeOrderID);
                BLL.CommonClass.ChangeLogs cl_h_info2 = new BLL.CommonClass.ChangeLogs("OrderGoodsDetail", "ordergoodsID");
                cl_h_info2.AddRecordtran(tr, storeOrderID);

                StoreOrderDAL.DelStoreOrderItemProc(tr, storeOrderID);
                //StockDAL.DelStoreOrder(tr, OrderDetailDAL.GetOrderGoodsDetail(storeOrderID), StoreOrderDAL.GetStoreIdByGoodsId(storeOrderID));//还原店库存
                //OrderDetailDAL.DelOrderGoodsDetail(tr, storeOrderID);//明细表删除失败回滚
                //StoreOrderDAL.DelOrderGoods(storeOrderID, tr); //订单表删除失败回滚

                cl_h_info.AddRecordtran(tr, storeOrderID);
                cl_h_info.DeletedIntoLogstran(tr, BLL.CommonClass.ChangeCategory.store10, storeOrderID, BLL.CommonClass.ENUM_USERTYPE.objecttype2);
                cl_h_info2.AddRecordtran(tr, storeOrderID);
                cl_h_info2.DeletedIntoLogstran(tr, BLL.CommonClass.ChangeCategory.store10, storeOrderID, BLL.CommonClass.ENUM_USERTYPE.objecttype2);

                tr.Commit();
            }
            catch
            {
                temp = false;
                tr.Rollback();
            }
            finally
            {
                // tr.Connection.Close();
                tr.Dispose();
                conn.Close();
            }
            return(temp);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 确认订单按钮
        /// </summary>
        /// <param name="storeId"></param>
        /// <returns></returns>
        public Boolean OrderSubmit(string storeId, List <OrderDetailModel> orderDetails, OrderGoodsMedel storeItem, bool IsEdit)
        {
            using (SqlConnection conn = new SqlConnection(DBHelper.connString))
            {
                conn.Open();
                SqlTransaction tr = conn.BeginTransaction();//开启事务

                try
                {
                    if (IsEdit)                                                                                              //如果是修改订单,先删除原来的订单并还原原来的信息
                    {
                        BLL.CommonClass.ChangeLogs cl_h_info = new BLL.CommonClass.ChangeLogs("OrderGoods", "OrderGoodsID"); //实例日志类
                        cl_h_info.AddRecordtran(tr, storeItem.OrderGoodsID);                                                 //添加日志,修改前记录原来数据

                        StoreOrderDAL.DelStoreOrderItemProc(tr, storeItem.OrderGoodsID);
                        //StockDAL.DelStoreOrder(tr, OrderDetailDAL.GetOrderGoodsDetail(storeItem.StoreorderId), storeItem.StoreId);//还原店库存
                        //OrderDetailDAL.DelOrderGoodsDetail(tr, storeItem.StoreorderId);//明细表删除失败回滚
                        //StoreOrderDAL.DelOrderGoods(storeItem.StoreorderId, tr); //订单表删除失败回滚

                        cl_h_info.AddRecordtran(tr, storeItem.OrderGoodsID);                                                                                           //添加日志,修改后记录原来数据
                        cl_h_info.ModifiedIntoLogstran(tr, BLL.CommonClass.ChangeCategory.store10, storeItem.OrderGoodsID, BLL.CommonClass.ENUM_USERTYPE.objecttype2); //插入日志
                    }

                    //插入订单
                    if (new StoreOrderDAL().AddOrderGoods(storeItem, tr))
                    {
                        //订单表插入成功插入明细表
                        foreach (OrderDetailModel orderDetailItem in orderDetails)
                        {
                            if (!OrderDetailDAL.AddOrderGoodsDetail(tr, orderDetailItem, storeItem.OrderGoodsID))
                            {
                                tr.Rollback();
                                return(false);
                            }
                        }
                        //修改库存信息(预订数量)
                        foreach (OrderDetailModel orderDetailItem in orderDetails)
                        {
                            if (!StockDAL.UpdStockHasOrderCount(tr, storeItem.StoreId, orderDetailItem.ProductId, orderDetailItem.Quantity))
                            {
                                tr.Rollback();
                                return(false);
                            }
                        }

                        tr.Commit();//插入订单信息完成
                    }
                    else
                    {//订单插入失败回滚数据
                        tr.Rollback();
                        return(false);
                    }
                }
                catch
                {
                    //订单插入失败回滚数据
                    tr.Rollback();
                    return(false);
                }
                finally
                {
                    conn.Close();
                }
            }
            return(true);
        }