예제 #1
0
파일: ShardDb.cs 프로젝트: wynet321/aimu
        public static bool insertOrder(Order order, List <OrderDetail> orderDetails, OrderFlow orderFlow)
        {
            Queue <Statement> sqls = generateOrderQueue(order, orderDetails, orderFlow);

            return(shardDb.save(sqls));
        }
예제 #2
0
파일: ShardDb.cs 프로젝트: wynet321/aimu
        public static bool updateOrderbyId(Order order, List <OrderDetail> orderDetails, List <OrderDetail> originalOrderDetails, OrderFlow orderFlow)
        {
            Queue <Statement> sqls = new Queue <Statement>();
            Statement         sql  = new Statement("delete from [order] where id=" + order.id);

            sqls.Enqueue(sql);
            sql = new Statement("delete from [orderdetail] where orderid=" + order.id);
            sqls.Enqueue(sql);
            foreach (OrderDetail orderDetail in originalOrderDetails)
            {
                if (orderDetail.orderType == "卖样衣")
                {
                    sql = new Statement("update dress set wd_count=(select wd_count from dress where wd_id='" + orderDetail.wd_id + "' and wd_size='" + ((orderDetail.wd_size == null) ? (Object)DBNull.Value : orderDetail.wd_size) + "' and storeId=" + Sharevariables.StoreId + ")+1 where wd_id='" + orderDetail.wd_id + "' and wd_size='" + ((orderDetail.wd_size == null) ? (Object)DBNull.Value : orderDetail.wd_size) + "' and storeId=" + Sharevariables.StoreId);
                    sqls.Enqueue(sql);
                }
            }
            Queue <Statement> sqlsNewOrder = generateOrderQueue(order, orderDetails, orderFlow);

            while (sqlsNewOrder.Count > 0)
            {
                sqls.Enqueue(sqlsNewOrder.Dequeue());
            }
            return(shardDb.save(sqls));
        }
예제 #3
0
파일: ShardDb.cs 프로젝트: wynet321/aimu
        private static Queue <Statement> generateOrderQueue(Order order, List <OrderDetail> orderDetails, OrderFlow orderFlow)
        {
            Queue <Statement> sqls = new Queue <Statement>();
            Statement         sql;

            if (Sharevariables.EnableWorkFlow)
            {
                sql             = new Statement("declare @flowId int; insert into [orderFlow] (statusId,changeReason,customizedPrice, expressNumberToStore, expressNumberToFactory, expressNumberToCustomer,parentId) values('" + orderFlow.statusId + "','" + ((orderFlow.changeReason == null) ? (object)DBNull.Value : orderFlow.changeReason) + "','" + orderFlow.customizedPrice + "','" + ((orderFlow.expressNumberToStore == null) ? (object)DBNull.Value : orderFlow.expressNumberToStore) + "','" + ((orderFlow.expressNumberToFactory == null) ? (object)DBNull.Value : orderFlow.expressNumberToFactory) + "', '" + ((orderFlow.expressNumberToCustomer == null) ? (object)DBNull.Value : orderFlow.expressNumberToCustomer) + "'," + orderFlow.parentId + "); set @flowId=SCOPE_IDENTITY(); select @flowId;");
                sql.ReturnValue = true;
                sqls.Enqueue(sql);
                sql                = new Statement("declare @orderId int;insert into [order] (customerid, orderamountafter, depositamount,totalamount,deliveryType,getdate,returndate,address, memo,createdDate,flowId,storeId) values ('" + order.customerID + "', " + order.orderAmountafter.ToString() + "," + order.depositAmount.ToString() + ", " + order.totalAmount.ToString() + ",'" + order.deliveryType + "','" + order.getDate.ToShortDateString() + "','" + order.returnDate.ToShortDateString() + "','" + order.address + "','" + order.memo + "', '" + DateTime.Today.ToShortDateString() + "',@returnedValue,'" + Sharevariables.StoreId + "'); set @orderId=SCOPE_IDENTITY(); select @orderId");
                sql.ReturnValue    = true;
                sql.UseReturnValue = true;
                sqls.Enqueue(sql);
            }
            else
            {
                sql                = new Statement("declare @orderId int;insert into [order] (customerid, orderamountafter, depositamount,totalamount,deliveryType,getdate,returndate,address, memo,createdDate,storeId) values ('" + order.customerID + "', " + order.orderAmountafter.ToString() + "," + order.depositAmount.ToString() + ", " + order.totalAmount.ToString() + ",'" + order.deliveryType + "','" + order.getDate.ToShortDateString() + "','" + order.returnDate.ToShortDateString() + "','" + order.address + "','" + order.memo + "', '" + DateTime.Today.ToShortDateString() + "','" + Sharevariables.StoreId + "'); set @orderId=SCOPE_IDENTITY(); select @orderId");
                sql.ReturnValue    = true;
                sql.UseReturnValue = true;
                sqls.Enqueue(sql);
            }

            foreach (OrderDetail orderDetail in orderDetails)
            {
                sql = new Statement();
                sql.UseReturnValue = true;
                sql.Sql            = "insert into orderdetail(orderid,wd_id,wd_size,orderType,wd_color,wd_image) values(@returnedValue,'" + orderDetail.wd_id + "','" + ((orderDetail.wd_size == null) ? (Object)DBNull.Value : orderDetail.wd_size) + "','" + orderDetail.orderType + "','" + ((orderDetail.wd_color == null) ? (Object)DBNull.Value : orderDetail.wd_color) + "',@wd_image)";
                SqlParameter parameter;
                if (orderDetail.wd_image == null)
                {
                    parameter       = new SqlParameter("@wd_image", SqlDbType.Image);
                    parameter.Value = new byte[0];
                }
                else
                {
                    parameter       = new SqlParameter("@wd_image", SqlDbType.Image);
                    parameter.Value = orderDetail.wd_image;
                }
                List <SqlParameter> parameters = new List <SqlParameter>();
                parameters.Add(parameter);
                sql.Paremeters = parameters;
                sqls.Enqueue(sql);
            }
            foreach (OrderDetail orderDetail in orderDetails)
            {
                if (orderDetail.orderType == "卖样衣")
                {
                    sql = new Statement("update dress set wd_count=(select wd_count from dress where wd_id='" + orderDetail.wd_id + "' and wd_size='" + orderDetail.wd_size + "')-1 where wd_id='" + orderDetail.wd_id + "' and wd_size='" + orderDetail.wd_size + "' and storeId=" + Sharevariables.StoreId);
                    sqls.Enqueue(sql);
                }
            }
            sql = new Statement("update customers set accountpayable=" + (order.totalAmount - order.orderAmountafter).ToString() + " where id='" + order.customerID + "'");
            sqls.Enqueue(sql);
            return(sqls);
        }